aboutsummaryrefslogtreecommitdiff
path: root/node_modules/dot-prop/readme.md
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/dot-prop/readme.md
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/dot-prop/readme.md')
-rw-r--r--node_modules/dot-prop/readme.md103
1 files changed, 103 insertions, 0 deletions
diff --git a/node_modules/dot-prop/readme.md b/node_modules/dot-prop/readme.md
new file mode 100644
index 00000000..fab3b7af
--- /dev/null
+++ b/node_modules/dot-prop/readme.md
@@ -0,0 +1,103 @@
+# dot-prop [![Build Status](https://travis-ci.org/sindresorhus/dot-prop.svg?branch=master)](https://travis-ci.org/sindresorhus/dot-prop)
+
+> Get, set, or delete a property from a nested object using a dot path
+
+
+## Install
+
+```
+$ npm install --save dot-prop
+```
+
+
+## Usage
+
+```js
+const dotProp = require('dot-prop');
+
+// getter
+dotProp.get({foo: {bar: 'unicorn'}}, 'foo.bar');
+//=> 'unicorn'
+
+dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep');
+//=> undefined
+
+dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');
+//=> 'default value'
+
+dotProp.get({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
+//=> 'unicorn'
+
+// setter
+const obj = {foo: {bar: 'a'}};
+dotProp.set(obj, 'foo.bar', 'b');
+console.log(obj);
+//=> {foo: {bar: 'b'}}
+
+const foo = dotProp.set({}, 'foo.bar', 'c');
+console.log(foo);
+//=> {foo: {bar: 'c'}}
+
+dotProp.set(obj, 'foo.baz', 'x');
+console.log(obj);
+//=> {foo: {bar: 'b', baz: 'x'}}
+
+// has
+dotProp.has({foo: {bar: 'unicorn'}}, 'foo.bar');
+//=> true
+
+// deleter
+const obj = {foo: {bar: 'a'}};
+dotProp.delete(obj, 'foo.bar');
+console.log(obj);
+//=> {foo: {}}
+
+obj.foo.bar = {x: 'y', y: 'x'};
+dotProp.delete(obj, 'foo.bar.x');
+console.log(obj);
+//=> {foo: {bar: {y: 'x'}}}
+```
+
+
+## API
+
+### get(obj, path, [defaultValue])
+
+### set(obj, path, value)
+
+Returns the object.
+
+### has(obj, path)
+
+### delete(obj, path)
+
+#### obj
+
+Type: `Object`
+
+Object to get, set, or delete the `path` value.
+
+#### path
+
+Type: `string`
+
+Path of the property in the object, using `.` to separate each nested key.
+
+Use `\\.` if you have a `.` in the key.
+
+#### value
+
+Type: `any`
+
+Value to set at `path`.
+
+#### defaultValue
+
+Type: `any`
+
+Default value.
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)