Base storage
Provides easy way to get / set and check the existence of a paths in the objects
npm install --save base-storage
How to use
; const storage = a: b: c: d: 1 e: 2 f: 2; // has methodtobe;tobe; // get methodtobe;tobe;tobe; // set method storage;tobe;
Extends
; { superconfig; } { throw '"set" method is denied' }
Very useful for using as config storage with presets (shortcuts)
; routing: { let routes = this; routes; this; } { this; } { this; } ; exceptions: { let handlers = this; handlers; this; } ; api: this this this ; google: this this this { superconfig; } let config = ; // .... configgoogle;configgoogle; tobe; tobe;tobe;
Available methods
-
constructor(object)
- constructor takes object with which get / set / has methods will work -
get(path, defaultValue)
- gets the value at path of object. If the resolved value is undefined the defaultValue is used in its place. (lodash/get) -
set(path, value)
- sets the value at path of object. (lodash/set) -
has(path)
- returns true is path exists and false - if not. (lodash/has)
Community
You are always welcome for ideas and pull requests :)
TODO
- Feature request: freeze (make immutable) whole stored object and its parts
- Feature request: Support data structures. (likely to use tcomb)