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

delta-listener

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

delta-listener

Deeply compare JavaScript objects and listen to changes.

  • 1.0.0-alpha.3
  • npm
  • Socket score

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

delta-listener Build status

Deeply compare JavaScript objects and listen to changes. Used in colyseus.js v0.6.0+.

Usage

import { DeltaContainer } from "delta-listener"
let container = new DeltaContainer({
    entities: {
        one: { x: 10, y: 10 },
        two: { x: 10, y: 10 }
    }
});

container.listen("entities/:id", "add", (entityId: string, value: any) => {
    console.log("new entity", entityId, value);
})

container.set({
    entities: {
        one: { x: 20, y: 10 },
        two: { x: 10, y: 10 }
    }
})

See tests for more usage examples.

Built-in placeholders

  • :id: /([a-zA-Z0-9\-_]+)/
  • :number: /([0-9]+)/
  • :string: /(\w+)/
  • *: /(.*)/

When any other name is used starting with : (e.g. :example), * will be used instead.

Example:

container.listen("players/:entityId", "replace", (entityId: string, value: any) => {
    console.log(key, "changed to", value);
})

Is equivalent to:

container.listen("players/*", "replace", (entityId: string, value: any) => {
    console.log(key, "changed to", value);
})

Special thanks

The compare method is highly based on fast-json-patch implementation.

License

MIT

Keywords

FAQs

Package last updated on 11 Dec 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