@skyrpex/remember
v1.0.1
Published
Method that retrieves a value from an object given a path
Downloads
3
Readme
Remember
Method that retrieves a value from an object given a path. If the path doesn't exist in the object, it assigns the default value from the given callback.
Installation
npm install @skyrpex/remember
Usage
import remember from '@skyrpex/remember';
const object = {
a: 'value A',
};
remember(object, 'a', () => 'default A'); // 'value A'
remember(object, 'b', () => 'default B'); // 'default B'
object.b; // 'default B'