Template Upload
This commit is contained in:
111
node_modules/dot-prop/index.js
generated
vendored
Normal file
111
node_modules/dot-prop/index.js
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
'use strict';
|
||||
var isObj = require('is-obj');
|
||||
|
||||
module.exports.get = function (obj, path) {
|
||||
if (!isObj(obj) || typeof path !== 'string') {
|
||||
return obj;
|
||||
}
|
||||
|
||||
var pathArr = getPathSegments(path);
|
||||
|
||||
for (var i = 0; i < pathArr.length; i++) {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, pathArr[i]) || Object.getOwnPropertyDescriptor(Object.prototype, pathArr[i]);
|
||||
if (descriptor && !descriptor.enumerable) {
|
||||
return;
|
||||
}
|
||||
|
||||
obj = obj[pathArr[i]];
|
||||
|
||||
if (obj === undefined || obj === null) {
|
||||
// `obj` is either `undefined` or `null` so we want to stop the loop, and
|
||||
// if this is not the last bit of the path, and
|
||||
// if it did't return `undefined`
|
||||
// it would return `null` if `obj` is `null`
|
||||
// but we want `get({foo: null}, 'foo.bar')` to equal `undefined` not `null`
|
||||
if (i !== pathArr.length - 1) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
module.exports.set = function (obj, path, value) {
|
||||
if (!isObj(obj) || typeof path !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var pathArr = getPathSegments(path);
|
||||
|
||||
for (var i = 0; i < pathArr.length; i++) {
|
||||
var p = pathArr[i];
|
||||
|
||||
if (!isObj(obj[p])) {
|
||||
obj[p] = {};
|
||||
}
|
||||
|
||||
if (i === pathArr.length - 1) {
|
||||
obj[p] = value;
|
||||
}
|
||||
|
||||
obj = obj[p];
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.delete = function (obj, path) {
|
||||
if (!isObj(obj) || typeof path !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var pathArr = getPathSegments(path);
|
||||
|
||||
for (var i = 0; i < pathArr.length; i++) {
|
||||
var p = pathArr[i];
|
||||
|
||||
if (i === pathArr.length - 1) {
|
||||
delete obj[p];
|
||||
return;
|
||||
}
|
||||
|
||||
obj = obj[p];
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.has = function (obj, path) {
|
||||
if (!isObj(obj) || typeof path !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
var pathArr = getPathSegments(path);
|
||||
|
||||
for (var i = 0; i < pathArr.length; i++) {
|
||||
obj = obj[pathArr[i]];
|
||||
|
||||
if (obj === undefined) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
function getPathSegments(path) {
|
||||
var pathArr = path.split('.');
|
||||
var parts = [];
|
||||
|
||||
for (var i = 0; i < pathArr.length; i++) {
|
||||
var p = pathArr[i];
|
||||
|
||||
while (p[p.length - 1] === '\\' && pathArr[i + 1] !== undefined) {
|
||||
p = p.slice(0, -1) + '.';
|
||||
p += pathArr[++i];
|
||||
}
|
||||
|
||||
parts.push(p);
|
||||
}
|
||||
|
||||
return parts;
|
||||
}
|
21
node_modules/dot-prop/license
generated
vendored
Normal file
21
node_modules/dot-prop/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
103
node_modules/dot-prop/package.json
generated
vendored
Normal file
103
node_modules/dot-prop/package.json
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"dot-prop@^3.0.0",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\configstore"
|
||||
]
|
||||
],
|
||||
"_from": "dot-prop@>=3.0.0-0 <4.0.0-0",
|
||||
"_id": "dot-prop@3.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/dot-prop",
|
||||
"_nodeVersion": "4.4.2",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-16-east.internal.npmjs.com",
|
||||
"tmp": "tmp/dot-prop-3.0.0.tgz_1463682431324_0.5166875969152898"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"name": "sindresorhus"
|
||||
},
|
||||
"_npmVersion": "2.15.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "dot-prop",
|
||||
"raw": "dot-prop@^3.0.0",
|
||||
"rawSpec": "^3.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=3.0.0-0 <4.0.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/configstore"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz",
|
||||
"_shasum": "1b708af094a49c9a0e7dbcad790aba539dac1177",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "dot-prop@^3.0.0",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\configstore",
|
||||
"author": {
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"name": "Sindre Sorhus",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/dot-prop/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-obj": "^1.0.0"
|
||||
},
|
||||
"description": "Get, set, or delete a property from a nested object using a dot path",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"matcha": "^0.7.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "1b708af094a49c9a0e7dbcad790aba539dac1177",
|
||||
"tarball": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "e50dd5becf66fda1e2307506eeb3162c0f9f3bb8",
|
||||
"homepage": "https://github.com/sindresorhus/dot-prop#readme",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"access",
|
||||
"del",
|
||||
"delete",
|
||||
"dot",
|
||||
"dotty",
|
||||
"get",
|
||||
"notation",
|
||||
"obj",
|
||||
"object",
|
||||
"path",
|
||||
"prop",
|
||||
"property",
|
||||
"set"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "dot-prop",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/dot-prop.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "matcha bench.js",
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "3.0.0"
|
||||
}
|
82
node_modules/dot-prop/readme.md
generated
vendored
Normal file
82
node_modules/dot-prop/readme.md
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
# dot-prop [](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: {'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'}}
|
||||
|
||||
dotProp.set(obj, 'foo.baz', 'x');
|
||||
console.log(obj);
|
||||
//=> {foo: {bar: 'b', baz: 'x'}}
|
||||
|
||||
// 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)
|
||||
|
||||
### set(obj, path, value)
|
||||
|
||||
### 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`.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
Reference in New Issue
Block a user