New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

diffback

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diffback

Fire callbacks whenever properties of an object change.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

diffback

Fire callbacks whenever properties of an object change.

No observers etc. As performant as changing the value and manually executing the callbacks.

Install

npm install diffback

Attach callbacks

var diffback = require('diffback');
function print(value) {
  console.log('Executing: ', value);
}

var obj = {
  a: 1,
  b: 2
};


diffback(obj, 'a', print);

obj.a = 100;

Remove callbacks

diffback.remove(obj, 'a', print); // Removes print callback

// If no callback is specified then all callbacks are removed.
diffback.remove(obj, 'a'); // Removes all callbacks

Example

var diffback = require('diffback');

function print(newValue, oldValue) {
  console.log(newValue, oldValue);
}
var object = {
  a: 10,
  b: "hello"
};

diffback(object, 'z', print);

object.z = 100; // Prints: 100 (new value) undefined (old value)

object.z = 200; // Prints: 200 (new value) 100 (old value)

diffback.remove(object, 'z', print); // removes print callback

Keywords

FAQs

Package last updated on 17 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc