From cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 27 Mar 2019 21:01:33 +0100 Subject: remove node_modules --- node_modules/dot-prop/index.js | 123 ----------------------------------------- 1 file changed, 123 deletions(-) delete mode 100644 node_modules/dot-prop/index.js (limited to 'node_modules/dot-prop/index.js') diff --git a/node_modules/dot-prop/index.js b/node_modules/dot-prop/index.js deleted file mode 100644 index 15282bb39..000000000 --- a/node_modules/dot-prop/index.js +++ /dev/null @@ -1,123 +0,0 @@ -'use strict'; -const isObj = require('is-obj'); - -function getPathSegments(path) { - const pathArr = path.split('.'); - const parts = []; - - for (let i = 0; i < pathArr.length; i++) { - let 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; -} - -module.exports = { - get(obj, path, value) { - if (!isObj(obj) || typeof path !== 'string') { - return value === undefined ? obj : value; - } - - const pathArr = getPathSegments(path); - - for (let i = 0; i < pathArr.length; i++) { - if (!Object.prototype.propertyIsEnumerable.call(obj, pathArr[i])) { - return value; - } - - 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`, or the supplied value, not `null` - if (i !== pathArr.length - 1) { - return value; - } - - break; - } - } - - return obj; - }, - - set(obj, path, value) { - if (!isObj(obj) || typeof path !== 'string') { - return obj; - } - - const root = obj; - const pathArr = getPathSegments(path); - - for (let i = 0; i < pathArr.length; i++) { - const p = pathArr[i]; - - if (!isObj(obj[p])) { - obj[p] = {}; - } - - if (i === pathArr.length - 1) { - obj[p] = value; - } - - obj = obj[p]; - } - - return root; - }, - - delete(obj, path) { - if (!isObj(obj) || typeof path !== 'string') { - return; - } - - const pathArr = getPathSegments(path); - - for (let i = 0; i < pathArr.length; i++) { - const p = pathArr[i]; - - if (i === pathArr.length - 1) { - delete obj[p]; - return; - } - - obj = obj[p]; - - if (!isObj(obj)) { - return; - } - } - }, - - has(obj, path) { - if (!isObj(obj) || typeof path !== 'string') { - return false; - } - - const pathArr = getPathSegments(path); - - for (let i = 0; i < pathArr.length; i++) { - if (isObj(obj)) { - if (!(pathArr[i] in obj)) { - return false; - } - - obj = obj[pathArr[i]]; - } else { - return false; - } - } - - return true; - } -}; -- cgit v1.2.3