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

Argument Type Required Description
path String No* 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.

Argument Type Required Description
original Object No The object
...paths Arguments Yes The path strings/symbols

dotGetPathInO

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

Argument Type Required Description
original Object No The object
pathstring String Yes The dot-notated path string

putPathInO

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

Argument Type Required Description
original Object No The object
value Any Yes The new element
...paths Arguments Yes The path strings/symbols

dotPutPathInO

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

Argument Type Required Description
original Object No The object
value Any Yes The new element
pathstring String Yes The dot-notated path strings

Testing

npm test