Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kvcobj

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kvcobj

Key-value coding for javascript objects.

  • 0.1.0-6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

KVCObject

Key-value coding for javascript objects. Gives access to values in object trees via keypaths. Emits update events as they come, with minimal changesets. Good for finding deltas for new versions of objects, and linking views to models.

Public API

Methods

  • (constructor)([< object >options])
    Creates and returns a new KVCObject.
    Valid options:

    • delimiter - string - The string to use as delimiter between keys. Default: '.'
  • setObject(< object >object, [< bool >silent]) - (void)
    Sets the current root, overwriting the existing root. If this leads to a change of the object, an update (and possibly also a create or delete , see below) event will be triggered, unless silent is set to true.

  • getObject() - (object)
    Returns the current root as a normal object.

  • setObjectForKeypath(< object >object, < string >rootKeypath, [< bool >silent]) - (void)
    Sets all values of object, where rootKeypath will be the keypath to the root of the object. If this leads to a change of the object, an update (and possibly also a create or delete, see below) event will be triggered, unless silent is set to true.

  • getObjectForKeypath(< string >keypath) - (object)
    Returns the object from keypath.

  • setValueForKeypath(< non-object >value, < string >keypath, [< bool >silent]) - (void)
    Sets value at keypath. If this leads to a change of the object, an update (and possibly also a create or delete , see below) event will be triggered, unless silent is set to true.

  • getValueForKeypath(< string >keypath) - (non-object)
    Returns the value at keypath.

  • commit() - (void)
    Commits uncommited changes made with silent set to true. This leads to change events being emitted.

Events

  • create(< object >created)
    Emitted when a value (or a set of values) is set for a keypath (or a set of keypaths) for the first time.
    created is an object with the new keypaths as keys and their corresponding values as values
    Note: a new create event will be emitted when the value for a keypath is deleted (set to undefined) and the reset to a value
    Note: a matching update event will also be emitted for each create event

  • update(< object >updated)
    Emitted when a value (or a set of values) is changed for a keypath (or a set of keypaths).
    updated is an object with the updated keypaths as keys and corresponding values as values
    Note: an update event will be emitted even if there is no previous value for the keypath

  • delete(< object >deleted)
    Emitted when a value (or a set of values) is deleted (or set to undefined) for a keypath (or a set of keypaths).
    deleted is an object with the deleted keypaths as keys and corresponding values as values
    Note: a matching update event will also be emitted for each delete event

Keywords

FAQs

Package last updated on 05 Sep 2013

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