@hyperfrontend/list-utils 0.0.1 → 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 +9 -0
- package/README.md +4 -11
- 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-range.d.ts.map +1 -1
- package/create-value-picker.d.ts.map +1 -1
- package/get-last-key-in-map.d.ts.map +1 -1
- package/index.cjs.js +120 -15
- package/index.cjs.js.map +1 -1
- package/index.d.ts.map +1 -1
- package/index.esm.js +118 -13
- package/index.esm.js.map +1 -1
- package/non-empty-strings.d.ts.map +1 -1
- package/package.json +13 -16
- package/unique-strings.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,4 +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
|
+
|
|
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)
|
|
13
|
+
|
|
5
14
|
## 0.0.1 (2026-02-15)
|
package/README.md
CHANGED
|
@@ -26,9 +26,6 @@
|
|
|
26
26
|
<a href="https://github.com/AndrewRedican/hyperfrontend">
|
|
27
27
|
<img src="https://img.shields.io/github/stars/AndrewRedican/hyperfrontend?style=flat-square" alt="GitHub stars">
|
|
28
28
|
</a>
|
|
29
|
-
<a href="https://bundlephobia.com/package/@hyperfrontend/list-utils">
|
|
30
|
-
<img src="https://img.shields.io/bundlephobia/minzip/@hyperfrontend/list-utils?style=flat-square" alt="Bundle Size">
|
|
31
|
-
</a>
|
|
32
29
|
<img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen?style=flat-square&logo=node.js" alt="Node Version">
|
|
33
30
|
<img src="https://img.shields.io/badge/tree%20shakeable-%E2%9C%93-success?style=flat-square" alt="Tree Shakeable">
|
|
34
31
|
</p>
|
|
@@ -48,7 +45,7 @@ The library enforces immutability through frozen interfaces while maintaining hi
|
|
|
48
45
|
- **String sanitization** utilities (dedupe, trim, filter empty)
|
|
49
46
|
- **Range generation** for loop-free number sequences
|
|
50
47
|
- **Map utilities** for common Map operations
|
|
51
|
-
- **Zero dependencies**
|
|
48
|
+
- **Zero dependencies** - Self-contained implementation with no third-party runtime dependencies
|
|
52
49
|
|
|
53
50
|
### Architecture Highlights
|
|
54
51
|
|
|
@@ -158,15 +155,11 @@ const cleaned = uniqueStrings(nonEmptyStrings(userInputs)) // ['hello', 'world']
|
|
|
158
155
|
|
|
159
156
|
**Global variable:** `HyperfrontendListUtils`
|
|
160
157
|
|
|
161
|
-
### Dependencies
|
|
162
|
-
|
|
163
|
-
| Package | Type |
|
|
164
|
-
| ------------------------- | -------- |
|
|
165
|
-
| @hyperfrontend/data-utils | Internal |
|
|
166
|
-
|
|
167
158
|
## Part of hyperfrontend
|
|
168
159
|
|
|
169
|
-
This library is part of the [hyperfrontend](https://github.com/AndrewRedican/hyperfrontend) monorepo.
|
|
160
|
+
This library is part of the [hyperfrontend](https://github.com/AndrewRedican/hyperfrontend) monorepo.
|
|
161
|
+
|
|
162
|
+
**📖 [Full documentation](https://www.hyperfrontend.dev/docs/libraries/utils/list)**
|
|
170
163
|
|
|
171
164
|
- Used by [@hyperfrontend/network-protocol](https://github.com/AndrewRedican/hyperfrontend/tree/main/libs/network-protocol) for message queue management
|
|
172
165
|
|
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;;;;;;;IAO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AAC;QAC7B,OAAU,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACnC;;ICJA;;;;;IAKG;IACG,SAAU,eAAe,CAAC,MAAgB,EAAA;IAC9C,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;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,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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;;;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AAC,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;IAChG;;ICLA;;;;;IAKG;IACG,SAAU,aAAa,CAAC,MAAgB,EAAA;IAC5C,IAAA,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC;;;;;;;;;;;;;;"}
|
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,IA2BT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,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-fifo-list.d.ts","sourceRoot":"","sources":["
|
|
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":["
|
|
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"}
|
package/create-range.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-range.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"create-range.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/create-range.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAMhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-value-picker.d.ts","sourceRoot":"","sources":["
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-last-key-in-map.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"get-last-key-in-map.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/get-last-key-in-map.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,GAAI,CAAC,GAAG,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,KAAG,CAG3D,CAAA"}
|
package/index.cjs.js
CHANGED
|
@@ -1,6 +1,111 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
|
|
19
|
+
const registeredClasses = [];
|
|
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
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the data type of the target.
|
|
42
|
+
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
43
|
+
* Also, when classes are registered via `registerClass`, it checks if objects are instance of any known registered class.
|
|
44
|
+
*
|
|
45
|
+
* @param target - The target to get the data type of.
|
|
46
|
+
* @returns The data type of the target.
|
|
47
|
+
*/
|
|
48
|
+
const getType = (target) => {
|
|
49
|
+
if (target === null)
|
|
50
|
+
return 'null';
|
|
51
|
+
const nativeDataType = typeof target;
|
|
52
|
+
if (nativeDataType === 'object') {
|
|
53
|
+
if (isArray(target))
|
|
54
|
+
return 'array';
|
|
55
|
+
for (const registeredClass of registeredClasses) {
|
|
56
|
+
if (target instanceof registeredClass)
|
|
57
|
+
return registeredClass.name;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return nativeDataType;
|
|
61
|
+
};
|
|
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] : []);
|
|
4
109
|
|
|
5
110
|
/**
|
|
6
111
|
* Creates a FIFO (First-In-First-Out) list.
|
|
@@ -9,13 +114,13 @@ var dataUtils = require('@hyperfrontend/data-utils');
|
|
|
9
114
|
* @returns {FifoList<T>} A FIFO list with methods to manipulate and query the list.
|
|
10
115
|
*/
|
|
11
116
|
function createFifoList() {
|
|
12
|
-
const list =
|
|
117
|
+
const list = createSet();
|
|
13
118
|
const push = (item) => {
|
|
14
|
-
if (
|
|
15
|
-
throw
|
|
119
|
+
if (getType(item) !== 'object') {
|
|
120
|
+
throw createError('A fifo list only non-primitive values');
|
|
16
121
|
}
|
|
17
122
|
if (list.has(item)) {
|
|
18
|
-
throw
|
|
123
|
+
throw createError('Cannot a item that already exists');
|
|
19
124
|
}
|
|
20
125
|
list.add(item);
|
|
21
126
|
};
|
|
@@ -25,7 +130,7 @@ function createFifoList() {
|
|
|
25
130
|
return value;
|
|
26
131
|
};
|
|
27
132
|
const map = (callback) => {
|
|
28
|
-
return
|
|
133
|
+
return from(list.values()).map(callback);
|
|
29
134
|
};
|
|
30
135
|
const forEach = (callback) => {
|
|
31
136
|
list.forEach(callback);
|
|
@@ -44,7 +149,7 @@ function createFifoList() {
|
|
|
44
149
|
size,
|
|
45
150
|
clear,
|
|
46
151
|
};
|
|
47
|
-
return
|
|
152
|
+
return freeze(result);
|
|
48
153
|
}
|
|
49
154
|
|
|
50
155
|
/**
|
|
@@ -54,22 +159,22 @@ function createFifoList() {
|
|
|
54
159
|
* @returns {LifoList<T>} A LIFO list with methods to manipulate and query the list.
|
|
55
160
|
*/
|
|
56
161
|
function createLifoList() {
|
|
57
|
-
const list =
|
|
162
|
+
const list = createSet();
|
|
58
163
|
const push = (item) => {
|
|
59
|
-
if (
|
|
60
|
-
throw
|
|
164
|
+
if (getType(item) !== 'object') {
|
|
165
|
+
throw createError('A lifo list only supports non-primitive values');
|
|
61
166
|
}
|
|
62
167
|
list.add(item);
|
|
63
168
|
};
|
|
64
169
|
const pull = () => {
|
|
65
|
-
const lastItem =
|
|
170
|
+
const lastItem = from(list).pop();
|
|
66
171
|
if (lastItem) {
|
|
67
172
|
list.delete(lastItem);
|
|
68
173
|
}
|
|
69
174
|
return lastItem;
|
|
70
175
|
};
|
|
71
176
|
const map = (callback) => {
|
|
72
|
-
return
|
|
177
|
+
return from(list).map(callback);
|
|
73
178
|
};
|
|
74
179
|
const forEach = (callback) => {
|
|
75
180
|
list.forEach(callback);
|
|
@@ -90,7 +195,7 @@ function createLifoList() {
|
|
|
90
195
|
size,
|
|
91
196
|
clear,
|
|
92
197
|
};
|
|
93
|
-
return
|
|
198
|
+
return freeze(result);
|
|
94
199
|
}
|
|
95
200
|
|
|
96
201
|
/**
|
|
@@ -116,7 +221,7 @@ function createRange(start, end) {
|
|
|
116
221
|
*/
|
|
117
222
|
function createValuePicker(values) {
|
|
118
223
|
if (!values || !values.length) {
|
|
119
|
-
throw
|
|
224
|
+
throw createError('Expected values not to be an empty list.');
|
|
120
225
|
}
|
|
121
226
|
let index = -1;
|
|
122
227
|
/**
|
|
@@ -169,7 +274,7 @@ function nonEmptyStrings(values) {
|
|
|
169
274
|
* @returns A new array containing only unique strings
|
|
170
275
|
*/
|
|
171
276
|
function uniqueStrings(values) {
|
|
172
|
-
return
|
|
277
|
+
return from(createSet(values));
|
|
173
278
|
}
|
|
174
279
|
|
|
175
280
|
exports.createFifoList = createFifoList;
|
package/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["
|
|
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,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AC,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.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA"}
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,109 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
17
|
+
const registeredClasses = [];
|
|
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
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns the data type of the target.
|
|
40
|
+
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
41
|
+
* Also, when classes are registered via `registerClass`, it checks if objects are instance of any known registered class.
|
|
42
|
+
*
|
|
43
|
+
* @param target - The target to get the data type of.
|
|
44
|
+
* @returns The data type of the target.
|
|
45
|
+
*/
|
|
46
|
+
const getType = (target) => {
|
|
47
|
+
if (target === null)
|
|
48
|
+
return 'null';
|
|
49
|
+
const nativeDataType = typeof target;
|
|
50
|
+
if (nativeDataType === 'object') {
|
|
51
|
+
if (isArray(target))
|
|
52
|
+
return 'array';
|
|
53
|
+
for (const registeredClass of registeredClasses) {
|
|
54
|
+
if (target instanceof registeredClass)
|
|
55
|
+
return registeredClass.name;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return nativeDataType;
|
|
59
|
+
};
|
|
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] : []);
|
|
2
107
|
|
|
3
108
|
/**
|
|
4
109
|
* Creates a FIFO (First-In-First-Out) list.
|
|
@@ -7,13 +112,13 @@ import { getType } from '@hyperfrontend/data-utils';
|
|
|
7
112
|
* @returns {FifoList<T>} A FIFO list with methods to manipulate and query the list.
|
|
8
113
|
*/
|
|
9
114
|
function createFifoList() {
|
|
10
|
-
const list =
|
|
115
|
+
const list = createSet();
|
|
11
116
|
const push = (item) => {
|
|
12
117
|
if (getType(item) !== 'object') {
|
|
13
|
-
throw
|
|
118
|
+
throw createError('A fifo list only non-primitive values');
|
|
14
119
|
}
|
|
15
120
|
if (list.has(item)) {
|
|
16
|
-
throw
|
|
121
|
+
throw createError('Cannot a item that already exists');
|
|
17
122
|
}
|
|
18
123
|
list.add(item);
|
|
19
124
|
};
|
|
@@ -23,7 +128,7 @@ function createFifoList() {
|
|
|
23
128
|
return value;
|
|
24
129
|
};
|
|
25
130
|
const map = (callback) => {
|
|
26
|
-
return
|
|
131
|
+
return from(list.values()).map(callback);
|
|
27
132
|
};
|
|
28
133
|
const forEach = (callback) => {
|
|
29
134
|
list.forEach(callback);
|
|
@@ -42,7 +147,7 @@ function createFifoList() {
|
|
|
42
147
|
size,
|
|
43
148
|
clear,
|
|
44
149
|
};
|
|
45
|
-
return
|
|
150
|
+
return freeze(result);
|
|
46
151
|
}
|
|
47
152
|
|
|
48
153
|
/**
|
|
@@ -52,22 +157,22 @@ function createFifoList() {
|
|
|
52
157
|
* @returns {LifoList<T>} A LIFO list with methods to manipulate and query the list.
|
|
53
158
|
*/
|
|
54
159
|
function createLifoList() {
|
|
55
|
-
const list =
|
|
160
|
+
const list = createSet();
|
|
56
161
|
const push = (item) => {
|
|
57
162
|
if (getType(item) !== 'object') {
|
|
58
|
-
throw
|
|
163
|
+
throw createError('A lifo list only supports non-primitive values');
|
|
59
164
|
}
|
|
60
165
|
list.add(item);
|
|
61
166
|
};
|
|
62
167
|
const pull = () => {
|
|
63
|
-
const lastItem =
|
|
168
|
+
const lastItem = from(list).pop();
|
|
64
169
|
if (lastItem) {
|
|
65
170
|
list.delete(lastItem);
|
|
66
171
|
}
|
|
67
172
|
return lastItem;
|
|
68
173
|
};
|
|
69
174
|
const map = (callback) => {
|
|
70
|
-
return
|
|
175
|
+
return from(list).map(callback);
|
|
71
176
|
};
|
|
72
177
|
const forEach = (callback) => {
|
|
73
178
|
list.forEach(callback);
|
|
@@ -88,7 +193,7 @@ function createLifoList() {
|
|
|
88
193
|
size,
|
|
89
194
|
clear,
|
|
90
195
|
};
|
|
91
|
-
return
|
|
196
|
+
return freeze(result);
|
|
92
197
|
}
|
|
93
198
|
|
|
94
199
|
/**
|
|
@@ -114,7 +219,7 @@ function createRange(start, end) {
|
|
|
114
219
|
*/
|
|
115
220
|
function createValuePicker(values) {
|
|
116
221
|
if (!values || !values.length) {
|
|
117
|
-
throw
|
|
222
|
+
throw createError('Expected values not to be an empty list.');
|
|
118
223
|
}
|
|
119
224
|
let index = -1;
|
|
120
225
|
/**
|
|
@@ -167,7 +272,7 @@ function nonEmptyStrings(values) {
|
|
|
167
272
|
* @returns A new array containing only unique strings
|
|
168
273
|
*/
|
|
169
274
|
function uniqueStrings(values) {
|
|
170
|
-
return
|
|
275
|
+
return from(createSet(values));
|
|
171
276
|
}
|
|
172
277
|
|
|
173
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":["
|
|
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;gBAAE,OAAU,eAAe,CAAC,IAAI;QACvE;IACF;AACA,IAAA,OAAU,cAAc;AAC1B,CAAC;;ACtBD;;;;;;;;;;AAUG;AAEH;AACA,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK;AAQ/B,MAAMA,UAAQ,GAAG,UAAU,CAAC,OAAO;AAGnC;;;;;;;AAOG;AACI,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAE,OAAsB,KAAmBA,UAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;;AChCrI;;;;;;;;;;AAUG;AAEH;AACA,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG;AAC3B,MAAM,QAAQ,GAAG,UAAU,CA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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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-empty-strings.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"non-empty-strings.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/list/src/non-empty-strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE1D"}
|
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,9 +25,17 @@
|
|
|
25
25
|
"functional",
|
|
26
26
|
"zero-dependencies"
|
|
27
27
|
],
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"import": "./index.esm.js",
|
|
33
|
+
"require": "./index.cjs.js"
|
|
34
|
+
},
|
|
35
|
+
"./bundle": {
|
|
36
|
+
"import": "./bundle/index.iife.min.js",
|
|
37
|
+
"require": "./bundle/index.iife.min.js"
|
|
38
|
+
}
|
|
31
39
|
},
|
|
32
40
|
"repository": {
|
|
33
41
|
"type": "git",
|
|
@@ -41,18 +49,7 @@
|
|
|
41
49
|
"name": "andrew.redican.mejia@gmail.com",
|
|
42
50
|
"url": "https://hyperfrontend.dev"
|
|
43
51
|
},
|
|
44
|
-
"
|
|
45
|
-
"./package.json": "./package.json",
|
|
46
|
-
".": {
|
|
47
|
-
"types": "./index.d.ts",
|
|
48
|
-
"import": "./index.esm.js",
|
|
49
|
-
"require": "./index.cjs.js"
|
|
50
|
-
},
|
|
51
|
-
"./bundle": {
|
|
52
|
-
"import": "./bundle/index.iife.min.js",
|
|
53
|
-
"require": "./bundle/index.iife.min.js"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
52
|
+
"main": "./index.cjs.js",
|
|
56
53
|
"module": "./index.esm.js",
|
|
57
54
|
"types": "./index.d.ts",
|
|
58
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":["
|
|
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"}
|