@terrygonguet/utils 0.10.1 → 0.12.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/dist/tableau.d.ts DELETED
@@ -1,63 +0,0 @@
1
- type Predicate<T> = (value: T, index: number, tableau: Tableau<T>) => boolean;
2
- type AssertPredicate<T, U extends T> = (value: T, index: number, tableau: Tableau<T>) => value is U;
3
- type Reducer<T, U> = (previousValue: U, currentValue: T, index: number, tableau: Tableau<T>) => U;
4
- type Mapper<T, U> = (value: T, index: number, tableau: Tableau<T>) => U;
5
- type Comparer<T> = (a: T, b: T) => number;
6
- type FlatTableau<Arr, Depth extends number> = {
7
- done: Arr;
8
- recur: Arr extends Tableau<infer InnerArr> ? FlatTableau<InnerArr, [
9
- -1,
10
- 0,
11
- 1,
12
- 2,
13
- 3,
14
- 4,
15
- 5,
16
- 6,
17
- 7,
18
- 8,
19
- 9,
20
- 10,
21
- 11,
22
- 12,
23
- 13,
24
- 14,
25
- 15,
26
- 16,
27
- 17,
28
- 18,
29
- 19,
30
- 20
31
- ][Depth]> : Arr;
32
- }[Depth extends -1 ? "done" : "recur"];
33
- declare class Tableau<T> extends Array<T> {
34
- constructor(length?: number);
35
- i(idx: number): T | undefined;
36
- ientries(): IterableIterator<[number, T]>;
37
- ievery<U extends T>(predicate: AssertPredicate<T, U>, thisArg?: any): this is Tableau<U>;
38
- ievery(predicate: Predicate<T>, thisArg?: any): boolean;
39
- ifilter<U extends T>(predicate: AssertPredicate<T, U>, thisArg?: any): Tableau<U>;
40
- ifilter(predicate: Predicate<T>, thisArg?: any): Tableau<T>;
41
- ifind<U extends T>(predicate: AssertPredicate<T, U>, thisArg?: any): U | undefined;
42
- ifind(predicate: Predicate<T>, thisArg?: any): T | undefined;
43
- ifindIndex(predicate: Predicate<T>, thisArg?: any): number | undefined;
44
- ifindLast<U extends T>(predicate: AssertPredicate<T, U>, thisArg?: any): U | undefined;
45
- ifindLast(predicate: Predicate<T>, thisArg?: any): T | undefined;
46
- ifindLastIndex(predicate: Predicate<T>, thisArg?: any): number | undefined;
47
- iflat<Depth extends number = 1>(depth?: Depth): FlatTableau<T, Depth>;
48
- iflatMap<U>(callback: Mapper<T, U | Tableau<U>>, thisArg?: any): Tableau<U>;
49
- iindexOf(searchElement: T, fromIndex?: number): number | undefined;
50
- ikeys(): IterableIterator<number>;
51
- ilastIndexOf(searchElement: T, fromIndex?: number): number | undefined;
52
- imap<U>(callbackFn: Mapper<T, U>, thisArg?: any): Tableau<U>;
53
- ireduce<U>(callbackFn: Reducer<T, U>, initialValue: U): U;
54
- ireduceRight<U>(callbackFn: Reducer<T, U>, initialValue: U): U;
55
- isome(predicate: Predicate<T>, thisArg?: any): boolean;
56
- isort(compareFn: Comparer<T>): Tableau<T>;
57
- isplice(start: number, deleteCount?: number, ...items: T[]): Tableau<T>;
58
- iwith(index: number, value: T): Tableau<T>;
59
- static from<T>(source: Iterable<T> | ArrayLike<T>): Tableau<T>;
60
- static of<T>(...elements: T[]): Tableau<T>;
61
- }
62
-
63
- export { Tableau };
package/dist/tableau.js DELETED
@@ -1,125 +0,0 @@
1
- // src/tableau.ts
2
- var Tableau = class _Tableau extends Array {
3
- constructor(length) {
4
- length == void 0 ? super() : super(length);
5
- }
6
- i(idx) {
7
- if (idx == 0) throw new RangeError("Cannot access index 0 in a Tableau");
8
- return this.at(idx - 1);
9
- }
10
- *ientries() {
11
- for (let i = 0; i < this.length; i++) {
12
- yield [i + 1, this[i]];
13
- }
14
- }
15
- ievery(predicate, thisArg) {
16
- return this.every((value, i) => predicate(value, i + 1, this), thisArg);
17
- }
18
- ifilter(predicate, thisArg) {
19
- return this.filter((value, i) => predicate(value, i + 1, this), thisArg);
20
- }
21
- ifind(predicate, thisArg) {
22
- return this.find((value, i) => predicate(value, i + 1, this), thisArg);
23
- }
24
- ifindIndex(predicate, thisArg) {
25
- const idx = this.findIndex(
26
- (value, i) => predicate(value, i + 1, this),
27
- thisArg
28
- );
29
- return idx == -1 ? void 0 : idx + 1;
30
- }
31
- ifindLast(predicate, thisArg) {
32
- return this.findLast(
33
- (value, i) => predicate(value, i + 1, this),
34
- thisArg
35
- );
36
- }
37
- ifindLastIndex(predicate, thisArg) {
38
- const idx = this.findLastIndex(
39
- (value, i) => predicate(value, i + 1, this),
40
- thisArg
41
- );
42
- return idx == -1 ? void 0 : idx + 1;
43
- }
44
- iflat(depth) {
45
- return this.flat(depth);
46
- }
47
- iflatMap(callback, thisArg) {
48
- return this.flatMap(
49
- (value, i) => callback(value, i + 1, this),
50
- thisArg
51
- );
52
- }
53
- iindexOf(searchElement, fromIndex = 1) {
54
- if (fromIndex == 0)
55
- throw new RangeError("Cannot access index 0 in a Tableau");
56
- const idx = this.indexOf(searchElement, fromIndex - 1);
57
- return idx == -1 ? void 0 : idx + 1;
58
- }
59
- *ikeys() {
60
- for (const key of this.keys()) {
61
- yield key + 1;
62
- }
63
- }
64
- ilastIndexOf(searchElement, fromIndex = this.length) {
65
- if (fromIndex == 0)
66
- throw new RangeError("Cannot access index 0 in a Tableau");
67
- const idx = this.lastIndexOf(searchElement, fromIndex - 1);
68
- return idx == -1 ? void 0 : idx + 1;
69
- }
70
- imap(callbackFn, thisArg) {
71
- return this.map(
72
- (value, i) => callbackFn(value, i + 1, this),
73
- thisArg
74
- );
75
- }
76
- ireduce(callbackFn, initialValue) {
77
- return this.reduce(
78
- (acc, cur, i) => callbackFn(acc, cur, i + 1, this),
79
- initialValue
80
- );
81
- }
82
- ireduceRight(callbackFn, initialValue) {
83
- return this.reduceRight(
84
- (acc, cur, i) => callbackFn(acc, cur, i + 1, this),
85
- initialValue
86
- );
87
- }
88
- isome(predicate, thisArg) {
89
- return this.some((value, i) => predicate(value, i + 1, this), thisArg);
90
- }
91
- isort(compareFn) {
92
- return this.toSorted(compareFn);
93
- }
94
- isplice(start, deleteCount, ...items) {
95
- if (start == 0)
96
- throw new RangeError("Cannot access index 0 in a Tableau");
97
- return this.toSpliced(start - 1, deleteCount, ...items);
98
- }
99
- iwith(index, value) {
100
- if (index == 0)
101
- throw new RangeError("Cannot access index 0 in a Tableau");
102
- return this.with(index - 1, value);
103
- }
104
- static from(source) {
105
- if ("length" in source) {
106
- const litanie = new _Tableau(source.length);
107
- for (let i = 0; i < source.length; i++) {
108
- litanie[i] = source[i];
109
- }
110
- return litanie;
111
- } else {
112
- const litanie = new _Tableau();
113
- for (const element of source) {
114
- litanie.push(element);
115
- }
116
- return litanie;
117
- }
118
- }
119
- static of(...elements) {
120
- return _Tableau.from(elements);
121
- }
122
- };
123
- export {
124
- Tableau
125
- };