diff -Nru node-map-visit-0.1.5/bower.json node-map-visit-1.0.0/bower.json --- node-map-visit-0.1.5/bower.json 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/bower.json 2017-04-09 21:43:22.000000000 +0000 @@ -11,12 +11,14 @@ "index.js" ], "dependencies": { - "lazy-cache": "^0.2.4", - "object-visit": "^0.3.1" + "object-visit": "^1.0.0" }, "devDependencies": { - "mocha": "*", - "should": "*" + "clone-deep": "^0.2.4", + "extend-shallow": "^2.0.1", + "gulp-format-md": "^0.1.12", + "lodash": "^4.17.4", + "mocha": "^3.2.0" }, "keywords": [ "array", @@ -32,5 +34,26 @@ "value", "visit", "visitor" + ], + "version": "0.1.5", + "bugs": { + "url": "https://github.com/jonschlinkert/map-visit/issues" + }, + "files": [ + "index.js" + ], + "ignore": [ + "actual", + "bower_components", + "fixtures", + "node_modules", + "temp", + "test", + "test.js", + "tmp" + ], + "contributors": [ + "Brian Woodward (https://twitter.com/doowb)", + "Jon Schlinkert (http://twitter.com/jonschlinkert)" ] } \ No newline at end of file diff -Nru node-map-visit-0.1.5/debian/changelog node-map-visit-1.0.0/debian/changelog --- node-map-visit-0.1.5/debian/changelog 2016-10-31 09:43:34.000000000 +0000 +++ node-map-visit-1.0.0/debian/changelog 2018-01-11 07:50:21.000000000 +0000 @@ -1,3 +1,12 @@ +node-map-visit (1.0.0-1) unstable; urgency=medium + + * Team upload + * New upstream release + * Bump standards version + * Change section to javascript + + -- Pirate Praveen Thu, 11 Jan 2018 13:20:21 +0530 + node-map-visit (0.1.5-2) unstable; urgency=medium * Add node-should to builddeps (Closes: #842669) diff -Nru node-map-visit-0.1.5/debian/control node-map-visit-1.0.0/debian/control --- node-map-visit-0.1.5/debian/control 2016-10-31 09:43:34.000000000 +0000 +++ node-map-visit-1.0.0/debian/control 2018-01-11 07:50:21.000000000 +0000 @@ -1,5 +1,5 @@ Source: node-map-visit -Section: web +Section: javascript Priority: optional Maintainer: Debian Javascript Maintainers Uploaders: Sruthi Chandran @@ -8,10 +8,10 @@ , dh-buildinfo , nodejs , mocha - , node-should - , node-object-visit (>= 0.3.4) - , node-lazy-cache (>= 2.0.1) -Standards-Version: 3.9.8 + , node-object-visit (>= 1.0.0) + , node-clone-deep + , node-extend-shallow (>= 2.0.1) +Standards-Version: 4.1.3 Homepage: https://github.com/jonschlinkert/map-visit Vcs-Git: https://anonscm.debian.org/git/pkg-javascript/node-map-visit.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-javascript/node-map-visit.git @@ -21,8 +21,7 @@ Depends: ${misc:Depends} , nodejs - , node-object-visit (>= 0.3.4) - , node-lazy-cache (>= 2.0.1) + , node-object-visit (>= 1.0.0) Description: Map `visit` over an array of objects /usr/share/doc/node-map-visit/README.md for more info. . diff -Nru node-map-visit-0.1.5/debian/examples node-map-visit-1.0.0/debian/examples --- node-map-visit-0.1.5/debian/examples 1970-01-01 00:00:00.000000000 +0000 +++ node-map-visit-1.0.0/debian/examples 2018-01-11 07:48:23.000000000 +0000 @@ -0,0 +1 @@ +example.js diff -Nru node-map-visit-0.1.5/debian/install node-map-visit-1.0.0/debian/install --- node-map-visit-0.1.5/debian/install 2016-10-31 09:43:34.000000000 +0000 +++ node-map-visit-1.0.0/debian/install 2018-01-11 07:47:50.000000000 +0000 @@ -1,3 +1,2 @@ package.json usr/lib/nodejs/map-visit/ index.js usr/lib/nodejs/map-visit/ -utils.js usr/lib/nodejs/map-visit/ diff -Nru node-map-visit-0.1.5/.gitignore node-map-visit-1.0.0/.gitignore --- node-map-visit-0.1.5/.gitignore 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/.gitignore 2017-04-09 21:43:22.000000000 +0000 @@ -1,15 +1,27 @@ +# always ignore files *.DS_Store *.sublime-* -_gh_pages -bower_components + +# test related, or directories generated by tests +test/actual +actual +coverage +.nyc* + +# npm node_modules npm-debug.log -actual -test/actual + +# yarn +yarn.lock +yarn-error.log + +# misc +_gh_pages +_draft +_drafts +bower_components +vendor temp tmp TODO.md -vendor -.idea -benchmark -coverage diff -Nru node-map-visit-0.1.5/index.js node-map-visit-1.0.0/index.js --- node-map-visit-0.1.5/index.js 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/index.js 2017-04-09 21:43:22.000000000 +0000 @@ -1,6 +1,7 @@ 'use strict'; -var utils = require('./utils'); +var util = require('util'); +var visit = require('object-visit'); /** * Map `visit` over an array of objects. @@ -10,16 +11,27 @@ * @param {Object} `arr` Array of objects. */ -module.exports = function mapVisit(collection, method, arr) { - if (!Array.isArray(arr)) { - throw new TypeError('expected an array'); +module.exports = function mapVisit(collection, method, val) { + if (isObject(val)) { + return visit.apply(null, arguments); } - arr.forEach(function(val) { - if (typeof val === 'string') { - collection[method](val); + if (!Array.isArray(val)) { + throw new TypeError('expected an array: ' + util.inspect(val)); + } + + var args = [].slice.call(arguments, 3); + + for (var i = 0; i < val.length; i++) { + var ele = val[i]; + if (isObject(ele)) { + visit.apply(null, [collection, method, ele].concat(args)); } else { - utils.visit(collection, method, val); + collection[method].apply(collection, [ele].concat(args)); } - }); + } }; + +function isObject(val) { + return val && (typeof val === 'function' || (!Array.isArray(val) && typeof val === 'object')); +} diff -Nru node-map-visit-0.1.5/package.json node-map-visit-1.0.0/package.json --- node-map-visit-0.1.5/package.json 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/package.json 2017-04-09 21:43:22.000000000 +0000 @@ -1,17 +1,20 @@ { "name": "map-visit", "description": "Map `visit` over an array of objects.", - "version": "0.1.5", + "version": "1.0.0", "homepage": "https://github.com/jonschlinkert/map-visit", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", + "contributors": [ + "Brian Woodward (https://twitter.com/doowb)", + "Jon Schlinkert (http://twitter.com/jonschlinkert)" + ], "repository": "jonschlinkert/map-visit", "bugs": { "url": "https://github.com/jonschlinkert/map-visit/issues" }, "license": "MIT", "files": [ - "index.js", - "utils.js" + "index.js" ], "main": "index.js", "engines": { @@ -21,14 +24,14 @@ "test": "mocha" }, "dependencies": { - "lazy-cache": "^2.0.1", - "object-visit": "^0.3.4" + "object-visit": "^1.0.0" }, "devDependencies": { - "gulp-format-md": "^0.1.10", - "lodash": "^4.14.1", - "mocha": "^3.0.1", - "should": "^10.0.0" + "clone-deep": "^0.2.4", + "extend-shallow": "^2.0.1", + "gulp-format-md": "^0.1.12", + "lodash": "^4.17.4", + "mocha": "^3.2.0" }, "keywords": [ "array", @@ -46,12 +49,6 @@ "visitor" ], "verb": { - "related": { - "list": [ - "collection-visit", - "object-visit" - ] - }, "toc": false, "layout": "default", "tasks": [ @@ -63,6 +60,12 @@ "lint": { "reflinks": true }, + "related": { + "list": [ + "collection-visit", + "object-visit" + ] + }, "reflinks": [ "verb", "verb-generate-readme" diff -Nru node-map-visit-0.1.5/README.md node-map-visit-1.0.0/README.md --- node-map-visit-0.1.5/README.md 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/README.md 2017-04-09 21:43:22.000000000 +0000 @@ -1,6 +1,6 @@ -# map-visit [![NPM version](https://img.shields.io/npm/v/map-visit.svg?style=flat)](https://www.npmjs.com/package/map-visit) [![NPM downloads](https://img.shields.io/npm/dm/map-visit.svg?style=flat)](https://npmjs.org/package/map-visit) [![Build Status](https://img.shields.io/travis/jonschlinkert/map-visit.svg?style=flat)](https://travis-ci.org/jonschlinkert/map-visit) +# map-visit [![NPM version](https://img.shields.io/npm/v/map-visit.svg?style=flat)](https://www.npmjs.com/package/map-visit) [![NPM monthly downloads](https://img.shields.io/npm/dm/map-visit.svg?style=flat)](https://npmjs.org/package/map-visit) [![NPM total downloads](https://img.shields.io/npm/dt/map-visit.svg?style=flat)](https://npmjs.org/package/map-visit) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/map-visit.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/map-visit) -Map `visit` over an array of objects. +> Map `visit` over an array of objects. ## Install @@ -16,7 +16,9 @@ var mapVisit = require('map-visit'); ``` -## Assign or Merge vs. Visit +## What does this do? + +**Assign/Merge/Extend vs. Visit** Let's say you want to add a `set` method to your application that will: @@ -26,7 +28,7 @@ **Example using `extend`** -Here is one way to accomplish this using Lo-Dash's `extend`: +Here is one way to accomplish this using Lo-Dash's `extend` (comparable to `Object.assign`): ```js var _ = require('lodash'); @@ -52,11 +54,16 @@ //=> {a: 'a', b: 'b', c: 'c', d: { e: 'f' }} ``` -The above approach works fine for most use cases. But **if you also want to emit an event** each time a property is added to the `data` object. A better approach would be to use `visit`. +The above approach works fine for most use cases. However, **if you also want to emit an event** each time a property is added to the `data` object, or you want more control over what happens as the object is extended, a better approach would be to use `visit`. **Example using `visit`** -In this approach, when an array is passed to `set`, `mapVisit` calls `set` on each object in the array. When an object is passed, `visit` calls `set` on each property in the object. As a result, the `data` event will be emitted every time a property is added to `data`. +In this approach: + +* when an array is passed to `set`, the `mapVisit` library calls the `set` method on each object in the array. +* when an object is passed, `visit` calls `set` on each property in the object. + +As a result, the `data` event will be emitted every time a property is added to `data` (events are just an example, you can use this approach to perform any necessary logic every time the method is called). ```js var mapVisit = require('map-visit'); @@ -70,7 +77,7 @@ } else if (typeof key === 'object') { visit(obj, 'set', key); } else { - // some event-emitter + // simulate an event-emitter console.log('emit', key, value); obj.data[key] = value; } @@ -106,22 +113,29 @@ Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). +### Contributors + +| **Commits** | **Contributor** | +| --- | --- | +| 15 | [jonschlinkert](https://github.com/jonschlinkert) | +| 7 | [doowb](https://github.com/doowb) | + ### Building docs -_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ +_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ -To generate the readme and API documentation with [verb](https://github.com/verbose/verb): +To generate the readme, run the following command: ```sh -$ npm install -g verb verb-generate-readme && verb +$ npm install -g verbose/verb#dev verb-generate-readme && verb ``` ### Running tests -Install dev dependencies: +Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh -$ npm install -d && npm test +$ npm install && npm test ``` ### Author @@ -129,13 +143,13 @@ **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) -* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) +* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) ### License -Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). -Released under the [MIT license](https://github.com/jonschlinkert/map-visit/blob/master/LICENSE). +Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). +Released under the [MIT License](LICENSE). *** -_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on August 05, 2016._ \ No newline at end of file +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 09, 2017._ \ No newline at end of file diff -Nru node-map-visit-0.1.5/test.js node-map-visit-1.0.0/test.js --- node-map-visit-0.1.5/test.js 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/test.js 2017-04-09 21:43:22.000000000 +0000 @@ -1,42 +1,42 @@ 'use strict'; require('mocha'); -require('should'); +var clone = require('clone-deep'); var assert = require('assert'); +var extend = require('extend-shallow'); var visit = require('object-visit'); var mapVisit = require('./'); +var ctx; -var ctx = { +var fixture = { data: {}, + options: {}, set: function(key, value) { - if (Array.isArray(key)) { - mapVisit(ctx, 'set', key); - } else if (typeof key === 'object') { - visit(ctx, 'set', key); + if (typeof key !== 'string') { + if (value) extend(this.options, value); + mapVisit(this, 'set', key, value); } else { - ctx.data[key] = value; + this.data[key] = value; } } }; describe('visit', function() { - it('should throw an error when value is not an array.', function(done) { - try { + beforeEach(function() { + ctx = clone(fixture); + }); + + it('should throw an error when value is not an array', function() { + assert.throws(function() { mapVisit({}, 'foo', 'bar'); - done(new Error('expected an error')); - } catch (err) { - assert(err); - assert(err.message); - assert(err.message === 'expected an array'); - done(); - } + }); }); - it('should call visit on every value in the given object:', function() { + it('should call visit on every value in the given object', function() { ctx.set('a', 'a'); ctx.set([{b: 'b'}, {c: 'c'}]); ctx.set({d: {e: 'f'}}); - ctx.data.should.eql({ + assert.deepEqual(ctx.data, { a: 'a', b: 'b', c: 'c', @@ -44,13 +44,13 @@ }); }); - it('should call visit on every value in the given object:', function() { + it('should call visit on every element of any array', function() { ctx.set('a', 'a'); ctx.set(['x', 'y']); ctx.set([{b: 'b'}, {c: 'c'}]); ctx.set({d: {e: 'f'}}); - ctx.data.should.eql({ + assert.deepEqual(ctx.data, { a: 'a', b: 'b', c: 'c', @@ -59,4 +59,18 @@ y: undefined }); }); + + it('should set the second arg on every element', function() { + ctx.set(['foo', 'bar'], function() {}); + + assert.equal(typeof ctx.data.foo, 'function'); + assert.equal(typeof ctx.data.bar, 'function'); + }); + + it('should set the second arg on every object', function() { + ctx.set({a: 'aaa', b: 'bbb'}, {cwd: process.cwd()}); + + assert.equal(ctx.options.cwd, process.cwd()); + assert.equal(ctx.options.cwd, process.cwd()); + }); }); diff -Nru node-map-visit-0.1.5/.travis.yml node-map-visit-1.0.0/.travis.yml --- node-map-visit-0.1.5/.travis.yml 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/.travis.yml 2017-04-09 21:43:22.000000000 +0000 @@ -1,14 +1,16 @@ sudo: false +os: + - linux + - osx language: node_js node_js: + - node + - '7' - '6' - '5' - '4' - '0.12' - '0.10' matrix: + allow_failures: [] fast_finish: true - allow_failures: - - node_js: '4' - - node_js: '0.10' - - node_js: '0.12' diff -Nru node-map-visit-0.1.5/utils.js node-map-visit-1.0.0/utils.js --- node-map-visit-0.1.5/utils.js 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/utils.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -'use strict'; - -var utils = require('lazy-cache')(require); -var fn = require; - -require = utils; // trick browserify -require('object-visit', 'visit'); -require = fn; - -/** - * Expose utils - */ - -module.exports = utils; diff -Nru node-map-visit-0.1.5/.verb.md node-map-visit-1.0.0/.verb.md --- node-map-visit-0.1.5/.verb.md 2016-08-05 21:52:30.000000000 +0000 +++ node-map-visit-1.0.0/.verb.md 2017-04-09 21:43:22.000000000 +0000 @@ -1,11 +1,12 @@ -{{#block "logo"}}{{/block}} ## Usage ```js var mapVisit = require('{%= name %}'); ``` -## Assign or Merge vs. Visit +## What does this do? + +**Assign/Merge/Extend vs. Visit** Let's say you want to add a `set` method to your application that will: @@ -15,7 +16,7 @@ **Example using `extend`** -Here is one way to accomplish this using Lo-Dash's `extend`: +Here is one way to accomplish this using Lo-Dash's `extend` (comparable to `Object.assign`): ```js var _ = require('lodash'); @@ -41,11 +42,16 @@ //=> {a: 'a', b: 'b', c: 'c', d: { e: 'f' }} ``` -The above approach works fine for most use cases. But **if you also want to emit an event** each time a property is added to the `data` object. A better approach would be to use `visit`. +The above approach works fine for most use cases. However, **if you also want to emit an event** each time a property is added to the `data` object, or you want more control over what happens as the object is extended, a better approach would be to use `visit`. **Example using `visit`** -In this approach, when an array is passed to `set`, `mapVisit` calls `set` on each object in the array. When an object is passed, `visit` calls `set` on each property in the object. As a result, the `data` event will be emitted every time a property is added to `data`. +In this approach: + +- when an array is passed to `set`, the `mapVisit` library calls the `set` method on each object in the array. +- when an object is passed, `visit` calls `set` on each property in the object. + +As a result, the `data` event will be emitted every time a property is added to `data` (events are just an example, you can use this approach to perform any necessary logic every time the method is called). ```js var mapVisit = require('{%= name %}'); @@ -59,7 +65,7 @@ } else if (typeof key === 'object') { visit(obj, 'set', key); } else { - // some event-emitter + // simulate an event-emitter console.log('emit', key, value); obj.data[key] = value; }