{"_id":"modification","_rev":"269051","name":"modification","description":"Process changes that should be made on the prototype and emit `change` event for each changed property","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"3rdeden","email":""},{"name":"v1","email":""}],"time":{"modified":"2023-06-28T12:13:44.000Z","created":"2014-10-24T07:28:22.730Z","1.0.0":"2015-03-02T23:35:15.197Z","0.0.0":"2014-10-24T07:28:22.730Z"},"users":{},"author":{"name":"Arnout Kazemier"},"repository":{"type":"git","url":"https://github.com/unshiftio/modification"},"versions":{"1.0.0":{"name":"modification","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":{"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/unshiftio/modification"},"keywords":["change","changes","modification","modify","process","update"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/unshiftio/modification/issues"},"homepage":"https://github.com/unshiftio/modification","devDependencies":{"assume":"1.1.x","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"1.0.x"},"gitHead":"8224e91cea72951bcd7be1714abf474867a328ee","_id":"modification@1.0.0","_shasum":"b988ea311432a25a78c635c4d5e865e318b3b151","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""},{"name":"v1","email":""}],"dist":{"shasum":"b988ea311432a25a78c635c4d5e865e318b3b151","size":4484,"noattachment":false,"key":"/modification/-/modification-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/modification/download/modification-1.0.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:24:45.442Z","publish_time":1425339315197,"_cnpm_publish_time":1425339315197},"0.0.0":{"name":"modification","version":"0.0.0","description":"Listen and apply modifications","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/observing/modification"},"keywords":["change","observe","diff","modification","changes","observer","observing","object"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/observing/modification/issues"},"homepage":"https://github.com/observing/modification","_id":"modification@0.0.0","_shasum":"947adb6b945e3368b265b12638accab2cd05c839","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"V1","email":"info@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""},{"name":"v1","email":""}],"dist":{"shasum":"947adb6b945e3368b265b12638accab2cd05c839","size":482,"noattachment":false,"key":"/modification/-/modification-0.0.0.tgz","tarball":"http://name.csiicloud.com:7001/modification/download/modification-0.0.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T13:24:44.576Z","publish_time":1414135702730,"_cnpm_publish_time":1414135702730}},"readme":"# modification\n\n[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/modification)[![Build Status][build]](https://travis-ci.org/unshiftio/modification)[![Dependencies][david]](https://david-dm.org/unshiftio/modification)[![Coverage Status][cover]](https://coveralls.io/r/unshiftio/modification?branch=master)[![IRC channel][irc]](http://webchat.freenode.net/?channels=unshift)\n\n[made-by]: https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square\n[version]: https://img.shields.io/npm/v/modification.svg?style=flat-square\n[build]: https://img.shields.io/travis/unshiftio/modification/master.svg?style=flat-square\n[david]: https://img.shields.io/david/unshiftio/modification.svg?style=flat-square\n[cover]: https://img.shields.io/coveralls/unshiftio/modification/master.svg?style=flat-square\n[irc]: https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square\n\nModification is a small helper function that helps you process changes on the\nprototype of your instances as it will automatically emit change events for\nproperties that you've changed.\n\n## Installation\n\nThis module is intended for server and client usage and is released in the public\nnpm repository and can be installed using:\n\n```\nnpm install --save modification\n```\n\n## Usage\n\nIn all of the examples we're going to assume the following setup:\n\n```js\n'use strict';\n\nvar modification = require('modification')\n  , EventEmitter = require('events').EventEmitter;\n\nfunction Foo() {\n  this.bar = 'baz';\n  this.foo = 'bar';\n\n  EventEmitter.call(this);\n}\n\nrequire('util').inherits(Foo, EventEmitter);\n```\n\nThe `modification` module exports function that returns another function upon\ninvocation. The `modification` function can called with 1 option argument which\nspecifies the suffix of the event that needs to be emitted:\n\n```js\nFoo.prototype.change = modification(' changed');\n```\n\nIn the example above we will automatically emit `foo changed` once we change the\n`foo` property through the set `.change` method:\n\n```js\nvar foo = new Foo();\n\nconsole.log(foo.foo); // 'bar';\n\nfoo.on('foo changed', function (currently, previously) {\n  console.log(this.foo);    // hi\n  console.log(currently);   // hi\n  console.log(previously);  // bar\n});\n\nfoo.change({ foo: 'hi' });\n```\n\nAs you can see in the example above we need to pass an object with the changes\nfor the prototype. If one of the properties in the supplied object does not\nexist on the `foo` instance we will ignore it. If it does exist but is the same\nwe will **not** emit the event or change the value. If it has a different value\nwe will emit: `<name of the property><supplied suffix>` with the current value\nand the previous value.\n\nThe introduced `.change` method will `this` so it can be used for chaining.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/unshiftio/modification","bugs":{"url":"https://github.com/unshiftio/modification/issues"},"license":"MIT"}