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

notation

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

notation

Utility for modifying / processing the contents of Javascript objects by object notation strings or globs.

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34K
decreased by-17.75%
Maintainers
1
Weekly downloads
 
Created
Source

Notation.js

for Node and Browser.

build-status npm release dependencies license maintained

© 2017, Onur Yıldırım (@onury). MIT License.

Utility for modifying / processing the contents of Javascript objects by parsing object notation strings or globs.

Note that this library will only deal with enumerable properties of the source object; so it should be used to manipulate data objects. It will not deal with preserving the prototype-chain of the given object.

Usage

Install via NPM:

npm i notation --save
var Notation = require('notation');

var obj = { car: { brand: "Dodge", model: "Charger" }, dog: { breed: "Akita" } };
var notation = new Notation(obj);
notation.get('car.model');      // "Charger"
notation
    .set('car.color', 'red')         // { car: { brand: "Dodge", model: "Charger", color: "red" }, dog: { breed: "Akita" } }
    .remove('car.model')             // { car: { brand: "Dodge", color: "red" }, dog: { breed: "Akita" } }
    .filter(['*', '!car'])           // { dog: { breed: "Akita" } }
    .flatten()                       // { "dog.breed": "Akita" }
    .expand()                        // { dog: { breed: "Akita" } }
    .merge({ 'dog.color': 'white' }) // { dog: { breed: "Akita", color: "white" } }
    .copyFrom(other, 'boat.name')    // { dog: { breed: "Akita", color: "white" }, boat: { name: "Mojo" } }
    .rename('boat.name', 'dog.name') // { dog: { breed: "Akita", color: "white", name: "Mojo" } }
    .value;                          // source object

Documentation

You can read the full API reference here.

Change-Log

1.3.0 (2017-09-30)

  • Completely re-wrote Notation.Glob.union() static method.
    • Fixed the array mutation issue. Fixes issue #2.
    • Fixed an issue where a glob with wildcard is not properly union'ed. Fixes issue #3.
    • sort (boolean) argument is removed (the output is now always sorted.)
    • Union output is now properly normalized, duplicates and redundant globs are removed, etc...
  • Fixed an issue where negated wildcards would be filtered incorrectly in some edge cases (e.g. !*.*.*).
  • Added Notation.Glob.normalize(array) static method.
  • Added Notation.Glob.toRegExp(glob) static method.
  • Aded Notation.countNotes(notation) convenience method.
  • Improved glob validation.
  • Fix import typo that prevents Travis builds succeed.
  • Minor revisions, clean-up.
  • (dev) Removed dev-dependencies (Grunt and plugins) in favor of NPM scripts. Updated other dev-dependencies. Added more, comprehensive tests.

1.1.0 (2016-09-27)

  • Added Notation#expand() method (alias Notation#aggregate()).
  • Refactored Notation#getFlat() to Notation#flatten(). Returns instance (chainable) instead of source.
  • Notation#separate() returns instance (chainable) instead of source.
  • Minor revisions.

v1.0.0 (2016-04-10)

  • initial release.

License

MIT.

Keywords

FAQs

Package last updated on 30 Sep 2017

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