Package Exports
- keyd
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (keyd) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
keyd
A small library for using and manipulating key path in JavaScript.
Installation
npm install --save keyd
Getting / Setting Values
const keyd = require('keyd');
Getting Values
keyd(obj).get('my.keypath');
Getting values in array and sub-arrays.
keyd(obj).getAll('my.keypath');
Setting Values
keyd(obj).set('my.keypath', value);
Manipulating Key Paths
Components
const components = keyd.components('my.key.path');
/* -> ['my','key','path'] */
Joining
const keyPath = keyd.join(['my','key','path']);
/* -> 'my.key.path' */
Appending Keys
const keyPath = keyd.append('my.key', 'path');
/* -> 'my.key.path' */
or
const keyPath = keyd.append('my', ['key', 'path']);
/* -> 'my.key.path' */
Last
Getting
const lastComponent = keyd.last('my.key.path');
/* -> 'path' */
Removing
const keyPath = keyd.eatLast('my.key.path');
/* -> 'my.key' */
First
Getting
const firstComponent = keyd.first('my.key.path');
/* -> 'my' */
Removing
const keyPath = keyd.eatFirst('my.key.path');
/* -> 'key.path' */
Match
const within = keyd.within('my.key.path', 'my.key');
/* -> true */
License
MIT (see LICENSE).