pxth
Tiny utility library for object property path handling

Install
npm install pxth
Or
yarn add pxth
Api reference
Here are all functions described.
Pxth<T>
Holds path to field of type T in the origin object.
const a: Pxth<string>;
const b: Pxth<number>;
If T is object, it is possible to get paths to its fields:
const objectPath: Pxth<{ inner: string }>;
const innerPath: Pxth<string> = objectPath.inner;
const lengthPath: Pxth<number> = innerPath.length;
const deepLengthPath: Pxth<number> = objectPath.inner.length;
deepGet
Deeply get value from object.
Usage:
import { deepGet } from 'pxth';
const somePath: Pxth<string> = ;
const value = deepGet({ a: { b: { c: 'Hello world!' } } }, somePath);
console.log(value);
deepSet
Deeply set value in object. Mutates the object and returns it. If value already exists, overwrites it.
Usage:
import { deepSet } from 'pxth';
const somePath: Pxth<string> = ;
deepSet({ a: { hello: 'asdf' } }, somePath, 'New value');
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
MIT © Artiom Tretjakovas
Created with aqu 🌊