1.0.10 • Published 4 years ago

pathino v1.0.10

Weekly downloads
3
License
Unlicense
Repository
github
Last release
4 years ago

VersionBuild Status codecov

license JavaScript Style Guide


pathino

Documentation

Get and put element E at path P in object O.

A bunch of other libraries do this already. Search "dot notation" on npm to find some of them.

This package is for when the objects contain symbol keys.


Installation

Run npm install pathino

Usage

This package exports five functions:

dotParse

Parse a dot notated path, remove whitespace-only path elements

ArgumentTypeRequiredDescription
pathStringNo*The dot path to parse
  • dotParse won't throw without path, but it won't return anything useful either.

getPathInO

Deep find element in an object by path elements p, returning undefined if the path or element at the path was undefined.

ArgumentTypeRequiredDescription
originalObjectNoThe object
...pathsArgumentsYesThe path strings/symbols

dotGetPathInO

Deep find something in an object using dot-notation formatted path string

ArgumentTypeRequiredDescription
originalObjectNoThe object
pathstringStringYesThe dot-notated path string

putPathInO

Deep put something in an object by path elements p, creating tree as needed, using Object.assign

ArgumentTypeRequiredDescription
originalObjectNoThe object
valueAnyYesThe new element
...pathsArgumentsYesThe path strings/symbols

dotPutPathInO

Deep put something in an object using dot-notation formatted path string and Object.assign

ArgumentTypeRequiredDescription
originalObjectNoThe object
valueAnyYesThe new element
pathstringStringYesThe dot-notated path strings

Testing

npm test

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago