atomic-fns 1.1.5 → 1.1.7
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 +1 -1
- package/dist/collections/Heap.d.ts +2 -2
- package/dist/collections/LRUCache.d.ts +2 -2
- package/dist/collections/SortedMap.d.ts +4 -4
- package/dist/collections/SortedMap.js +2 -1
- package/dist/collections/SortedSet.d.ts +2 -2
- package/dist/collections/SortedTree.d.ts +7 -7
- package/dist/collections/SortedTree.js +4 -4
- package/dist/collections/SplayTree.d.ts +10 -10
- package/dist/collections/SplayTree.js +3 -3
- package/dist/collections/Trie.d.ts +1 -1
- package/dist/collections/deque.d.ts +10 -10
- package/dist/collections/index.d.ts +17 -16
- package/dist/decimal/index.d.ts +2 -3
- package/dist/decimal/index.js +0 -1
- package/dist/functools/index.d.ts +5 -5
- package/dist/functools/index.js +1 -1
- package/dist/globals/index.d.ts +4 -4
- package/dist/globals/index.js +1 -1
- package/dist/i18n/currency.d.ts +7 -7
- package/dist/i18n/date/index.d.ts +6 -7
- package/dist/i18n/date/index.js +16 -15
- package/dist/i18n/date/utils.d.ts +2 -2
- package/dist/i18n/duration.d.ts +2 -2
- package/dist/i18n/format.d.ts +5 -0
- package/dist/i18n/format.js +20 -9
- package/dist/itertools/index.d.ts +12 -12
- package/dist/itertools/index.js +8 -8
- package/dist/math/index.d.ts +3 -3
- package/dist/mod.d.ts +1 -0
- package/dist/mod.js +1 -0
- package/dist/operators/index.d.ts +5 -1
- package/dist/operators/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,11 +25,11 @@ export declare class Heap<T> extends Collection {
|
|
|
25
25
|
/**
|
|
26
26
|
* Removes the top element.
|
|
27
27
|
*/
|
|
28
|
-
pop(): T;
|
|
28
|
+
pop(): T | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Accesses the top element.
|
|
31
31
|
*/
|
|
32
|
-
top(): T;
|
|
32
|
+
top(): T | undefined;
|
|
33
33
|
/**
|
|
34
34
|
* Check if element is in heap.
|
|
35
35
|
* @param item The item want to find.
|
|
@@ -35,7 +35,7 @@ export declare class LRUCache<K = any, V = any> extends Mapping<K, V> {
|
|
|
35
35
|
* @param {K} key
|
|
36
36
|
* @returns {?V} The associated value or `undefined`
|
|
37
37
|
*/
|
|
38
|
-
get(key: K): V;
|
|
38
|
+
get(key: K): V | undefined;
|
|
39
39
|
/**
|
|
40
40
|
* Removes all keys and values from the cache.
|
|
41
41
|
* @returns {this}
|
|
@@ -52,7 +52,7 @@ export declare class LRUCache<K = any, V = any> extends Mapping<K, V> {
|
|
|
52
52
|
* @param {K} key
|
|
53
53
|
* @returns {?V} The value if it was removed or `undefined`.
|
|
54
54
|
*/
|
|
55
|
-
remove(key: K): V;
|
|
55
|
+
remove(key: K): V | undefined;
|
|
56
56
|
/**
|
|
57
57
|
* Returns the total number of elements in the cache.
|
|
58
58
|
*/
|
|
@@ -24,24 +24,24 @@ export declare class SortedMap<K, V> extends Mapping<K, V> {
|
|
|
24
24
|
* @param {K} key
|
|
25
25
|
* @returns {?V} The key value or `undefined`.
|
|
26
26
|
*/
|
|
27
|
-
get(key: K):
|
|
27
|
+
get(key: K): V | undefined;
|
|
28
28
|
/**
|
|
29
29
|
* Sets the value for the given `key`.
|
|
30
30
|
* @param {K} key
|
|
31
31
|
* @param {V} value
|
|
32
32
|
* @returns {this} Returns the Map object.
|
|
33
33
|
*/
|
|
34
|
-
set(key: K, value: V):
|
|
34
|
+
set(key: K, value: V): this;
|
|
35
35
|
/**
|
|
36
36
|
* Returns the smallest key in the tree.
|
|
37
37
|
* @returns {?K}
|
|
38
38
|
*/
|
|
39
|
-
min(): K;
|
|
39
|
+
min(): K | undefined;
|
|
40
40
|
/**
|
|
41
41
|
* Returns the largest key in the tree.
|
|
42
42
|
* @returns {?K}
|
|
43
43
|
*/
|
|
44
|
-
max(): K;
|
|
44
|
+
max(): K | undefined;
|
|
45
45
|
/**
|
|
46
46
|
* Returns `true` if the `key` existed in the map and was removed.
|
|
47
47
|
* @param {K} key
|
|
@@ -23,12 +23,12 @@ export declare class SortedSet<T> extends Collection {
|
|
|
23
23
|
* Returns the smallest value in the set.
|
|
24
24
|
* @returns {?T}
|
|
25
25
|
*/
|
|
26
|
-
min(): T;
|
|
26
|
+
min(): T | undefined;
|
|
27
27
|
/**
|
|
28
28
|
* Returns the largest value in the set.
|
|
29
29
|
* @returns {?T}
|
|
30
30
|
*/
|
|
31
|
-
max(): T;
|
|
31
|
+
max(): T | undefined;
|
|
32
32
|
/**
|
|
33
33
|
* Removes the value from the set and returns `true` if the value was found and removed.
|
|
34
34
|
* @param {T} value
|
|
@@ -25,7 +25,7 @@ export declare class SortedTree<K, V> extends Mapping<K, V> {
|
|
|
25
25
|
* @param {K} key
|
|
26
26
|
* @returns {?V} The key value or `undefined`.
|
|
27
27
|
*/
|
|
28
|
-
get(key: K): V;
|
|
28
|
+
get(key: K): V | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Sets the value for the given `key`.
|
|
31
31
|
* @param {K} key
|
|
@@ -37,12 +37,12 @@ export declare class SortedTree<K, V> extends Mapping<K, V> {
|
|
|
37
37
|
* Returns the smallest key in the tree.
|
|
38
38
|
* @returns {?K}
|
|
39
39
|
*/
|
|
40
|
-
min(): K;
|
|
40
|
+
min(): K | undefined;
|
|
41
41
|
/**
|
|
42
42
|
* Returns the largest key in the tree.
|
|
43
43
|
* @returns {?K}
|
|
44
44
|
*/
|
|
45
|
-
max(): K;
|
|
45
|
+
max(): K | undefined;
|
|
46
46
|
/**
|
|
47
47
|
* Returns `true` if the `key` existed in the tree and was removed.
|
|
48
48
|
* @param {K} key
|
|
@@ -60,7 +60,7 @@ export declare class SortedTree<K, V> extends Mapping<K, V> {
|
|
|
60
60
|
freeze(): this;
|
|
61
61
|
/**
|
|
62
62
|
* Returns a new iterator of `[K, V]` pairs in reverse order of keys.
|
|
63
|
-
* @returns {
|
|
63
|
+
* @returns {IterableIterator<[K, V]>}
|
|
64
64
|
*/
|
|
65
65
|
reversed(): IterableIterator<[K, V]>;
|
|
66
66
|
/**
|
|
@@ -87,17 +87,17 @@ export declare class SortedTree<K, V> extends Mapping<K, V> {
|
|
|
87
87
|
has(key: K): boolean;
|
|
88
88
|
/**
|
|
89
89
|
* Returns a new iterator of all **ordered** keys in the tree.
|
|
90
|
-
* @returns {
|
|
90
|
+
* @returns {IterableIterator<K>}
|
|
91
91
|
*/
|
|
92
92
|
keys(): IterableIterator<K>;
|
|
93
93
|
/**
|
|
94
94
|
* Returns a new iterator of all values **ordered** by their keys.
|
|
95
|
-
* @returns {
|
|
95
|
+
* @returns {IterableIterator<V>}
|
|
96
96
|
*/
|
|
97
97
|
values(): IterableIterator<V>;
|
|
98
98
|
/**
|
|
99
99
|
* Returns a new iterator of all key value pairs **ordered** by their keys.
|
|
100
|
-
* @returns {
|
|
100
|
+
* @returns {IterableIterator<[K, V]>}
|
|
101
101
|
*/
|
|
102
102
|
entries(): IterableIterator<[K, V]>;
|
|
103
103
|
}
|
|
@@ -82,7 +82,7 @@ export class SortedTree extends Mapping {
|
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* Returns a new iterator of `[K, V]` pairs in reverse order of keys.
|
|
85
|
-
* @returns {
|
|
85
|
+
* @returns {IterableIterator<[K, V]>}
|
|
86
86
|
*/
|
|
87
87
|
reversed() {
|
|
88
88
|
return this.store.reversed();
|
|
@@ -119,21 +119,21 @@ export class SortedTree extends Mapping {
|
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Returns a new iterator of all **ordered** keys in the tree.
|
|
122
|
-
* @returns {
|
|
122
|
+
* @returns {IterableIterator<K>}
|
|
123
123
|
*/
|
|
124
124
|
keys() {
|
|
125
125
|
return this.store.keys();
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Returns a new iterator of all values **ordered** by their keys.
|
|
129
|
-
* @returns {
|
|
129
|
+
* @returns {IterableIterator<V>}
|
|
130
130
|
*/
|
|
131
131
|
values() {
|
|
132
132
|
return this.store.values();
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* Returns a new iterator of all key value pairs **ordered** by their keys.
|
|
136
|
-
* @returns {
|
|
136
|
+
* @returns {IterableIterator<[K, V]>}
|
|
137
137
|
*/
|
|
138
138
|
entries() {
|
|
139
139
|
return this.store.entries();
|
|
@@ -10,7 +10,7 @@ declare class Node<K = any, V = any> {
|
|
|
10
10
|
left?: Node<K, V>;
|
|
11
11
|
right?: Node<K, V>;
|
|
12
12
|
constructor(key: K, value: V);
|
|
13
|
-
get height():
|
|
13
|
+
get height(): number;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* A splay tree is a *self-balancing binary* search tree with the additional property that recently accessed elements are quick to access again.
|
|
@@ -31,16 +31,16 @@ export declare class SplayTree<K, V = any> extends Mapping<K, V> {
|
|
|
31
31
|
* @param p When an element is accessed, with probability `p` splay the tree. With probability `1 - p`, leave the tree as it is.
|
|
32
32
|
*/
|
|
33
33
|
constructor(compareFn?: any, p?: number);
|
|
34
|
-
top(): K;
|
|
34
|
+
top(): K | undefined;
|
|
35
35
|
get size(): number;
|
|
36
36
|
empty(): boolean;
|
|
37
|
-
get height():
|
|
37
|
+
get height(): number;
|
|
38
38
|
/**
|
|
39
39
|
* Returns the value for `key` or `undefined` if the key is not found.
|
|
40
40
|
* @param key The key to find.
|
|
41
41
|
* @returns {?V} The value for the key or `undefined`.
|
|
42
42
|
*/
|
|
43
|
-
get(key: K):
|
|
43
|
+
get(key: K): V | undefined;
|
|
44
44
|
/**
|
|
45
45
|
* Inserts the `key` and `value` in the tree if the `key` does not exist.
|
|
46
46
|
* @param {K} key A key which can be any comparable value
|
|
@@ -51,25 +51,25 @@ export declare class SplayTree<K, V = any> extends Mapping<K, V> {
|
|
|
51
51
|
/**
|
|
52
52
|
* Removes a specified key if it exists in the tree. The removed value is returned or `undefined` if not found.
|
|
53
53
|
* @param {K} key The key to remove.
|
|
54
|
-
* @returns {V} The removed value associated with `key`.
|
|
54
|
+
* @returns {?V} The removed value associated with `key`.
|
|
55
55
|
*/
|
|
56
|
-
remove(key: K): V;
|
|
56
|
+
remove(key: K): V | undefined;
|
|
57
57
|
/**
|
|
58
58
|
* Returns the minimum key in the tree or subtree.
|
|
59
59
|
* @returns The minimum key.
|
|
60
60
|
*/
|
|
61
|
-
min(root?: Node<K, V>): K;
|
|
61
|
+
min(root?: Node<K, V>): K | undefined;
|
|
62
62
|
/**
|
|
63
63
|
* Returns the maximum key in the tree or subtree.
|
|
64
64
|
* @returns The maximum key.
|
|
65
65
|
*/
|
|
66
|
-
max(root?: Node<K, V>): K;
|
|
66
|
+
max(root?: Node<K, V>): K | undefined;
|
|
67
67
|
/**
|
|
68
68
|
* Returns the largest key that is less than a given key.
|
|
69
69
|
* @param key The given key
|
|
70
|
-
* @returns The largest key found or `undefined`.
|
|
70
|
+
* @returns {?K} The largest key found or `undefined`.
|
|
71
71
|
*/
|
|
72
|
-
lowerBound(key: any): K |
|
|
72
|
+
lowerBound(key: any): K | undefined;
|
|
73
73
|
/**
|
|
74
74
|
* This is the simplified top-down splaying method proposed by Sleator and Tarjan in {@link https://doi.org/10.1145%2F3828.3835 Self-Adjusting Binary Search Trees}.
|
|
75
75
|
* @param key
|
|
@@ -140,7 +140,7 @@ export class SplayTree extends Mapping {
|
|
|
140
140
|
/**
|
|
141
141
|
* Removes a specified key if it exists in the tree. The removed value is returned or `undefined` if not found.
|
|
142
142
|
* @param {K} key The key to remove.
|
|
143
|
-
* @returns {V} The removed value associated with `key`.
|
|
143
|
+
* @returns {?V} The removed value associated with `key`.
|
|
144
144
|
*/
|
|
145
145
|
remove(key) {
|
|
146
146
|
if (!this.root) {
|
|
@@ -203,7 +203,7 @@ export class SplayTree extends Mapping {
|
|
|
203
203
|
/**
|
|
204
204
|
* Returns the largest key that is less than a given key.
|
|
205
205
|
* @param key The given key
|
|
206
|
-
* @returns The largest key found or `undefined`.
|
|
206
|
+
* @returns {?K} The largest key found or `undefined`.
|
|
207
207
|
*/
|
|
208
208
|
lowerBound(key) {
|
|
209
209
|
if (!this.root)
|
|
@@ -214,7 +214,7 @@ export class SplayTree extends Mapping {
|
|
|
214
214
|
// Now the result is either the root node or the greatest node in
|
|
215
215
|
// the left subtree.
|
|
216
216
|
if (this.cmp(this.root.key, key) < 0) {
|
|
217
|
-
return this.root;
|
|
217
|
+
return this.root.key;
|
|
218
218
|
}
|
|
219
219
|
else if (this.root.left) {
|
|
220
220
|
return this.max(this.root.left);
|
|
@@ -25,7 +25,7 @@ export declare class Trie extends Collection {
|
|
|
25
25
|
* @param word A prefix string
|
|
26
26
|
* @param {number} [limit=20] The number of results to return.
|
|
27
27
|
*/
|
|
28
|
-
matches: (word: string, limit?: number) => Generator<
|
|
28
|
+
matches: (word: string, limit?: number) => Generator<string>;
|
|
29
29
|
/**
|
|
30
30
|
* Returns `true` if the given string is found in the tree.
|
|
31
31
|
* @param {string} word
|
|
@@ -44,28 +44,28 @@ export declare class Deque<T = any> extends Sequence<T> {
|
|
|
44
44
|
* Removes and returns the element at the end of the deque.
|
|
45
45
|
* @returns {?T} Returns the popped item.
|
|
46
46
|
*/
|
|
47
|
-
pop(): T;
|
|
47
|
+
pop(): T | undefined;
|
|
48
48
|
/**
|
|
49
49
|
* Alias of {@link Deque.pop}
|
|
50
50
|
* @returns {?T} Returns the popped item.
|
|
51
51
|
*/
|
|
52
|
-
remove(): T;
|
|
52
|
+
remove(): T | undefined;
|
|
53
53
|
/**
|
|
54
54
|
* Removes and returns the element at the beginning of the deque.
|
|
55
55
|
* @returns {?T} Returns the removed deque element.
|
|
56
56
|
*/
|
|
57
|
-
popleft(): T;
|
|
57
|
+
popleft(): T | undefined;
|
|
58
58
|
/**
|
|
59
59
|
* Returns the element at the beginning of the deque.
|
|
60
60
|
* @returns {?T} The element if exists
|
|
61
61
|
*/
|
|
62
|
-
first(): T;
|
|
62
|
+
first(): T | undefined;
|
|
63
63
|
/**
|
|
64
64
|
* Returns the element at a specified index position in the deque.
|
|
65
65
|
* @param {number} index The given index
|
|
66
66
|
* @returns {?T} The element if exists
|
|
67
67
|
*/
|
|
68
|
-
get(index: any): T;
|
|
68
|
+
get(index: any): T | undefined;
|
|
69
69
|
/**
|
|
70
70
|
* Update the element at a given `index`.
|
|
71
71
|
* @param {number} index The given index
|
|
@@ -82,7 +82,7 @@ export declare class Deque<T = any> extends Sequence<T> {
|
|
|
82
82
|
* @param {Iteratee<T>} iteratee A function that will be invoked per element
|
|
83
83
|
* @returns {?T} The element if exists
|
|
84
84
|
*/
|
|
85
|
-
find(iteratee: Iteratee<T>): T;
|
|
85
|
+
find(iteratee: Iteratee<T>): T | undefined;
|
|
86
86
|
/**
|
|
87
87
|
* Calls `iteratee` function for every element in the deque.
|
|
88
88
|
* @param {Iteratee<T>} iteratee A function that will be invoked per element
|
|
@@ -92,12 +92,12 @@ export declare class Deque<T = any> extends Sequence<T> {
|
|
|
92
92
|
* Returns a new array with all the elements in reverse order.
|
|
93
93
|
* @returns {Array<T>} The elements reversed
|
|
94
94
|
*/
|
|
95
|
-
reversed():
|
|
95
|
+
reversed(): T[];
|
|
96
96
|
/**
|
|
97
97
|
* Returns a new array with all the elements in the order they were added to the deque.
|
|
98
98
|
* @returns {Array<T>} The elements array
|
|
99
99
|
*/
|
|
100
|
-
toArray():
|
|
100
|
+
toArray(): T[];
|
|
101
101
|
/**
|
|
102
102
|
* Returns an iterator over the deque's values.
|
|
103
103
|
* @returns {Iterator}
|
|
@@ -111,7 +111,7 @@ export declare class Deque<T = any> extends Sequence<T> {
|
|
|
111
111
|
* Creates an iterator of `[index, value]` pairs for all elements in the deque.
|
|
112
112
|
* @returns {Iterator}
|
|
113
113
|
*/
|
|
114
|
-
entries(): Iterable<[number, T]
|
|
114
|
+
entries(): Iterable<[number, T]>;
|
|
115
115
|
[Symbol.iterator](): Iterable<T>;
|
|
116
|
-
inspect():
|
|
116
|
+
inspect(): T[];
|
|
117
117
|
}
|
|
@@ -86,7 +86,7 @@ let users = [
|
|
|
86
86
|
{ 'user': 'pebbles', 'age': 1, 'active': true }
|
|
87
87
|
]
|
|
88
88
|
|
|
89
|
-
find(users,
|
|
89
|
+
find(users, o => o.age < 40)
|
|
90
90
|
// object for 'barney'
|
|
91
91
|
|
|
92
92
|
// The shape iteratee shorthand.
|
|
@@ -142,12 +142,14 @@ export declare function matches(shape: any): (obj: any) => boolean;
|
|
|
142
142
|
forEach([1, 2], (value) => {
|
|
143
143
|
console.log(value)
|
|
144
144
|
})
|
|
145
|
-
//
|
|
145
|
+
// 1
|
|
146
|
+
// 2
|
|
146
147
|
|
|
147
148
|
forEach({ 'a': 1, 'b': 2 }, (value, key) => {
|
|
148
149
|
console.log(key)
|
|
149
150
|
})
|
|
150
|
-
//
|
|
151
|
+
// 'a'
|
|
152
|
+
// 'b'
|
|
151
153
|
```
|
|
152
154
|
* @param {Array|Object} collection The collection to iterate over.
|
|
153
155
|
* @param {Iteratee} fn The function invoked per iteration.
|
|
@@ -162,8 +164,8 @@ export declare function forEach<T>(collection: Object, fn: Iteratee<T>): void;
|
|
|
162
164
|
* This method is like {@link find} except that it iterates from right to left.
|
|
163
165
|
* @example
|
|
164
166
|
```js
|
|
165
|
-
findLast([1, 2, 3, 4],
|
|
166
|
-
//
|
|
167
|
+
findLast([1, 2, 3, 4], n => n % 2 === 1)
|
|
168
|
+
// 3
|
|
167
169
|
```
|
|
168
170
|
* @param {Array} arr The collection to iterate over.
|
|
169
171
|
* @param {Function} fn The function invoked per iteration.
|
|
@@ -179,10 +181,9 @@ export declare function findLast<T>(arr: Object, fn: Object): T | undefined;
|
|
|
179
181
|
|
|
180
182
|
* @example
|
|
181
183
|
```js
|
|
182
|
-
forEachRight([1, 2],
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// Logs `2` then `1`.
|
|
184
|
+
forEachRight([1, 2], console.log)
|
|
185
|
+
// 2
|
|
186
|
+
// 1
|
|
186
187
|
```
|
|
187
188
|
* @param {Array|Object} collection The collection to iterate over.
|
|
188
189
|
* @param {Iteratee} fn The function invoked per iteration.
|
|
@@ -276,7 +277,7 @@ let object = { a: 1, b: '2', c: 3 }
|
|
|
276
277
|
pick(object, ['a', 'c'])
|
|
277
278
|
// { a: 1, c: 3 }
|
|
278
279
|
|
|
279
|
-
pick(object,
|
|
280
|
+
pick(object, x => isNumber(x))
|
|
280
281
|
// { a: 1, c: 3 }
|
|
281
282
|
```
|
|
282
283
|
*
|
|
@@ -293,7 +294,7 @@ let object = { 'a': 1, 'b': '2', 'c': 3 }
|
|
|
293
294
|
omit(object, ['a', 'c'])
|
|
294
295
|
// { 'b': '2' }
|
|
295
296
|
|
|
296
|
-
omit(object,
|
|
297
|
+
omit(object, x => isNumber(x))
|
|
297
298
|
// { 'b': '2' }
|
|
298
299
|
```
|
|
299
300
|
* @param {Object} obj The source object.
|
|
@@ -317,7 +318,7 @@ let users = [
|
|
|
317
318
|
{ 'user': 'pebbles', 'active': true }
|
|
318
319
|
]
|
|
319
320
|
|
|
320
|
-
findIndex(users,
|
|
321
|
+
findIndex(users, o => o.user == 'barney')
|
|
321
322
|
// 0
|
|
322
323
|
|
|
323
324
|
// The `shape` iteratee shorthand.
|
|
@@ -368,7 +369,7 @@ let users = [
|
|
|
368
369
|
{ 'user': 'pebbles', 'active': false }
|
|
369
370
|
]
|
|
370
371
|
|
|
371
|
-
findLastIndex(users,
|
|
372
|
+
findLastIndex(users, o => o.user == 'pebbles')
|
|
372
373
|
// 2
|
|
373
374
|
|
|
374
375
|
// The `shape` iteratee shorthand.
|
|
@@ -512,7 +513,7 @@ export declare function defaults(object: Object, ...sources: Object[]): Object;
|
|
|
512
513
|
* @see {@link union}
|
|
513
514
|
* @see {@link intersection}
|
|
514
515
|
*/
|
|
515
|
-
export declare function difference<T>(...args: Array<Iterable<T>>): Generator<T
|
|
516
|
+
export declare function difference<T>(...args: Array<Iterable<T>>): Generator<T>;
|
|
516
517
|
/**
|
|
517
518
|
* Creates a generator of unique values that are included in all given arrays.
|
|
518
519
|
* @param args The arrays to inspect
|
|
@@ -524,7 +525,7 @@ export declare function difference<T>(...args: Array<Iterable<T>>): Generator<T,
|
|
|
524
525
|
* @see {@link difference}
|
|
525
526
|
* @see {@link union}
|
|
526
527
|
*/
|
|
527
|
-
export declare function intersection<T>(...args: Array<Iterable<T>>): Generator<T
|
|
528
|
+
export declare function intersection<T>(...args: Array<Iterable<T>>): Generator<T>;
|
|
528
529
|
/**
|
|
529
530
|
* Creates a generator of unique values from all given arrays using `Set` for equality comparisons.
|
|
530
531
|
* @param args The arrays to perform union on.
|
|
@@ -536,7 +537,7 @@ export declare function intersection<T>(...args: Array<Iterable<T>>): Generator<
|
|
|
536
537
|
* @see {@link difference}
|
|
537
538
|
* @see {@link intersection}
|
|
538
539
|
*/
|
|
539
|
-
export declare function union<T>(...args: Array<Iterable<T>>): Generator<T
|
|
540
|
+
export declare function union<T>(...args: Array<Iterable<T>>): Generator<T>;
|
|
540
541
|
/**
|
|
541
542
|
* Creates an object composed of keys generated from the results of running each element of `arr` thru `func`. The order of grouped values is determined by the order they occur in `arr`. The corresponding value of each key is an array of elements responsible for generating the key.
|
|
542
543
|
*
|
package/dist/decimal/index.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export declare class Decimal {
|
|
|
79
79
|
```
|
|
80
80
|
* @returns {Decimal}
|
|
81
81
|
*/
|
|
82
|
-
div(x:
|
|
82
|
+
div(x: Decimal | string | number): Decimal;
|
|
83
83
|
/**
|
|
84
84
|
* Returns the square root of this `Decimal`.
|
|
85
85
|
* @returns {TDecimal}
|
|
@@ -97,7 +97,6 @@ export declare class Decimal {
|
|
|
97
97
|
private _truncate;
|
|
98
98
|
/**
|
|
99
99
|
* Returns a string representation of this decimal.
|
|
100
|
-
* @returns {Decimal}
|
|
101
100
|
*/
|
|
102
101
|
toString(): string;
|
|
103
102
|
/**
|
|
@@ -127,7 +126,7 @@ export declare class Decimal {
|
|
|
127
126
|
* @param {*} x
|
|
128
127
|
* @returns {number}
|
|
129
128
|
*/
|
|
130
|
-
compare(x: any):
|
|
129
|
+
compare(x: any): 0 | 1 | -1;
|
|
131
130
|
/**
|
|
132
131
|
* Returns `true` if this value is greater than the value of `x`, otherwise `false`.
|
|
133
132
|
* @param {*} x
|
package/dist/decimal/index.js
CHANGED
|
@@ -12,13 +12,13 @@ import { Function } from '../globals/index.js';
|
|
|
12
12
|
* @returns {Function} Returns the new bound function.
|
|
13
13
|
* @see {@link partial}
|
|
14
14
|
*/
|
|
15
|
-
export declare function bind(fn: Function, thisArg: any, ...partials: any[]):
|
|
15
|
+
export declare function bind(fn: Function, thisArg: any, ...partials: any[]): Function;
|
|
16
16
|
/**
|
|
17
17
|
* Creates a function that accepts arguments of `func` and either invokes `func` returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining `func` arguments, and so on. The arity of `func` may be specified if `func.length` is not sufficient.
|
|
18
18
|
* @param {Function} func The function to curry.
|
|
19
19
|
* @returns Returns the new curried function.
|
|
20
20
|
*/
|
|
21
|
-
export declare function curry(func: Function):
|
|
21
|
+
export declare function curry(func: Function): Function<ReturnType<typeof func>>;
|
|
22
22
|
/**
|
|
23
23
|
* Creates a function that invokes `fn` with partials prepended to the arguments it receives.
|
|
24
24
|
* **Note:** The given function will have `this` bound to `undefined`. If using `this` inside `fn`, consider {@link bind} instead.
|
|
@@ -26,13 +26,13 @@ export declare function curry(func: Function): (...args: any[]) => any;
|
|
|
26
26
|
* @param {...*} [args] The arguments to apply to `fn`.
|
|
27
27
|
* @returns {Function} Returns the new partially applied function
|
|
28
28
|
*/
|
|
29
|
-
export declare function partial(fn:
|
|
29
|
+
export declare function partial(fn: Function, ...args: any[]): Function<ReturnType<typeof fn>>;
|
|
30
30
|
/**
|
|
31
31
|
* Creates a function composition from a given set of functions that will be each applied on the result of the previous one from left to right.
|
|
32
32
|
* @param {...*} [args] The set of functions to apply.
|
|
33
33
|
* @returns {Function} A new function that applies each given function on the result of the previous one.
|
|
34
34
|
*/
|
|
35
|
-
export declare function flow(...args:
|
|
35
|
+
export declare function flow(...args: Function[]): Function;
|
|
36
36
|
/**
|
|
37
37
|
* This is just an alias for the {@link flow} function.
|
|
38
38
|
* @see {@link flow}
|
|
@@ -43,7 +43,7 @@ export declare const pipe: typeof flow;
|
|
|
43
43
|
* @param {...*} [args] The set of functions to apply.
|
|
44
44
|
* @returns {Function} A new function that applies each given function on the result of the previous step.
|
|
45
45
|
*/
|
|
46
|
-
export declare function compose(...args:
|
|
46
|
+
export declare function compose(...args: Function[]): Function;
|
|
47
47
|
/**
|
|
48
48
|
* Creates a function that memoizes the result of `func`. If `resolver` is provided, it determines the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the map cache key.
|
|
49
49
|
*
|
package/dist/functools/index.js
CHANGED
|
@@ -63,7 +63,7 @@ export const pipe = flow;
|
|
|
63
63
|
* @returns {Function} A new function that applies each given function on the result of the previous step.
|
|
64
64
|
*/
|
|
65
65
|
export function compose(...args) {
|
|
66
|
-
return flow(args.reverse());
|
|
66
|
+
return flow(...args.reverse());
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Creates a function that memoizes the result of `func`. If `resolver` is provided, it determines the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the map cache key.
|
package/dist/globals/index.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export declare function type(value: any): string;
|
|
|
76
76
|
* @returns `obj.toString()` or `''` if `obj` is `null` or `undefined`.
|
|
77
77
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString | Object.toString }
|
|
78
78
|
*/
|
|
79
|
-
export declare function str(obj: any):
|
|
79
|
+
export declare function str(obj: any): string;
|
|
80
80
|
/** Check if value is a boolean type. */
|
|
81
81
|
export declare function isBool(x: any): x is boolean;
|
|
82
82
|
/** Check if value is an `Error` type. */
|
|
@@ -170,7 +170,7 @@ export declare function uuid(): string;
|
|
|
170
170
|
* @param {...any[]} args
|
|
171
171
|
* @return `obj.key(...args)` or `undefined`.
|
|
172
172
|
*/
|
|
173
|
-
export declare function call(obj: any, key: PropertyKey, ...args: any[]):
|
|
173
|
+
export declare function call<T = any>(obj: any, key: PropertyKey, ...args: any[]): T;
|
|
174
174
|
/** Convert number to unicode character */
|
|
175
175
|
export declare function chr(x: number): string;
|
|
176
176
|
/** Convert character to Unicode code point */
|
|
@@ -181,14 +181,14 @@ export declare function ord(x: string): number;
|
|
|
181
181
|
* @returns The array of object keys.
|
|
182
182
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys Object.keys()}
|
|
183
183
|
*/
|
|
184
|
-
export declare function keys<T>(object: T):
|
|
184
|
+
export declare function keys<T>(object: T): Array<keyof T>;
|
|
185
185
|
/**
|
|
186
186
|
* Returns an array of the own enumerable property values of `object`.
|
|
187
187
|
* @param object The given object.
|
|
188
188
|
* @returns The array of object keys.
|
|
189
189
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values Object.values()}
|
|
190
190
|
*/
|
|
191
|
-
export declare function values(object: any):
|
|
191
|
+
export declare function values<T = any>(object: any): T[];
|
|
192
192
|
/**
|
|
193
193
|
* Check if a given property is present in a given object.
|
|
194
194
|
* @param obj The object to check.
|
package/dist/globals/index.js
CHANGED
package/dist/i18n/currency.d.ts
CHANGED
|
@@ -8,17 +8,17 @@ export declare class Currency extends Decimal {
|
|
|
8
8
|
private readonly numberFormat;
|
|
9
9
|
private readonly options;
|
|
10
10
|
constructor(amount: any, currency: string, locale?: string, opts?: Intl.NumberFormatOptions);
|
|
11
|
-
clone(n:
|
|
11
|
+
clone(n: Currency): Currency;
|
|
12
12
|
negated(): Currency;
|
|
13
|
-
add(x:
|
|
14
|
-
sub(x:
|
|
15
|
-
div(x:
|
|
16
|
-
mul(x:
|
|
17
|
-
toDecimal():
|
|
13
|
+
add(x: Currency | string): Currency;
|
|
14
|
+
sub(x: Currency | string): Currency;
|
|
15
|
+
div(x: Currency | Decimal | string | number): Currency;
|
|
16
|
+
mul(x: Currency | Decimal): Currency;
|
|
17
|
+
toDecimal(): Decimal;
|
|
18
18
|
toString(): string;
|
|
19
19
|
format(opts?: Intl.NumberFormatOptions, locale?: string): string;
|
|
20
20
|
displayName(): string;
|
|
21
21
|
accounting(): string;
|
|
22
22
|
precision(digits?: number): string;
|
|
23
|
-
eq(x: any):
|
|
23
|
+
eq(x: any): boolean;
|
|
24
24
|
}
|
|
@@ -3,8 +3,7 @@ import { asDate, formatDate, strftime } from '../format.js';
|
|
|
3
3
|
import { DateObject, daysInMonth, daysInYear, isLeapYear, maxDate, minDate, weeksInYear } from './utils.js';
|
|
4
4
|
export { asDate, daysInMonth, daysInYear, formatDate, isLeapYear, maxDate, minDate, strftime, weeksInYear };
|
|
5
5
|
export { DateObject };
|
|
6
|
-
export declare type
|
|
7
|
-
export declare type DateLike = DateInput | IntlDate | DateObject;
|
|
6
|
+
export declare type DateLike = number | string | Date | IntlDate | DateObject;
|
|
8
7
|
/**
|
|
9
8
|
* Creates a date tied to a given locale (default system locale) which can be formatted in that locale's language using the native {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl Intl Apis} directly or using a formatting string.
|
|
10
9
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl Intl Apis}
|
|
@@ -15,7 +14,7 @@ export declare class IntlDate {
|
|
|
15
14
|
intlRelativeFormat: Intl.RelativeTimeFormat;
|
|
16
15
|
/** Parses the provided value as UTC date or returns the current UTC date. */
|
|
17
16
|
static UTC(value?: DateLike, locale?: string): IntlDate;
|
|
18
|
-
/** Returns the current local date and time
|
|
17
|
+
/** Returns the current local date and time. */
|
|
19
18
|
static now(): IntlDate;
|
|
20
19
|
/** Creates a new date from a Unix timestamp (seconds since the unix epoch) */
|
|
21
20
|
static unix(seconds: number): IntlDate;
|
|
@@ -58,9 +57,9 @@ export declare class IntlDate {
|
|
|
58
57
|
/** Gets the number of weeks in the current year, according to ISO weeks. */
|
|
59
58
|
isoWeeksInYear(): number;
|
|
60
59
|
/** Returns the current week of the year. */
|
|
61
|
-
week():
|
|
60
|
+
week(): number;
|
|
62
61
|
/** Returns the ISO week of the year. */
|
|
63
|
-
isoWeek():
|
|
62
|
+
isoWeek(): number;
|
|
64
63
|
/**
|
|
65
64
|
* Returns a localized string representation of this date.
|
|
66
65
|
* @param {Intl.DateTimeFormatOptions} opts The options to use for the format
|
|
@@ -193,7 +192,7 @@ export declare class IntlDate {
|
|
|
193
192
|
static min(...args: any[]): any;
|
|
194
193
|
inspect(): string;
|
|
195
194
|
}
|
|
196
|
-
export declare function addDuration(date:
|
|
195
|
+
export declare function addDuration(date: number | string | Date, duration: number | Duration | TDuration, exact?: boolean): Date;
|
|
197
196
|
/**
|
|
198
197
|
* Subtract the specified years, months, weeks, days, hours, minutes and seconds from the given date.
|
|
199
198
|
* @param date
|
|
@@ -201,4 +200,4 @@ export declare function addDuration(date: DateInput, duration: number | Duration
|
|
|
201
200
|
* @param exact
|
|
202
201
|
* @returns
|
|
203
202
|
*/
|
|
204
|
-
export declare function subDuration(date:
|
|
203
|
+
export declare function subDuration(date: number | string | Date, duration: number | Duration | TDuration, exact?: boolean): Date;
|
package/dist/i18n/date/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export class IntlDate {
|
|
|
17
17
|
static UTC(value, locale) {
|
|
18
18
|
return new IntlDate(value, { utc: true, locale });
|
|
19
19
|
}
|
|
20
|
-
/** Returns the current local date and time
|
|
20
|
+
/** Returns the current local date and time. */
|
|
21
21
|
static now() {
|
|
22
22
|
return new IntlDate();
|
|
23
23
|
}
|
|
@@ -308,7 +308,7 @@ export class IntlDate {
|
|
|
308
308
|
compare(other) {
|
|
309
309
|
if (!this.isValid())
|
|
310
310
|
return 1;
|
|
311
|
-
|
|
311
|
+
const dt = new IntlDate(other);
|
|
312
312
|
if (!dt.isValid())
|
|
313
313
|
return -1;
|
|
314
314
|
return this.getTime() - dt.getTime();
|
|
@@ -317,7 +317,7 @@ export class IntlDate {
|
|
|
317
317
|
if (!this.isValid())
|
|
318
318
|
return this;
|
|
319
319
|
const normalized = normalizeObject(values, normalizeUnit);
|
|
320
|
-
|
|
320
|
+
const mixed = { ...this.toObject(), ...normalized };
|
|
321
321
|
// if we didn't set the day but we ended up on an overflow date,
|
|
322
322
|
// use the last day of the right month
|
|
323
323
|
if (normalized.day === undefined) {
|
|
@@ -335,24 +335,24 @@ export class IntlDate {
|
|
|
335
335
|
return this.relativeFormat.format(n, unit);
|
|
336
336
|
}
|
|
337
337
|
fromNow(unit = 'seconds') {
|
|
338
|
-
|
|
338
|
+
const diff = this.diff(new Date(), unit);
|
|
339
339
|
return this.relativeTime(diff, unit);
|
|
340
340
|
}
|
|
341
341
|
from(other, unit = 'seconds') {
|
|
342
|
-
|
|
342
|
+
const diff = this.diff(other, unit);
|
|
343
343
|
return this.relativeTime(diff, unit);
|
|
344
344
|
}
|
|
345
345
|
toNow(unit = 'seconds') {
|
|
346
|
-
|
|
346
|
+
const diff = this.diff(new Date(), unit);
|
|
347
347
|
return this.relativeTime(-diff, unit);
|
|
348
348
|
}
|
|
349
349
|
to(other, unit = 'seconds') {
|
|
350
|
-
|
|
350
|
+
const diff = this.diff(other, unit);
|
|
351
351
|
return this.relativeTime(-diff, unit);
|
|
352
352
|
}
|
|
353
353
|
diff(other, unit = 'milliseconds', exact = false) {
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
const dt = new IntlDate(other);
|
|
355
|
+
const dur = new Duration(this.getTime() - dt.getTime(), exact);
|
|
356
356
|
let total = dur.total(unit);
|
|
357
357
|
if (!exact)
|
|
358
358
|
total = Math.trunc(total);
|
|
@@ -367,7 +367,8 @@ export class IntlDate {
|
|
|
367
367
|
startOf(unit) {
|
|
368
368
|
if (!this.isValid())
|
|
369
369
|
return this;
|
|
370
|
-
const obj = {}
|
|
370
|
+
const obj = {};
|
|
371
|
+
const normalizedUnit = UNITS_PLURAL[unit.toLowerCase()];
|
|
371
372
|
switch (normalizedUnit) {
|
|
372
373
|
case 'years':
|
|
373
374
|
obj.month = 1;
|
|
@@ -424,18 +425,18 @@ export class IntlDate {
|
|
|
424
425
|
}
|
|
425
426
|
// Check if the new offset is different because we crossed to DST
|
|
426
427
|
function fixOffset(startDate, endDate) {
|
|
427
|
-
|
|
428
|
-
|
|
428
|
+
const startOffset = startDate.getTimezoneOffset();
|
|
429
|
+
const endOffset = endDate.getTimezoneOffset();
|
|
429
430
|
if (startOffset === endOffset)
|
|
430
431
|
return new Date(endDate);
|
|
431
|
-
|
|
432
|
+
const postoffset = (startOffset - endOffset) * 60 * 1000;
|
|
432
433
|
return new Date(+endDate + postoffset);
|
|
433
434
|
}
|
|
434
435
|
export function addDuration(date, duration, exact = false) {
|
|
435
436
|
// Get the current offset of this date timezone
|
|
436
|
-
|
|
437
|
+
const newDate = new Date(date);
|
|
437
438
|
// Get the number of ticks forward
|
|
438
|
-
|
|
439
|
+
const { values } = new Duration(duration, exact).normalize();
|
|
439
440
|
// Apply any time changes that may have happened
|
|
440
441
|
for (const unit in values) {
|
|
441
442
|
setDateUnit(newDate, unit, Math.floor(values[unit]));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface DateObject {
|
|
2
2
|
year?: number;
|
|
3
3
|
month?: number;
|
|
4
4
|
day?: number;
|
|
@@ -7,7 +7,7 @@ export declare type DateObject = {
|
|
|
7
7
|
minute?: number;
|
|
8
8
|
second?: number;
|
|
9
9
|
millisecond?: number;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
/**
|
|
12
12
|
* Returns the minimum (most distant past) of the given date values.
|
|
13
13
|
* @template T
|
package/dist/i18n/duration.d.ts
CHANGED
|
@@ -38,14 +38,14 @@ export declare class Duration {
|
|
|
38
38
|
* @example Duration.fromObject({years: 2, days: 3}).get('days') // 3
|
|
39
39
|
* @return {number}
|
|
40
40
|
*/
|
|
41
|
-
get(unit:
|
|
41
|
+
get(unit: string): number;
|
|
42
42
|
add(duration: TDuration): Duration;
|
|
43
43
|
/**
|
|
44
44
|
* Make this Duration shorter by the specified amount. Return a newly-constructed Duration.
|
|
45
45
|
* @param {Duration|Object|number} duration - The amount to subtract.
|
|
46
46
|
* @return {Duration}
|
|
47
47
|
*/
|
|
48
|
-
subtract(duration:
|
|
48
|
+
subtract(duration: Duration | TDuration | number): Duration;
|
|
49
49
|
/**
|
|
50
50
|
* Return the negative of this Duration.
|
|
51
51
|
* @example
|
package/dist/i18n/format.d.ts
CHANGED
|
@@ -22,5 +22,10 @@ export declare function formatDate(formatStr: string, date: Date, locale?: strin
|
|
|
22
22
|
* @param {?string} locale The locale to use when formatting (default is system locale).
|
|
23
23
|
* @returns {string} The string representation of date
|
|
24
24
|
* @see {@link https://strftime.org/ strftime format}
|
|
25
|
+
* @example
|
|
26
|
+
```js
|
|
27
|
+
strftime('%A, %d/%m/%y', new Date())
|
|
28
|
+
// 'Saturday, 01/02/2020'
|
|
29
|
+
```
|
|
25
30
|
*/
|
|
26
31
|
export declare function strftime(fmt: string, date: Date, locale?: string): string;
|
package/dist/i18n/format.js
CHANGED
|
@@ -2,14 +2,16 @@ const NATIVE_DATE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d
|
|
|
2
2
|
const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
|
|
3
3
|
const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|Q|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|N{1,4}|LTS?|L{1,4}|l{1,4}|x|X|SSS/g;
|
|
4
4
|
const FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ssZ';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function padStart(string, length, pad) {
|
|
6
|
+
return String(string).padStart(length, pad);
|
|
7
|
+
}
|
|
8
|
+
function padZoneStr(instance) {
|
|
7
9
|
const negMinutes = -instance.getTimezoneOffset();
|
|
8
10
|
const minutes = Math.abs(negMinutes);
|
|
9
11
|
const hourOffset = Math.floor(minutes / 60);
|
|
10
12
|
const minuteOffset = minutes % 60;
|
|
11
13
|
return `${negMinutes <= 0 ? '+' : '-'}${padStart(hourOffset, 2, '0')}:${padStart(minuteOffset, 2, '0')}`;
|
|
12
|
-
}
|
|
14
|
+
}
|
|
13
15
|
/**
|
|
14
16
|
* Returns a new Date from the given arguments.
|
|
15
17
|
* @param {string | number | Date} date The date value
|
|
@@ -142,16 +144,20 @@ const TOKENS = {
|
|
|
142
144
|
const HOUR_PARTS = { '%I': 1, '%-I': 1, '%K': 1, '%k': 1 };
|
|
143
145
|
const ERA_PARTS = { '%n': 1, '%N': 1, '%nn': 1 };
|
|
144
146
|
const TZ_PARTS = { '%ZZ': 1, '%-ZZ': 1, '%-z': 1, '%z': 1, '%-Z': 1, '%Z': 1 };
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
function formatter(locale, opts) {
|
|
148
|
+
return new Intl.DateTimeFormat(locale, opts);
|
|
149
|
+
}
|
|
150
|
+
function formatHour(h, maxLength) {
|
|
151
|
+
return String(h % 12 || 12).padStart(maxLength, '0');
|
|
152
|
+
}
|
|
153
|
+
function formatMeridiem(hour, isLowercase) {
|
|
148
154
|
const m = hour < 12 ? 'AM' : 'PM';
|
|
149
155
|
return isLowercase ? m.toLowerCase() : m;
|
|
150
|
-
}
|
|
151
|
-
|
|
156
|
+
}
|
|
157
|
+
function formatPart(locale, t, date) {
|
|
152
158
|
const value = formatter(locale, TOKENS[t]).format(date);
|
|
153
159
|
return value.split(/\s+/g).slice(1).join(' ');
|
|
154
|
-
}
|
|
160
|
+
}
|
|
155
161
|
/**
|
|
156
162
|
* Returns a localized string representation of this date, according to the given format string. Format codes use the same specification as {@link https://momentjs.com/docs/#/displaying/format/ moment}.
|
|
157
163
|
* @param {string} str The format string to use
|
|
@@ -221,6 +227,11 @@ export function formatDate(formatStr, date, locale) {
|
|
|
221
227
|
* @param {?string} locale The locale to use when formatting (default is system locale).
|
|
222
228
|
* @returns {string} The string representation of date
|
|
223
229
|
* @see {@link https://strftime.org/ strftime format}
|
|
230
|
+
* @example
|
|
231
|
+
```js
|
|
232
|
+
strftime('%A, %d/%m/%y', new Date())
|
|
233
|
+
// 'Saturday, 01/02/2020'
|
|
234
|
+
```
|
|
224
235
|
*/
|
|
225
236
|
export function strftime(fmt, date, locale) {
|
|
226
237
|
const results = [];
|
|
@@ -12,7 +12,7 @@ import { Function, Iteratee, Predicate } from '../types';
|
|
|
12
12
|
* @param initial Optional initial value (defaults to the first element in iterable)
|
|
13
13
|
* @returns A sequence of accumulated values
|
|
14
14
|
*/
|
|
15
|
-
export declare function accumulate<T>(iterable: Iterable<T>, func?: typeof add, initial?: any): Generator<
|
|
15
|
+
export declare function accumulate<T>(iterable: Iterable<T>, func?: typeof add, initial?: any): Generator<T>;
|
|
16
16
|
/**
|
|
17
17
|
* Returns `true` when all of the items in iterable are truthy. An optional predicate function can be used to define what truthiness means for this specific collection.
|
|
18
18
|
* @param iterable
|
|
@@ -26,7 +26,7 @@ all([0])
|
|
|
26
26
|
all([1, 2, 3])
|
|
27
27
|
// true
|
|
28
28
|
|
|
29
|
-
all([2, 4, 6]
|
|
29
|
+
all([2, 4, 6], n => n > 1)
|
|
30
30
|
// true
|
|
31
31
|
```
|
|
32
32
|
@see {@link any}
|
|
@@ -45,7 +45,7 @@ any([0])
|
|
|
45
45
|
any([0, 1, null, undefined])
|
|
46
46
|
// true
|
|
47
47
|
|
|
48
|
-
any([1, 4, 5]
|
|
48
|
+
any([1, 4, 5], n => n % 2 === 0)
|
|
49
49
|
// true
|
|
50
50
|
```
|
|
51
51
|
@see {@link all}
|
|
@@ -74,7 +74,7 @@ contains('abcd', 'bc')
|
|
|
74
74
|
*
|
|
75
75
|
* @see {@link collections.find}
|
|
76
76
|
*/
|
|
77
|
-
export declare function contains(collection: Iterable<any>, value: any):
|
|
77
|
+
export declare function contains(collection: Iterable<any>, value: any): boolean;
|
|
78
78
|
/**
|
|
79
79
|
* Returns a generator that drops elements from the iterable as long as the predicate is `true`; afterwards, returns every remaining element. Note, the generator does not produce any output until the predicate first becomes `false`.
|
|
80
80
|
* @param iterable The iterable to inspect.
|
|
@@ -189,11 +189,11 @@ export declare function reduce<T>(iterable: Iterable<T>, reducer: (prev: T, valu
|
|
|
189
189
|
export declare function reversed<T>(iterable: Iterable<T>): T[];
|
|
190
190
|
/**
|
|
191
191
|
* Creates a new sorted list from the elements in the array. This can be called many ways:
|
|
192
|
-
* - sorted([...], true)
|
|
193
|
-
* - sorted([...], fn =
|
|
194
|
-
* - sorted([...], fn =
|
|
195
|
-
* - sorted([...], false, (x, y) => number)
|
|
196
|
-
* - sorted([...], fn =
|
|
192
|
+
* - sorted([...], true) - reverse order
|
|
193
|
+
* - sorted([...], fn = x => any) - using a key fn
|
|
194
|
+
* - sorted([...], fn = x => any, true) - reverse order using key
|
|
195
|
+
* - sorted([...], false, (x, y) => number) - using custom compare
|
|
196
|
+
* - sorted([...], fn = x => any, true, (x, y) => number) - custom key, reverse and compare
|
|
197
197
|
*
|
|
198
198
|
* If `args` is an Object, returns the sorted keys.
|
|
199
199
|
*
|
|
@@ -211,9 +211,9 @@ export declare function sorted<T>(args: T[], key: Function): T[];
|
|
|
211
211
|
export declare function sorted<T>(args: T[], key: Function, reverse: boolean): T[];
|
|
212
212
|
/**
|
|
213
213
|
* Sort `args` in place. Can be called like this:
|
|
214
|
-
* - sort([...], true)
|
|
215
|
-
* - sort([...], (x, y) => number)
|
|
216
|
-
* - sort([...], true, (x, y) => number)
|
|
214
|
+
* - sort([...], true) - reverse order
|
|
215
|
+
* - sort([...], (x, y) => number) - using custom compare
|
|
216
|
+
* - sort([...], true, (x, y) => number) - reverse and using custom compare
|
|
217
217
|
*
|
|
218
218
|
* @param {any[]} args
|
|
219
219
|
* @param {(boolean | Comparer)} [reverse]
|
package/dist/itertools/index.js
CHANGED
|
@@ -15,15 +15,15 @@ import { add, bool, compare, eq, id } from '../operators/index.js';
|
|
|
15
15
|
export function* accumulate(iterable, func = add, initial) {
|
|
16
16
|
const it = iter(iterable);
|
|
17
17
|
let total = initial;
|
|
18
|
-
let
|
|
18
|
+
let current = it.next();
|
|
19
19
|
if (initial == null)
|
|
20
|
-
total =
|
|
21
|
-
while (!
|
|
20
|
+
total = current.value;
|
|
21
|
+
while (!current.done) {
|
|
22
22
|
yield total;
|
|
23
|
-
|
|
24
|
-
if (
|
|
23
|
+
current = it.next();
|
|
24
|
+
if (current.done)
|
|
25
25
|
return;
|
|
26
|
-
total = func(total,
|
|
26
|
+
total = func(total, current.value);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
@@ -39,7 +39,7 @@ all([0])
|
|
|
39
39
|
all([1, 2, 3])
|
|
40
40
|
// true
|
|
41
41
|
|
|
42
|
-
all([2, 4, 6]
|
|
42
|
+
all([2, 4, 6], n => n > 1)
|
|
43
43
|
// true
|
|
44
44
|
```
|
|
45
45
|
@see {@link any}
|
|
@@ -64,7 +64,7 @@ any([0])
|
|
|
64
64
|
any([0, 1, null, undefined])
|
|
65
65
|
// true
|
|
66
66
|
|
|
67
|
-
any([1, 4, 5]
|
|
67
|
+
any([1, 4, 5], n => n % 2 === 0)
|
|
68
68
|
// true
|
|
69
69
|
```
|
|
70
70
|
@see {@link all}
|
package/dist/math/index.d.ts
CHANGED
|
@@ -44,8 +44,8 @@ export declare function ceil(x: number): number;
|
|
|
44
44
|
* @returns
|
|
45
45
|
*/
|
|
46
46
|
export declare function divmod(x: number, y: number): [number, number];
|
|
47
|
-
export declare function log2(x:
|
|
48
|
-
export declare function logBase(x:
|
|
47
|
+
export declare function log2(x: number): number;
|
|
48
|
+
export declare function logBase(x: number, y: number): number;
|
|
49
49
|
/**
|
|
50
50
|
* Returns the smallest element in an iterable. The optional `key` argument specifies a transform on the elements before comparing them. If the elements in the iterable are objects that implement a custom `lt` method, this will be called to compare.
|
|
51
51
|
* @param iterable The iterable to inspect.
|
|
@@ -72,7 +72,7 @@ export declare function max<T>(iterable: Iterable<T>, key?: Predicate<T>): T;
|
|
|
72
72
|
```js
|
|
73
73
|
let objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]
|
|
74
74
|
|
|
75
|
-
mean(objects,
|
|
75
|
+
mean(objects, o => o.n)
|
|
76
76
|
// 5
|
|
77
77
|
```
|
|
78
78
|
*/
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js';
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js';
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module operators
|
|
5
5
|
*/
|
|
6
|
-
/**
|
|
6
|
+
/** @deprecated Use the `identity` function instead.
|
|
7
|
+
* @see {@link identity}
|
|
8
|
+
*/
|
|
7
9
|
export declare function id(x: any): any;
|
|
10
|
+
/** This is the identity function. It always returns the same value that was passed in. */
|
|
11
|
+
export declare const identity: <T>(x: T) => T;
|
|
8
12
|
/**
|
|
9
13
|
* Called to implement truth value testing.
|
|
10
14
|
* @param x
|
package/dist/operators/index.js
CHANGED
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
* @module operators
|
|
5
5
|
*/
|
|
6
6
|
import { call, isObject } from '../globals/index.js';
|
|
7
|
-
/**
|
|
7
|
+
/** @deprecated Use the `identity` function instead.
|
|
8
|
+
* @see {@link identity}
|
|
9
|
+
*/
|
|
8
10
|
export function id(x) {
|
|
9
11
|
return x;
|
|
10
12
|
}
|
|
13
|
+
/** This is the identity function. It always returns the same value that was passed in. */
|
|
14
|
+
export const identity = (x) => x;
|
|
11
15
|
/**
|
|
12
16
|
* Called to implement truth value testing.
|
|
13
17
|
* @param x
|