This commit is contained in:
2025-10-24 17:06:14 -05:00
parent 12d0690b91
commit df8c75603f
11289 changed files with 1209053 additions and 318 deletions

23
qwen/nodejs/node_modules/dottie/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
The MIT License
Copyright (c) 2013-2014 Mick Hansen. http://mhansen.io
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.

112
qwen/nodejs/node_modules/dottie/README.md generated vendored Normal file
View File

@@ -0,0 +1,112 @@
[![Build Status](https://travis-ci.org/mickhansen/dottie.js.svg?branch=master)](https://travis-ci.org/mickhansen/dottie.js)
Dottie helps you easily (and without sacrificing too much performance) look up and play with nested keys in objects, without them throwing up in your face.
**Not actively maintained. You are likely better off using lodash or ES6+**
## Install
npm install dottie
## Usage
For detailed usage, check source or tests.
### Get value
Gets nested value, or undefined if unreachable, or a default value if passed.
```js
var values = {
some: {
nested: {
key: 'foobar';
}
},
'some.dot.included': {
key: 'barfoo'
}
}
dottie.get(values, 'some.nested.key'); // returns 'foobar'
dottie.get(values, 'some.undefined.key'); // returns undefined
dottie.get(values, 'some.undefined.key', 'defaultval'); // returns 'defaultval'
dottie.get(values, ['some.dot.included', 'key']); // returns 'barfoo'
```
*Note: lodash.get() also works fine for this*
### Set value
Sets nested value, creates nested structure if needed
```js
dottie.set(values, 'some.nested.value', someValue);
dottie.set(values, ['some.dot.included', 'value'], someValue);
dottie.set(values, 'some.nested.object', someValue, {
force: true // force overwrite defined non-object keys into objects if needed
});
```
### Transform object
Transform object from keys with dottie notation to nested objects
```js
var values = {
'user.name': 'Gummy Bear',
'user.email': 'gummybear@candymountain.com',
'user.professional.title': 'King',
'user.professional.employer': 'Candy Mountain'
};
var transformed = dottie.transform(values);
/*
{
user: {
name: 'Gummy Bear',
email: 'gummybear@candymountain.com',
professional: {
title: 'King',
employer: 'Candy Mountain'
}
}
}
*/
```
#### With a custom delimiter
```js
var values = {
'user_name': 'Mick Hansen',
'user_email': 'maker@mhansen.io'
};
var transformed = dottie.transform(values, { delimiter: '_' });
/*
{
user: {
name: 'Mick Hansen',
email: 'maker@mhansen.io'
}
}
*/
```
### Get paths in object
```js
var object = {
a: 1,
b: {
c: 2,
d: { e: 3 }
}
};
dottie.paths(object); // ["a", "b.c", "b.d.e"];
```
## Performance
`0.3.1` and up ships with `dottie.memoizePath: true` by default, if this causes any bugs, please try setting it to false
## License
[MIT](https://github.com/mickhansen/dottie.js/blob/master/LICENSE)

231
qwen/nodejs/node_modules/dottie/dottie.js generated vendored Normal file
View File

@@ -0,0 +1,231 @@
(function(undefined) {
var root = this;
// Weird IE shit, objects do not have hasOwn, but the prototype does...
var hasOwnProp = Object.prototype.hasOwnProperty;
var reverseDupArray = function (array) {
var result = new Array(array.length);
var index = array.length;
var arrayMaxIndex = index - 1;
while (index--) {
result[arrayMaxIndex - index] = array[index];
}
return result;
};
var Dottie = function() {
var args = Array.prototype.slice.call(arguments);
if (args.length == 2) {
return Dottie.find.apply(this, args);
}
return Dottie.transform.apply(this, args);
};
// Legacy syntax, changed syntax to have get/set be similar in arg order
Dottie.find = function(path, object) {
return Dottie.get(object, path);
};
// Dottie memoization flag
Dottie.memoizePath = true;
var memoized = {};
// Traverse object according to path, return value if found - Return undefined if destination is unreachable
Dottie.get = function(object, path, defaultVal) {
if ((object === undefined) || (object === null) || (path === undefined) || (path === null)) {
return defaultVal;
}
var names;
if (typeof path === "string") {
if (Dottie.memoizePath) {
if (memoized[path]) {
names = memoized[path].slice(0);
} else {
names = path.split('.').reverse();
memoized[path] = names.slice(0);
}
} else {
names = path.split('.').reverse();
}
} else if (Array.isArray(path)) {
names = reverseDupArray(path);
}
while (names.length && (object = object[names.pop()]) !== undefined && object !== null);
// Handle cases where accessing a childprop of a null value
if (object === null && names.length) object = undefined;
return (object === undefined ? defaultVal : object);
};
Dottie.exists = function(object, path) {
return Dottie.get(object, path) !== undefined;
};
// Set nested value
Dottie.set = function(object, path, value, options) {
var pieces = Array.isArray(path) ? path : path.split('.'), current = object, piece, length = pieces.length;
if (pieces[0] === '__proto__') return;
if (typeof current !== 'object') {
throw new Error('Parent is not an object.');
}
for (var index = 0; index < length; index++) {
piece = pieces[index];
// Create namespace (object) where none exists.
// If `force === true`, bruteforce the path without throwing errors.
if (
!hasOwnProp.call(current, piece)
|| current[piece] === undefined
|| ((typeof current[piece] !== 'object' || current[piece] === null) && options && options.force === true)) {
current[piece] = {};
}
if (index == (length - 1)) {
// Set final value
current[piece] = value;
} else {
// We do not overwrite existing path pieces by default
if (typeof current[piece] !== 'object' || current[piece] === null) {
throw new Error('Target key "' + piece + '" is not suitable for a nested value. (It is in use as non-object. Set `force` to `true` to override.)');
}
// Traverse next in path
current = current[piece];
}
}
// Is there any case when this is relevant? It's also the last line in the above for-loop
current[piece] = value;
};
// Set default nested value
Dottie['default'] = function(object, path, value) {
if (Dottie.get(object, path) === undefined) {
Dottie.set(object, path, value);
}
};
// Transform unnested object with .-seperated keys into a nested object.
Dottie.transform = function Dottie$transformfunction(object, options) {
if (Array.isArray(object)) {
return object.map(function(o) {
return Dottie.transform(o, options);
});
}
options = options || {};
options.delimiter = options.delimiter || '.';
var pieces
, piecesLength
, piece
, current
, transformed = {}
, key
, keys = Object.keys(object)
, length = keys.length
, i;
for (i = 0; i < length; i++) {
key = keys[i];
if (key.indexOf(options.delimiter) !== -1) {
pieces = key.split(options.delimiter);
if (pieces[0] === '__proto__') break;
piecesLength = pieces.length;
current = transformed;
for (var index = 0; index < piecesLength; index++) {
piece = pieces[index];
if (index != (piecesLength - 1) && !current.hasOwnProperty(piece)) {
current[piece] = {};
}
if (index == (piecesLength - 1)) {
current[piece] = object[key];
}
current = current[piece];
if (current === null) {
break;
}
}
} else {
transformed[key] = object[key];
}
}
return transformed;
};
Dottie.flatten = function(object, seperator) {
if (typeof seperator === "undefined") seperator = '.';
var flattened = {}
, current
, nested;
for (var key in object) {
if (hasOwnProp.call(object, key)) {
current = object[key];
if (Object.prototype.toString.call(current) === "[object Object]") {
nested = Dottie.flatten(current, seperator);
for (var _key in nested) {
flattened[key+seperator+_key] = nested[_key];
}
} else {
flattened[key] = current;
}
}
}
return flattened;
};
Dottie.paths = function(object, prefixes) {
var paths = [];
var value;
var key;
prefixes = prefixes || [];
if (typeof object === 'object') {
for (key in object) {
value = object[key];
if (typeof value === 'object' && value !== null) {
paths = paths.concat(Dottie.paths(value, prefixes.concat([key])));
} else {
paths.push(prefixes.concat(key).join('.'));
}
}
} else {
throw new Error('Paths was called with non-object argument.');
}
return paths;
};
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = Dottie;
} else {
root['Dottie'] = Dottie;
root['Dot'] = Dottie; //BC
if (typeof define === "function") {
define([], function () { return Dottie; });
}
}
})();

22
qwen/nodejs/node_modules/dottie/package.json generated vendored Normal file
View File

@@ -0,0 +1,22 @@
{
"name": "dottie",
"version": "2.0.6",
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^10.2.0"
},
"license": "MIT",
"files": [
"dottie.js"
],
"description": "Fast and safe nested object access and manipulation in JavaScript",
"author": "Mick Hansen <maker@mhansen.io>",
"repository": {
"type": "git",
"url": "git://github.com/mickhansen/dottie.js.git"
},
"main": "dottie.js",
"scripts": {
"test": "mocha -t 5000 -s 100 --reporter spec test"
}
}