atomic-fns 1.1.7 → 2.0.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 +405 -60
- package/dist/array/index.d.ts +9 -0
- package/dist/array/index.js +9 -0
- package/dist/array/list.d.ts +99 -0
- package/dist/array/list.js +133 -0
- package/dist/array/sets.d.ts +130 -0
- package/dist/array/sets.js +213 -0
- package/dist/async/index.d.ts +6 -0
- package/dist/async/index.js +6 -0
- package/dist/async/retry.d.ts +38 -0
- package/dist/async/retry.js +56 -0
- package/dist/async/sleep.d.ts +42 -0
- package/dist/async/sleep.js +76 -0
- package/dist/collections/bisect.d.ts +103 -0
- package/dist/collections/bisect.js +157 -0
- package/dist/collections/deque.d.ts +67 -97
- package/dist/collections/deque.js +197 -249
- package/dist/collections/entries.d.ts +89 -0
- package/dist/collections/entries.js +131 -0
- package/dist/collections/frozen-set.d.ts +42 -0
- package/dist/collections/frozen-set.js +64 -0
- package/dist/collections/group.d.ts +141 -0
- package/dist/collections/group.js +241 -0
- package/dist/collections/heap.d.ts +64 -0
- package/dist/collections/heap.js +205 -0
- package/dist/collections/index.d.ts +15 -642
- package/dist/collections/index.js +14 -716
- package/dist/collections/internal/arrayKeys.d.ts +19 -0
- package/dist/collections/internal/arrayKeys.js +83 -0
- package/dist/collections/internal/invariants.d.ts +4 -0
- package/dist/collections/internal/invariants.js +12 -0
- package/dist/collections/internal/iterable.d.ts +25 -0
- package/dist/collections/internal/iterable.js +62 -0
- package/dist/collections/iterate.d.ts +162 -0
- package/dist/collections/iterate.js +188 -0
- package/dist/collections/lru-cache.d.ts +58 -0
- package/dist/collections/lru-cache.js +164 -0
- package/dist/collections/order.d.ts +19 -0
- package/dist/collections/order.js +38 -0
- package/dist/collections/shape.d.ts +32 -0
- package/dist/collections/shape.js +86 -0
- package/dist/collections/sorted-map.d.ts +171 -0
- package/dist/collections/sorted-map.js +845 -0
- package/dist/collections/sorted-set.d.ts +103 -0
- package/dist/collections/sorted-set.js +147 -0
- package/dist/collections/splay-tree.d.ts +82 -0
- package/dist/collections/splay-tree.js +354 -0
- package/dist/collections/trie.d.ts +58 -0
- package/dist/collections/trie.js +196 -0
- package/dist/decimal/currency.d.ts +211 -0
- package/dist/decimal/currency.js +321 -0
- package/dist/decimal/decimal.d.ts +299 -0
- package/dist/decimal/decimal.js +660 -0
- package/dist/decimal/index.d.ts +11 -145
- package/dist/decimal/index.js +10 -374
- package/dist/decimal/internal/bits.d.ts +2 -0
- package/dist/decimal/internal/bits.js +7 -0
- package/dist/decimal/internal/echo.d.ts +4 -0
- package/dist/decimal/internal/echo.js +6 -0
- package/dist/decimal/internal/isqrt.d.ts +9 -0
- package/dist/decimal/internal/isqrt.js +34 -0
- package/dist/decimal/internal/locale.d.ts +7 -0
- package/dist/decimal/internal/locale.js +24 -0
- package/dist/decimal/internal/minor-units.d.ts +2 -0
- package/dist/decimal/internal/minor-units.js +33 -0
- package/dist/decimal/internal/pow10.d.ts +24 -0
- package/dist/decimal/internal/pow10.js +96 -0
- package/dist/encoding/base64.d.ts +39 -0
- package/dist/encoding/base64.js +53 -0
- package/dist/encoding/hex.d.ts +23 -0
- package/dist/encoding/hex.js +34 -0
- package/dist/encoding/index.d.ts +6 -0
- package/dist/encoding/index.js +6 -0
- package/dist/function/debounce.d.ts +68 -0
- package/dist/function/debounce.js +203 -0
- package/dist/function/index.d.ts +6 -0
- package/dist/function/index.js +6 -0
- package/dist/function/shared.d.ts +2 -0
- package/dist/function/shared.js +5 -0
- package/dist/function/wrap.d.ts +130 -0
- package/dist/function/wrap.js +113 -0
- package/dist/hash/digest.d.ts +18 -0
- package/dist/hash/digest.js +26 -0
- package/dist/hash/hash.d.ts +22 -0
- package/dist/hash/hash.js +252 -0
- package/dist/hash/hashString.d.ts +13 -0
- package/dist/hash/hashString.js +53 -0
- package/dist/hash/index.d.ts +8 -0
- package/dist/hash/index.js +8 -0
- package/dist/hash/stableStringify.d.ts +19 -0
- package/dist/hash/stableStringify.js +102 -0
- package/dist/id/index.d.ts +7 -0
- package/dist/id/index.js +7 -0
- package/dist/id/nanoid.d.ts +16 -0
- package/dist/id/nanoid.js +65 -0
- package/dist/id/uniqueId.d.ts +14 -0
- package/dist/id/uniqueId.js +20 -0
- package/dist/id/uuid.d.ts +25 -0
- package/dist/id/uuid.js +64 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.js +15 -8
- package/dist/internal/bytes.d.ts +11 -0
- package/dist/internal/bytes.js +33 -0
- package/dist/internal/codec.d.ts +11 -0
- package/dist/internal/codec.js +84 -0
- package/dist/internal/compare.d.ts +10 -0
- package/dist/internal/compare.js +26 -0
- package/dist/internal/crypto.d.ts +5 -0
- package/dist/internal/crypto.js +11 -0
- package/dist/internal/keys.d.ts +12 -0
- package/dist/internal/keys.js +23 -0
- package/dist/internal/kind.d.ts +44 -0
- package/dist/internal/kind.js +139 -0
- package/dist/internal/sparse.d.ts +51 -0
- package/dist/internal/sparse.js +104 -0
- package/dist/internal/text.d.ts +7 -0
- package/dist/internal/text.js +15 -0
- package/dist/internal/timer.d.ts +10 -0
- package/dist/internal/timer.js +17 -0
- package/dist/internal/truncate.d.ts +10 -0
- package/dist/internal/truncate.js +22 -0
- package/dist/internal/walk.d.ts +47 -0
- package/dist/internal/walk.js +100 -0
- package/dist/is/index.d.ts +8 -0
- package/dist/is/index.js +8 -0
- package/dist/is/isArrayLike.d.ts +18 -0
- package/dist/is/isArrayLike.js +25 -0
- package/dist/is/isError.d.ts +13 -0
- package/dist/is/isError.js +18 -0
- package/dist/is/isNil.d.ts +12 -0
- package/dist/is/isNil.js +14 -0
- package/dist/is/isPlainObject.d.ts +15 -0
- package/dist/is/isPlainObject.js +34 -0
- package/dist/number/index.d.ts +7 -0
- package/dist/number/index.js +7 -0
- package/dist/number/round.d.ts +86 -0
- package/dist/number/round.js +130 -0
- package/dist/number/stats.d.ts +52 -0
- package/dist/number/stats.js +115 -0
- package/dist/object/cloneDeep.d.ts +28 -0
- package/dist/object/cloneDeep.js +200 -0
- package/dist/object/index.d.ts +14 -0
- package/dist/object/index.js +13 -0
- package/dist/object/isEqual.d.ts +64 -0
- package/dist/object/isEqual.js +289 -0
- package/dist/object/matches.d.ts +40 -0
- package/dist/object/matches.js +284 -0
- package/dist/object/merge.d.ts +66 -0
- package/dist/object/merge.js +272 -0
- package/dist/object/parsePath.d.ts +22 -0
- package/dist/object/parsePath.js +111 -0
- package/dist/object/path.d.ts +85 -0
- package/dist/object/path.js +208 -0
- package/dist/object/pick.d.ts +91 -0
- package/dist/object/pick.js +180 -0
- package/dist/object/reshape.d.ts +73 -0
- package/dist/object/reshape.js +144 -0
- package/dist/random/index.d.ts +96 -32
- package/dist/random/index.js +215 -50
- package/dist/string/case.d.ts +71 -0
- package/dist/string/case.js +152 -0
- package/dist/string/fold.d.ts +35 -0
- package/dist/string/fold.js +100 -0
- package/dist/string/index.d.ts +6 -187
- package/dist/string/index.js +6 -226
- package/dist/string/truncate.d.ts +25 -0
- package/dist/string/truncate.js +44 -0
- package/dist/string/words.d.ts +27 -0
- package/dist/string/words.js +241 -0
- package/package.json +101 -58
- package/dist/collections/BTree.d.ts +0 -229
- package/dist/collections/BTree.js +0 -1165
- package/dist/collections/Heap.d.ts +0 -69
- package/dist/collections/Heap.js +0 -181
- package/dist/collections/LRUCache.d.ts +0 -80
- package/dist/collections/LRUCache.js +0 -126
- package/dist/collections/SortedMap.d.ts +0 -92
- package/dist/collections/SortedMap.js +0 -131
- package/dist/collections/SortedSet.d.ts +0 -69
- package/dist/collections/SortedSet.js +0 -99
- package/dist/collections/SortedTree.d.ts +0 -103
- package/dist/collections/SortedTree.js +0 -141
- package/dist/collections/SplayTree.d.ts +0 -105
- package/dist/collections/SplayTree.js +0 -338
- package/dist/collections/Trie.d.ts +0 -42
- package/dist/collections/Trie.js +0 -104
- package/dist/collections/abc.d.ts +0 -152
- package/dist/collections/abc.js +0 -39
- package/dist/collections/frozenset.d.ts +0 -19
- package/dist/collections/frozenset.js +0 -30
- package/dist/functools/index.d.ts +0 -130
- package/dist/functools/index.js +0 -235
- package/dist/globals/index.d.ts +0 -285
- package/dist/globals/index.js +0 -463
- package/dist/i18n/currency.d.ts +0 -24
- package/dist/i18n/currency.js +0 -85
- package/dist/i18n/date/index.d.ts +0 -203
- package/dist/i18n/date/index.js +0 -531
- package/dist/i18n/date/utils.d.ts +0 -65
- package/dist/i18n/date/utils.js +0 -290
- package/dist/i18n/duration.d.ts +0 -112
- package/dist/i18n/duration.js +0 -392
- package/dist/i18n/format.d.ts +0 -31
- package/dist/i18n/format.js +0 -506
- package/dist/i18n/index.d.ts +0 -8
- package/dist/i18n/index.js +0 -8
- package/dist/itertools/index.d.ts +0 -255
- package/dist/itertools/index.js +0 -437
- package/dist/math/index.d.ts +0 -96
- package/dist/math/index.js +0 -98
- package/dist/mod.d.ts +0 -1
- package/dist/mod.js +0 -1
- package/dist/operators/index.d.ts +0 -152
- package/dist/operators/index.js +0 -305
- package/dist/types.d.ts +0 -19
- package/dist/types.js +0 -1
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a new immutable Set object with elements from `iterable`. Its contents cannot be altered after it's created.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @class FrozenSet
|
|
6
|
-
* @extends {Set<T>}
|
|
7
|
-
* @template T
|
|
8
|
-
*/
|
|
9
|
-
export class FrozenSet extends Set {
|
|
10
|
-
constructor(iterable) {
|
|
11
|
-
super(iterable);
|
|
12
|
-
return this.freeze();
|
|
13
|
-
}
|
|
14
|
-
/** @private */
|
|
15
|
-
add() {
|
|
16
|
-
return this;
|
|
17
|
-
}
|
|
18
|
-
/** @private */
|
|
19
|
-
delete() {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
/** @private */
|
|
23
|
-
clear() {
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
/** @private */
|
|
27
|
-
freeze() {
|
|
28
|
-
return Object.freeze(this);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module includes functions that promote a more functional programming style.
|
|
3
|
-
*
|
|
4
|
-
* @module functools
|
|
5
|
-
*/
|
|
6
|
-
import { Function } from '../globals/index.js';
|
|
7
|
-
/**
|
|
8
|
-
* Creates a function that invokes `fn` with the this binding of `thisArg` and `partials` as partially applied arguments.
|
|
9
|
-
* @param {Function} fn The function to bind.
|
|
10
|
-
* @param {*} thisArg The `this` value of `fn`.
|
|
11
|
-
* @param {...*} [partials] The arguments to prepend to `fn`.
|
|
12
|
-
* @returns {Function} Returns the new bound function.
|
|
13
|
-
* @see {@link partial}
|
|
14
|
-
*/
|
|
15
|
-
export declare function bind(fn: Function, thisArg: any, ...partials: any[]): Function;
|
|
16
|
-
/**
|
|
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
|
-
* @param {Function} func The function to curry.
|
|
19
|
-
* @returns Returns the new curried function.
|
|
20
|
-
*/
|
|
21
|
-
export declare function curry(func: Function): Function<ReturnType<typeof func>>;
|
|
22
|
-
/**
|
|
23
|
-
* Creates a function that invokes `fn` with partials prepended to the arguments it receives.
|
|
24
|
-
* **Note:** The given function will have `this` bound to `undefined`. If using `this` inside `fn`, consider {@link bind} instead.
|
|
25
|
-
* @param {Function} fn The function to bind.
|
|
26
|
-
* @param {...*} [args] The arguments to apply to `fn`.
|
|
27
|
-
* @returns {Function} Returns the new partially applied function
|
|
28
|
-
*/
|
|
29
|
-
export declare function partial(fn: Function, ...args: any[]): Function<ReturnType<typeof fn>>;
|
|
30
|
-
/**
|
|
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
|
-
* @param {...*} [args] The set of functions to apply.
|
|
33
|
-
* @returns {Function} A new function that applies each given function on the result of the previous one.
|
|
34
|
-
*/
|
|
35
|
-
export declare function flow(...args: Function[]): Function;
|
|
36
|
-
/**
|
|
37
|
-
* This is just an alias for the {@link flow} function.
|
|
38
|
-
* @see {@link flow}
|
|
39
|
-
*/
|
|
40
|
-
export declare const pipe: typeof flow;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a function composition from a given set of functions that will be each applied on the result of the previous one from right to left.
|
|
43
|
-
* @param {...*} [args] The set of functions to apply.
|
|
44
|
-
* @returns {Function} A new function that applies each given function on the result of the previous step.
|
|
45
|
-
*/
|
|
46
|
-
export declare function compose(...args: Function[]): Function;
|
|
47
|
-
/**
|
|
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
|
-
*
|
|
50
|
-
* @param {Function} func The function to have its output memoized.
|
|
51
|
-
* @param {Function} [resolver] The function to resolve the cache key.
|
|
52
|
-
* @return {Function} Returns the new memoized function.
|
|
53
|
-
*/
|
|
54
|
-
export declare function memoize<T>(func: Function<T>, resolver?: Function): Function<T>;
|
|
55
|
-
/**
|
|
56
|
-
* Can be used as a decorator on any function or method to memoize its results.
|
|
57
|
-
* **NOTE:** By default the given function is memoized using it's first argument, regardless of others.
|
|
58
|
-
* @param target
|
|
59
|
-
* @param name
|
|
60
|
-
* @param descriptor
|
|
61
|
-
* @returns A memoized version of the given function
|
|
62
|
-
*/
|
|
63
|
-
export declare function cache(target: any, name: any, descriptor: any): any;
|
|
64
|
-
/**
|
|
65
|
-
* Creates a debounced function that delays invoking `func` until after `wait` milliseconds have elapsed since the last time the debounced function was invoked. Subsequent calls to the debounced function return the result of the last successful invocation. Provide options to set the `maxWait` milliseconds, regardless of when the function was last invoked.
|
|
66
|
-
*
|
|
67
|
-
* @param {Function} func The function to debounce.
|
|
68
|
-
* @param {number} wait The number of milliseconds to delay.
|
|
69
|
-
* @param {{ maxWait: number }} [opts] The maximum time `func` is allowed to be delayed before it's invoked.
|
|
70
|
-
* @returns Returns the new debounced function.
|
|
71
|
-
*/
|
|
72
|
-
export declare function debounce(func: Function, wait: number, { maxWait }?: {
|
|
73
|
-
maxWait?: number;
|
|
74
|
-
}): Function;
|
|
75
|
-
/**
|
|
76
|
-
* Creates a throttled function that only invokes `func` at most once per every `wait` milliseconds. Subsequent calls to the throttled function return the result of the last successful invocation.
|
|
77
|
-
*
|
|
78
|
-
* @param {Function} func The function to throttle.
|
|
79
|
-
* @param {number} wait The number of milliseconds to throttle invocations to.
|
|
80
|
-
* @return {Function} Returns the new throttled function.
|
|
81
|
-
*/
|
|
82
|
-
export declare function throttle(func: Function, wait: number): Function;
|
|
83
|
-
/**
|
|
84
|
-
* Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first invocation. The `func` is invoked with the arguments of the created function.
|
|
85
|
-
*
|
|
86
|
-
* @param {Function} func The function to restrict
|
|
87
|
-
* @returns {Function} Returns the new restricted function.
|
|
88
|
-
* @example
|
|
89
|
-
```js
|
|
90
|
-
let func = x => x
|
|
91
|
-
let single = once(func)
|
|
92
|
-
single(1) // 1
|
|
93
|
-
single(2) // 1
|
|
94
|
-
single(3) // 1
|
|
95
|
-
// ...
|
|
96
|
-
// `func` is invoked only once.
|
|
97
|
-
```
|
|
98
|
-
*/
|
|
99
|
-
export declare function once<T>(func: Function<T>): Function<T>;
|
|
100
|
-
export declare type Maybe<T> = T | undefined;
|
|
101
|
-
export declare type Result<T, E = any> = [Maybe<T>, Maybe<E>];
|
|
102
|
-
export declare type Optional<T> = Maybe<T>;
|
|
103
|
-
/**
|
|
104
|
-
* Wraps a function to catch any exceptions inside and return a {@link Result} tuple with the value and error, if any.
|
|
105
|
-
* @template T,E
|
|
106
|
-
* @param {Function<T>} fn The function to wrap.
|
|
107
|
-
* @returns {Function} A new function that wraps `fn` and returns the result tuple.
|
|
108
|
-
*/
|
|
109
|
-
export declare function result<T = any, E = unknown>(fn: Function<T>): Function<Result<T, E>>;
|
|
110
|
-
/**
|
|
111
|
-
* Wraps an async function to catch any exceptions inside and return a {@link Result} tuple with the value and error, if any.
|
|
112
|
-
* @template T,E
|
|
113
|
-
* @param {Function<Promise<T>>} fn The async function to await.
|
|
114
|
-
* @returns {Function<Promise<Result<T, E>>>} A new function that awaits the given function and returns the result tuple.
|
|
115
|
-
*/
|
|
116
|
-
export declare function resultAsync<T = any, E = unknown>(fn: Function<Promise<T>>): Function<Promise<Result<T, E>>>;
|
|
117
|
-
/**
|
|
118
|
-
* Converts a function that expects a node-style callback argument like `(err, result)` to return a `Promise` instead.
|
|
119
|
-
* @template T
|
|
120
|
-
* @param {Function<T>} fun The given function to convert from callback style to `Promise`.
|
|
121
|
-
* @param {*} thisArg
|
|
122
|
-
* @returns {Function<Promise<T>>} A function that wraps `fun` and returns a `Promise`.
|
|
123
|
-
*/
|
|
124
|
-
export declare function promisify<T>(fun: Function, thisArg?: any): Function<Promise<T>>;
|
|
125
|
-
/**
|
|
126
|
-
* Invokes a given function that accepts callback arguments for success, error and returns a `Promise` of the results.
|
|
127
|
-
* @param {Function} fn A function that accepts callback arguments for success, error.
|
|
128
|
-
* @returns {Promise<T>} A `Promise` that will be resolved when `successCallback` is called or rejected when `errorCallback` is called.
|
|
129
|
-
*/
|
|
130
|
-
export declare function callAsync<T = any>(fn: (successCallback: (data: T) => any, errorCallback: Function) => any): Promise<T>;
|
package/dist/functools/index.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module includes functions that promote a more functional programming style.
|
|
3
|
-
*
|
|
4
|
-
* @module functools
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Creates a function that invokes `fn` with the this binding of `thisArg` and `partials` as partially applied arguments.
|
|
8
|
-
* @param {Function} fn The function to bind.
|
|
9
|
-
* @param {*} thisArg The `this` value of `fn`.
|
|
10
|
-
* @param {...*} [partials] The arguments to prepend to `fn`.
|
|
11
|
-
* @returns {Function} Returns the new bound function.
|
|
12
|
-
* @see {@link partial}
|
|
13
|
-
*/
|
|
14
|
-
export function bind(fn, thisArg, ...partials) {
|
|
15
|
-
return fn.bind(thisArg, ...partials);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 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.
|
|
19
|
-
* @param {Function} func The function to curry.
|
|
20
|
-
* @returns Returns the new curried function.
|
|
21
|
-
*/
|
|
22
|
-
export function curry(func) {
|
|
23
|
-
return function curried(...args) {
|
|
24
|
-
if (args.length >= func.length) {
|
|
25
|
-
return func.apply(this, args);
|
|
26
|
-
}
|
|
27
|
-
return (...args2) => {
|
|
28
|
-
return curried.apply(this, args.concat(args2));
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Creates a function that invokes `fn` with partials prepended to the arguments it receives.
|
|
34
|
-
* **Note:** The given function will have `this` bound to `undefined`. If using `this` inside `fn`, consider {@link bind} instead.
|
|
35
|
-
* @param {Function} fn The function to bind.
|
|
36
|
-
* @param {...*} [args] The arguments to apply to `fn`.
|
|
37
|
-
* @returns {Function} Returns the new partially applied function
|
|
38
|
-
*/
|
|
39
|
-
export function partial(fn, ...args) {
|
|
40
|
-
return bind(fn, undefined, ...args);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 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.
|
|
44
|
-
* @param {...*} [args] The set of functions to apply.
|
|
45
|
-
* @returns {Function} A new function that applies each given function on the result of the previous one.
|
|
46
|
-
*/
|
|
47
|
-
export function flow(...args) {
|
|
48
|
-
return (x) => {
|
|
49
|
-
for (const fn of args) {
|
|
50
|
-
x = fn(x);
|
|
51
|
-
}
|
|
52
|
-
return x;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* This is just an alias for the {@link flow} function.
|
|
57
|
-
* @see {@link flow}
|
|
58
|
-
*/
|
|
59
|
-
export const pipe = flow;
|
|
60
|
-
/**
|
|
61
|
-
* Creates a function composition from a given set of functions that will be each applied on the result of the previous one from right to left.
|
|
62
|
-
* @param {...*} [args] The set of functions to apply.
|
|
63
|
-
* @returns {Function} A new function that applies each given function on the result of the previous step.
|
|
64
|
-
*/
|
|
65
|
-
export function compose(...args) {
|
|
66
|
-
return flow(...args.reverse());
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
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.
|
|
70
|
-
*
|
|
71
|
-
* @param {Function} func The function to have its output memoized.
|
|
72
|
-
* @param {Function} [resolver] The function to resolve the cache key.
|
|
73
|
-
* @return {Function} Returns the new memoized function.
|
|
74
|
-
*/
|
|
75
|
-
export function memoize(func, resolver) {
|
|
76
|
-
const cache = new Map();
|
|
77
|
-
return (...args) => {
|
|
78
|
-
const key = resolver ? resolver(...args) : args[0];
|
|
79
|
-
const prev = cache.get(key);
|
|
80
|
-
if (prev !== undefined)
|
|
81
|
-
return prev;
|
|
82
|
-
const value = func(...args);
|
|
83
|
-
cache.set(key, value);
|
|
84
|
-
return value;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Can be used as a decorator on any function or method to memoize its results.
|
|
89
|
-
* **NOTE:** By default the given function is memoized using it's first argument, regardless of others.
|
|
90
|
-
* @param target
|
|
91
|
-
* @param name
|
|
92
|
-
* @param descriptor
|
|
93
|
-
* @returns A memoized version of the given function
|
|
94
|
-
*/
|
|
95
|
-
export function cache(target, name, descriptor) {
|
|
96
|
-
const original = descriptor.value;
|
|
97
|
-
if (typeof original === 'function') {
|
|
98
|
-
descriptor.value = memoize(original);
|
|
99
|
-
}
|
|
100
|
-
return descriptor;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Creates a debounced function that delays invoking `func` until after `wait` milliseconds have elapsed since the last time the debounced function was invoked. Subsequent calls to the debounced function return the result of the last successful invocation. Provide options to set the `maxWait` milliseconds, regardless of when the function was last invoked.
|
|
104
|
-
*
|
|
105
|
-
* @param {Function} func The function to debounce.
|
|
106
|
-
* @param {number} wait The number of milliseconds to delay.
|
|
107
|
-
* @param {{ maxWait: number }} [opts] The maximum time `func` is allowed to be delayed before it's invoked.
|
|
108
|
-
* @returns Returns the new debounced function.
|
|
109
|
-
*/
|
|
110
|
-
export function debounce(func, wait, { maxWait } = {}) {
|
|
111
|
-
let timer, maxTimer, lastResult;
|
|
112
|
-
return (...args) => {
|
|
113
|
-
if (timer)
|
|
114
|
-
clearTimeout(timer);
|
|
115
|
-
timer = setTimeout(() => {
|
|
116
|
-
clearTimeout(maxTimer);
|
|
117
|
-
maxTimer = null;
|
|
118
|
-
lastResult = func(...args);
|
|
119
|
-
}, wait);
|
|
120
|
-
if (maxWait && !maxTimer) {
|
|
121
|
-
maxTimer = setTimeout(() => {
|
|
122
|
-
clearTimeout(timer);
|
|
123
|
-
maxTimer = null;
|
|
124
|
-
lastResult = func(...args);
|
|
125
|
-
}, maxWait);
|
|
126
|
-
}
|
|
127
|
-
return lastResult;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Creates a throttled function that only invokes `func` at most once per every `wait` milliseconds. Subsequent calls to the throttled function return the result of the last successful invocation.
|
|
132
|
-
*
|
|
133
|
-
* @param {Function} func The function to throttle.
|
|
134
|
-
* @param {number} wait The number of milliseconds to throttle invocations to.
|
|
135
|
-
* @return {Function} Returns the new throttled function.
|
|
136
|
-
*/
|
|
137
|
-
export function throttle(func, wait) {
|
|
138
|
-
let pending = false;
|
|
139
|
-
return (...args) => {
|
|
140
|
-
if (pending)
|
|
141
|
-
return;
|
|
142
|
-
func(...args);
|
|
143
|
-
pending = true;
|
|
144
|
-
setTimeout(() => {
|
|
145
|
-
pending = false;
|
|
146
|
-
}, wait);
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first invocation. The `func` is invoked with the arguments of the created function.
|
|
151
|
-
*
|
|
152
|
-
* @param {Function} func The function to restrict
|
|
153
|
-
* @returns {Function} Returns the new restricted function.
|
|
154
|
-
* @example
|
|
155
|
-
```js
|
|
156
|
-
let func = x => x
|
|
157
|
-
let single = once(func)
|
|
158
|
-
single(1) // 1
|
|
159
|
-
single(2) // 1
|
|
160
|
-
single(3) // 1
|
|
161
|
-
// ...
|
|
162
|
-
// `func` is invoked only once.
|
|
163
|
-
```
|
|
164
|
-
*/
|
|
165
|
-
export function once(func) {
|
|
166
|
-
let result, isCalled;
|
|
167
|
-
return (...args) => {
|
|
168
|
-
if (!isCalled) {
|
|
169
|
-
result = func(...args);
|
|
170
|
-
isCalled = true;
|
|
171
|
-
}
|
|
172
|
-
return result;
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Wraps a function to catch any exceptions inside and return a {@link Result} tuple with the value and error, if any.
|
|
177
|
-
* @template T,E
|
|
178
|
-
* @param {Function<T>} fn The function to wrap.
|
|
179
|
-
* @returns {Function} A new function that wraps `fn` and returns the result tuple.
|
|
180
|
-
*/
|
|
181
|
-
export function result(fn) {
|
|
182
|
-
return (...args) => {
|
|
183
|
-
let value, err;
|
|
184
|
-
try {
|
|
185
|
-
value = fn(...args);
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
err = error;
|
|
189
|
-
}
|
|
190
|
-
return [value, err];
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Wraps an async function to catch any exceptions inside and return a {@link Result} tuple with the value and error, if any.
|
|
195
|
-
* @template T,E
|
|
196
|
-
* @param {Function<Promise<T>>} fn The async function to await.
|
|
197
|
-
* @returns {Function<Promise<Result<T, E>>>} A new function that awaits the given function and returns the result tuple.
|
|
198
|
-
*/
|
|
199
|
-
export function resultAsync(fn) {
|
|
200
|
-
return async (...args) => {
|
|
201
|
-
let value, err;
|
|
202
|
-
try {
|
|
203
|
-
value = await fn(...args);
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
err = error;
|
|
207
|
-
}
|
|
208
|
-
return [value, err];
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Converts a function that expects a node-style callback argument like `(err, result)` to return a `Promise` instead.
|
|
213
|
-
* @template T
|
|
214
|
-
* @param {Function<T>} fun The given function to convert from callback style to `Promise`.
|
|
215
|
-
* @param {*} thisArg
|
|
216
|
-
* @returns {Function<Promise<T>>} A function that wraps `fun` and returns a `Promise`.
|
|
217
|
-
*/
|
|
218
|
-
export function promisify(fun, thisArg) {
|
|
219
|
-
const original = thisArg ? fun.bind(thisArg) : fun;
|
|
220
|
-
return async (...args) => {
|
|
221
|
-
return await new Promise((resolve, reject) => original(...args, (err, result) => {
|
|
222
|
-
if (err)
|
|
223
|
-
return reject(err);
|
|
224
|
-
resolve(result);
|
|
225
|
-
}));
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Invokes a given function that accepts callback arguments for success, error and returns a `Promise` of the results.
|
|
230
|
-
* @param {Function} fn A function that accepts callback arguments for success, error.
|
|
231
|
-
* @returns {Promise<T>} A `Promise` that will be resolved when `successCallback` is called or rejected when `errorCallback` is called.
|
|
232
|
-
*/
|
|
233
|
-
export async function callAsync(fn) {
|
|
234
|
-
return await new Promise(fn);
|
|
235
|
-
}
|
package/dist/globals/index.d.ts
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This module includes global functions and constants.
|
|
3
|
-
*
|
|
4
|
-
* @module globals
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* A generic function type with arbitrary arguments and return.
|
|
8
|
-
*/
|
|
9
|
-
export declare type Function<TReturn = any> = (...args: any) => TReturn;
|
|
10
|
-
/** This is just a noop function. */
|
|
11
|
-
export declare function noop(): void;
|
|
12
|
-
/** A function that always returns `true`. */
|
|
13
|
-
export declare const True: () => boolean;
|
|
14
|
-
/** A function that always returns `false`. */
|
|
15
|
-
export declare const False: () => boolean;
|
|
16
|
-
/**
|
|
17
|
-
* A custom error class that inherits from the Error object.
|
|
18
|
-
* @class CustomError
|
|
19
|
-
* @extends {Error}
|
|
20
|
-
*/
|
|
21
|
-
export declare class CustomError extends Error {
|
|
22
|
-
/**
|
|
23
|
-
* Returns a new CustomError with the specified message.
|
|
24
|
-
* @param {string} message
|
|
25
|
-
* @constructor
|
|
26
|
-
*/
|
|
27
|
-
constructor(message?: string);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Custom error to signal an invalid index access.
|
|
31
|
-
* @extends {CustomError}
|
|
32
|
-
*/
|
|
33
|
-
export declare class IndexError extends CustomError {
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Raised when a system function returns an I/O failure such as "file not found"
|
|
37
|
-
* or "disk full".
|
|
38
|
-
* @extends {CustomError}
|
|
39
|
-
*/
|
|
40
|
-
export declare class IOError extends CustomError {
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Custom error to signal an invalid key access.
|
|
44
|
-
* @extends {CustomError}
|
|
45
|
-
*/
|
|
46
|
-
export declare class KeyError extends CustomError {
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Custom error to signal an invalid operation.
|
|
50
|
-
* @extends {CustomError}
|
|
51
|
-
*/
|
|
52
|
-
export declare class NotImplementedError extends CustomError {
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Custom error to signal an invalid value.
|
|
56
|
-
* @extends {CustomError}
|
|
57
|
-
*/
|
|
58
|
-
export declare class ValueError extends CustomError {
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Raised when the second argument of a division or modulo operation is zero.
|
|
62
|
-
* @extends {CustomError}
|
|
63
|
-
*/
|
|
64
|
-
export declare class ZeroDivisionError extends CustomError {
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Returns the true type of any value with correct detection for `null`, `Array`,
|
|
68
|
-
* `Object`, `Promise`, `Symbol`, and `NaN`. The correct values are inferred from {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag | Symbol.toStringTag} and the value's prototype.
|
|
69
|
-
* @param value
|
|
70
|
-
* @returns The value type.
|
|
71
|
-
*/
|
|
72
|
-
export declare function type(value: any): string;
|
|
73
|
-
/**
|
|
74
|
-
* Returns a string representing the object.
|
|
75
|
-
* @param obj
|
|
76
|
-
* @returns `obj.toString()` or `''` if `obj` is `null` or `undefined`.
|
|
77
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString | Object.toString }
|
|
78
|
-
*/
|
|
79
|
-
export declare function str(obj: any): string;
|
|
80
|
-
/** Check if value is a boolean type. */
|
|
81
|
-
export declare function isBool(x: any): x is boolean;
|
|
82
|
-
/** Check if value is an `Error` type. */
|
|
83
|
-
export declare function isError(x: any): x is Error;
|
|
84
|
-
/** Check if value is an iterable type. */
|
|
85
|
-
export declare function isIterable(x: any): x is IterableIterator<any>;
|
|
86
|
-
/** Check if value is a native `Date` type. */
|
|
87
|
-
export declare function isDate(x: any): x is Date;
|
|
88
|
-
/** Check if value is an object type. */
|
|
89
|
-
export declare function isObject(x: any): x is Object;
|
|
90
|
-
/** Check if value is a string type. */
|
|
91
|
-
export declare function isString(x: any): x is string;
|
|
92
|
-
/** Check if value is an Array type. */
|
|
93
|
-
export declare function isArray(x: any): x is any[];
|
|
94
|
-
/**
|
|
95
|
-
* Check if value is Array-like type.
|
|
96
|
-
* A value is considered array-like if it's not a function and has a `.length` number property.
|
|
97
|
-
*/
|
|
98
|
-
export declare function isArrayLike(x: any): boolean;
|
|
99
|
-
/** Check if value is a number type. */
|
|
100
|
-
export declare function isNumber(x: any): x is number;
|
|
101
|
-
/** Check if value is an integer number type. */
|
|
102
|
-
export declare function isInteger(x: any): x is number;
|
|
103
|
-
/** Check if value is a bigint type. */
|
|
104
|
-
export declare function isBigint(x: any): x is BigInt;
|
|
105
|
-
/** Check if value is a Promise type. */
|
|
106
|
-
export declare function isPromise(x: any): x is Promise<any>;
|
|
107
|
-
/** Check if value is a function type. */
|
|
108
|
-
export declare function isFunction(x: any): x is Function;
|
|
109
|
-
/** Check if value is an async function type. */
|
|
110
|
-
export declare function isAsyncFunction(x: any): boolean;
|
|
111
|
-
/** Check if value is a generator function type. */
|
|
112
|
-
export declare function isGenerator(x: any): x is Generator;
|
|
113
|
-
/** Check if value is `null` or `undefined`. */
|
|
114
|
-
export declare function isNull(x: any): x is null | undefined;
|
|
115
|
-
/** Check if value === `undefined`. */
|
|
116
|
-
export declare function isUndefined(x: any): x is undefined;
|
|
117
|
-
/** Check if value is not `null` or `undefined`. */
|
|
118
|
-
export declare function notNull(x: any): boolean;
|
|
119
|
-
/** Returns `true` for objects without length or falsy values. */
|
|
120
|
-
export declare function isEmpty(x: any): boolean;
|
|
121
|
-
/** Check if value is a `RegExp` type */
|
|
122
|
-
export declare function isRegExp(x: any): x is RegExp;
|
|
123
|
-
/** Check if value is a `Symbol` type */
|
|
124
|
-
export declare function isSymbol(x: any): x is symbol;
|
|
125
|
-
/** Check if value is a `Set` type. */
|
|
126
|
-
export declare function isSet<T>(x: any): x is Set<T>;
|
|
127
|
-
/** Check if value is a `Map` type. */
|
|
128
|
-
export declare function isMap<K, V>(x: any): x is Map<K, V>;
|
|
129
|
-
/** Check if value is a `WeakSet` type. */
|
|
130
|
-
export declare function isWeakSet<T extends object>(x: any): x is WeakSet<T>;
|
|
131
|
-
/** Check if value is a `WeakMap` type. */
|
|
132
|
-
export declare function isWeakMap<K extends object, V>(x: any): x is WeakMap<K, V>;
|
|
133
|
-
/**
|
|
134
|
-
* Returns the number of elements in a collection type.
|
|
135
|
-
*
|
|
136
|
-
* If `value.length` or `value.size()` is defined, this will be returned.
|
|
137
|
-
* If `value` is an `Object`, it returns the number of keys.
|
|
138
|
-
* @param value
|
|
139
|
-
* @returns The number of elements in the collection or `undefined`.
|
|
140
|
-
*/
|
|
141
|
-
export declare function len(value: any): number;
|
|
142
|
-
/**
|
|
143
|
-
* Generates a unique ID using random numbers. If a prefix is given, the ID is appended to it and returned as a string.
|
|
144
|
-
* @param {string} [pre=''] The id prefix.
|
|
145
|
-
* @returns {number|string} Returns the numeric or string ID.
|
|
146
|
-
* @example
|
|
147
|
-
```js
|
|
148
|
-
uniqueId()
|
|
149
|
-
// 3445556877
|
|
150
|
-
|
|
151
|
-
uniqueId('user_')
|
|
152
|
-
// 'user_1033763188'
|
|
153
|
-
```
|
|
154
|
-
*/
|
|
155
|
-
export declare function uniqueId(pre?: string): string;
|
|
156
|
-
/**
|
|
157
|
-
* Generates a monotonically increasing, pseudo-random based uuid-v4 string. These are sortable, url-friendly and are 100% unique if the IDs are generated more than 1 millisecond apart. If two IDs are generated at the same millisecond, the chance of collision is still pretty low (1 in 10^15).
|
|
158
|
-
* @returns Returns a GUID formatted string.
|
|
159
|
-
* @example
|
|
160
|
-
```js
|
|
161
|
-
uuid()
|
|
162
|
-
// '183f8ef3-b8f0-4000-81f5-89234c836d00'
|
|
163
|
-
```
|
|
164
|
-
*/
|
|
165
|
-
export declare function uuid(): string;
|
|
166
|
-
/**
|
|
167
|
-
* Checks if `obj.key` is a function, and calls it with any given `args`.
|
|
168
|
-
* @param {*} obj
|
|
169
|
-
* @param {PropertyKey} key
|
|
170
|
-
* @param {...any[]} args
|
|
171
|
-
* @return `obj.key(...args)` or `undefined`.
|
|
172
|
-
*/
|
|
173
|
-
export declare function call<T = any>(obj: any, key: PropertyKey, ...args: any[]): T;
|
|
174
|
-
/** Convert number to unicode character */
|
|
175
|
-
export declare function chr(x: number): string;
|
|
176
|
-
/** Convert character to Unicode code point */
|
|
177
|
-
export declare function ord(x: string): number;
|
|
178
|
-
/**
|
|
179
|
-
* Returns an array of the own enumerable property names of `object`.
|
|
180
|
-
* @param object The given object.
|
|
181
|
-
* @returns The array of object keys.
|
|
182
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys Object.keys()}
|
|
183
|
-
*/
|
|
184
|
-
export declare function keys<T>(object: T): Array<keyof T>;
|
|
185
|
-
/**
|
|
186
|
-
* Returns an array of the own enumerable property values of `object`.
|
|
187
|
-
* @param object The given object.
|
|
188
|
-
* @returns The array of object keys.
|
|
189
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values Object.values()}
|
|
190
|
-
*/
|
|
191
|
-
export declare function values<T = any>(object: any): T[];
|
|
192
|
-
/**
|
|
193
|
-
* Check if a given property is present in a given object.
|
|
194
|
-
* @param obj The object to check.
|
|
195
|
-
* @param attr A property key name.
|
|
196
|
-
* @returns `true` if the object has the property name.
|
|
197
|
-
*/
|
|
198
|
-
export declare function has(obj: any, attr: PropertyKey): boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Check if the attribute is present in the object or return a default value instead.
|
|
201
|
-
* @param {PropertyKey} key
|
|
202
|
-
* @param {*} obj
|
|
203
|
-
* @param {*} [value=undefined]
|
|
204
|
-
* @return The property value or default value.
|
|
205
|
-
*/
|
|
206
|
-
export declare function get<T>(key: PropertyKey, obj: T, value?: any): any;
|
|
207
|
-
export declare function get<T>(key: PropertyKey[], obj: T, value?: any): any;
|
|
208
|
-
/**
|
|
209
|
-
* Deletes a given property key from an object.
|
|
210
|
-
* @param attr The property name.
|
|
211
|
-
* @param x The given object.
|
|
212
|
-
* @returns The modified object.
|
|
213
|
-
*/
|
|
214
|
-
export declare function del<T>(attr: PropertyKey, x: T): T;
|
|
215
|
-
/**
|
|
216
|
-
* Adds a property to an object, or modifies the existing value.
|
|
217
|
-
* @param attr The name or Symbol of the property to be defined or modified.
|
|
218
|
-
* @param obj The container object.
|
|
219
|
-
* @param value The value associated with the property
|
|
220
|
-
* @param {boolean} [writable=false] If `true` the value may be changed later. Defaults to `false`.
|
|
221
|
-
* @param {boolean} [enumerable=false] If `true` this property shows up during enumeration of the properties in the object. Defaults to `false`.
|
|
222
|
-
* @returns
|
|
223
|
-
*/
|
|
224
|
-
export declare function set(attr: PropertyKey, obj: any, value: any, writable?: boolean, enumerable?: boolean): any;
|
|
225
|
-
export declare const HASH_KEY: unique symbol;
|
|
226
|
-
/**
|
|
227
|
-
* Return a hash value for a given object. The hash will be the same for subsequent invocations.
|
|
228
|
-
* @param obj The given object.
|
|
229
|
-
* @returns The hash value.
|
|
230
|
-
*/
|
|
231
|
-
export declare function hash(obj: string): number;
|
|
232
|
-
export declare function hash<T>(obj: T): T;
|
|
233
|
-
/**
|
|
234
|
-
* A hash value generator for strings.
|
|
235
|
-
* @param {string} str The given string.
|
|
236
|
-
* @returns {number} The hash value of the string.
|
|
237
|
-
* @see {@link http://isthe.com/chongo/tech/comp/fnv/ FNV hash}
|
|
238
|
-
*/
|
|
239
|
-
export declare function hashCode(str: string): number;
|
|
240
|
-
/**
|
|
241
|
-
* Converts a number to a binary string.
|
|
242
|
-
* @param n The given number.
|
|
243
|
-
* @returns The binary string representation of `n`.
|
|
244
|
-
*/
|
|
245
|
-
export declare function bin(n: number): string;
|
|
246
|
-
/**
|
|
247
|
-
* Converts a number to a hexadecimal string.
|
|
248
|
-
* @param n The given number.
|
|
249
|
-
* @returns The hexadecimal string representation of `n`.
|
|
250
|
-
*/
|
|
251
|
-
export declare function hex(n: number): string;
|
|
252
|
-
/**
|
|
253
|
-
* Converts a number to an octal string.
|
|
254
|
-
* @param n The given number.
|
|
255
|
-
* @returns The octal string representation of `n`.
|
|
256
|
-
*/
|
|
257
|
-
export declare function oct(n: number): string;
|
|
258
|
-
/**
|
|
259
|
-
* Returns a floating point number constructed from a number or string `x`.
|
|
260
|
-
* @param x The number or string.
|
|
261
|
-
* @returns A floating point number parsed from the given value or `NaN`.
|
|
262
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat parseFloat}
|
|
263
|
-
*/
|
|
264
|
-
export declare function float(x: string): number;
|
|
265
|
-
/**
|
|
266
|
-
* Returns an integer number constructed from a number or string `x`.
|
|
267
|
-
* @param x The number or string.
|
|
268
|
-
* @returns An integer number parsed from the given value or `NaN`.
|
|
269
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt parseInt}
|
|
270
|
-
*/
|
|
271
|
-
export declare function int(x: string, base?: number): number;
|
|
272
|
-
/**
|
|
273
|
-
* Converts the value to an array using `Array.from()`.
|
|
274
|
-
* @param value
|
|
275
|
-
* @returns A new array value.
|
|
276
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from Array.from()}
|
|
277
|
-
*/
|
|
278
|
-
export declare function list<T>(value?: any): T[];
|
|
279
|
-
/**
|
|
280
|
-
* Retrieve the next item from the iterator by calling its `next()` method.
|
|
281
|
-
* @param iter The iterator.
|
|
282
|
-
* @returns The next value from the iterator.
|
|
283
|
-
*/
|
|
284
|
-
export declare function next<T>(iter: Iterator<T>): T | undefined;
|
|
285
|
-
export declare function next<T>(iter: Generator<any, T>): T | undefined;
|