modification
Advanced tools
Comparing version 0.0.0 to 1.0.0
37
index.js
'use strict'; | ||
module.exports = function (obj, prop, fn) { | ||
/** | ||
* Return a function which will process changes on the instance based on the | ||
* object that is provided and emit a dedicated "change" event. | ||
* | ||
* @param {String} suffix The suffix for the event we emit. | ||
* @returns {Function} | ||
* @api public | ||
*/ | ||
module.exports = function modification(suffix) { | ||
suffix = arguments.length ? suffix : ''; | ||
/** | ||
* Changes processor. | ||
* | ||
* @param {Object} changed Properties that have to be changed. | ||
* @returns {That} What ever the value of `this` is. | ||
* @api public | ||
*/ | ||
return function change(changed) { | ||
var currently, previously | ||
, that = this | ||
, key; | ||
if (!changed) return that; | ||
for (key in changed) { | ||
if (key in that && that[key] !== changed[key]) { | ||
currently = changed[key]; | ||
previously = that[key]; | ||
that[key] = currently; | ||
that.emit(key + suffix, currently, previously); | ||
} | ||
} | ||
return that; | ||
}; | ||
}; |
{ | ||
"name": "modification", | ||
"version": "0.0.0", | ||
"description": "Listen and apply modifications", | ||
"version": "1.0.0", | ||
"description": "Process changes that should be made on the prototype and emit `change` event for each changed property", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100", | ||
"test": "mocha test.js", | ||
"watch": "mocha --watch test.js", | ||
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js", | ||
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/observing/modification" | ||
"url": "https://github.com/unshiftio/modification" | ||
}, | ||
"keywords": [ | ||
"change", | ||
"observe", | ||
"diff", | ||
"changes", | ||
"modification", | ||
"changes", | ||
"observer", | ||
"observing", | ||
"object" | ||
"modify", | ||
"process", | ||
"update" | ||
], | ||
@@ -26,5 +28,11 @@ "author": "Arnout Kazemier", | ||
"bugs": { | ||
"url": "https://github.com/observing/modification/issues" | ||
"url": "https://github.com/unshiftio/modification/issues" | ||
}, | ||
"homepage": "https://github.com/observing/modification" | ||
"homepage": "https://github.com/unshiftio/modification", | ||
"devDependencies": { | ||
"assume": "1.1.x", | ||
"istanbul": "0.3.x", | ||
"mocha": "2.1.x", | ||
"pre-commit": "1.0.x" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
8906
7
103
1
0
1
82
4