Commit
This commit is contained in:
commit
d1c8cae2c1
1417 changed files with 326736 additions and 0 deletions
18
node_modules/mongoose/lib/helpers/path/parentPaths.js
generated
vendored
Normal file
18
node_modules/mongoose/lib/helpers/path/parentPaths.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
const dotRE = /\./g;
|
||||
module.exports = function parentPaths(path) {
|
||||
if (path.indexOf('.') === -1) {
|
||||
return [path];
|
||||
}
|
||||
const pieces = path.split(dotRE);
|
||||
const len = pieces.length;
|
||||
const ret = new Array(len);
|
||||
let cur = '';
|
||||
for (let i = 0; i < len; ++i) {
|
||||
cur += (cur.length !== 0) ? '.' + pieces[i] : pieces[i];
|
||||
ret[i] = cur;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
33
node_modules/mongoose/lib/helpers/path/setDottedPath.js
generated
vendored
Normal file
33
node_modules/mongoose/lib/helpers/path/setDottedPath.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
const specialProperties = require('../specialProperties');
|
||||
|
||||
|
||||
module.exports = function setDottedPath(obj, path, val) {
|
||||
if (path.indexOf('.') === -1) {
|
||||
if (specialProperties.has(path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
obj[path] = val;
|
||||
return;
|
||||
}
|
||||
const parts = path.split('.');
|
||||
|
||||
const last = parts.pop();
|
||||
let cur = obj;
|
||||
for (const part of parts) {
|
||||
if (specialProperties.has(part)) {
|
||||
continue;
|
||||
}
|
||||
if (cur[part] == null) {
|
||||
cur[part] = {};
|
||||
}
|
||||
|
||||
cur = cur[part];
|
||||
}
|
||||
|
||||
if (!specialProperties.has(last)) {
|
||||
cur[last] = val;
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue