flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
21
BACK_BACK/node_modules/index-array-by/LICENSE
generated
vendored
Executable file
21
BACK_BACK/node_modules/index-array-by/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 Vasco Asturiano
|
||||
|
||||
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.
|
||||
129
BACK_BACK/node_modules/index-array-by/README.md
generated
vendored
Executable file
129
BACK_BACK/node_modules/index-array-by/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,129 @@
|
|||
index-array-by
|
||||
==============
|
||||
|
||||
[![NPM package][npm-img]][npm-url]
|
||||
[![Build Size][build-size-img]][build-size-url]
|
||||
[![NPM Downloads][npm-downloads-img]][npm-downloads-url]
|
||||
|
||||
A utility function to index arrays by any criteria.
|
||||
|
||||
`indexBy(list, keyAccessors, multiItem = true)`
|
||||
|
||||
## Quick start
|
||||
|
||||
```js
|
||||
import indexBy from 'index-array-by';
|
||||
```
|
||||
or using a *script* tag
|
||||
```html
|
||||
<script src="//unpkg.com/index-array-by"></script>
|
||||
```
|
||||
|
||||
## Usage example
|
||||
|
||||
Given an array
|
||||
```js
|
||||
const people = [
|
||||
{ name: 'Mary', surname: 'Jane', age: 28 },
|
||||
{ name: 'John', surname: 'Smith', age: 24 },
|
||||
{ name: 'John', surname: 'Doe', age: 32 }
|
||||
];
|
||||
```
|
||||
|
||||
Use `indexBy` to index it by a given attribute (string type `keyAccessor`) or any other custom criteria (function type `keyAccessor`). You can also pass an array of `keyAccessors` to retrieve a nested object recursively indexed by the multiple keys.
|
||||
|
||||
Use the third parameter (`multiItem`) to indicate whether each key should point to a single item (unadvised if the keys are not unique) or an array of multiple items (default behavior).
|
||||
|
||||
```js
|
||||
indexBy(people, 'surname', false);
|
||||
|
||||
// Result:
|
||||
{
|
||||
Doe: { name: 'John', age: 32 },
|
||||
Jane: { name: 'Mary', age: 28 },
|
||||
Smith: { name: 'John', age: 24 }
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
indexBy(people, 'name', true);
|
||||
|
||||
// Result:
|
||||
{
|
||||
Mary: [ { surname: 'Jane', age: 28 } ],
|
||||
John: [
|
||||
{ surname: 'Smith', age: 24 },
|
||||
{ surname: 'Doe', age: 32 }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
indexBy(people, ({ name, surname }) => `${surname}, ${name}`, false);
|
||||
|
||||
// Result:
|
||||
{
|
||||
'Jane, Mary': { name: 'Mary', surname: 'Jane', age: 28 },
|
||||
'Smith, John': { name: 'John', surname: 'Smith', age: 24 },
|
||||
'Doe, John': { name: 'John', surname: 'Doe', age: 32 }
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
indexBy(people, ['name', 'surname'], false));
|
||||
|
||||
// Result:
|
||||
{
|
||||
Mary: { Jane: { age: 28 }},
|
||||
John: { Smith: { age: 24 }, Doe: { age: 32 }}
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
indexBy(people, ({ age }) => `${Math.floor(age / 10) * 10}s`, true);
|
||||
|
||||
// Result:
|
||||
{
|
||||
'20s': [
|
||||
{ name: 'Mary', surname: 'Jane', age: 28 },
|
||||
{ name: 'John', surname: 'Smith', age: 24 },
|
||||
],
|
||||
'30s': [{ name: 'John', surname: 'Doe', age: 32 }]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
The `multiItem` parameter also accepts a transformation function with the method to reduce multiple items into a single one. In this case, it's keeping only the max age.
|
||||
|
||||
```js
|
||||
indexBy(people, 'name', items => Math.max(...items.map(item => item.age)));
|
||||
|
||||
// Result:
|
||||
|
||||
{
|
||||
John: 32,
|
||||
Mary: 28
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
A fourth optional parameter (`flattenKeys`) (default: `false`) allows you to receive a flat array structure instead of the default nested format, with each item formatted as `{ keys: [<ordered unique keys for the item>], vals: <single or multiple item> }`.
|
||||
|
||||
```js
|
||||
indexBy(people, ['name', 'surname'], true, true));
|
||||
|
||||
// Result:
|
||||
[
|
||||
{ keys: ['Mary', 'Jane'], vals: [{ age: 28 }] },
|
||||
{ keys: ['John', 'Smith'], vals: [{ age: 24 }] },
|
||||
{ keys: ['John', 'Doe'], vals: [{ age: 32 }] }
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
[npm-img]: https://img.shields.io/npm/v/index-array-by
|
||||
[npm-url]: https://npmjs.org/package/index-array-by
|
||||
[build-size-img]: https://img.shields.io/bundlephobia/minzip/index-array-by
|
||||
[build-size-url]: https://bundlephobia.com/result?p=index-array-by
|
||||
[npm-downloads-img]: https://img.shields.io/npm/dt/index-array-by
|
||||
[npm-downloads-url]: https://www.npmtrends.com/index-array-by
|
||||
23
BACK_BACK/node_modules/index-array-by/dist/index-array-by.d.ts
generated
vendored
Executable file
23
BACK_BACK/node_modules/index-array-by/dist/index-array-by.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
type ListItem = any;
|
||||
|
||||
type KeyAccessor = string | ((listItem: ListItem) => string);
|
||||
|
||||
type ReducerFn = (items: ListItem[]) => any;
|
||||
|
||||
interface NestedResult {
|
||||
[key: string]: NestedResult | ListItem | ListItem[];
|
||||
}
|
||||
|
||||
type FlatResult = {
|
||||
keys: string[];
|
||||
vals: ListItem | ListItem[]
|
||||
}[];
|
||||
|
||||
declare function indexBy(
|
||||
list: ListItem[],
|
||||
keyAccessors: KeyAccessor | KeyAccessor[],
|
||||
multiItem?: boolean | ReducerFn,
|
||||
flattenKeys?: boolean
|
||||
): NestedResult | FlatResult;
|
||||
|
||||
export { indexBy as default };
|
||||
193
BACK_BACK/node_modules/index-array-by/dist/index-array-by.js
generated
vendored
Executable file
193
BACK_BACK/node_modules/index-array-by/dist/index-array-by.js
generated
vendored
Executable file
|
|
@ -0,0 +1,193 @@
|
|||
// Version 1.4.2 index-array-by - https://github.com/vasturiano/index-array-by
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.indexBy = factory());
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
function _arrayLikeToArray(r, a) {
|
||||
(null == a || a > r.length) && (a = r.length);
|
||||
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
||||
return n;
|
||||
}
|
||||
function _arrayWithHoles(r) {
|
||||
if (Array.isArray(r)) return r;
|
||||
}
|
||||
function _arrayWithoutHoles(r) {
|
||||
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
||||
}
|
||||
function _iterableToArray(r) {
|
||||
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
||||
}
|
||||
function _iterableToArrayLimit(r, l) {
|
||||
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
||||
if (null != t) {
|
||||
var e,
|
||||
n,
|
||||
i,
|
||||
u,
|
||||
a = [],
|
||||
f = !0,
|
||||
o = !1;
|
||||
try {
|
||||
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
||||
} catch (r) {
|
||||
o = !0, n = r;
|
||||
} finally {
|
||||
try {
|
||||
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
||||
} finally {
|
||||
if (o) throw n;
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
function _nonIterableSpread() {
|
||||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
function _objectWithoutProperties(e, t) {
|
||||
if (null == e) return {};
|
||||
var o,
|
||||
r,
|
||||
i = _objectWithoutPropertiesLoose(e, t);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var s = Object.getOwnPropertySymbols(e);
|
||||
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
function _objectWithoutPropertiesLoose(r, e) {
|
||||
if (null == r) return {};
|
||||
var t = {};
|
||||
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
||||
if (e.includes(n)) continue;
|
||||
t[n] = r[n];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
function _slicedToArray(r, e) {
|
||||
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
||||
}
|
||||
function _toConsumableArray(r) {
|
||||
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
||||
}
|
||||
function _toPrimitive(t, r) {
|
||||
if ("object" != typeof t || !t) return t;
|
||||
var e = t[Symbol.toPrimitive];
|
||||
if (void 0 !== e) {
|
||||
var i = e.call(t, r );
|
||||
if ("object" != typeof i) return i;
|
||||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||||
}
|
||||
return (String )(t);
|
||||
}
|
||||
function _toPropertyKey(t) {
|
||||
var i = _toPrimitive(t, "string");
|
||||
return "symbol" == typeof i ? i : i + "";
|
||||
}
|
||||
function _unsupportedIterableToArray(r, a) {
|
||||
if (r) {
|
||||
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
||||
var t = {}.toString.call(r).slice(8, -1);
|
||||
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
||||
}
|
||||
}
|
||||
|
||||
var index = (function () {
|
||||
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
var keyAccessors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
var multiItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
var flattenKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
||||
var keys = (keyAccessors instanceof Array ? keyAccessors.length ? keyAccessors : [undefined] : [keyAccessors]).map(function (key) {
|
||||
return {
|
||||
keyAccessor: key,
|
||||
isProp: !(key instanceof Function)
|
||||
};
|
||||
});
|
||||
var indexedResult = list.reduce(function (res, item) {
|
||||
var iterObj = res;
|
||||
var itemVal = item;
|
||||
keys.forEach(function (_ref, idx) {
|
||||
var keyAccessor = _ref.keyAccessor,
|
||||
isProp = _ref.isProp;
|
||||
var key;
|
||||
if (isProp) {
|
||||
var _itemVal = itemVal,
|
||||
propVal = _itemVal[keyAccessor],
|
||||
rest = _objectWithoutProperties(_itemVal, [keyAccessor].map(_toPropertyKey));
|
||||
key = propVal;
|
||||
itemVal = rest;
|
||||
} else {
|
||||
key = keyAccessor(itemVal, idx);
|
||||
}
|
||||
if (idx + 1 < keys.length) {
|
||||
if (!iterObj.hasOwnProperty(key)) {
|
||||
iterObj[key] = {};
|
||||
}
|
||||
iterObj = iterObj[key];
|
||||
} else {
|
||||
// Leaf key
|
||||
if (multiItem) {
|
||||
if (!iterObj.hasOwnProperty(key)) {
|
||||
iterObj[key] = [];
|
||||
}
|
||||
iterObj[key].push(itemVal);
|
||||
} else {
|
||||
iterObj[key] = itemVal;
|
||||
}
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}, {});
|
||||
if (multiItem instanceof Function) {
|
||||
// Reduce leaf multiple values
|
||||
(function reduce(node) {
|
||||
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
if (level === keys.length) {
|
||||
Object.keys(node).forEach(function (k) {
|
||||
return node[k] = multiItem(node[k]);
|
||||
});
|
||||
} else {
|
||||
Object.values(node).forEach(function (child) {
|
||||
return reduce(child, level + 1);
|
||||
});
|
||||
}
|
||||
})(indexedResult); // IIFE
|
||||
}
|
||||
var result = indexedResult;
|
||||
if (flattenKeys) {
|
||||
// flatten into array
|
||||
result = [];
|
||||
(function flatten(node) {
|
||||
var accKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
if (accKeys.length === keys.length) {
|
||||
result.push({
|
||||
keys: accKeys,
|
||||
vals: node
|
||||
});
|
||||
} else {
|
||||
Object.entries(node).forEach(function (_ref2) {
|
||||
var _ref3 = _slicedToArray(_ref2, 2),
|
||||
key = _ref3[0],
|
||||
val = _ref3[1];
|
||||
return flatten(val, [].concat(_toConsumableArray(accKeys), [key]));
|
||||
});
|
||||
}
|
||||
})(indexedResult); //IIFE
|
||||
|
||||
if (keyAccessors instanceof Array && keyAccessors.length === 0 && result.length === 1) {
|
||||
// clear keys if there's no key accessors (single result)
|
||||
result[0].keys = [];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
return index;
|
||||
|
||||
}));
|
||||
//# sourceMappingURL=index-array-by.js.map
|
||||
1
BACK_BACK/node_modules/index-array-by/dist/index-array-by.js.map
generated
vendored
Executable file
1
BACK_BACK/node_modules/index-array-by/dist/index-array-by.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
2
BACK_BACK/node_modules/index-array-by/dist/index-array-by.min.js
generated
vendored
Executable file
2
BACK_BACK/node_modules/index-array-by/dist/index-array-by.min.js
generated
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
// Version 1.4.2 index-array-by - https://github.com/vasturiano/index-array-by
|
||||
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r="undefined"!=typeof globalThis?globalThis:r||self).indexBy=n()}(this,(function(){"use strict";function r(r,n){(null==n||n>r.length)&&(n=r.length);for(var t=0,e=Array(n);t<n;t++)e[t]=r[t];return e}function n(r,n){return function(r){if(Array.isArray(r))return r}(r)||function(r,n){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,o,i,u,a=[],l=!0,f=!1;try{if(i=(t=t.call(r)).next,0===n);else for(;!(l=(e=i.call(t)).done)&&(a.push(e.value),a.length!==n);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(f)throw o}}return a}}(r,n)||o(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(n){return function(n){if(Array.isArray(n))return r(n)}(n)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(n)||o(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(r){var n=function(r,n){if("object"!=typeof r||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var e=t.call(r,n);if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}(r,"string");return"symbol"==typeof n?n:n+""}function o(n,t){if(n){if("string"==typeof n)return r(n,t);var e={}.toString.call(n).slice(8,-1);return"Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e?Array.from(n):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?r(n,t):void 0}}return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=(o instanceof Array?o.length?o:[void 0]:[o]).map((function(r){return{keyAccessor:r,isProp:!(r instanceof Function)}})),l=r.reduce((function(r,n){var t=r,o=n;return a.forEach((function(r,n){var u,l=r.keyAccessor;if(r.isProp){var f=o,c=f[l],s=function(r,n){if(null==r)return{};var t,e,o=function(r,n){if(null==r)return{};var t={};for(var e in r)if({}.hasOwnProperty.call(r,e)){if(n.includes(e))continue;t[e]=r[e]}return t}(r,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(e=0;e<i.length;e++)t=i[e],n.includes(t)||{}.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}(f,[l].map(e));u=c,o=s}else u=l(o,n);n+1<a.length?(t.hasOwnProperty(u)||(t[u]={}),t=t[u]):i?(t.hasOwnProperty(u)||(t[u]=[]),t[u].push(o)):t[u]=o})),r}),{});i instanceof Function&&function r(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;t===a.length?Object.keys(n).forEach((function(r){return n[r]=i(n[r])})):Object.values(n).forEach((function(n){return r(n,t+1)}))}(l);var f=l;return u&&(f=[],function r(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];o.length===a.length?f.push({keys:o,vals:e}):Object.entries(e).forEach((function(e){var i=n(e,2),u=i[0],a=i[1];return r(a,[].concat(t(o),[u]))}))}(l),o instanceof Array&&0===o.length&&1===f.length&&(f[0].keys=[])),f}}));
|
||||
183
BACK_BACK/node_modules/index-array-by/dist/index-array-by.mjs
generated
vendored
Executable file
183
BACK_BACK/node_modules/index-array-by/dist/index-array-by.mjs
generated
vendored
Executable file
|
|
@ -0,0 +1,183 @@
|
|||
function _arrayLikeToArray(r, a) {
|
||||
(null == a || a > r.length) && (a = r.length);
|
||||
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
||||
return n;
|
||||
}
|
||||
function _arrayWithHoles(r) {
|
||||
if (Array.isArray(r)) return r;
|
||||
}
|
||||
function _arrayWithoutHoles(r) {
|
||||
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
||||
}
|
||||
function _iterableToArray(r) {
|
||||
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
||||
}
|
||||
function _iterableToArrayLimit(r, l) {
|
||||
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
||||
if (null != t) {
|
||||
var e,
|
||||
n,
|
||||
i,
|
||||
u,
|
||||
a = [],
|
||||
f = !0,
|
||||
o = !1;
|
||||
try {
|
||||
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
||||
} catch (r) {
|
||||
o = !0, n = r;
|
||||
} finally {
|
||||
try {
|
||||
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
||||
} finally {
|
||||
if (o) throw n;
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
function _nonIterableSpread() {
|
||||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
function _objectWithoutProperties(e, t) {
|
||||
if (null == e) return {};
|
||||
var o,
|
||||
r,
|
||||
i = _objectWithoutPropertiesLoose(e, t);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var s = Object.getOwnPropertySymbols(e);
|
||||
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
function _objectWithoutPropertiesLoose(r, e) {
|
||||
if (null == r) return {};
|
||||
var t = {};
|
||||
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
||||
if (e.includes(n)) continue;
|
||||
t[n] = r[n];
|
||||
}
|
||||
return t;
|
||||
}
|
||||
function _slicedToArray(r, e) {
|
||||
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
||||
}
|
||||
function _toConsumableArray(r) {
|
||||
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
||||
}
|
||||
function _toPrimitive(t, r) {
|
||||
if ("object" != typeof t || !t) return t;
|
||||
var e = t[Symbol.toPrimitive];
|
||||
if (void 0 !== e) {
|
||||
var i = e.call(t, r );
|
||||
if ("object" != typeof i) return i;
|
||||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||||
}
|
||||
return (String )(t);
|
||||
}
|
||||
function _toPropertyKey(t) {
|
||||
var i = _toPrimitive(t, "string");
|
||||
return "symbol" == typeof i ? i : i + "";
|
||||
}
|
||||
function _unsupportedIterableToArray(r, a) {
|
||||
if (r) {
|
||||
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
||||
var t = {}.toString.call(r).slice(8, -1);
|
||||
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
||||
}
|
||||
}
|
||||
|
||||
var index = (function () {
|
||||
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
var keyAccessors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
var multiItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
var flattenKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
||||
var keys = (keyAccessors instanceof Array ? keyAccessors.length ? keyAccessors : [undefined] : [keyAccessors]).map(function (key) {
|
||||
return {
|
||||
keyAccessor: key,
|
||||
isProp: !(key instanceof Function)
|
||||
};
|
||||
});
|
||||
var indexedResult = list.reduce(function (res, item) {
|
||||
var iterObj = res;
|
||||
var itemVal = item;
|
||||
keys.forEach(function (_ref, idx) {
|
||||
var keyAccessor = _ref.keyAccessor,
|
||||
isProp = _ref.isProp;
|
||||
var key;
|
||||
if (isProp) {
|
||||
var _itemVal = itemVal,
|
||||
propVal = _itemVal[keyAccessor],
|
||||
rest = _objectWithoutProperties(_itemVal, [keyAccessor].map(_toPropertyKey));
|
||||
key = propVal;
|
||||
itemVal = rest;
|
||||
} else {
|
||||
key = keyAccessor(itemVal, idx);
|
||||
}
|
||||
if (idx + 1 < keys.length) {
|
||||
if (!iterObj.hasOwnProperty(key)) {
|
||||
iterObj[key] = {};
|
||||
}
|
||||
iterObj = iterObj[key];
|
||||
} else {
|
||||
// Leaf key
|
||||
if (multiItem) {
|
||||
if (!iterObj.hasOwnProperty(key)) {
|
||||
iterObj[key] = [];
|
||||
}
|
||||
iterObj[key].push(itemVal);
|
||||
} else {
|
||||
iterObj[key] = itemVal;
|
||||
}
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}, {});
|
||||
if (multiItem instanceof Function) {
|
||||
// Reduce leaf multiple values
|
||||
(function reduce(node) {
|
||||
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
if (level === keys.length) {
|
||||
Object.keys(node).forEach(function (k) {
|
||||
return node[k] = multiItem(node[k]);
|
||||
});
|
||||
} else {
|
||||
Object.values(node).forEach(function (child) {
|
||||
return reduce(child, level + 1);
|
||||
});
|
||||
}
|
||||
})(indexedResult); // IIFE
|
||||
}
|
||||
var result = indexedResult;
|
||||
if (flattenKeys) {
|
||||
// flatten into array
|
||||
result = [];
|
||||
(function flatten(node) {
|
||||
var accKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
if (accKeys.length === keys.length) {
|
||||
result.push({
|
||||
keys: accKeys,
|
||||
vals: node
|
||||
});
|
||||
} else {
|
||||
Object.entries(node).forEach(function (_ref2) {
|
||||
var _ref3 = _slicedToArray(_ref2, 2),
|
||||
key = _ref3[0],
|
||||
val = _ref3[1];
|
||||
return flatten(val, [].concat(_toConsumableArray(accKeys), [key]));
|
||||
});
|
||||
}
|
||||
})(indexedResult); //IIFE
|
||||
|
||||
if (keyAccessors instanceof Array && keyAccessors.length === 0 && result.length === 1) {
|
||||
// clear keys if there's no key accessors (single result)
|
||||
result[0].keys = [];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
export { index as default };
|
||||
57
BACK_BACK/node_modules/index-array-by/package.json
generated
vendored
Executable file
57
BACK_BACK/node_modules/index-array-by/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"name": "index-array-by",
|
||||
"version": "1.4.2",
|
||||
"description": "A utility function to index arrays by any criteria",
|
||||
"type": "module",
|
||||
"unpkg": "dist/index-array-by.min.js",
|
||||
"jsdelivr": "dist/index-array-by.min.js",
|
||||
"main": "dist/index-array-by.mjs",
|
||||
"module": "dist/index-array-by.mjs",
|
||||
"types": "dist/index-array-by.d.ts",
|
||||
"exports": {
|
||||
"types": "./dist/index-array-by.d.ts",
|
||||
"umd": "./dist/index-array-by.min.js",
|
||||
"default": "./dist/index-array-by.mjs"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vasturiano/index-array-by.git"
|
||||
},
|
||||
"keywords": [
|
||||
"index",
|
||||
"array",
|
||||
"helper"
|
||||
],
|
||||
"author": {
|
||||
"name": "Vasco Asturiano",
|
||||
"url": "https://github.com/vasturiano"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vasturiano/index-array-by/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vasturiano/index-array-by",
|
||||
"scripts": {
|
||||
"build": "rimraf dist && rollup -c",
|
||||
"dev": "rollup -w -c",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.24.9",
|
||||
"@babel/preset-env": "^7.24.8",
|
||||
"@rollup/plugin-babel": "^6.0.4",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"rimraf": "^6.0.1",
|
||||
"rollup": "^4.18.1",
|
||||
"rollup-plugin-dts": "^6.1.1",
|
||||
"typescript": "^5.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue