This commit is contained in:
Jonasz Bigda
2023-03-25 21:51:42 +01:00
parent 0db1d5117e
commit b332e9ceb0
1044 changed files with 37502 additions and 63938 deletions

21
node_modules/mpath/History.md generated vendored
View File

@@ -1,3 +1,24 @@
0.8.4 / 2021-09-01
==================
* fix: throw error if `parts` contains an element that isn't a string or number #13
0.8.3 / 2020-12-30
==================
* fix: use var instead of let/const for Node.js 4.x support
0.8.2 / 2020-12-30
==================
* fix(stringToParts): fall back to legacy treatment for square brackets if square brackets contents aren't a number Automattic/mongoose#9640
* chore: add eslint
0.8.1 / 2020-12-10
==================
* fix(stringToParts): handle empty string and trailing dot the same way that `split()` does for backwards compat
0.8.0 / 2020-11-14
==================
* feat: support square bracket indexing for `get()`, `set()`, `has()`, and `unset()`
0.7.0 / 2020-03-24
==================
* BREAKING CHANGE: remove `component.json` #9 [AlexeyGrigorievBoost](https://github.com/AlexeyGrigorievBoost)

133
node_modules/mpath/bench.js generated vendored
View File

@@ -1,109 +1,110 @@
'use strict';
var mpath = require('./')
var Bench = require('benchmark');
var sha = require('child_process').exec("git log --pretty=format:'%h' -n 1", function (err, sha) {
const mpath = require('./');
const Bench = require('benchmark');
require('child_process').exec('git log --pretty=format:\'%h\' -n 1', function(err, sha) {
if (err) throw err;
var fs = require('fs')
var filename = __dirname + '/bench.out';
var out = fs.createWriteStream(filename, { flags: 'a', encoding: 'utf8' });
const fs = require('fs');
const filename = __dirname + '/bench.out';
const out = fs.createWriteStream(filename, { flags: 'a', encoding: 'utf8' });
/**
* test doc creator
*/
function doc () {
var o = { first: { second: { third: [3,{ name: 'aaron' }, 9] }}};
function doc() {
const o = { first: { second: { third: [3, { name: 'aaron' }, 9] } } };
o.comments = [
{ name: 'one' }
, { name: 'two', _doc: { name: '2' }}
, { name: 'three'
, comments: [{},{ comments: [{val: 'twoo'}]}]
, _doc: { name: '3', comments: [{},{ _doc: { comments: [{ val: 2 }] }}] }}
{ name: 'one' },
{ name: 'two', _doc: { name: '2' } },
{ name: 'three',
comments: [{}, { comments: [{ val: 'twoo' }] }],
_doc: { name: '3', comments: [{}, { _doc: { comments: [{ val: 2 }] } }] } }
];
o.name = 'jiro';
o.array = [
{ o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
, { o: { array: [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: {b: 'hi'}}] }}
, { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
, { o: { array: [{x: null }] }}
, { o: { array: [{y: 3 }] }}
, { o: { array: [3, 0, null] }}
, { o: { name: 'ha' }}
{ o: { array: [{ x: { b: [4, 6, 8] } }, { y: 10 }] } },
{ o: { array: [{ x: { b: [1, 2, 3] } }, { x: { z: 10 } }, { x: { b: 'hi' } }] } },
{ o: { array: [{ x: { b: null } }, { x: { b: [null, 1] } }] } },
{ o: { array: [{ x: null }] } },
{ o: { array: [{ y: 3 }] } },
{ o: { array: [3, 0, null] } },
{ o: { name: 'ha' } }
];
o.arr = [
{ arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
, { yep: true }
]
{ arr: [{ a: { b: 47 } }, { a: { c: 48 } }, { d: 'yep' }] },
{ yep: true }
];
return o;
}
var o = doc();
const o = doc();
var s = new Bench.Suite;
s.add('mpath.get("first", obj)', function () {
const s = new Bench.Suite;
s.add('mpath.get("first", obj)', function() {
mpath.get('first', o);
})
s.add('mpath.get("first.second", obj)', function () {
});
s.add('mpath.get("first.second", obj)', function() {
mpath.get('first.second', o);
})
s.add('mpath.get("first.second.third.1.name", obj)', function () {
});
s.add('mpath.get("first.second.third.1.name", obj)', function() {
mpath.get('first.second.third.1.name', o);
})
s.add('mpath.get("comments", obj)', function () {
});
s.add('mpath.get("comments", obj)', function() {
mpath.get('comments', o);
})
s.add('mpath.get("comments.1", obj)', function () {
});
s.add('mpath.get("comments.1", obj)', function() {
mpath.get('comments.1', o);
})
s.add('mpath.get("comments.2.name", obj)', function () {
});
s.add('mpath.get("comments.2.name", obj)', function() {
mpath.get('comments.2.name', o);
})
s.add('mpath.get("comments.2.comments.1.comments.0.val", obj)', function () {
});
s.add('mpath.get("comments.2.comments.1.comments.0.val", obj)', function() {
mpath.get('comments.2.comments.1.comments.0.val', o);
})
s.add('mpath.get("comments.name", obj)', function () {
});
s.add('mpath.get("comments.name", obj)', function() {
mpath.get('comments.name', o);
})
});
s.add('mpath.set("first", obj, val)', function () {
s.add('mpath.set("first", obj, val)', function() {
mpath.set('first', o, 1);
})
s.add('mpath.set("first.second", obj, val)', function () {
});
s.add('mpath.set("first.second", obj, val)', function() {
mpath.set('first.second', o, 1);
})
s.add('mpath.set("first.second.third.1.name", obj, val)', function () {
});
s.add('mpath.set("first.second.third.1.name", obj, val)', function() {
mpath.set('first.second.third.1.name', o, 1);
})
s.add('mpath.set("comments", obj, val)', function () {
});
s.add('mpath.set("comments", obj, val)', function() {
mpath.set('comments', o, 1);
})
s.add('mpath.set("comments.1", obj, val)', function () {
});
s.add('mpath.set("comments.1", obj, val)', function() {
mpath.set('comments.1', o, 1);
})
s.add('mpath.set("comments.2.name", obj, val)', function () {
});
s.add('mpath.set("comments.2.name", obj, val)', function() {
mpath.set('comments.2.name', o, 1);
})
s.add('mpath.set("comments.2.comments.1.comments.0.val", obj, val)', function () {
});
s.add('mpath.set("comments.2.comments.1.comments.0.val", obj, val)', function() {
mpath.set('comments.2.comments.1.comments.0.val', o, 1);
})
s.add('mpath.set("comments.name", obj, val)', function () {
});
s.add('mpath.set("comments.name", obj, val)', function() {
mpath.set('comments.name', o, 1);
})
});
s.on('start', function () {
s.on('start', function() {
console.log('starting...');
out.write('*' + sha + ': ' + String(new Date()) + '\n');
});
s.on('cycle', function (e) {
var s = String(e.target);
s.on('cycle', function(e) {
const s = String(e.target);
console.log(s);
out.write(s + '\n');
})
s.on('complete', function () {
console.log('done')
});
s.on('complete', function() {
console.log('done');
out.end('');
})
s.run()
})
});
s.run();
});

2
node_modules/mpath/index.js generated vendored
View File

@@ -1 +1,3 @@
'use strict';
module.exports = exports = require('./lib');

58
node_modules/mpath/lib/index.js generated vendored
View File

@@ -1,3 +1,9 @@
/* eslint strict:off */
/* eslint no-var: off */
/* eslint no-redeclare: off */
var stringToParts = require('./stringToParts');
// These properties are special and can open client libraries to security
// issues
var ignoreProperties = ['__proto__', 'constructor', 'prototype'];
@@ -30,7 +36,7 @@ var ignoreProperties = ['__proto__', 'constructor', 'prototype'];
* @param {Function} [map] Optional function which receives each individual found value. The value returned from `map` is used in the original values place.
*/
exports.get = function (path, o, special, map) {
exports.get = function(path, o, special, map) {
var lookup;
if ('function' == typeof special) {
@@ -46,18 +52,21 @@ exports.get = function (path, o, special, map) {
map || (map = K);
var parts = 'string' == typeof path
? path.split('.')
: path
? stringToParts(path)
: path;
if (!Array.isArray(parts)) {
throw new TypeError('Invalid `path`. Must be either string or array');
}
var obj = o
, part;
var obj = o,
part;
for (var i = 0; i < parts.length; ++i) {
part = parts[i];
if (typeof parts[i] !== 'string' && typeof parts[i] !== 'number') {
throw new TypeError('Each segment of path to `get()` must be a string or number, got ' + typeof parts[i]);
}
if (Array.isArray(obj) && !/^\d+$/.test(part)) {
// reading a property from the array items
@@ -65,7 +74,7 @@ exports.get = function (path, o, special, map) {
// Need to `concat()` to avoid `map()` calling a constructor of an array
// subclass
return [].concat(obj).map(function (item) {
return [].concat(obj).map(function(item) {
return item
? exports.get(paths, item, special || lookup, map)
: map(undefined);
@@ -94,9 +103,9 @@ exports.get = function (path, o, special, map) {
* @param {Object} o
*/
exports.has = function (path, o) {
exports.has = function(path, o) {
var parts = typeof path === 'string' ?
path.split('.') :
stringToParts(path) :
path;
if (!Array.isArray(parts)) {
@@ -106,6 +115,9 @@ exports.has = function (path, o) {
var len = parts.length;
var cur = o;
for (var i = 0; i < len; ++i) {
if (typeof parts[i] !== 'string' && typeof parts[i] !== 'number') {
throw new TypeError('Each segment of path to `has()` must be a string or number, got ' + typeof parts[i]);
}
if (cur == null || typeof cur !== 'object' || !(parts[i] in cur)) {
return false;
}
@@ -122,9 +134,9 @@ exports.has = function (path, o) {
* @param {Object} o
*/
exports.unset = function (path, o) {
exports.unset = function(path, o) {
var parts = typeof path === 'string' ?
path.split('.') :
stringToParts(path) :
path;
if (!Array.isArray(parts)) {
@@ -137,6 +149,9 @@ exports.unset = function (path, o) {
if (cur == null || typeof cur !== 'object' || !(parts[i] in cur)) {
return false;
}
if (typeof parts[i] !== 'string' && typeof parts[i] !== 'number') {
throw new TypeError('Each segment of path to `unset()` must be a string or number, got ' + typeof parts[i]);
}
// Disallow any updates to __proto__ or special properties.
if (ignoreProperties.indexOf(parts[i]) !== -1) {
return false;
@@ -161,7 +176,7 @@ exports.unset = function (path, o) {
* @param {Function} [map] Optional function which is passed each individual value before setting it. The value returned from `map` is used in the original values place.
*/
exports.set = function (path, val, o, special, map, _copying) {
exports.set = function(path, val, o, special, map, _copying) {
var lookup;
if ('function' == typeof special) {
@@ -177,8 +192,8 @@ exports.set = function (path, val, o, special, map, _copying) {
map || (map = K);
var parts = 'string' == typeof path
? path.split('.')
: path
? stringToParts(path)
: path;
if (!Array.isArray(parts)) {
throw new TypeError('Invalid `path`. Must be either string or array');
@@ -187,6 +202,9 @@ exports.set = function (path, val, o, special, map, _copying) {
if (null == o) return;
for (var i = 0; i < parts.length; ++i) {
if (typeof parts[i] !== 'string' && typeof parts[i] !== 'number') {
throw new TypeError('Each segment of path to `set()` must be a string or number, got ' + typeof parts[i]);
}
// Silently ignore any updates to `__proto__`, these are potentially
// dangerous if using mpath with unsanitized data.
if (ignoreProperties.indexOf(parts[i]) !== -1) {
@@ -199,9 +217,9 @@ exports.set = function (path, val, o, special, map, _copying) {
// the array to the one by one to matching positions of the
// current array. Unless the user explicitly opted out by passing
// false, see Automattic/mongoose#6273
var copy = _copying || (/\$/.test(path) && _copying !== false)
, obj = o
, part
var copy = _copying || (/\$/.test(path) && _copying !== false),
obj = o,
part;
for (var i = 0, len = parts.length - 1; i < len; ++i) {
part = parts[i];
@@ -257,7 +275,7 @@ exports.set = function (path, val, o, special, map, _copying) {
_setArray(obj, val, part, lookup, special, map);
} else {
for (var j = 0; j < obj.length; ++j) {
item = obj[j];
var item = obj[j];
if (item) {
if (lookup) {
lookup(item, part, map(val));
@@ -277,7 +295,7 @@ exports.set = function (path, val, o, special, map, _copying) {
obj[part] = map(val);
}
}
}
};
/*!
* Recursively set nested arrays
@@ -303,6 +321,6 @@ function _setArray(obj, val, part, lookup, special, map) {
* Returns the value passed to it.
*/
function K (v) {
function K(v) {
return v;
}
}

129
node_modules/mpath/package.json generated vendored
View File

@@ -1,9 +1,10 @@
{
"name": "mpath",
"version": "0.7.0",
"version": "0.8.4",
"description": "{G,S}et object values using MongoDB-like path notation",
"main": "index.js",
"scripts": {
"lint": "eslint .",
"test": "mocha test/*"
},
"engines": {
@@ -20,10 +21,124 @@
"license": "MIT",
"devDependencies": {
"mocha": "5.x",
"benchmark": "~1.0.0"
"benchmark": "~1.0.0",
"eslint": "7.16.0"
},
"eslintConfig": {
"extends": [
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 2015
},
"env": {
"node": true,
"es6": true
},
"rules": {
"comma-style": "error",
"indent": [
"error",
2,
{
"SwitchCase": 1,
"VariableDeclarator": 2
}
],
"keyword-spacing": "error",
"no-whitespace-before-property": "error",
"no-buffer-constructor": "warn",
"no-console": "off",
"no-multi-spaces": "error",
"no-constant-condition": "off",
"func-call-spacing": "error",
"no-trailing-spaces": "error",
"no-undef": "error",
"no-unneeded-ternary": "error",
"no-const-assign": "error",
"no-useless-rename": "error",
"no-dupe-keys": "error",
"space-in-parens": [
"error",
"never"
],
"spaced-comment": [
"error",
"always",
{
"block": {
"markers": [
"!"
],
"balanced": true
}
}
],
"key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true
}
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"array-bracket-spacing": 1,
"arrow-spacing": [
"error",
{
"before": true,
"after": true
}
],
"object-curly-spacing": [
"error",
"always"
],
"comma-dangle": [
"error",
"never"
],
"no-unreachable": "error",
"quotes": [
"error",
"single"
],
"quote-props": [
"error",
"as-needed"
],
"semi": "error",
"no-extra-semi": "error",
"semi-spacing": "error",
"no-spaced-func": "error",
"no-throw-literal": "error",
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
"never"
],
"space-infix-ops": "error",
"space-unary-ops": "error",
"no-var": "warn",
"prefer-const": "warn",
"strict": [
"error",
"global"
],
"no-restricted-globals": [
"error",
{
"name": "context",
"message": "Don't use Mocha's global context"
}
],
"no-prototype-builtins": "off"
}
}
,"_resolved": "https://registry.npmjs.org/mpath/-/mpath-0.7.0.tgz"
,"_integrity": "sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg=="
,"_from": "mpath@0.7.0"
}
}

1660
node_modules/mpath/test/index.js generated vendored

File diff suppressed because it is too large Load Diff