@telperion/js-utils 3.5.1 → 3.7.0
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/README.md +32 -1
- package/array/gather.cjs +60 -0
- package/array/gather.d.ts +48 -0
- package/array/gather.js +59 -0
- package/array/gather.js.map +1 -0
- package/array/index.cjs +1 -0
- package/array/index.d.ts +1 -0
- package/array/index.js +1 -0
- package/array/index.js.map +1 -1
- package/array/proto/gather.cjs +6 -0
- package/array/proto/gather.d.ts +32 -0
- package/array/proto/gather.js +6 -0
- package/array/proto/gather.js.map +1 -0
- package/array/proto/remove.d.ts +1 -1
- package/array/proto/remove.js.map +1 -1
- package/array/proto/replace.js.map +1 -1
- package/function/proto/debounce.js.map +1 -1
- package/index.cjs +3 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/object/deepest.d.ts +1 -1
- package/object/deepest.js.map +1 -1
- package/object/index.cjs +1 -0
- package/object/index.d.ts +1 -0
- package/object/index.js +1 -0
- package/object/index.js.map +1 -1
- package/object/map.cjs +41 -0
- package/object/map.d.ts +32 -0
- package/object/map.js +40 -0
- package/object/map.js.map +1 -0
- package/object/static/map.cjs +4 -0
- package/object/static/map.d.ts +26 -0
- package/object/static/map.js +4 -0
- package/object/static/map.js.map +1 -0
- package/open-promise.d.ts +1 -1
- package/open-promise.js.map +1 -1
- package/package.json +32 -3
- package/string/proto/limit.d.ts +1 -1
- package/string/proto/limit.js.map +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Javascript utility functions for web development
|
|
3
3
|
|
|
4
4
|
[](https://www.npmjs.com/package/@telperion/js-utils)
|
|
5
|
-
[](https://www.npmjs.com/package/@telperion/js-utils)
|
|
6
|
+
[](https://app.codecov.io/gh/telperiontech/telperion/tree/main?flags%5B0%5D=js-utils)
|
|
6
7
|
[](https://github.com/ellerbrock/typescript-badges/)
|
|
7
8
|
[](https://github.com/telperiontech/telperion/blob/main/LICENSE)
|
|
8
9
|
|
|
@@ -81,6 +82,25 @@ const array = [{a: 1}, {a: 2}, {a: 3}];
|
|
|
81
82
|
findByKey(array, "a", 2); // {a: 2}
|
|
82
83
|
```
|
|
83
84
|
|
|
85
|
+
#### [Gather](https://open-source.telperion.tr/js-utils/modules/_array_gather_.html)
|
|
86
|
+
Groups array items by a specified key into a Map
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { gather } from "@telperion/js-utils/array";
|
|
90
|
+
|
|
91
|
+
const users = [
|
|
92
|
+
{ role: "admin", name: "Alice" },
|
|
93
|
+
{ role: "user", name: "Bob" },
|
|
94
|
+
{ role: "admin", name: "Charlie" },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const grouped = gather(users, "role");
|
|
98
|
+
// Map {
|
|
99
|
+
// "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
100
|
+
// "user" => [{ role: "user", name: "Bob" }]
|
|
101
|
+
// }
|
|
102
|
+
```
|
|
103
|
+
|
|
84
104
|
#### [Intersection](https://open-source.telperion.tr/js-utils/modules/_array_intersection_.html)
|
|
85
105
|
Gets the intersection of the two arrays or sets
|
|
86
106
|
|
|
@@ -293,6 +313,17 @@ const a = {
|
|
|
293
313
|
compact(a); // {z: 20}
|
|
294
314
|
```
|
|
295
315
|
|
|
316
|
+
#### [Map](https://open-source.telperion.tr/js-utils/modules/_object_map_.html)
|
|
317
|
+
Maps the values of an object using a callback function
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
import { map } from "@telperion/js-utils/object";
|
|
321
|
+
|
|
322
|
+
const obj = { a: 1, b: 2, c: 3 };
|
|
323
|
+
|
|
324
|
+
map(obj, value => value * 2); // { a: 2, b: 4, c: 6 }
|
|
325
|
+
```
|
|
326
|
+
|
|
296
327
|
#### [Deepest](https://open-source.telperion.tr/js-utils/modules/_object_deepest_.html)
|
|
297
328
|
Get deepest value in an object chain
|
|
298
329
|
|
package/array/gather.cjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gather = gather;
|
|
4
|
+
/**
|
|
5
|
+
* #### Groups array items by a specified key into a Map
|
|
6
|
+
*
|
|
7
|
+
* Iterates over the array and groups items that share the same value for the given key.
|
|
8
|
+
* Returns a `Map` where each key is a unique value of the specified property and each value is an array of matching items.
|
|
9
|
+
*
|
|
10
|
+
* * * *
|
|
11
|
+
* Example usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { gather } from "@telperion/js-utils/array";
|
|
14
|
+
*
|
|
15
|
+
* const users = [
|
|
16
|
+
* { role: "admin", name: "Alice" },
|
|
17
|
+
* { role: "user", name: "Bob" },
|
|
18
|
+
* { role: "admin", name: "Charlie" },
|
|
19
|
+
* ];
|
|
20
|
+
*
|
|
21
|
+
* const grouped = gather(users, "role");
|
|
22
|
+
* // Map {
|
|
23
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
24
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
25
|
+
* // }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Example as Array Prototype:
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import "@telperion/js-utils/array/proto/gather";
|
|
31
|
+
*
|
|
32
|
+
* const users = [
|
|
33
|
+
* { role: "admin", name: "Alice" },
|
|
34
|
+
* { role: "user", name: "Bob" },
|
|
35
|
+
* { role: "admin", name: "Charlie" },
|
|
36
|
+
* ];
|
|
37
|
+
*
|
|
38
|
+
* const grouped = users.gather("role");
|
|
39
|
+
* // Map {
|
|
40
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
41
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
42
|
+
* // }
|
|
43
|
+
* ```
|
|
44
|
+
* * * *
|
|
45
|
+
* @param array Array of objects to group
|
|
46
|
+
* @param key Key to group items by
|
|
47
|
+
* @typeparam T Type of array items
|
|
48
|
+
* @typeparam P Key type
|
|
49
|
+
* @returns A Map grouping items by the specified key's value
|
|
50
|
+
*/
|
|
51
|
+
function gather(array, key) {
|
|
52
|
+
return array.reduce((acc, item) => {
|
|
53
|
+
const groupKey = item[key];
|
|
54
|
+
if (!acc.has(groupKey)) {
|
|
55
|
+
acc.set(groupKey, []);
|
|
56
|
+
}
|
|
57
|
+
acc.get(groupKey).push(item);
|
|
58
|
+
return acc;
|
|
59
|
+
}, new Map());
|
|
60
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Groups array items by a specified key into a Map
|
|
3
|
+
*
|
|
4
|
+
* Iterates over the array and groups items that share the same value for the given key.
|
|
5
|
+
* Returns a `Map` where each key is a unique value of the specified property and each value is an array of matching items.
|
|
6
|
+
*
|
|
7
|
+
* * * *
|
|
8
|
+
* Example usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { gather } from "@telperion/js-utils/array";
|
|
11
|
+
*
|
|
12
|
+
* const users = [
|
|
13
|
+
* { role: "admin", name: "Alice" },
|
|
14
|
+
* { role: "user", name: "Bob" },
|
|
15
|
+
* { role: "admin", name: "Charlie" },
|
|
16
|
+
* ];
|
|
17
|
+
*
|
|
18
|
+
* const grouped = gather(users, "role");
|
|
19
|
+
* // Map {
|
|
20
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
21
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
22
|
+
* // }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Example as Array Prototype:
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import "@telperion/js-utils/array/proto/gather";
|
|
28
|
+
*
|
|
29
|
+
* const users = [
|
|
30
|
+
* { role: "admin", name: "Alice" },
|
|
31
|
+
* { role: "user", name: "Bob" },
|
|
32
|
+
* { role: "admin", name: "Charlie" },
|
|
33
|
+
* ];
|
|
34
|
+
*
|
|
35
|
+
* const grouped = users.gather("role");
|
|
36
|
+
* // Map {
|
|
37
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
38
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
39
|
+
* // }
|
|
40
|
+
* ```
|
|
41
|
+
* * * *
|
|
42
|
+
* @param array Array of objects to group
|
|
43
|
+
* @param key Key to group items by
|
|
44
|
+
* @typeparam T Type of array items
|
|
45
|
+
* @typeparam P Key type
|
|
46
|
+
* @returns A Map grouping items by the specified key's value
|
|
47
|
+
*/
|
|
48
|
+
export declare function gather<T extends Record<any, any>, P extends keyof T>(array: T[], key: P): Map<T[P], T[]>;
|
package/array/gather.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Groups array items by a specified key into a Map
|
|
3
|
+
*
|
|
4
|
+
* Iterates over the array and groups items that share the same value for the given key.
|
|
5
|
+
* Returns a `Map` where each key is a unique value of the specified property and each value is an array of matching items.
|
|
6
|
+
*
|
|
7
|
+
* * * *
|
|
8
|
+
* Example usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { gather } from "@telperion/js-utils/array";
|
|
11
|
+
*
|
|
12
|
+
* const users = [
|
|
13
|
+
* { role: "admin", name: "Alice" },
|
|
14
|
+
* { role: "user", name: "Bob" },
|
|
15
|
+
* { role: "admin", name: "Charlie" },
|
|
16
|
+
* ];
|
|
17
|
+
*
|
|
18
|
+
* const grouped = gather(users, "role");
|
|
19
|
+
* // Map {
|
|
20
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
21
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
22
|
+
* // }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Example as Array Prototype:
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import "@telperion/js-utils/array/proto/gather";
|
|
28
|
+
*
|
|
29
|
+
* const users = [
|
|
30
|
+
* { role: "admin", name: "Alice" },
|
|
31
|
+
* { role: "user", name: "Bob" },
|
|
32
|
+
* { role: "admin", name: "Charlie" },
|
|
33
|
+
* ];
|
|
34
|
+
*
|
|
35
|
+
* const grouped = users.gather("role");
|
|
36
|
+
* // Map {
|
|
37
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
38
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
39
|
+
* // }
|
|
40
|
+
* ```
|
|
41
|
+
* * * *
|
|
42
|
+
* @param array Array of objects to group
|
|
43
|
+
* @param key Key to group items by
|
|
44
|
+
* @typeparam T Type of array items
|
|
45
|
+
* @typeparam P Key type
|
|
46
|
+
* @returns A Map grouping items by the specified key's value
|
|
47
|
+
*/
|
|
48
|
+
export function gather(array, key) {
|
|
49
|
+
return array.reduce((acc, item) => {
|
|
50
|
+
const groupKey = item[key];
|
|
51
|
+
if (!acc.has(groupKey)) {
|
|
52
|
+
acc.set(groupKey, []);
|
|
53
|
+
}
|
|
54
|
+
acc.get(groupKey).push(item);
|
|
55
|
+
return acc;
|
|
56
|
+
}, new Map());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=gather.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/array/gather.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,UAAU,MAAM,CAAgD,KAAU,EAAE,GAAM;IACtF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QAE3B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvB,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACxB,CAAC;QAED,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9B,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,IAAI,GAAG,EAAa,CAAC,CAAC;AAC3B,CAAC","file":"gather.js","sourcesContent":["/**\r\n * #### Groups array items by a specified key into a Map\r\n *\r\n * Iterates over the array and groups items that share the same value for the given key.\r\n * Returns a `Map` where each key is a unique value of the specified property and each value is an array of matching items.\r\n *\r\n * * * *\r\n * Example usage:\r\n * ```typescript\r\n * import { gather } from \"@telperion/js-utils/array\";\r\n *\r\n * const users = [\r\n * { role: \"admin\", name: \"Alice\" },\r\n * { role: \"user\", name: \"Bob\" },\r\n * { role: \"admin\", name: \"Charlie\" },\r\n * ];\r\n *\r\n * const grouped = gather(users, \"role\");\r\n * // Map {\r\n * // \"admin\" => [{ role: \"admin\", name: \"Alice\" }, { role: \"admin\", name: \"Charlie\" }],\r\n * // \"user\" => [{ role: \"user\", name: \"Bob\" }]\r\n * // }\r\n * ```\r\n *\r\n * Example as Array Prototype:\r\n * ```typescript\r\n * import \"@telperion/js-utils/array/proto/gather\";\r\n *\r\n * const users = [\r\n * { role: \"admin\", name: \"Alice\" },\r\n * { role: \"user\", name: \"Bob\" },\r\n * { role: \"admin\", name: \"Charlie\" },\r\n * ];\r\n *\r\n * const grouped = users.gather(\"role\");\r\n * // Map {\r\n * // \"admin\" => [{ role: \"admin\", name: \"Alice\" }, { role: \"admin\", name: \"Charlie\" }],\r\n * // \"user\" => [{ role: \"user\", name: \"Bob\" }]\r\n * // }\r\n * ```\r\n * * * *\r\n * @param array Array of objects to group\r\n * @param key Key to group items by\r\n * @typeparam T Type of array items\r\n * @typeparam P Key type\r\n * @returns A Map grouping items by the specified key's value\r\n */\r\nexport function gather<T extends Record<any, any>, P extends keyof T>(array: T[], key: P) {\r\n return array.reduce((acc, item) => {\r\n const groupKey = item[key];\r\n\r\n if (!acc.has(groupKey)) {\r\n acc.set(groupKey, []);\r\n }\r\n\r\n acc.get(groupKey)!.push(item);\r\n\r\n return acc;\r\n }, new Map<T[P], T[]>());\r\n}\r\n"]}
|
package/array/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ tslib_1.__exportStar(require("@telperion/js-utils/array/async-map"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("@telperion/js-utils/array/compact"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("@telperion/js-utils/array/difference"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("@telperion/js-utils/array/find-by-key"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("@telperion/js-utils/array/gather"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("@telperion/js-utils/array/intersection"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("@telperion/js-utils/array/limit"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("@telperion/js-utils/array/remove"), exports);
|
package/array/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from '@telperion/js-utils/array/async-map';
|
|
|
3
3
|
export * from '@telperion/js-utils/array/compact';
|
|
4
4
|
export * from '@telperion/js-utils/array/difference';
|
|
5
5
|
export * from '@telperion/js-utils/array/find-by-key';
|
|
6
|
+
export * from '@telperion/js-utils/array/gather';
|
|
6
7
|
export * from '@telperion/js-utils/array/intersection';
|
|
7
8
|
export * from '@telperion/js-utils/array/limit';
|
|
8
9
|
export * from '@telperion/js-utils/array/remove';
|
package/array/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from '@telperion/js-utils/array/async-map';
|
|
|
3
3
|
export * from '@telperion/js-utils/array/compact';
|
|
4
4
|
export * from '@telperion/js-utils/array/difference';
|
|
5
5
|
export * from '@telperion/js-utils/array/find-by-key';
|
|
6
|
+
export * from '@telperion/js-utils/array/gather';
|
|
6
7
|
export * from '@telperion/js-utils/array/intersection';
|
|
7
8
|
export * from '@telperion/js-utils/array/limit';
|
|
8
9
|
export * from '@telperion/js-utils/array/remove';
|
package/array/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wCAAwC,CAAC;AACvD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,2CAA2C,CAAC","file":"index.js","sourcesContent":["export * from '@telperion/js-utils/array/arrayize';\nexport * from '@telperion/js-utils/array/async-map';\nexport * from '@telperion/js-utils/array/compact';\nexport * from '@telperion/js-utils/array/difference';\nexport * from '@telperion/js-utils/array/find-by-key';\nexport * from '@telperion/js-utils/array/intersection';\nexport * from '@telperion/js-utils/array/limit';\nexport * from '@telperion/js-utils/array/remove';\nexport * from '@telperion/js-utils/array/replace';\nexport * from '@telperion/js-utils/array/uniquify';\nexport * from '@telperion/js-utils/array/uniquify-by-key';\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,2CAA2C,CAAC","file":"index.js","sourcesContent":["export * from '@telperion/js-utils/array/arrayize';\nexport * from '@telperion/js-utils/array/async-map';\nexport * from '@telperion/js-utils/array/compact';\nexport * from '@telperion/js-utils/array/difference';\nexport * from '@telperion/js-utils/array/find-by-key';\nexport * from '@telperion/js-utils/array/gather';\nexport * from '@telperion/js-utils/array/intersection';\nexport * from '@telperion/js-utils/array/limit';\nexport * from '@telperion/js-utils/array/remove';\nexport * from '@telperion/js-utils/array/replace';\nexport * from '@telperion/js-utils/array/uniquify';\nexport * from '@telperion/js-utils/array/uniquify-by-key';\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
export interface Array<T> {
|
|
3
|
+
/**
|
|
4
|
+
* #### Gather
|
|
5
|
+
*
|
|
6
|
+
* Groups array items by a specified key into a Map
|
|
7
|
+
*
|
|
8
|
+
* * * *
|
|
9
|
+
* Example:
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import "@telperion/js-utils/array/proto/gather";
|
|
12
|
+
*
|
|
13
|
+
* const users = [
|
|
14
|
+
* { role: "admin", name: "Alice" },
|
|
15
|
+
* { role: "user", name: "Bob" },
|
|
16
|
+
* { role: "admin", name: "Charlie" },
|
|
17
|
+
* ];
|
|
18
|
+
*
|
|
19
|
+
* const grouped = users.gather("role");
|
|
20
|
+
* // Map {
|
|
21
|
+
* // "admin" => [{ role: "admin", name: "Alice" }, { role: "admin", name: "Charlie" }],
|
|
22
|
+
* // "user" => [{ role: "user", name: "Bob" }]
|
|
23
|
+
* // }
|
|
24
|
+
* ```
|
|
25
|
+
* * * *
|
|
26
|
+
* @param key Key to group items by
|
|
27
|
+
* @return A Map grouping items by the specified key's value
|
|
28
|
+
*/
|
|
29
|
+
gather<P extends keyof T>(key: P): Map<T[P], T[]>;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/array/proto/gather.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAkC1D,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,UAAmE,GAAM;IAChG,OAAO,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC","file":"gather.js","sourcesContent":["import { gather } from '@telperion/js-utils/array/gather';\r\n\r\ndeclare global {\r\n export interface Array<T> {\r\n /**\r\n * #### Gather\r\n *\r\n * Groups array items by a specified key into a Map\r\n *\r\n * * * *\r\n * Example:\r\n * ```typescript\r\n * import \"@telperion/js-utils/array/proto/gather\";\r\n *\r\n * const users = [\r\n * { role: \"admin\", name: \"Alice\" },\r\n * { role: \"user\", name: \"Bob\" },\r\n * { role: \"admin\", name: \"Charlie\" },\r\n * ];\r\n *\r\n * const grouped = users.gather(\"role\");\r\n * // Map {\r\n * // \"admin\" => [{ role: \"admin\", name: \"Alice\" }, { role: \"admin\", name: \"Charlie\" }],\r\n * // \"user\" => [{ role: \"user\", name: \"Bob\" }]\r\n * // }\r\n * ```\r\n * * * *\r\n * @param key Key to group items by\r\n * @return A Map grouping items by the specified key's value\r\n */\r\n gather<P extends keyof T>(key: P): Map<T[P], T[]>;\r\n }\r\n}\r\n\r\nArray.prototype.gather = function<T extends Record<any, any>, P extends keyof T>(this: T[], key: P): Map<T[P], T[]> {\r\n return gather(this, key);\r\n};\r\n"]}
|
package/array/proto/remove.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/array/proto/remove.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAiC1D,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,UAAuB,GAAG,IAAkB;IACnE,OAAO,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC","file":"remove.js","sourcesContent":["import type { Tail } from '@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/array/proto/remove.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAiC1D,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,UAAuB,GAAG,IAAkB;IACnE,OAAO,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC","file":"remove.js","sourcesContent":["import type { Tail } from '@telperion/extra-ts-types';\n\nimport { remove } from '@telperion/js-utils/array/remove';\n\ntype FuncType<T> = typeof remove<T>;\ntype FuncArgs<T> = Parameters<FuncType<T>>;\ntype FuncReturn<T> = ReturnType<FuncType<T>>;\ntype ProtoArgs<T> = Tail<FuncArgs<T>>;\n\ndeclare global {\n export interface Array<T> {\n /**\n * #### Remove\n *\n * Removes an item from the array\n *\n * Removes all item references if multi is set to `true`\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/array/proto/remove\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * array.remove(\"b\", true); // [\"a\", \"c\", \"a\", \"c\"]\n * ```\n * * * *\n * @param itemToRemove Item to remove\n * @return New array\n */\n remove(...args: ProtoArgs<T>): FuncReturn<T>;\n }\n}\n\nArray.prototype.remove = function<T>(this: T[], ...args: ProtoArgs<T>): FuncReturn<T> {\n return remove(this, ...args);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/array/proto/replace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAA4C,MAAM,mCAAmC,CAAC;AA4EtG,KAAK,CAAC,SAAS,CAAC,OAAO,GAA0B,UAAuB,GAAG,IAAyC;IAClH,OAAO,OAAO,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC","file":"replace.js","sourcesContent":["import type { Tail } from '@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/array/proto/replace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAA4C,MAAM,mCAAmC,CAAC;AA4EtG,KAAK,CAAC,SAAS,CAAC,OAAO,GAA0B,UAAuB,GAAG,IAAyC;IAClH,OAAO,OAAO,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC","file":"replace.js","sourcesContent":["import type { Tail } from '@telperion/extra-ts-types';\n\nimport { replace, ReplaceItemsOptions, ReplaceByMapOptions } from '@telperion/js-utils/array/replace';\n\ndeclare global {\n export interface Array<T> {\n /**\n * #### Replace\n *\n * Replaces an item with passed one of an array\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/array/proto/replace\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * array.replace(\"b\", \"x\"); // [\"a\", \"x\", \"c\", \"a\", \"b\", \"c\"]\n * ```\n * * * *\n * @param array Array to replace its item\n * @param itemToRemove Item to remove\n * @param itemToReplace Item to replace with\n * @return New replaced array\n */\n replace(itemToRemove: T, itemToReplace: T): T[];\n\n /**\n * #### Replace\n *\n * Deletes items and replaces new ones from passed starting index of an array\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/array/proto/replace\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n *\n * array.replace({startingIndex: 3, deleteCount: 1, itemsToReplace: ['x', 'y']}); // [\"a\", \"b\", \"c\", \"x\", \"y\", \"b\", \"c\"];\n * ```\n * * * *\n * @param array Array to replace its item\n * @param replaceOptions Replace options\n * @template T Typeof array items\n * @return New replaced array\n */\n replace(replaceOptions: ReplaceItemsOptions<T>): T[];\n\n /**\n * #### Replace\n *\n * Deletes items and replaces new ones by passed matcher map\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/array/proto/replace\";\n *\n * const array = [\"a\", \"b\", \"c\", \"a\", \"b\", \"c\"];\n * const map = new Map();\n * map.set(\"a\", \"x\")\n * map.set(\"b\", \"y\");\n *\n * array.replace({itemsToReplace: map}); // [\"x\", \"y\", \"c\", \"a\", \"b\", \"c\"];\n * array.replace({itemsToReplace: map, multi: true}); // [\"x\", \"y\", \"c\", \"x\", \"y\", \"c\"];\n * ```\n * * * *\n * @param array Array to replace its item\n * @param replaceOptions Replace options\n * @template T Typeof array items\n * @return New replaced array\n */\n replace(replaceOptions: ReplaceByMapOptions<T>): T[];\n }\n}\n\nArray.prototype.replace = <Array<any>['replace']>function<T>(this: T[], ...args: Tail<Parameters<typeof replace<T>>>): T[] {\n return replace(this, ...args);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/function/proto/debounce.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAgCxF,QAAQ,CAAC,SAAS,CAAC,QAAQ,GAAG,UAA4B,IAAI,GAAG,qBAAqB,EAAE,aAAkB,IAAI,EAAE,GAAG,IAAW;IAC5H,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;AACnD,CAAC,CAAC","file":"debounce.js","sourcesContent":["import type { AnyFunction } from '@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/function/proto/debounce.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAgCxF,QAAQ,CAAC,SAAS,CAAC,QAAQ,GAAG,UAA4B,IAAI,GAAG,qBAAqB,EAAE,aAAkB,IAAI,EAAE,GAAG,IAAW;IAC5H,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;AACnD,CAAC,CAAC","file":"debounce.js","sourcesContent":["import type { AnyFunction } from '@telperion/extra-ts-types';\n\nimport { debounce, DEFAULT_DEBOUNCE_TIME } from '@telperion/js-utils/function/debounce';\n\ndeclare global {\n export interface Function {\n /**\n * #### Debounces a function that delays invoking until after given time have elapsed since the last time the debounced function was invoked\n *\n * * * *\n * Example usage:\n * ```typescript\n * import \"@telperion/js-utils/function/proto/debounce\";\n *\n * function foo() {\n * console.log(\"hello\");\n * }\n *\n * for (let i = 0; i < 5; i++) {\n * foo.debounce();\n * }\n *\n * // logs \"hello\" only once\n * ```\n * * * *\n * @param [time = 180] Time for debouncing\n * @param [thisObject = null] This object to execute the callback function with\n * @param args Function arguments\n * @return A promise which resolves right after the debouncing sequence has been finished\n */\n debounce(time?: number, thisObject?: any, ...args: any[]): Promise<any>;\n }\n}\n\nFunction.prototype.debounce = function(this: AnyFunction, time = DEFAULT_DEBOUNCE_TIME, thisObject: any = null, ...args: any[]): Promise<any> {\n return debounce(this, time, thisObject, ...args);\n};\n"]}
|
package/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deepFreeze = exports.deepest = exports.clone = exports.uniquifyByKey = exports.uniquify = exports.replace = exports.remove = exports.intersection = exports.findByKey = exports.difference = exports.asyncMap = exports.arrayize = void 0;
|
|
3
|
+
exports.map = exports.deepFreeze = exports.deepest = exports.clone = exports.uniquifyByKey = exports.uniquify = exports.replace = exports.remove = exports.intersection = exports.gather = exports.findByKey = exports.difference = exports.asyncMap = exports.arrayize = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var array_1 = require("@telperion/js-utils/array");
|
|
6
6
|
Object.defineProperty(exports, "arrayize", { enumerable: true, get: function () { return array_1.arrayize; } });
|
|
7
7
|
Object.defineProperty(exports, "asyncMap", { enumerable: true, get: function () { return array_1.asyncMap; } });
|
|
8
8
|
Object.defineProperty(exports, "difference", { enumerable: true, get: function () { return array_1.difference; } });
|
|
9
9
|
Object.defineProperty(exports, "findByKey", { enumerable: true, get: function () { return array_1.findByKey; } });
|
|
10
|
+
Object.defineProperty(exports, "gather", { enumerable: true, get: function () { return array_1.gather; } });
|
|
10
11
|
Object.defineProperty(exports, "intersection", { enumerable: true, get: function () { return array_1.intersection; } });
|
|
11
12
|
Object.defineProperty(exports, "remove", { enumerable: true, get: function () { return array_1.remove; } });
|
|
12
13
|
Object.defineProperty(exports, "replace", { enumerable: true, get: function () { return array_1.replace; } });
|
|
@@ -20,6 +21,7 @@ var object_1 = require("@telperion/js-utils/object");
|
|
|
20
21
|
Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return object_1.clone; } });
|
|
21
22
|
Object.defineProperty(exports, "deepest", { enumerable: true, get: function () { return object_1.deepest; } });
|
|
22
23
|
Object.defineProperty(exports, "deepFreeze", { enumerable: true, get: function () { return object_1.deepFreeze; } });
|
|
24
|
+
Object.defineProperty(exports, "map", { enumerable: true, get: function () { return object_1.map; } });
|
|
23
25
|
tslib_1.__exportStar(require("@telperion/js-utils/promise"), exports);
|
|
24
26
|
tslib_1.__exportStar(require("@telperion/js-utils/time"), exports);
|
|
25
27
|
// export { } from '@telperion/js-utils/string';
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { ReplaceByMapOptions, ReplaceItemsOptions, Inclusion, Substraction, arrayize, asyncMap, difference, findByKey, intersection, remove, replace, uniquify, uniquifyByKey } from '@telperion/js-utils/array';
|
|
1
|
+
export { ReplaceByMapOptions, ReplaceItemsOptions, Inclusion, Substraction, arrayize, asyncMap, difference, findByKey, gather, intersection, remove, replace, uniquify, uniquifyByKey } from '@telperion/js-utils/array';
|
|
2
2
|
export * from '@telperion/js-utils/class';
|
|
3
3
|
export * from '@telperion/js-utils/function';
|
|
4
4
|
export * from '@telperion/js-utils/map';
|
|
5
5
|
export * from '@telperion/js-utils/math';
|
|
6
|
-
export { clone, deepest, deepFreeze } from '@telperion/js-utils/object';
|
|
6
|
+
export { clone, deepest, deepFreeze, map } from '@telperion/js-utils/object';
|
|
7
7
|
export * from '@telperion/js-utils/promise';
|
|
8
8
|
export * from '@telperion/js-utils/time';
|
|
9
9
|
export * from '@telperion/js-utils/compact';
|
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { arrayize, asyncMap, difference, findByKey, intersection, remove, replace, uniquify, uniquifyByKey } from '@telperion/js-utils/array';
|
|
1
|
+
export { arrayize, asyncMap, difference, findByKey, gather, intersection, remove, replace, uniquify, uniquifyByKey } from '@telperion/js-utils/array';
|
|
2
2
|
export * from '@telperion/js-utils/class';
|
|
3
3
|
export * from '@telperion/js-utils/function';
|
|
4
4
|
export * from '@telperion/js-utils/map';
|
|
5
5
|
export * from '@telperion/js-utils/math';
|
|
6
|
-
export { clone, deepest, deepFreeze } from '@telperion/js-utils/object';
|
|
6
|
+
export { clone, deepest, deepFreeze, map } from '@telperion/js-utils/object';
|
|
7
7
|
export * from '@telperion/js-utils/promise';
|
|
8
8
|
export * from '@telperion/js-utils/time';
|
|
9
9
|
// export { } from '@telperion/js-utils/string';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,MAAM,EACN,YAAY,EACZ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAC7E,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,iDAAiD;AAEjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC","file":"index.js","sourcesContent":["export {\n ReplaceByMapOptions,\n ReplaceItemsOptions,\n Inclusion,\n Substraction,\n arrayize,\n asyncMap,\n difference,\n findByKey,\n gather,\n intersection,\n remove,\n replace,\n uniquify,\n uniquifyByKey\n} from '@telperion/js-utils/array';\nexport * from '@telperion/js-utils/class';\nexport * from '@telperion/js-utils/function';\nexport * from '@telperion/js-utils/map';\nexport * from '@telperion/js-utils/math';\nexport { clone, deepest, deepFreeze, map } from '@telperion/js-utils/object';\nexport * from '@telperion/js-utils/promise';\nexport * from '@telperion/js-utils/time';\n// export { } from '@telperion/js-utils/string';\n\nexport * from '@telperion/js-utils/compact';\nexport * from '@telperion/js-utils/is-falsy';\nexport * from '@telperion/js-utils/is-truthy';\nexport * from '@telperion/js-utils/open-promise';\nexport * from '@telperion/js-utils/smart-map';\nexport * from '@telperion/js-utils/unique-id';\nexport * from '@telperion/js-utils/limit';\n"]}
|
package/object/deepest.d.ts
CHANGED
package/object/deepest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/object/deepest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,UAAU,OAAO,CAAuB,MAAS,EAAE,GAAM;IAC7D,IAAI,GAAG,GAAG,MAAM,CAAC;IAEjB,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAChB,GAAG,GAAG,GAAG,CAAC,GAAG,CAAM,CAAC;IACtB,CAAC;IAED,OAAO,GAA0B,CAAC;AACpC,CAAC","file":"deepest.js","sourcesContent":["import type { DeepestObject } from \"@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/object/deepest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,UAAU,OAAO,CAAuB,MAAS,EAAE,GAAM;IAC7D,IAAI,GAAG,GAAG,MAAM,CAAC;IAEjB,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAChB,GAAG,GAAG,GAAG,CAAC,GAAG,CAAM,CAAC;IACtB,CAAC;IAED,OAAO,GAA0B,CAAC;AACpC,CAAC","file":"deepest.js","sourcesContent":["import type { DeepestObject } from \"@telperion/extra-ts-types\";\n\n/**\n * #### Get deepest object in an object chain\n *\n * * * * *\n * Example usage:\n * ```typescript\n * import { deepest } from \"@telperion/js-utils/object\";\n *\n * const a = {\n * x: null\n * };\n *\n * const b = {\n * x: a\n * };\n *\n * const c = {\n * x: b\n * };\n *\n * deepest(c, 'x'); // {x: null} (a)\n *\n * ```\n * Static usage example:\n * ```typescript\n * import \"@telperion/js-utils/object/static/deepest\";\n *\n * const a = {\n * x: null\n * };\n *\n * const b = {\n * x: a\n * };\n *\n * const c = {\n * x: b\n * };\n *\n * Object.deepest(c, 'x'); // a\n * ```\n * * * *\n * @param object Object to deep dive\n * @param key key of the object which contains same type instance\n */\nexport function deepest<T, K extends keyof T>(object: T, key: K): DeepestObject<T, K> {\n let obj = object;\n\n while (obj[key]) {\n obj = obj[key] as T;\n }\n\n return obj as DeepestObject<T, K>;\n}\n"]}
|
package/object/index.cjs
CHANGED
|
@@ -5,3 +5,4 @@ tslib_1.__exportStar(require("@telperion/js-utils/object/clone"), exports);
|
|
|
5
5
|
tslib_1.__exportStar(require("@telperion/js-utils/object/compact"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("@telperion/js-utils/object/deepest"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("@telperion/js-utils/object/deep-freeze"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("@telperion/js-utils/object/map"), exports);
|
package/object/index.d.ts
CHANGED
package/object/index.js
CHANGED
|
@@ -2,5 +2,6 @@ export * from '@telperion/js-utils/object/clone';
|
|
|
2
2
|
export * from '@telperion/js-utils/object/compact';
|
|
3
3
|
export * from '@telperion/js-utils/object/deepest';
|
|
4
4
|
export * from '@telperion/js-utils/object/deep-freeze';
|
|
5
|
+
export * from '@telperion/js-utils/object/map';
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/object/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC","file":"index.js","sourcesContent":["export * from '@telperion/js-utils/object/clone';\nexport * from '@telperion/js-utils/object/compact';\nexport * from '@telperion/js-utils/object/deepest';\nexport * from '@telperion/js-utils/object/deep-freeze';\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC","file":"index.js","sourcesContent":["export * from '@telperion/js-utils/object/clone';\nexport * from '@telperion/js-utils/object/compact';\nexport * from '@telperion/js-utils/object/deepest';\nexport * from '@telperion/js-utils/object/deep-freeze';\nexport * from '@telperion/js-utils/object/map';\n"]}
|
package/object/map.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.map = map;
|
|
4
|
+
/**
|
|
5
|
+
* #### Maps the values of an object using a callback function
|
|
6
|
+
*
|
|
7
|
+
* Similar to `Array.prototype.map`, but for objects. Iterates over own enumerable properties
|
|
8
|
+
* and returns a new object with the same keys and transformed values.
|
|
9
|
+
*
|
|
10
|
+
* * * *
|
|
11
|
+
* Example usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { map } from "@telperion/js-utils/object";
|
|
14
|
+
*
|
|
15
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
16
|
+
*
|
|
17
|
+
* map(obj, value => value * 2); // { a: 2, b: 4, c: 6 }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Example with key usage:
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { map } from "@telperion/js-utils/object";
|
|
23
|
+
*
|
|
24
|
+
* const obj = { x: 1, y: 2 };
|
|
25
|
+
*
|
|
26
|
+
* map(obj, (value, key) => `${key}_${value}`); // { x: "x_1", y: "y_2" }
|
|
27
|
+
* ```
|
|
28
|
+
* * * *
|
|
29
|
+
* @param object Object to map
|
|
30
|
+
* @param fn Callback function to transform each value, receives the value, key, and the entire object as arguments
|
|
31
|
+
* @returns A new object with the same keys and transformed values
|
|
32
|
+
*/
|
|
33
|
+
function map(object, fn) {
|
|
34
|
+
const result = {};
|
|
35
|
+
for (const key in object) {
|
|
36
|
+
if (object.hasOwnProperty(key)) {
|
|
37
|
+
result[key] = fn(object[key], key, object);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
package/object/map.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Maps the values of an object using a callback function
|
|
3
|
+
*
|
|
4
|
+
* Similar to `Array.prototype.map`, but for objects. Iterates over own enumerable properties
|
|
5
|
+
* and returns a new object with the same keys and transformed values.
|
|
6
|
+
*
|
|
7
|
+
* * * *
|
|
8
|
+
* Example usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { map } from "@telperion/js-utils/object";
|
|
11
|
+
*
|
|
12
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
13
|
+
*
|
|
14
|
+
* map(obj, value => value * 2); // { a: 2, b: 4, c: 6 }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Example with key usage:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { map } from "@telperion/js-utils/object";
|
|
20
|
+
*
|
|
21
|
+
* const obj = { x: 1, y: 2 };
|
|
22
|
+
*
|
|
23
|
+
* map(obj, (value, key) => `${key}_${value}`); // { x: "x_1", y: "y_2" }
|
|
24
|
+
* ```
|
|
25
|
+
* * * *
|
|
26
|
+
* @param object Object to map
|
|
27
|
+
* @param fn Callback function to transform each value, receives the value, key, and the entire object as arguments
|
|
28
|
+
* @returns A new object with the same keys and transformed values
|
|
29
|
+
*/
|
|
30
|
+
export declare function map<T extends Object, R>(object: T, fn: (value: T[keyof T], key: keyof T, object: T) => R): {
|
|
31
|
+
[K in keyof T]: R;
|
|
32
|
+
};
|
package/object/map.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Maps the values of an object using a callback function
|
|
3
|
+
*
|
|
4
|
+
* Similar to `Array.prototype.map`, but for objects. Iterates over own enumerable properties
|
|
5
|
+
* and returns a new object with the same keys and transformed values.
|
|
6
|
+
*
|
|
7
|
+
* * * *
|
|
8
|
+
* Example usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { map } from "@telperion/js-utils/object";
|
|
11
|
+
*
|
|
12
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
13
|
+
*
|
|
14
|
+
* map(obj, value => value * 2); // { a: 2, b: 4, c: 6 }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Example with key usage:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { map } from "@telperion/js-utils/object";
|
|
20
|
+
*
|
|
21
|
+
* const obj = { x: 1, y: 2 };
|
|
22
|
+
*
|
|
23
|
+
* map(obj, (value, key) => `${key}_${value}`); // { x: "x_1", y: "y_2" }
|
|
24
|
+
* ```
|
|
25
|
+
* * * *
|
|
26
|
+
* @param object Object to map
|
|
27
|
+
* @param fn Callback function to transform each value, receives the value, key, and the entire object as arguments
|
|
28
|
+
* @returns A new object with the same keys and transformed values
|
|
29
|
+
*/
|
|
30
|
+
export function map(object, fn) {
|
|
31
|
+
const result = {};
|
|
32
|
+
for (const key in object) {
|
|
33
|
+
if (object.hasOwnProperty(key)) {
|
|
34
|
+
result[key] = fn(object[key], key, object);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/object/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,EAAqD;IAErD,MAAM,MAAM,GAAG,EAA2B,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","file":"map.js","sourcesContent":["/**\r\n * #### Maps the values of an object using a callback function\r\n *\r\n * Similar to `Array.prototype.map`, but for objects. Iterates over own enumerable properties\r\n * and returns a new object with the same keys and transformed values.\r\n *\r\n * * * *\r\n * Example usage:\r\n * ```typescript\r\n * import { map } from \"@telperion/js-utils/object\";\r\n *\r\n * const obj = { a: 1, b: 2, c: 3 };\r\n *\r\n * map(obj, value => value * 2); // { a: 2, b: 4, c: 6 }\r\n * ```\r\n *\r\n * Example with key usage:\r\n * ```typescript\r\n * import { map } from \"@telperion/js-utils/object\";\r\n *\r\n * const obj = { x: 1, y: 2 };\r\n *\r\n * map(obj, (value, key) => `${key}_${value}`); // { x: \"x_1\", y: \"y_2\" }\r\n * ```\r\n * * * *\r\n * @param object Object to map\r\n * @param fn Callback function to transform each value, receives the value, key, and the entire object as arguments\r\n * @returns A new object with the same keys and transformed values\r\n */\r\nexport function map<T extends Object, R>(\r\n object: T,\r\n fn: (value: T[keyof T], key: keyof T, object: T) => R\r\n): { [K in keyof T]: R } {\r\n const result = {} as { [K in keyof T]: R };\r\n\r\n for (const key in object) {\r\n if (object.hasOwnProperty(key)) {\r\n result[key] = fn(object[key], key, object);\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { map } from '@telperion/js-utils/object/map';
|
|
2
|
+
declare global {
|
|
3
|
+
export interface ObjectConstructor {
|
|
4
|
+
/**
|
|
5
|
+
* #### Maps the values of an object using a callback function
|
|
6
|
+
*
|
|
7
|
+
* Similar to `Array.prototype.map`, but for objects. Iterates over own enumerable properties
|
|
8
|
+
* and returns a new object with the same keys and transformed values.
|
|
9
|
+
*
|
|
10
|
+
* * * *
|
|
11
|
+
* Example usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import "@telperion/js-utils/object/static/map";
|
|
14
|
+
*
|
|
15
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
16
|
+
*
|
|
17
|
+
* Object.map(obj, value => value * 2); // { a: 2, b: 4, c: 6 }
|
|
18
|
+
* ```
|
|
19
|
+
* * * *
|
|
20
|
+
* @param object Object to map
|
|
21
|
+
* @param fn Callback function to transform each value, receives the value, key, and the entire object as arguments
|
|
22
|
+
* @returns A new object with the same keys and transformed values
|
|
23
|
+
*/
|
|
24
|
+
map: typeof map;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/object/static/map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AA4BrD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC","file":"map.js","sourcesContent":["import { map } from '@telperion/js-utils/object/map';\r\n\r\ndeclare global {\r\n export interface ObjectConstructor {\r\n /**\r\n * #### Maps the values of an object using a callback function\r\n *\r\n * Similar to `Array.prototype.map`, but for objects. Iterates over own enumerable properties\r\n * and returns a new object with the same keys and transformed values.\r\n *\r\n * * * *\r\n * Example usage:\r\n * ```typescript\r\n * import \"@telperion/js-utils/object/static/map\";\r\n *\r\n * const obj = { a: 1, b: 2, c: 3 };\r\n *\r\n * Object.map(obj, value => value * 2); // { a: 2, b: 4, c: 6 }\r\n * ```\r\n * * * *\r\n * @param object Object to map\r\n * @param fn Callback function to transform each value, receives the value, key, and the entire object as arguments\r\n * @returns A new object with the same keys and transformed values\r\n */\r\n map: typeof map;\r\n }\r\n}\r\n\r\nObject.map = map;\r\n"]}
|
package/open-promise.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConstructorType } from '@
|
|
1
|
+
import type { ConstructorType } from '@telperion/extra-ts-types';
|
|
2
2
|
type Executor<T> = ConstructorParameters<ConstructorType<typeof Promise<T>>>[0];
|
|
3
3
|
type ExecutorParams<T> = Parameters<Executor<T>>;
|
|
4
4
|
type Resolver<T> = ExecutorParams<T>[0];
|
package/open-promise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/open-promise.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AAOzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,8DAA8D;AAC9D,MAAM,OAAO,WAAqB,SAAQ,OAAU;IAClD,MAAM,CAAC,eAAe,GAAkB,IAAI,CAAC;IAC7C,MAAM,CAAC,eAAe,GAAa,IAAI,CAAC;IAExC,SAAS,GAAG,KAAK,CAAC;IAClB,SAAS,GAAG,KAAK,CAAC;IAElB,SAAS,GAAgB,IAAI,CAAC;IAC9B,SAAS,GAAa,IAAI,CAAC;IAG3B;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,YAAY,WAAwB,IAAI;QACtC,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxB,WAAW,CAAC,eAAe,GAAG,OAAO,CAAC;YACtC,WAAW,CAAC,eAAe,GAAG,MAAM,CAAC;YAErC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,eAAe,CAAC;QAE7C,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC;QACnC,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,GAAG,IAA6B;QACtC,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAElE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAG,IAA0B;QAClC,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAElE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAmB;QACxB,OAAO;aACJ,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC/B,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC","file":"open-promise.js","sourcesContent":["import type { ConstructorType } from '@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/open-promise.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AAOzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,8DAA8D;AAC9D,MAAM,OAAO,WAAqB,SAAQ,OAAU;IAClD,MAAM,CAAC,eAAe,GAAkB,IAAI,CAAC;IAC7C,MAAM,CAAC,eAAe,GAAa,IAAI,CAAC;IAExC,SAAS,GAAG,KAAK,CAAC;IAClB,SAAS,GAAG,KAAK,CAAC;IAElB,SAAS,GAAgB,IAAI,CAAC;IAC9B,SAAS,GAAa,IAAI,CAAC;IAG3B;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,YAAY,WAAwB,IAAI;QACtC,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxB,WAAW,CAAC,eAAe,GAAG,OAAO,CAAC;YACtC,WAAW,CAAC,eAAe,GAAG,MAAM,CAAC;YAErC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,eAAe,CAAC;QAE7C,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC;QACnC,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,GAAG,IAA6B;QACtC,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAElE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAG,IAA0B;QAClC,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAElE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAmB;QACxB,OAAO;aACJ,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC/B,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC","file":"open-promise.js","sourcesContent":["import type { ConstructorType } from '@telperion/extra-ts-types';\nimport { noop } from '@telperion/js-utils/function/noop';\n\ntype Executor<T> = ConstructorParameters<ConstructorType<typeof Promise<T>>>[0];\ntype ExecutorParams<T> = Parameters<Executor<T>>;\ntype Resolver<T> = ExecutorParams<T>[0];\ntype Rejector = ExecutorParams<unknown>[1];\n\n/**\n * #### Open Promise\n * A promise constructor to resolve or reject from outside\n *\n * @deprecated Use the native `Promise.withResolvers()` instead, which provides the same functionality.\n *\n * * * *\n * Example with native alternative:\n * ```typescript\n * // Instead of:\n * // import { OpenPromise } from \"@telperion/js-utils\";\n * // const aPromiseWillBeResolvedLater = new OpenPromise();\n *\n * // Use:\n * const { promise, resolve, reject } = Promise.withResolvers();\n *\n * promise.then(val => console.log(val));\n * ...\n * ...\n *\n * resolve({x: 1});\n * ```\n *\n * Legacy Example:\n * ```typescript\n * import { OpenPromise } from \"@telperion/js-utils\";\n *\n * const aPromiseWillBeResolvedLater = new OpenPromise();\n *\n * aPromiseWillBeResolvedLater.then(val => console.log(val));\n * // aPromiseWillBeResolvedLater.finished // false\n * ...\n * ...\n *\n * aPromiseWillBeResolvedLater.resolve({x: 1});\n * // aPromiseWillBeResolvedLater.finished // true\n * ```\n * * * *\n * @template T typeof the value which is going to be resolved\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class OpenPromise<T = any> extends Promise<T> {\n static #resolverHolder: Resolver<any> = noop;\n static #rejectorHolder: Rejector = noop;\n\n #resolved = false;\n #rejected = false;\n\n #resolver: Resolver<T> = noop;\n #rejector: Rejector = noop;\n\n\n /**\n * Returns whether is the promise resolved\n */\n get resolved() {\n return this.#resolved;\n }\n\n /**\n * Returns whether is the promise rejected\n */\n get rejected() {\n return this.#rejected;\n }\n\n /**\n * Returns whether is the promise finished\n */\n get finished() {\n return this.#resolved || this.#rejected;\n }\n\n /**\n * Open Promise Constructor\n */\n constructor(executor: Executor<T> = noop) {\n super((resolve, reject) => {\n OpenPromise.#resolverHolder = resolve;\n OpenPromise.#rejectorHolder = reject;\n\n executor(resolve, reject);\n });\n\n this.#resolver = OpenPromise.#resolverHolder;\n this.#rejector = OpenPromise.#rejectorHolder;\n\n OpenPromise.#resolverHolder = noop;\n OpenPromise.#rejectorHolder = noop;\n }\n\n /**\n * Resolves promise\n * @param value Value to resolve the promise\n */\n resolve(...args: Parameters<Resolver<T>>): void {\n if (this.finished) throw new Error('Promise is already finished');\n\n this.#resolved = true;\n this.#resolver(...args);\n }\n\n /**\n * Rejects promise\n * @param reason Error to reject promise\n */\n reject(...args: Parameters<Rejector>): void {\n if (this.finished) throw new Error('Promise is already finished');\n\n this.#rejected = true;\n this.#rejector(...args);\n }\n\n /**\n * Binds a promise to the inner promise to resolve or reject with it\n * @param promise A promise to bind inner promise\n */\n bindTo(promise: Promise<T>): void {\n promise\n .then(e => { this.resolve(e); })\n .catch(e => this.reject(e));\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telperion/js-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Javascript utility functions for web development",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"object",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"remove",
|
|
27
27
|
"deepest",
|
|
28
28
|
"never",
|
|
29
|
-
"arrayize"
|
|
29
|
+
"arrayize",
|
|
30
|
+
"gather"
|
|
30
31
|
],
|
|
31
32
|
"homepage": "https://open-source.telperion.tr/js-utils",
|
|
32
33
|
"repository": {
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"directory": "libs/js-utils"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
+
"@telperion/extra-ts-types": "^1.5.0",
|
|
39
40
|
"tslib": "^2.3.0"
|
|
40
41
|
},
|
|
41
42
|
"type": "module",
|
|
@@ -159,6 +160,13 @@
|
|
|
159
160
|
"require": "./array/proto/find-by-key.cjs",
|
|
160
161
|
"types": "./array/proto/find-by-key.d.ts"
|
|
161
162
|
},
|
|
163
|
+
"./array/proto/gather": {
|
|
164
|
+
"default": "./array/proto/gather.cjs",
|
|
165
|
+
"import": "./array/proto/gather.js",
|
|
166
|
+
"node": "./array/proto/gather.cjs",
|
|
167
|
+
"require": "./array/proto/gather.cjs",
|
|
168
|
+
"types": "./array/proto/gather.d.ts"
|
|
169
|
+
},
|
|
162
170
|
"./array/proto/intersection": {
|
|
163
171
|
"default": "./array/proto/intersection.cjs",
|
|
164
172
|
"import": "./array/proto/intersection.js",
|
|
@@ -243,6 +251,13 @@
|
|
|
243
251
|
"require": "./array/find-by-key.cjs",
|
|
244
252
|
"types": "./array/find-by-key.d.ts"
|
|
245
253
|
},
|
|
254
|
+
"./array/gather": {
|
|
255
|
+
"default": "./array/gather.cjs",
|
|
256
|
+
"import": "./array/gather.js",
|
|
257
|
+
"node": "./array/gather.cjs",
|
|
258
|
+
"require": "./array/gather.cjs",
|
|
259
|
+
"types": "./array/gather.d.ts"
|
|
260
|
+
},
|
|
246
261
|
"./array/intersection": {
|
|
247
262
|
"default": "./array/intersection.cjs",
|
|
248
263
|
"import": "./array/intersection.js",
|
|
@@ -446,6 +461,13 @@
|
|
|
446
461
|
"require": "./object/static/deep-freeze.cjs",
|
|
447
462
|
"types": "./object/static/deep-freeze.d.ts"
|
|
448
463
|
},
|
|
464
|
+
"./object/static/map": {
|
|
465
|
+
"default": "./object/static/map.cjs",
|
|
466
|
+
"import": "./object/static/map.js",
|
|
467
|
+
"node": "./object/static/map.cjs",
|
|
468
|
+
"require": "./object/static/map.cjs",
|
|
469
|
+
"types": "./object/static/map.d.ts"
|
|
470
|
+
},
|
|
449
471
|
"./object/clone": {
|
|
450
472
|
"default": "./object/clone.cjs",
|
|
451
473
|
"import": "./object/clone.js",
|
|
@@ -474,6 +496,13 @@
|
|
|
474
496
|
"require": "./object/deep-freeze.cjs",
|
|
475
497
|
"types": "./object/deep-freeze.d.ts"
|
|
476
498
|
},
|
|
499
|
+
"./object/map": {
|
|
500
|
+
"default": "./object/map.cjs",
|
|
501
|
+
"import": "./object/map.js",
|
|
502
|
+
"node": "./object/map.cjs",
|
|
503
|
+
"require": "./object/map.cjs",
|
|
504
|
+
"types": "./object/map.d.ts"
|
|
505
|
+
},
|
|
477
506
|
"./promise": {
|
|
478
507
|
"default": "./promise/index.cjs",
|
|
479
508
|
"import": "./promise/index.js",
|
package/string/proto/limit.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/js-utils/src/string/proto/limit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AA+BzD,MAAM,CAAC,SAAS,CAAC,KAAK,GAAG,UAAwB,GAAG,IAAe;IACjE,OAAO,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC","file":"limit.js","sourcesContent":["import type { Tail } from '@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/string/proto/limit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AA+BzD,MAAM,CAAC,SAAS,CAAC,KAAK,GAAG,UAAwB,GAAG,IAAe;IACjE,OAAO,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC","file":"limit.js","sourcesContent":["import type { Tail } from '@telperion/extra-ts-types';\n\nimport { limit } from '@telperion/js-utils/string/limit';\n\ntype FuncType = typeof limit;\ntype FuncArgs = Parameters<FuncType>;\ntype FuncReturn = ReturnType<FuncType>;\ntype ProtoArgs = Tail<FuncArgs>;\n\ndeclare global {\n export interface String {\n /**\n * #### Limit\n *\n * Limits the string to `n` character\n *\n * * * *\n * Example:\n * ```typescript\n * import \"@telperion/js-utils/string/proto/limit\";\n *\n * const str = 'foobarbaz';\n *\n * str.limit(3); // 'foo'\n * ```\n * * * *\n * @param count Count to limit string character size\n * @return Limited string\n */\n limit(...args: ProtoArgs): FuncReturn;\n }\n}\n\nString.prototype.limit = function (this: string, ...args: ProtoArgs): FuncReturn {\n return limit(this, ...args);\n};\n"]}
|