weoptions
0.0.11 • Public • Published weoptions
我想要有个公共 options
, 但可以通过不同的ID
, just init/get/set
中文 | english
Install
npm install weoptions
yarn add weoptions
Usage
let strict = false;
const weoptions = require('weoptions')('id', strict);
let options = {
name: 'yobrave',
a: {
b: {
c: 1,
},
},
};
let w = weoptions(options);
w.set('a.b.c', 2);
w.set('a.b.e.d', 2);
w.get();
w.get('a.b.c');
const weoptions = require('weoptions')('id');
w.get();
w.set('a.b.c', 1);
w._setStrict(true);
API
1. weoptions(id, strict)
id
name: |
id |
Type: |
string |
Desc: |
the id of your options, just like debug |
strict
name: |
strict |
Type: |
boolean |
Default: |
false |
Desc: |
the strict of your options |
⚠️: |
if true , anything after WEOPTIONS(options) add/remove/new willthrow Error |
return
name: |
return |
Type: |
WEOPTIONS | W |
Desc: |
if id had init, return W , else return WEOPTIONS |
- WEOPTIONS(options):W
options
name: |
options |
Type: |
any |
Desc: |
options init |
- W.set(position, value)
position
name: |
position |
Type: |
string |
Desc: |
options position |
value
name: |
value |
Type: |
any |
Desc: |
options value |
use dset API
- W.get(position)
position
name: |
position |
Type: |
string |
Desc: |
options position |
use dlv API
- W._setStrict(bool)
bool
name: |
bool |
Type: |
boolean |
Desc: |
change strict to bool |
License
MIT © chinanf-boy
Package Sidebar
Install
Weekly Downloads