@hyperfrontend/list-utils 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/bundle/index.iife.js +95 -13
- package/bundle/index.iife.js.map +1 -1
- package/bundle/index.iife.min.js +1 -1
- package/bundle/index.iife.min.js.map +1 -1
- package/bundle/index.umd.js +95 -13
- package/bundle/index.umd.js.map +1 -1
- package/bundle/index.umd.min.js +1 -1
- package/bundle/index.umd.min.js.map +1 -1
- package/create-fifo-list.d.ts.map +1 -1
- package/create-lifo-list.d.ts.map +1 -1
- package/create-value-picker.d.ts.map +1 -1
- package/index.cjs.js +95 -13
- package/index.cjs.js.map +1 -1
- package/index.esm.js +95 -13
- package/index.esm.js.map +1 -1
- package/package.json +14 -14
- package/unique-strings.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.0.3](https://github.com/AndrewRedican/hyperfrontend/compare/lib-list-utils@0.0.2...lib-list-utils@0.0.3) (2026-03-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **lib-list-utils:** correct package exports ([5966537](https://github.com/AndrewRedican/hyperfrontend/commit/5966537bda3addd6d3bc22bb7b2e9a5cfef7c247))
|
|
11
|
+
|
|
5
12
|
## [0.0.2](https://github.com/AndrewRedican/hyperfrontend/compare/lib-list-utils@0.0.1...lib-list-utils@0.0.2) (2026-02-26)
|
|
6
13
|
|
|
7
14
|
## 0.0.1 (2026-02-15)
|
package/bundle/index.iife.js
CHANGED
|
@@ -1,8 +1,43 @@
|
|
|
1
1
|
var HyperfrontendListUtils = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Safe copies of Object built-in methods.
|
|
6
|
+
*
|
|
7
|
+
* These references are captured at module initialization time to protect against
|
|
8
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
9
|
+
*
|
|
10
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/object
|
|
11
|
+
*/
|
|
12
|
+
// Capture references at module initialization time
|
|
13
|
+
const _Object = globalThis.Object;
|
|
14
|
+
/**
|
|
15
|
+
* (Safe copy) Prevents modification of existing property attributes and values,
|
|
16
|
+
* and prevents the addition of new properties.
|
|
17
|
+
*/
|
|
18
|
+
const freeze = _Object.freeze;
|
|
19
|
+
|
|
4
20
|
const registeredClasses = [];
|
|
5
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Safe copies of Array built-in static methods.
|
|
24
|
+
*
|
|
25
|
+
* These references are captured at module initialization time to protect against
|
|
26
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
27
|
+
*
|
|
28
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
29
|
+
*/
|
|
30
|
+
// Capture references at module initialization time
|
|
31
|
+
const _Array = globalThis.Array;
|
|
32
|
+
/**
|
|
33
|
+
* (Safe copy) Determines whether the passed value is an Array.
|
|
34
|
+
*/
|
|
35
|
+
const isArray = _Array.isArray;
|
|
36
|
+
/**
|
|
37
|
+
* (Safe copy) Creates an array from an array-like or iterable object.
|
|
38
|
+
*/
|
|
39
|
+
const from = _Array.from;
|
|
40
|
+
|
|
6
41
|
/**
|
|
7
42
|
* Returns the data type of the target.
|
|
8
43
|
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
@@ -16,7 +51,7 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
16
51
|
return 'null';
|
|
17
52
|
const nativeDataType = typeof target;
|
|
18
53
|
if (nativeDataType === 'object') {
|
|
19
|
-
if (
|
|
54
|
+
if (isArray(target))
|
|
20
55
|
return 'array';
|
|
21
56
|
for (const registeredClass of registeredClasses) {
|
|
22
57
|
if (target instanceof registeredClass)
|
|
@@ -26,6 +61,53 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
26
61
|
return nativeDataType;
|
|
27
62
|
};
|
|
28
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Safe copies of Error built-ins via factory functions.
|
|
66
|
+
*
|
|
67
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
68
|
+
* provides factory functions that use Reflect.construct internally.
|
|
69
|
+
*
|
|
70
|
+
* These references are captured at module initialization time to protect against
|
|
71
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
72
|
+
*
|
|
73
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/error
|
|
74
|
+
*/
|
|
75
|
+
// Capture references at module initialization time
|
|
76
|
+
const _Error = globalThis.Error;
|
|
77
|
+
const _Reflect$1 = globalThis.Reflect;
|
|
78
|
+
/**
|
|
79
|
+
* (Safe copy) Creates a new Error using the captured Error constructor.
|
|
80
|
+
* Use this instead of `new Error()`.
|
|
81
|
+
*
|
|
82
|
+
* @param message - Optional error message.
|
|
83
|
+
* @param options - Optional error options.
|
|
84
|
+
* @returns A new Error instance.
|
|
85
|
+
*/
|
|
86
|
+
const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Safe copies of Set built-in via factory function.
|
|
90
|
+
*
|
|
91
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
92
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
93
|
+
*
|
|
94
|
+
* These references are captured at module initialization time to protect against
|
|
95
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
96
|
+
*
|
|
97
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/set
|
|
98
|
+
*/
|
|
99
|
+
// Capture references at module initialization time
|
|
100
|
+
const _Set = globalThis.Set;
|
|
101
|
+
const _Reflect = globalThis.Reflect;
|
|
102
|
+
/**
|
|
103
|
+
* (Safe copy) Creates a new Set using the captured Set constructor.
|
|
104
|
+
* Use this instead of `new Set()`.
|
|
105
|
+
*
|
|
106
|
+
* @param iterable - Optional iterable of values.
|
|
107
|
+
* @returns A new Set instance.
|
|
108
|
+
*/
|
|
109
|
+
const createSet = (iterable) => _Reflect.construct(_Set, iterable ? [iterable] : []);
|
|
110
|
+
|
|
29
111
|
/**
|
|
30
112
|
* Creates a FIFO (First-In-First-Out) list.
|
|
31
113
|
*
|
|
@@ -33,13 +115,13 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
33
115
|
* @returns {FifoList<T>} A FIFO list with methods to manipulate and query the list.
|
|
34
116
|
*/
|
|
35
117
|
function createFifoList() {
|
|
36
|
-
const list =
|
|
118
|
+
const list = createSet();
|
|
37
119
|
const push = (item) => {
|
|
38
120
|
if (getType(item) !== 'object') {
|
|
39
|
-
throw
|
|
121
|
+
throw createError('A fifo list only non-primitive values');
|
|
40
122
|
}
|
|
41
123
|
if (list.has(item)) {
|
|
42
|
-
throw
|
|
124
|
+
throw createError('Cannot a item that already exists');
|
|
43
125
|
}
|
|
44
126
|
list.add(item);
|
|
45
127
|
};
|
|
@@ -49,7 +131,7 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
49
131
|
return value;
|
|
50
132
|
};
|
|
51
133
|
const map = (callback) => {
|
|
52
|
-
return
|
|
134
|
+
return from(list.values()).map(callback);
|
|
53
135
|
};
|
|
54
136
|
const forEach = (callback) => {
|
|
55
137
|
list.forEach(callback);
|
|
@@ -68,7 +150,7 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
68
150
|
size,
|
|
69
151
|
clear,
|
|
70
152
|
};
|
|
71
|
-
return
|
|
153
|
+
return freeze(result);
|
|
72
154
|
}
|
|
73
155
|
|
|
74
156
|
/**
|
|
@@ -78,22 +160,22 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
78
160
|
* @returns {LifoList<T>} A LIFO list with methods to manipulate and query the list.
|
|
79
161
|
*/
|
|
80
162
|
function createLifoList() {
|
|
81
|
-
const list =
|
|
163
|
+
const list = createSet();
|
|
82
164
|
const push = (item) => {
|
|
83
165
|
if (getType(item) !== 'object') {
|
|
84
|
-
throw
|
|
166
|
+
throw createError('A lifo list only supports non-primitive values');
|
|
85
167
|
}
|
|
86
168
|
list.add(item);
|
|
87
169
|
};
|
|
88
170
|
const pull = () => {
|
|
89
|
-
const lastItem =
|
|
171
|
+
const lastItem = from(list).pop();
|
|
90
172
|
if (lastItem) {
|
|
91
173
|
list.delete(lastItem);
|
|
92
174
|
}
|
|
93
175
|
return lastItem;
|
|
94
176
|
};
|
|
95
177
|
const map = (callback) => {
|
|
96
|
-
return
|
|
178
|
+
return from(list).map(callback);
|
|
97
179
|
};
|
|
98
180
|
const forEach = (callback) => {
|
|
99
181
|
list.forEach(callback);
|
|
@@ -114,7 +196,7 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
114
196
|
size,
|
|
115
197
|
clear,
|
|
116
198
|
};
|
|
117
|
-
return
|
|
199
|
+
return freeze(result);
|
|
118
200
|
}
|
|
119
201
|
|
|
120
202
|
/**
|
|
@@ -140,7 +222,7 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
140
222
|
*/
|
|
141
223
|
function createValuePicker(values) {
|
|
142
224
|
if (!values || !values.length) {
|
|
143
|
-
throw
|
|
225
|
+
throw createError('Expected values not to be an empty list.');
|
|
144
226
|
}
|
|
145
227
|
let index = -1;
|
|
146
228
|
/**
|
|
@@ -193,7 +275,7 @@ var HyperfrontendListUtils = (function (exports) {
|
|
|
193
275
|
* @returns A new array containing only unique strings
|
|
194
276
|
*/
|
|
195
277
|
function uniqueStrings(values) {
|
|
196
|
-
return
|
|
278
|
+
return from(createSet(values));
|
|
197
279
|
}
|
|
198
280
|
|
|
199
281
|
exports.createFifoList = createFifoList;
|
package/bundle/index.iife.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.iife.js","sources":["../../../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.iife.js","sources":["../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/array/index.ts","../../../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/set/index.ts","../../../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Reflect"],"mappings":";;;IAAA;;;;;;;IAOG;IAEH;IACA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;IAMjC;;;IAGG;IACI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;;IChB7B,MAAM,iBAAiB,GAAmB,EAAE;;ICJnD;;;;;;;IAOG;IAEH;IACA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK;IAG/B;;IAEG;IACI,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;IAErC;;IAEG;IACI,MAA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AI,EAAE,KAAK,EAAE,CAAC;IAChG;;ICLA;;;;;IAKG;IACG,SAAU,aAAa,CAAC,MAAgB,EAAA;IAC5C,IAAA,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC;;;;;;;;;;;;;;;;"}
|
package/bundle/index.iife.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var HyperfrontendListUtils=function(e){"use strict";const r=[],
|
|
1
|
+
var HyperfrontendListUtils=function(e){"use strict";const t=globalThis.Object.freeze,r=[],n=globalThis.Array,o=n.isArray,i=n.from,l=e=>{if(null===e)return"null";const t=typeof e;if("object"===t){if(o(e))return"array";for(const t of r)if(e instanceof t)return t.name}return t},s=globalThis.Error,a=globalThis.Reflect,u=(e,t)=>a.construct(s,[e,t]),c=globalThis.Set,f=globalThis.Reflect,h=e=>f.construct(c,e?[e]:[]);return e.createFifoList=function(){const e=h();return t({push:t=>{if("object"!==l(t))throw u("A fifo list only non-primitive values");if(e.has(t))throw u("Cannot a item that already exists");e.add(t)},pull:()=>{const t=e.values().next().value;return e.delete(t),t},map:t=>i(e.values()).map(t),forEach:t=>{e.forEach(t)},remove:t=>e.delete(t),has:t=>e.has(t),size:()=>e.size,clear:()=>e.clear()})},e.createLifoList=function(){const e=h();return t({push:t=>{if("object"!==l(t))throw u("A lifo list only supports non-primitive values");e.add(t)},pull:()=>{const t=i(e).pop();return t&&e.delete(t),t},map:t=>i(e).map(t),forEach:t=>{e.forEach(t)},remove:t=>e.delete(t),has:t=>e.has(t),size:()=>e.size,clear:()=>{e.clear()}})},e.createRange=function(e,t){const r=[];for(let n=e;n<=t;n+=1)r.push(n);return r},e.createValuePicker=function(e){if(!e||!e.length)throw u("Expected values not to be an empty list.");let t=-1;function r(){return t<0&&(t=0),e[t]}return{current:r,next:function(){return t<0?r():(t=++t<e.length?t:0,e[t])}}},e.getLastKeyInMap=e=>{const t=[...e.keys()];return t[t.length-1]},e.nonEmptyStrings=function(e){return e.filter(e=>![void 0,null,""].includes(e)&&""!==e.trim())},e.uniqueStrings=function(e){return i(h(e))},e}({});
|
|
2
2
|
//# sourceMappingURL=index.iife.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.iife.min.js","sources":["../../../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":["
|
|
1
|
+
{"version":3,"file":"index.iife.min.js","sources":["../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/array/index.ts","../../../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/set/index.ts","../../../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["freeze","globalThis","Object","registeredClasses","_Array","Array","isArray","from","getType","target","nativeDataType","registeredClass","name","_Error","Error","_Reflect","Reflect","createError","message","options","construct","_Set","Set","createSet","iterable","list","push","item","has","add","pull","value","values","next","delete","map","callback","forEach","remove","size","clear","lastItem","pop","start","end","range","i","length","index","current","items","keys","filter","undefined","includes","trim"],"mappings":"oDAUA,MAUaA,EAVGC,WAAWC,OAUGF,OChBjBG,EAAoC,GCM3CC,EAASH,WAAWI,MAMbC,EAAUF,EAAOE,QAKjBC,EAAOH,EAAOG,KCTdC,EAAwCC,IACnD,GAAe,OAAXA,EAAiB,MAAU,OAC/B,MAAMC,SAAwBD,EAC9B,GAAuB,WAAnBC,EAA6B,CAC/B,GAAIJ,EAAQG,GAAS,MAAU,QAC/B,IAAK,MAAME,KAAmBR,EAC5B,GAAIM,aAAkBE,EAAiB,OAAUA,EAAgBC,IAErE,CACA,OAAUF,GCRNG,EAASZ,WAAWa,MAQpBC,EAAWd,WAAWe,QAWfC,EAAc,CAACC,EAAkBC,IAAyCJ,EAASK,UAAUP,EAAQ,CAACK,EAASC,ICnBtHE,EAAOpB,WAAWqB,IAClBP,EAAWd,WAAWe,QAUfO,EAAgBC,GAAkDT,EAASK,UAAUC,EAAMG,EAAW,CAACA,GAAY,uCCA9H,MAAMC,EAAeF,IA6CrB,OAAOvB,EAXqB,CAC1B0B,KAjCYC,IACZ,GAAsB,WAAlBnB,EAAQmB,GACV,MAAMV,EAAY,yCAEpB,GAAIQ,EAAKG,IAAID,GACX,MAAMV,EAAY,qCAEpBQ,EAAKI,IAAIF,IA2BTG,KAxBW,KACX,MAAMC,EAAQN,EAAKO,SAASC,OAAOF,MAEnC,OADAN,EAAKS,OAAUH,GACLA,GAsBVI,IAnBcC,GACP7B,EAAKkB,EAAKO,UAAUG,IAAIC,GAmB/BC,QAhBeD,IACfX,EAAKY,QAAQD,IAgBbE,OAbcX,GAAqBF,EAAKS,OAAOP,GAc/CC,IAZWD,GAAqBF,EAAKG,IAAID,GAazCY,KAXW,IAAMd,EAAKc,KAYtBC,MAVY,IAAMf,EAAKe,SAc3B,8BC9CE,MAAMf,EAAeF,IA8CrB,OAAOvB,EAXqB,CAC1B0B,KAlCYC,IACZ,GAAsB,WAAlBnB,EAAQmB,GACV,MAAMV,EAAY,kDAEpBQ,EAAKI,IAAIF,IA+BTG,KA5BW,KACX,MAAMW,EAAWlC,EAAKkB,GAAMiB,MAI5B,OAHID,GACFhB,EAAKS,OAAOO,GAEPA,GAwBPN,IArBcC,GACP7B,EAAKkB,GAAMU,IAAIC,GAqBtBC,QAlBeD,IACfX,EAAKY,QAAQD,IAkBbE,OAfcX,GAAqBF,EAAKS,OAAOP,GAgB/CC,IAdWD,GAAqBF,EAAKG,IAAID,GAezCY,KAbW,IAAcd,EAAKc,KAc9BC,MAZY,KACZf,EAAKe,UAeT,gBChEM,SAAsBG,EAAeC,GACzC,MAAMC,EAAkB,GACxB,IAAK,IAAIC,EAAIH,EAAOG,GAAKF,EAAKE,GAAK,EACjCD,EAAMnB,KAAKoB,GAEb,OAAOD,CACT,sBCAM,SAA4Bb,GAChC,IAAKA,IAAWA,EAAOe,OACrB,MAAM9B,EAAY,4CAEpB,IAAI+B,GAAQ,EAMZ,SAASC,IAEP,OADID,EAAQ,IAAGA,EAAQ,GAChBhB,EAAOgB,EAChB,CAWA,MAAO,CACLC,QAASA,EACThB,KAPF,WACE,OAAIe,EAAQ,EAAUC,KACtBD,IAAUA,EAAQhB,EAAOe,OAASC,EAAQ,EACnChB,EAAOgB,GAChB,EAKF,oBCxCyCb,IACvC,MAAMe,EAAQ,IAAIf,EAAIgB,QACtB,OAAUD,EAAMA,EAAMH,OAAS,sBCG3B,SAA0Bf,GAC9B,OAAOA,EAAOoB,OAAQrB,IAAW,MAACsB,EAAW,KAAM,IAAIC,SAASvB,IAA2B,KAAjBA,EAAMwB,OAClF,kBCCM,SAAwBvB,GAC5B,OAAOzB,EAAKgB,EAAUS,GACxB"}
|
package/bundle/index.umd.js
CHANGED
|
@@ -4,8 +4,43 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.HyperfrontendListUtils = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Safe copies of Object built-in methods.
|
|
9
|
+
*
|
|
10
|
+
* These references are captured at module initialization time to protect against
|
|
11
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
12
|
+
*
|
|
13
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/object
|
|
14
|
+
*/
|
|
15
|
+
// Capture references at module initialization time
|
|
16
|
+
const _Object = globalThis.Object;
|
|
17
|
+
/**
|
|
18
|
+
* (Safe copy) Prevents modification of existing property attributes and values,
|
|
19
|
+
* and prevents the addition of new properties.
|
|
20
|
+
*/
|
|
21
|
+
const freeze = _Object.freeze;
|
|
22
|
+
|
|
7
23
|
const registeredClasses = [];
|
|
8
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Safe copies of Array built-in static methods.
|
|
27
|
+
*
|
|
28
|
+
* These references are captured at module initialization time to protect against
|
|
29
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
30
|
+
*
|
|
31
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
32
|
+
*/
|
|
33
|
+
// Capture references at module initialization time
|
|
34
|
+
const _Array = globalThis.Array;
|
|
35
|
+
/**
|
|
36
|
+
* (Safe copy) Determines whether the passed value is an Array.
|
|
37
|
+
*/
|
|
38
|
+
const isArray = _Array.isArray;
|
|
39
|
+
/**
|
|
40
|
+
* (Safe copy) Creates an array from an array-like or iterable object.
|
|
41
|
+
*/
|
|
42
|
+
const from = _Array.from;
|
|
43
|
+
|
|
9
44
|
/**
|
|
10
45
|
* Returns the data type of the target.
|
|
11
46
|
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
@@ -19,7 +54,7 @@
|
|
|
19
54
|
return 'null';
|
|
20
55
|
const nativeDataType = typeof target;
|
|
21
56
|
if (nativeDataType === 'object') {
|
|
22
|
-
if (
|
|
57
|
+
if (isArray(target))
|
|
23
58
|
return 'array';
|
|
24
59
|
for (const registeredClass of registeredClasses) {
|
|
25
60
|
if (target instanceof registeredClass)
|
|
@@ -29,6 +64,53 @@
|
|
|
29
64
|
return nativeDataType;
|
|
30
65
|
};
|
|
31
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Safe copies of Error built-ins via factory functions.
|
|
69
|
+
*
|
|
70
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
71
|
+
* provides factory functions that use Reflect.construct internally.
|
|
72
|
+
*
|
|
73
|
+
* These references are captured at module initialization time to protect against
|
|
74
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
75
|
+
*
|
|
76
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/error
|
|
77
|
+
*/
|
|
78
|
+
// Capture references at module initialization time
|
|
79
|
+
const _Error = globalThis.Error;
|
|
80
|
+
const _Reflect$1 = globalThis.Reflect;
|
|
81
|
+
/**
|
|
82
|
+
* (Safe copy) Creates a new Error using the captured Error constructor.
|
|
83
|
+
* Use this instead of `new Error()`.
|
|
84
|
+
*
|
|
85
|
+
* @param message - Optional error message.
|
|
86
|
+
* @param options - Optional error options.
|
|
87
|
+
* @returns A new Error instance.
|
|
88
|
+
*/
|
|
89
|
+
const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Safe copies of Set built-in via factory function.
|
|
93
|
+
*
|
|
94
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
95
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
96
|
+
*
|
|
97
|
+
* These references are captured at module initialization time to protect against
|
|
98
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
99
|
+
*
|
|
100
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/set
|
|
101
|
+
*/
|
|
102
|
+
// Capture references at module initialization time
|
|
103
|
+
const _Set = globalThis.Set;
|
|
104
|
+
const _Reflect = globalThis.Reflect;
|
|
105
|
+
/**
|
|
106
|
+
* (Safe copy) Creates a new Set using the captured Set constructor.
|
|
107
|
+
* Use this instead of `new Set()`.
|
|
108
|
+
*
|
|
109
|
+
* @param iterable - Optional iterable of values.
|
|
110
|
+
* @returns A new Set instance.
|
|
111
|
+
*/
|
|
112
|
+
const createSet = (iterable) => _Reflect.construct(_Set, iterable ? [iterable] : []);
|
|
113
|
+
|
|
32
114
|
/**
|
|
33
115
|
* Creates a FIFO (First-In-First-Out) list.
|
|
34
116
|
*
|
|
@@ -36,13 +118,13 @@
|
|
|
36
118
|
* @returns {FifoList<T>} A FIFO list with methods to manipulate and query the list.
|
|
37
119
|
*/
|
|
38
120
|
function createFifoList() {
|
|
39
|
-
const list =
|
|
121
|
+
const list = createSet();
|
|
40
122
|
const push = (item) => {
|
|
41
123
|
if (getType(item) !== 'object') {
|
|
42
|
-
throw
|
|
124
|
+
throw createError('A fifo list only non-primitive values');
|
|
43
125
|
}
|
|
44
126
|
if (list.has(item)) {
|
|
45
|
-
throw
|
|
127
|
+
throw createError('Cannot a item that already exists');
|
|
46
128
|
}
|
|
47
129
|
list.add(item);
|
|
48
130
|
};
|
|
@@ -52,7 +134,7 @@
|
|
|
52
134
|
return value;
|
|
53
135
|
};
|
|
54
136
|
const map = (callback) => {
|
|
55
|
-
return
|
|
137
|
+
return from(list.values()).map(callback);
|
|
56
138
|
};
|
|
57
139
|
const forEach = (callback) => {
|
|
58
140
|
list.forEach(callback);
|
|
@@ -71,7 +153,7 @@
|
|
|
71
153
|
size,
|
|
72
154
|
clear,
|
|
73
155
|
};
|
|
74
|
-
return
|
|
156
|
+
return freeze(result);
|
|
75
157
|
}
|
|
76
158
|
|
|
77
159
|
/**
|
|
@@ -81,22 +163,22 @@
|
|
|
81
163
|
* @returns {LifoList<T>} A LIFO list with methods to manipulate and query the list.
|
|
82
164
|
*/
|
|
83
165
|
function createLifoList() {
|
|
84
|
-
const list =
|
|
166
|
+
const list = createSet();
|
|
85
167
|
const push = (item) => {
|
|
86
168
|
if (getType(item) !== 'object') {
|
|
87
|
-
throw
|
|
169
|
+
throw createError('A lifo list only supports non-primitive values');
|
|
88
170
|
}
|
|
89
171
|
list.add(item);
|
|
90
172
|
};
|
|
91
173
|
const pull = () => {
|
|
92
|
-
const lastItem =
|
|
174
|
+
const lastItem = from(list).pop();
|
|
93
175
|
if (lastItem) {
|
|
94
176
|
list.delete(lastItem);
|
|
95
177
|
}
|
|
96
178
|
return lastItem;
|
|
97
179
|
};
|
|
98
180
|
const map = (callback) => {
|
|
99
|
-
return
|
|
181
|
+
return from(list).map(callback);
|
|
100
182
|
};
|
|
101
183
|
const forEach = (callback) => {
|
|
102
184
|
list.forEach(callback);
|
|
@@ -117,7 +199,7 @@
|
|
|
117
199
|
size,
|
|
118
200
|
clear,
|
|
119
201
|
};
|
|
120
|
-
return
|
|
202
|
+
return freeze(result);
|
|
121
203
|
}
|
|
122
204
|
|
|
123
205
|
/**
|
|
@@ -143,7 +225,7 @@
|
|
|
143
225
|
*/
|
|
144
226
|
function createValuePicker(values) {
|
|
145
227
|
if (!values || !values.length) {
|
|
146
|
-
throw
|
|
228
|
+
throw createError('Expected values not to be an empty list.');
|
|
147
229
|
}
|
|
148
230
|
let index = -1;
|
|
149
231
|
/**
|
|
@@ -196,7 +278,7 @@
|
|
|
196
278
|
* @returns A new array containing only unique strings
|
|
197
279
|
*/
|
|
198
280
|
function uniqueStrings(values) {
|
|
199
|
-
return
|
|
281
|
+
return from(createSet(values));
|
|
200
282
|
}
|
|
201
283
|
|
|
202
284
|
exports.createFifoList = createFifoList;
|
package/bundle/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../../../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/array/index.ts","../../../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/set/index.ts","../../../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Reflect"],"mappings":";;;;;;IAAA;;;;;;;IAOG;IAEH;IACA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;IAMjC;;;IAGG;IACI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;;IChB7B,MAAM,iBAAiB,GAAmB,EAAE;;ICJnD;;;;;;;IAOG;IAEH;IACA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK;IAG/B;;IAEG;IACI,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;IAErC;;IAEG;IACI,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI;;ICjB/B;;;;;;;IAOG;IACI,MAAM,OAAO,GAAG,CAA8B,MAAe,KAAO;QACzE,IAAI,MAAM,KAAK,IAAI;IAAE,QAAA,OAAU,MAAM;I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C;;;;;;;;;;;;;;"}
|
package/bundle/index.umd.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).HyperfrontendListUtils={})}(this,function(e){"use strict";const t=[],r=e=>{if(null===e)return"null";const
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).HyperfrontendListUtils={})}(this,function(e){"use strict";const t=globalThis.Object.freeze,n=[],r=globalThis.Array,o=r.isArray,i=r.from,s=e=>{if(null===e)return"null";const t=typeof e;if("object"===t){if(o(e))return"array";for(const t of n)if(e instanceof t)return t.name}return t},l=globalThis.Error,a=globalThis.Reflect,u=(e,t)=>a.construct(l,[e,t]),c=globalThis.Set,f=globalThis.Reflect,h=e=>f.construct(c,e?[e]:[]);e.createFifoList=function(){const e=h();return t({push:t=>{if("object"!==s(t))throw u("A fifo list only non-primitive values");if(e.has(t))throw u("Cannot a item that already exists");e.add(t)},pull:()=>{const t=e.values().next().value;return e.delete(t),t},map:t=>i(e.values()).map(t),forEach:t=>{e.forEach(t)},remove:t=>e.delete(t),has:t=>e.has(t),size:()=>e.size,clear:()=>e.clear()})},e.createLifoList=function(){const e=h();return t({push:t=>{if("object"!==s(t))throw u("A lifo list only supports non-primitive values");e.add(t)},pull:()=>{const t=i(e).pop();return t&&e.delete(t),t},map:t=>i(e).map(t),forEach:t=>{e.forEach(t)},remove:t=>e.delete(t),has:t=>e.has(t),size:()=>e.size,clear:()=>{e.clear()}})},e.createRange=function(e,t){const n=[];for(let r=e;r<=t;r+=1)n.push(r);return n},e.createValuePicker=function(e){if(!e||!e.length)throw u("Expected values not to be an empty list.");let t=-1;function n(){return t<0&&(t=0),e[t]}return{current:n,next:function(){return t<0?n():(t=++t<e.length?t:0,e[t])}}},e.getLastKeyInMap=e=>{const t=[...e.keys()];return t[t.length-1]},e.nonEmptyStrings=function(e){return e.filter(e=>![void 0,null,""].includes(e)&&""!==e.trim())},e.uniqueStrings=function(e){return i(h(e))}});
|
|
2
2
|
//# sourceMappingURL=index.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.min.js","sources":["../../../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":["
|
|
1
|
+
{"version":3,"file":"index.umd.min.js","sources":["../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/array/index.ts","../../../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/set/index.ts","../../../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["freeze","globalThis","Object","registeredClasses","_Array","Array","isArray","from","getType","target","nativeDataType","registeredClass","name","_Error","Error","_Reflect","Reflect","createError","message","options","construct","_Set","Set","createSet","iterable","list","push","item","has","add","pull","value","values","next","delete","map","callback","forEach","remove","size","clear","lastItem","pop","start","end","range","i","length","index","current","items","keys","filter","undefined","includes","trim"],"mappings":"6PAUA,MAUaA,EAVGC,WAAWC,OAUGF,OChBjBG,EAAoC,GCM3CC,EAASH,WAAWI,MAMbC,EAAUF,EAAOE,QAKjBC,EAAOH,EAAOG,KCTdC,EAAwCC,IACnD,GAAe,OAAXA,EAAiB,MAAU,OAC/B,MAAMC,SAAwBD,EAC9B,GAAuB,WAAnBC,EAA6B,CAC/B,GAAIJ,EAAQG,GAAS,MAAU,QAC/B,IAAK,MAAME,KAAmBR,EAC5B,GAAIM,aAAkBE,EAAiB,OAAUA,EAAgBC,IAErE,CACA,OAAUF,GCRNG,EAASZ,WAAWa,MAQpBC,EAAWd,WAAWe,QAWfC,EAAc,CAACC,EAAkBC,IAAyCJ,EAASK,UAAUP,EAAQ,CAACK,EAASC,ICnBtHE,EAAOpB,WAAWqB,IAClBP,EAAWd,WAAWe,QAUfO,EAAgBC,GAAkDT,EAASK,UAAUC,EAAMG,EAAW,CAACA,GAAY,gCCA9H,MAAMC,EAAeF,IA6CrB,OAAOvB,EAXqB,CAC1B0B,KAjCYC,IACZ,GAAsB,WAAlBnB,EAAQmB,GACV,MAAMV,EAAY,yCAEpB,GAAIQ,EAAKG,IAAID,GACX,MAAMV,EAAY,qCAEpBQ,EAAKI,IAAIF,IA2BTG,KAxBW,KACX,MAAMC,EAAQN,EAAKO,SAASC,OAAOF,MAEnC,OADAN,EAAKS,OAAUH,GACLA,GAsBVI,IAnBcC,GACP7B,EAAKkB,EAAKO,UAAUG,IAAIC,GAmB/BC,QAhBeD,IACfX,EAAKY,QAAQD,IAgBbE,OAbcX,GAAqBF,EAAKS,OAAOP,GAc/CC,IAZWD,GAAqBF,EAAKG,IAAID,GAazCY,KAXW,IAAMd,EAAKc,KAYtBC,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","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/create-fifo-list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-fifo-list.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/create-fifo-list.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,MAAM;IACxC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACnB,IAAI,IAAI,CAAC,CAAA;IACT,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAA;IACrC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,CAAA;IAC1C,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAA;IACxB,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAA;IACrB,IAAI,IAAI,MAAM,CAAA;IACd,KAAK,IAAI,IAAI,CAAA;CACd;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CA+C9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-lifo-list.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/create-lifo-list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-lifo-list.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/create-lifo-list.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,MAAM;IACxC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACnB,IAAI,IAAI,CAAC,GAAG,SAAS,CAAA;IACrB,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAA;IACrC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,CAAA;IAC1C,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAA;IACxB,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAA;IACrB,IAAI,IAAI,MAAM,CAAA;IACd,KAAK,IAAI,IAAI,CAAA;CACd;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAgD9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-value-picker.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/create-value-picker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-value-picker.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/create-value-picker.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,MAAM,CAAA;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,CA4B/D"}
|
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Safe copies of Object built-in methods.
|
|
5
|
+
*
|
|
6
|
+
* These references are captured at module initialization time to protect against
|
|
7
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
8
|
+
*
|
|
9
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/object
|
|
10
|
+
*/
|
|
11
|
+
// Capture references at module initialization time
|
|
12
|
+
const _Object = globalThis.Object;
|
|
13
|
+
/**
|
|
14
|
+
* (Safe copy) Prevents modification of existing property attributes and values,
|
|
15
|
+
* and prevents the addition of new properties.
|
|
16
|
+
*/
|
|
17
|
+
const freeze = _Object.freeze;
|
|
18
|
+
|
|
3
19
|
const registeredClasses = [];
|
|
4
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Safe copies of Array built-in static methods.
|
|
23
|
+
*
|
|
24
|
+
* These references are captured at module initialization time to protect against
|
|
25
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
26
|
+
*
|
|
27
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
28
|
+
*/
|
|
29
|
+
// Capture references at module initialization time
|
|
30
|
+
const _Array = globalThis.Array;
|
|
31
|
+
/**
|
|
32
|
+
* (Safe copy) Determines whether the passed value is an Array.
|
|
33
|
+
*/
|
|
34
|
+
const isArray = _Array.isArray;
|
|
35
|
+
/**
|
|
36
|
+
* (Safe copy) Creates an array from an array-like or iterable object.
|
|
37
|
+
*/
|
|
38
|
+
const from = _Array.from;
|
|
39
|
+
|
|
5
40
|
/**
|
|
6
41
|
* Returns the data type of the target.
|
|
7
42
|
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
@@ -15,7 +50,7 @@ const getType = (target) => {
|
|
|
15
50
|
return 'null';
|
|
16
51
|
const nativeDataType = typeof target;
|
|
17
52
|
if (nativeDataType === 'object') {
|
|
18
|
-
if (
|
|
53
|
+
if (isArray(target))
|
|
19
54
|
return 'array';
|
|
20
55
|
for (const registeredClass of registeredClasses) {
|
|
21
56
|
if (target instanceof registeredClass)
|
|
@@ -25,6 +60,53 @@ const getType = (target) => {
|
|
|
25
60
|
return nativeDataType;
|
|
26
61
|
};
|
|
27
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Safe copies of Error built-ins via factory functions.
|
|
65
|
+
*
|
|
66
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
67
|
+
* provides factory functions that use Reflect.construct internally.
|
|
68
|
+
*
|
|
69
|
+
* These references are captured at module initialization time to protect against
|
|
70
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
71
|
+
*
|
|
72
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/error
|
|
73
|
+
*/
|
|
74
|
+
// Capture references at module initialization time
|
|
75
|
+
const _Error = globalThis.Error;
|
|
76
|
+
const _Reflect$1 = globalThis.Reflect;
|
|
77
|
+
/**
|
|
78
|
+
* (Safe copy) Creates a new Error using the captured Error constructor.
|
|
79
|
+
* Use this instead of `new Error()`.
|
|
80
|
+
*
|
|
81
|
+
* @param message - Optional error message.
|
|
82
|
+
* @param options - Optional error options.
|
|
83
|
+
* @returns A new Error instance.
|
|
84
|
+
*/
|
|
85
|
+
const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]);
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Safe copies of Set built-in via factory function.
|
|
89
|
+
*
|
|
90
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
91
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
92
|
+
*
|
|
93
|
+
* These references are captured at module initialization time to protect against
|
|
94
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
95
|
+
*
|
|
96
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/set
|
|
97
|
+
*/
|
|
98
|
+
// Capture references at module initialization time
|
|
99
|
+
const _Set = globalThis.Set;
|
|
100
|
+
const _Reflect = globalThis.Reflect;
|
|
101
|
+
/**
|
|
102
|
+
* (Safe copy) Creates a new Set using the captured Set constructor.
|
|
103
|
+
* Use this instead of `new Set()`.
|
|
104
|
+
*
|
|
105
|
+
* @param iterable - Optional iterable of values.
|
|
106
|
+
* @returns A new Set instance.
|
|
107
|
+
*/
|
|
108
|
+
const createSet = (iterable) => _Reflect.construct(_Set, iterable ? [iterable] : []);
|
|
109
|
+
|
|
28
110
|
/**
|
|
29
111
|
* Creates a FIFO (First-In-First-Out) list.
|
|
30
112
|
*
|
|
@@ -32,13 +114,13 @@ const getType = (target) => {
|
|
|
32
114
|
* @returns {FifoList<T>} A FIFO list with methods to manipulate and query the list.
|
|
33
115
|
*/
|
|
34
116
|
function createFifoList() {
|
|
35
|
-
const list =
|
|
117
|
+
const list = createSet();
|
|
36
118
|
const push = (item) => {
|
|
37
119
|
if (getType(item) !== 'object') {
|
|
38
|
-
throw
|
|
120
|
+
throw createError('A fifo list only non-primitive values');
|
|
39
121
|
}
|
|
40
122
|
if (list.has(item)) {
|
|
41
|
-
throw
|
|
123
|
+
throw createError('Cannot a item that already exists');
|
|
42
124
|
}
|
|
43
125
|
list.add(item);
|
|
44
126
|
};
|
|
@@ -48,7 +130,7 @@ function createFifoList() {
|
|
|
48
130
|
return value;
|
|
49
131
|
};
|
|
50
132
|
const map = (callback) => {
|
|
51
|
-
return
|
|
133
|
+
return from(list.values()).map(callback);
|
|
52
134
|
};
|
|
53
135
|
const forEach = (callback) => {
|
|
54
136
|
list.forEach(callback);
|
|
@@ -67,7 +149,7 @@ function createFifoList() {
|
|
|
67
149
|
size,
|
|
68
150
|
clear,
|
|
69
151
|
};
|
|
70
|
-
return
|
|
152
|
+
return freeze(result);
|
|
71
153
|
}
|
|
72
154
|
|
|
73
155
|
/**
|
|
@@ -77,22 +159,22 @@ function createFifoList() {
|
|
|
77
159
|
* @returns {LifoList<T>} A LIFO list with methods to manipulate and query the list.
|
|
78
160
|
*/
|
|
79
161
|
function createLifoList() {
|
|
80
|
-
const list =
|
|
162
|
+
const list = createSet();
|
|
81
163
|
const push = (item) => {
|
|
82
164
|
if (getType(item) !== 'object') {
|
|
83
|
-
throw
|
|
165
|
+
throw createError('A lifo list only supports non-primitive values');
|
|
84
166
|
}
|
|
85
167
|
list.add(item);
|
|
86
168
|
};
|
|
87
169
|
const pull = () => {
|
|
88
|
-
const lastItem =
|
|
170
|
+
const lastItem = from(list).pop();
|
|
89
171
|
if (lastItem) {
|
|
90
172
|
list.delete(lastItem);
|
|
91
173
|
}
|
|
92
174
|
return lastItem;
|
|
93
175
|
};
|
|
94
176
|
const map = (callback) => {
|
|
95
|
-
return
|
|
177
|
+
return from(list).map(callback);
|
|
96
178
|
};
|
|
97
179
|
const forEach = (callback) => {
|
|
98
180
|
list.forEach(callback);
|
|
@@ -113,7 +195,7 @@ function createLifoList() {
|
|
|
113
195
|
size,
|
|
114
196
|
clear,
|
|
115
197
|
};
|
|
116
|
-
return
|
|
198
|
+
return freeze(result);
|
|
117
199
|
}
|
|
118
200
|
|
|
119
201
|
/**
|
|
@@ -139,7 +221,7 @@ function createRange(start, end) {
|
|
|
139
221
|
*/
|
|
140
222
|
function createValuePicker(values) {
|
|
141
223
|
if (!values || !values.length) {
|
|
142
|
-
throw
|
|
224
|
+
throw createError('Expected values not to be an empty list.');
|
|
143
225
|
}
|
|
144
226
|
let index = -1;
|
|
145
227
|
/**
|
|
@@ -192,7 +274,7 @@ function nonEmptyStrings(values) {
|
|
|
192
274
|
* @returns A new array containing only unique strings
|
|
193
275
|
*/
|
|
194
276
|
function uniqueStrings(values) {
|
|
195
|
-
return
|
|
277
|
+
return from(createSet(values));
|
|
196
278
|
}
|
|
197
279
|
|
|
198
280
|
exports.createFifoList = createFifoList;
|
package/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/array/index.ts","../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/set/index.ts","../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Reflect"],"mappings":";;AAAA;;;;;;;AAOG;AAEH;AACA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;AAMjC;;;AAGG;AACI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;;AChB7B,MAAM,iBAAiB,GAAmB,EAAE;;ACJnD;;;;;;;AAOG;AAEH;AACA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK;AAG/B;;AAEG;AACI,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;AAErC;;AAEG;AACI,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI;;ACjB/B;;;;;;;AAOG;AACI,MAAM,OAAO,GAAG,CAA8B,MAAe,KAAO;IACzE,IAAI,MAAM,KAAK,IAAI;AAAE,QAAA,OAAU,MAAM;AACrC,IAAA,MAAM,cAAc,GAAG,OAAO,MAAM;AACpC,IAAA,IAAI,cAAc,KAAK,QAAQ,EAAE;QAC/B,IAAI,OAAO,CAAC,MAAM,CAAC;AAAE,YAAA,OAAU,OAAO;AACtC,QAAA,KAAK,MAAM,eAAe,IAAI,iBAAiB,EAAE;YAC/C,IAAI,MAAM,YAAY,eAAe;gBAAE,OAAU,eAAe,CAAC,IAAI;QACvE;IACF;AACA,IAAA,OAAU,cAAc;AAC1B,CAAC;;ACtBD;;;;;;;;;;AAUG;AAEH;AACA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CAAC,KAAK,CAAC;IACtB;AACA;;;;AAIG;AACH,IAAA,SAAS,IAAI,GAAA;QACX,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,OAAO,EAAE;AAC/B,QAAA,KAAK,GAAG,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC;AAC3C,QAAA,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB;IACA,OAAO;AACL,QAAA,OAAO,EAAE,OAAO;AAChB,QAAA,IAAI,EAAE,IAAI;KACX;AACH;;ACzCA;AACO,MAAM,eAAe,GAAG,CAAU,GAAgB,KAAO;IAC9D,MAAM,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAU,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACnC;;ACJA;;;;;AAKG;AACG,SAAU,eAAe,CAAC,MAAgB,EAAA;AAC9C,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAChG;;ACLA;;;;;AAKG;AACG,SAAU,aAAa,CAAC,MAAgB,EAAA;AAC5C,IAAA,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAChC;;;;;;;;;;"}
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe copies of Object built-in methods.
|
|
3
|
+
*
|
|
4
|
+
* These references are captured at module initialization time to protect against
|
|
5
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
6
|
+
*
|
|
7
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/object
|
|
8
|
+
*/
|
|
9
|
+
// Capture references at module initialization time
|
|
10
|
+
const _Object = globalThis.Object;
|
|
11
|
+
/**
|
|
12
|
+
* (Safe copy) Prevents modification of existing property attributes and values,
|
|
13
|
+
* and prevents the addition of new properties.
|
|
14
|
+
*/
|
|
15
|
+
const freeze = _Object.freeze;
|
|
16
|
+
|
|
1
17
|
const registeredClasses = [];
|
|
2
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Safe copies of Array built-in static methods.
|
|
21
|
+
*
|
|
22
|
+
* These references are captured at module initialization time to protect against
|
|
23
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
24
|
+
*
|
|
25
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
26
|
+
*/
|
|
27
|
+
// Capture references at module initialization time
|
|
28
|
+
const _Array = globalThis.Array;
|
|
29
|
+
/**
|
|
30
|
+
* (Safe copy) Determines whether the passed value is an Array.
|
|
31
|
+
*/
|
|
32
|
+
const isArray = _Array.isArray;
|
|
33
|
+
/**
|
|
34
|
+
* (Safe copy) Creates an array from an array-like or iterable object.
|
|
35
|
+
*/
|
|
36
|
+
const from = _Array.from;
|
|
37
|
+
|
|
3
38
|
/**
|
|
4
39
|
* Returns the data type of the target.
|
|
5
40
|
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
@@ -13,7 +48,7 @@ const getType = (target) => {
|
|
|
13
48
|
return 'null';
|
|
14
49
|
const nativeDataType = typeof target;
|
|
15
50
|
if (nativeDataType === 'object') {
|
|
16
|
-
if (
|
|
51
|
+
if (isArray(target))
|
|
17
52
|
return 'array';
|
|
18
53
|
for (const registeredClass of registeredClasses) {
|
|
19
54
|
if (target instanceof registeredClass)
|
|
@@ -23,6 +58,53 @@ const getType = (target) => {
|
|
|
23
58
|
return nativeDataType;
|
|
24
59
|
};
|
|
25
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Safe copies of Error built-ins via factory functions.
|
|
63
|
+
*
|
|
64
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
65
|
+
* provides factory functions that use Reflect.construct internally.
|
|
66
|
+
*
|
|
67
|
+
* These references are captured at module initialization time to protect against
|
|
68
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
69
|
+
*
|
|
70
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/error
|
|
71
|
+
*/
|
|
72
|
+
// Capture references at module initialization time
|
|
73
|
+
const _Error = globalThis.Error;
|
|
74
|
+
const _Reflect$1 = globalThis.Reflect;
|
|
75
|
+
/**
|
|
76
|
+
* (Safe copy) Creates a new Error using the captured Error constructor.
|
|
77
|
+
* Use this instead of `new Error()`.
|
|
78
|
+
*
|
|
79
|
+
* @param message - Optional error message.
|
|
80
|
+
* @param options - Optional error options.
|
|
81
|
+
* @returns A new Error instance.
|
|
82
|
+
*/
|
|
83
|
+
const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Safe copies of Set built-in via factory function.
|
|
87
|
+
*
|
|
88
|
+
* Since constructors cannot be safely captured via Object.assign, this module
|
|
89
|
+
* provides a factory function that uses Reflect.construct internally.
|
|
90
|
+
*
|
|
91
|
+
* These references are captured at module initialization time to protect against
|
|
92
|
+
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
93
|
+
*
|
|
94
|
+
* @module @hyperfrontend/immutable-api-utils/built-in-copy/set
|
|
95
|
+
*/
|
|
96
|
+
// Capture references at module initialization time
|
|
97
|
+
const _Set = globalThis.Set;
|
|
98
|
+
const _Reflect = globalThis.Reflect;
|
|
99
|
+
/**
|
|
100
|
+
* (Safe copy) Creates a new Set using the captured Set constructor.
|
|
101
|
+
* Use this instead of `new Set()`.
|
|
102
|
+
*
|
|
103
|
+
* @param iterable - Optional iterable of values.
|
|
104
|
+
* @returns A new Set instance.
|
|
105
|
+
*/
|
|
106
|
+
const createSet = (iterable) => _Reflect.construct(_Set, iterable ? [iterable] : []);
|
|
107
|
+
|
|
26
108
|
/**
|
|
27
109
|
* Creates a FIFO (First-In-First-Out) list.
|
|
28
110
|
*
|
|
@@ -30,13 +112,13 @@ const getType = (target) => {
|
|
|
30
112
|
* @returns {FifoList<T>} A FIFO list with methods to manipulate and query the list.
|
|
31
113
|
*/
|
|
32
114
|
function createFifoList() {
|
|
33
|
-
const list =
|
|
115
|
+
const list = createSet();
|
|
34
116
|
const push = (item) => {
|
|
35
117
|
if (getType(item) !== 'object') {
|
|
36
|
-
throw
|
|
118
|
+
throw createError('A fifo list only non-primitive values');
|
|
37
119
|
}
|
|
38
120
|
if (list.has(item)) {
|
|
39
|
-
throw
|
|
121
|
+
throw createError('Cannot a item that already exists');
|
|
40
122
|
}
|
|
41
123
|
list.add(item);
|
|
42
124
|
};
|
|
@@ -46,7 +128,7 @@ function createFifoList() {
|
|
|
46
128
|
return value;
|
|
47
129
|
};
|
|
48
130
|
const map = (callback) => {
|
|
49
|
-
return
|
|
131
|
+
return from(list.values()).map(callback);
|
|
50
132
|
};
|
|
51
133
|
const forEach = (callback) => {
|
|
52
134
|
list.forEach(callback);
|
|
@@ -65,7 +147,7 @@ function createFifoList() {
|
|
|
65
147
|
size,
|
|
66
148
|
clear,
|
|
67
149
|
};
|
|
68
|
-
return
|
|
150
|
+
return freeze(result);
|
|
69
151
|
}
|
|
70
152
|
|
|
71
153
|
/**
|
|
@@ -75,22 +157,22 @@ function createFifoList() {
|
|
|
75
157
|
* @returns {LifoList<T>} A LIFO list with methods to manipulate and query the list.
|
|
76
158
|
*/
|
|
77
159
|
function createLifoList() {
|
|
78
|
-
const list =
|
|
160
|
+
const list = createSet();
|
|
79
161
|
const push = (item) => {
|
|
80
162
|
if (getType(item) !== 'object') {
|
|
81
|
-
throw
|
|
163
|
+
throw createError('A lifo list only supports non-primitive values');
|
|
82
164
|
}
|
|
83
165
|
list.add(item);
|
|
84
166
|
};
|
|
85
167
|
const pull = () => {
|
|
86
|
-
const lastItem =
|
|
168
|
+
const lastItem = from(list).pop();
|
|
87
169
|
if (lastItem) {
|
|
88
170
|
list.delete(lastItem);
|
|
89
171
|
}
|
|
90
172
|
return lastItem;
|
|
91
173
|
};
|
|
92
174
|
const map = (callback) => {
|
|
93
|
-
return
|
|
175
|
+
return from(list).map(callback);
|
|
94
176
|
};
|
|
95
177
|
const forEach = (callback) => {
|
|
96
178
|
list.forEach(callback);
|
|
@@ -111,7 +193,7 @@ function createLifoList() {
|
|
|
111
193
|
size,
|
|
112
194
|
clear,
|
|
113
195
|
};
|
|
114
|
-
return
|
|
196
|
+
return freeze(result);
|
|
115
197
|
}
|
|
116
198
|
|
|
117
199
|
/**
|
|
@@ -137,7 +219,7 @@ function createRange(start, end) {
|
|
|
137
219
|
*/
|
|
138
220
|
function createValuePicker(values) {
|
|
139
221
|
if (!values || !values.length) {
|
|
140
|
-
throw
|
|
222
|
+
throw createError('Expected values not to be an empty list.');
|
|
141
223
|
}
|
|
142
224
|
let index = -1;
|
|
143
225
|
/**
|
|
@@ -190,7 +272,7 @@ function nonEmptyStrings(values) {
|
|
|
190
272
|
* @returns A new array containing only unique strings
|
|
191
273
|
*/
|
|
192
274
|
function uniqueStrings(values) {
|
|
193
|
-
return
|
|
275
|
+
return from(createSet(values));
|
|
194
276
|
}
|
|
195
277
|
|
|
196
278
|
export { createFifoList, createLifoList, createRange, createValuePicker, getLastKeyInMap, nonEmptyStrings, uniqueStrings };
|
package/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../libs/utils/data/src/shared/consts.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/array/index.ts","../../../../../../../../libs/utils/data/src/get-type.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/set/index.ts","../../../../../../../../libs/utils/list/src/create-fifo-list.ts","../../../../../../../../libs/utils/list/src/create-lifo-list.ts","../../../../../../../../libs/utils/list/src/create-range.ts","../../../../../../../../libs/utils/list/src/create-value-picker.ts","../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts","../../../../../../../../libs/utils/list/src/non-empty-strings.ts","../../../../../../../../libs/utils/list/src/unique-strings.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Reflect"],"mappings":"AAAA;;;;;;;AAOG;AAEH;AACA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;AAMjC;;;AAGG;AACI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;;AChB7B,MAAM,iBAAiB,GAAmB,EAAE;;ACJnD;;;;;;;AAOG;AAEH;AACA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK;AAG/B;;AAEG;AACI,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;AAErC;;AAEG;AACI,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI;;ACjB/B;;;;;;;AAOG;AACI,MAAM,OAAO,GAAG,CAA8B,MAAe,KAAO;IACzE,IAAI,MAAM,KAAK,IAAI;AAAE,QAAA,OAAU,MAAM;AACrC,IAAA,MAAM,cAAc,GAAG,OAAO,MAAM;AACpC,IAAA,IAAI,cAAc,KAAK,QAAQ,EAAE;QAC/B,IAAI,OAAO,CAAC,MAAM,CAAC;AAAE,YAAA,OAAU,OAAO;AACtC,QAAA,KAAK,MAAM,eAAe,IAAI,iBAAiB,EAAE;YAC/C,IAAI,MAAM,YAAY,eAAe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;;AAIG;AACH,IAAA,SAAS,OAAO,GAAA;QACd,IAAI,KAAK,GAAG,CAAC;YAAE,KAAK,GAAG,CAAC;AACxB,QAAA,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB;AACA;;;;AAIG;AACH,IAAA,SAAS,IAAI,GAAA;QACX,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,OAAO,EAAE;AAC/B,QAAA,KAAK,GAAG,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC;AAC3C,QAAA,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB;IACA,OAAO;AACL,QAAA,OAAO,EAAE,OAAO;AAChB,QAAA,IAAI,EAAE,IAAI;KACX;AACH;;ACzCA;AACO,MAAM,eAAe,GAAG,CAAU,GAAgB,KAAO;IAC9D,MAAM,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAU,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACnC;;ACJA;;;;;AAKG;AACG,SAAU,eAAe,CAAC,MAAgB,EAAA;AAC9C,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAChG;;ACLA;;;;;AAKG;AACG,SAAU,aAAa,CAAC,MAAgB,EAAA;AAC5C,IAAA,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAChC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperfrontend/list-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Purpose-built collection utilities for queue management, filtering, and iteration patterns.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -25,19 +25,6 @@
|
|
|
25
25
|
"functional",
|
|
26
26
|
"zero-dependencies"
|
|
27
27
|
],
|
|
28
|
-
"main": "./index.cjs.js",
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/AndrewRedican/hyperfrontend.git"
|
|
32
|
-
},
|
|
33
|
-
"bugs": {
|
|
34
|
-
"url": "https://github.com/AndrewRedican/hyperfrontend/issues"
|
|
35
|
-
},
|
|
36
|
-
"homepage": "https://github.com/AndrewRedican/hyperfrontend#readme",
|
|
37
|
-
"author": {
|
|
38
|
-
"name": "andrew.redican.mejia@gmail.com",
|
|
39
|
-
"url": "https://hyperfrontend.dev"
|
|
40
|
-
},
|
|
41
28
|
"exports": {
|
|
42
29
|
"./package.json": "./package.json",
|
|
43
30
|
".": {
|
|
@@ -50,6 +37,19 @@
|
|
|
50
37
|
"require": "./bundle/index.iife.min.js"
|
|
51
38
|
}
|
|
52
39
|
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/AndrewRedican/hyperfrontend.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/AndrewRedican/hyperfrontend/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/AndrewRedican/hyperfrontend#readme",
|
|
48
|
+
"author": {
|
|
49
|
+
"name": "andrew.redican.mejia@gmail.com",
|
|
50
|
+
"url": "https://hyperfrontend.dev"
|
|
51
|
+
},
|
|
52
|
+
"main": "./index.cjs.js",
|
|
53
53
|
"module": "./index.esm.js",
|
|
54
54
|
"types": "./index.d.ts",
|
|
55
55
|
"unpkg": "./bundle/index.umd.min.js",
|
package/unique-strings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unique-strings.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/unique-strings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unique-strings.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/unique-strings.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAExD"}
|