atomic-fns 0.3.3-beta → 0.3.4
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/core/collections/index.js +5 -5
- package/core/collections/index.ts +5 -5
- package/core/functools/index.d.ts +2 -2
- package/core/functools/index.ts +6 -3
- package/core/globals/index.d.ts +22 -3
- package/core/globals/index.js +28 -5
- package/core/globals/index.ts +39 -6
- package/core/i18n/date/format.d.ts +16 -0
- package/core/i18n/date/format.js +307 -0
- package/core/i18n/date/format.ts +343 -0
- package/core/i18n/date/index.d.ts +223 -0
- package/core/i18n/date/index.js +387 -0
- package/core/i18n/date/index.ts +471 -0
- package/core/i18n/date/test.html +67 -0
- package/core/i18n/index.d.ts +7 -0
- package/core/i18n/index.js +7 -0
- package/core/i18n/index.ts +8 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/index.ts +1 -0
- package/core/operators/index.d.ts +1 -1
- package/core/operators/index.js +35 -5
- package/core/operators/index.ts +34 -6
- package/package.json +11 -11
- package/tests/globals.spec.ts +9 -9
- package/tsconfig.json +2 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module Collections
|
|
5
5
|
*/
|
|
6
6
|
import { partial } from '../functools/index.js';
|
|
7
|
-
import { call, get, isArray, isArrayLike, isBool, isEmpty,
|
|
7
|
+
import { call, get, isArray, isArrayLike, isBool, isEmpty, isFunction, isIterable, isNull, isNumber, isObject, isString, isSymbol, keys, set } from '../globals/index.js';
|
|
8
8
|
import { enumerate } from '../itertools/index.js';
|
|
9
9
|
import { compare, eq, id } from '../operators/index.js';
|
|
10
10
|
export * from './abc.js';
|
|
@@ -81,7 +81,7 @@ filter(users, 'active')
|
|
|
81
81
|
*/
|
|
82
82
|
export function filter(arr, fn = isNull) {
|
|
83
83
|
if (Array.isArray(arr)) {
|
|
84
|
-
if (
|
|
84
|
+
if (isFunction(fn))
|
|
85
85
|
return arr.filter(fn);
|
|
86
86
|
if (isNumber(fn) || isString(fn) || isSymbol(fn))
|
|
87
87
|
return arr.filter((x) => get(fn, x));
|
|
@@ -117,7 +117,7 @@ find(users, 'active')
|
|
|
117
117
|
*/
|
|
118
118
|
export function find(arr, fn) {
|
|
119
119
|
if (Array.isArray(arr)) {
|
|
120
|
-
if (
|
|
120
|
+
if (isFunction(fn))
|
|
121
121
|
return arr.find(fn);
|
|
122
122
|
if (isNumber(fn) || isString(fn) || isSymbol(fn))
|
|
123
123
|
return arr.find((x) => x?.[fn]);
|
|
@@ -644,7 +644,7 @@ export function clone(value, deep = false) {
|
|
|
644
644
|
return cloneArray(value, deep);
|
|
645
645
|
}
|
|
646
646
|
if (isObject(value)) {
|
|
647
|
-
if (
|
|
647
|
+
if (isFunction(value.clone)) {
|
|
648
648
|
return value.clone();
|
|
649
649
|
}
|
|
650
650
|
const copy = {};
|
|
@@ -976,7 +976,7 @@ export function remove(arr, func) {
|
|
|
976
976
|
return arr.filter((x, i) => {
|
|
977
977
|
if (isArray(func))
|
|
978
978
|
return !func.includes(x);
|
|
979
|
-
else if (
|
|
979
|
+
else if (isFunction(func))
|
|
980
980
|
return !func(x, i, arr);
|
|
981
981
|
return x !== func;
|
|
982
982
|
});
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
isArrayLike,
|
|
13
13
|
isBool,
|
|
14
14
|
isEmpty,
|
|
15
|
-
|
|
15
|
+
isFunction,
|
|
16
16
|
isIterable,
|
|
17
17
|
isNull,
|
|
18
18
|
isNumber,
|
|
@@ -114,7 +114,7 @@ filter(users, 'active')
|
|
|
114
114
|
*/
|
|
115
115
|
export function filter(arr, fn: Iteratee | PropertyKey | Object = isNull) {
|
|
116
116
|
if (Array.isArray(arr)) {
|
|
117
|
-
if (
|
|
117
|
+
if (isFunction(fn)) return arr.filter(fn)
|
|
118
118
|
if (isNumber(fn) || isString(fn) || isSymbol(fn)) return arr.filter((x) => get(fn, x))
|
|
119
119
|
if (isObject(fn)) return arr.filter(matches(fn))
|
|
120
120
|
}
|
|
@@ -148,7 +148,7 @@ find(users, 'active')
|
|
|
148
148
|
*/
|
|
149
149
|
export function find(arr, fn: Iteratee | PropertyKey | Object) {
|
|
150
150
|
if (Array.isArray(arr)) {
|
|
151
|
-
if (
|
|
151
|
+
if (isFunction(fn)) return arr.find(fn)
|
|
152
152
|
if (isNumber(fn) || isString(fn) || isSymbol(fn)) return arr.find((x) => x?.[fn])
|
|
153
153
|
if (isObject(fn)) return arr.find(matches(fn))
|
|
154
154
|
}
|
|
@@ -672,7 +672,7 @@ export function clone(value, deep = false) {
|
|
|
672
672
|
return cloneArray(value, deep)
|
|
673
673
|
}
|
|
674
674
|
if (isObject(value)) {
|
|
675
|
-
if (
|
|
675
|
+
if (isFunction(value.clone)) {
|
|
676
676
|
return value.clone()
|
|
677
677
|
}
|
|
678
678
|
const copy = {}
|
|
@@ -1015,7 +1015,7 @@ export function groupByMap<K = any, V = any>(
|
|
|
1015
1015
|
export function remove<T>(arr: T[], func: any) {
|
|
1016
1016
|
return arr.filter((x, i) => {
|
|
1017
1017
|
if (isArray(func)) return !func.includes(x)
|
|
1018
|
-
else if (
|
|
1018
|
+
else if (isFunction(func)) return !func(x, i, arr)
|
|
1019
1019
|
return x !== func
|
|
1020
1020
|
})
|
|
1021
1021
|
}
|
|
@@ -47,7 +47,7 @@ export declare const compose: (...args: any[]) => (x: any) => any;
|
|
|
47
47
|
* @param {Function} [resolver] The function to resolve the cache key.
|
|
48
48
|
* @return {Function} Returns the new memoized function.
|
|
49
49
|
*/
|
|
50
|
-
export declare function memoize(func: Function
|
|
50
|
+
export declare function memoize<T>(func: Function<T>, resolver?: Function): Function<ReturnType<typeof func>>;
|
|
51
51
|
export declare function cache(target: any, name: any, descriptor: any): any;
|
|
52
52
|
/**
|
|
53
53
|
* 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.
|
|
@@ -84,7 +84,7 @@ single(3) // => 1
|
|
|
84
84
|
// => `func` is invoked only once.
|
|
85
85
|
```
|
|
86
86
|
*/
|
|
87
|
-
export declare function once(func: Function): (...args: any[]) =>
|
|
87
|
+
export declare function once<T>(func: Function<T>): (...args: any[]) => T;
|
|
88
88
|
export declare type Maybe<T> = T | undefined;
|
|
89
89
|
export declare type Result<T, E = any> = [Maybe<T>, Maybe<E>];
|
|
90
90
|
/**
|
package/core/functools/index.ts
CHANGED
|
@@ -98,7 +98,10 @@ export const compose = (...args) => flow(args.reverse())
|
|
|
98
98
|
* @param {Function} [resolver] The function to resolve the cache key.
|
|
99
99
|
* @return {Function} Returns the new memoized function.
|
|
100
100
|
*/
|
|
101
|
-
export function memoize(
|
|
101
|
+
export function memoize<T>(
|
|
102
|
+
func: Function<T>,
|
|
103
|
+
resolver?: Function
|
|
104
|
+
): Function<ReturnType<typeof func>> {
|
|
102
105
|
const cache = new Map()
|
|
103
106
|
return (...args) => {
|
|
104
107
|
const key = resolver ? resolver(...args) : args[0]
|
|
@@ -188,14 +191,14 @@ single(3) // => 1
|
|
|
188
191
|
// => `func` is invoked only once.
|
|
189
192
|
```
|
|
190
193
|
*/
|
|
191
|
-
export function once(func: Function) {
|
|
194
|
+
export function once<T>(func: Function<T>) {
|
|
192
195
|
let result, isCalled
|
|
193
196
|
return (...args) => {
|
|
194
197
|
if (!isCalled) {
|
|
195
198
|
result = func(...args)
|
|
196
199
|
isCalled = true
|
|
197
200
|
}
|
|
198
|
-
return result
|
|
201
|
+
return result as T
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
204
|
|
package/core/globals/index.d.ts
CHANGED
|
@@ -92,10 +92,15 @@ export declare function type(value: any): any;
|
|
|
92
92
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString | Object.toString }
|
|
93
93
|
*/
|
|
94
94
|
export declare const str: (obj: any) => any;
|
|
95
|
+
export declare function hasOwnProperty(obj: any, prop: any): boolean;
|
|
95
96
|
/** Check if value is a boolean type. */
|
|
96
97
|
export declare const isBool: (x: any) => x is boolean;
|
|
98
|
+
/** Check if value is an `Error` type. */
|
|
99
|
+
export declare const isError: (x: any) => x is Error;
|
|
97
100
|
/** Check if value is an iterable type. */
|
|
98
101
|
export declare const isIterable: (x: any) => x is IterableIterator<any>;
|
|
102
|
+
/** Check if value is a native `Date` type. */
|
|
103
|
+
export declare const isDate: (x: any) => x is Date;
|
|
99
104
|
/** Check if value is an object type. */
|
|
100
105
|
export declare const isObject: (x: any) => x is Object;
|
|
101
106
|
/** Check if value is a string type. */
|
|
@@ -107,28 +112,42 @@ export declare const isArray: (x: any) => x is any[];
|
|
|
107
112
|
* A value is considered array-like if it's not a function and has a `.length` number property.
|
|
108
113
|
*/
|
|
109
114
|
export declare const isArrayLike: (x: any) => boolean;
|
|
110
|
-
/** Check if value is a function type. */
|
|
111
|
-
export declare const isFunc: (x: any) => x is Function<any>;
|
|
112
115
|
/** Check if value is a number type. */
|
|
113
116
|
export declare const isNumber: (x: any) => x is number;
|
|
117
|
+
/** Check if value is an integer number type. */
|
|
118
|
+
export declare const isInteger: (x: any) => x is number;
|
|
114
119
|
/** Check if value is a bigint type. */
|
|
115
120
|
export declare const isBigint: (x: any) => x is BigInt;
|
|
116
121
|
/** Check if value is NaN based on `Number.isNaN`. */
|
|
117
122
|
export declare const isNaN: (x: any) => x is number;
|
|
118
123
|
/** Check if value is a Promise type. */
|
|
119
124
|
export declare const isPromise: (x: any) => x is Promise<any>;
|
|
125
|
+
/** Check if value is a function type. */
|
|
126
|
+
export declare const isFunction: (x: any) => x is Function<any>;
|
|
120
127
|
/** Check if value is an async function type. */
|
|
121
|
-
export declare const
|
|
128
|
+
export declare const isAsyncFunction: (x: any) => boolean;
|
|
122
129
|
/** Check if value is a generator function type. */
|
|
123
130
|
export declare const isGenerator: (x: any) => x is Generator<unknown, any, unknown>;
|
|
124
131
|
/** Check if value is `null` or `undefined`. */
|
|
125
132
|
export declare const isNull: (x: any) => x is null | undefined;
|
|
133
|
+
/** Check if value === `undefined`. */
|
|
134
|
+
export declare function isUndefined(o: any): boolean;
|
|
126
135
|
/** Check if value is not `null` or `undefined`. */
|
|
127
136
|
export declare const notNull: (x: any) => boolean;
|
|
128
137
|
/** Returns `true` for objects without length or falsy values. */
|
|
129
138
|
export declare const isEmpty: (x: any) => boolean;
|
|
139
|
+
/** Check if value is a `RegExp` type */
|
|
140
|
+
export declare const isRegExp: (x: any) => x is RegExp;
|
|
130
141
|
/** Check if value is a `Symbol` type */
|
|
131
142
|
export declare const isSymbol: (x: any) => x is symbol;
|
|
143
|
+
/** Check if value is a `Set` type. */
|
|
144
|
+
export declare const isSet: <T>(x: any) => x is Set<T>;
|
|
145
|
+
/** Check if value is a `Map` type. */
|
|
146
|
+
export declare const isMap: <K, V>(x: any) => x is Map<K, V>;
|
|
147
|
+
/** Check if value is a `WeakSet` type. */
|
|
148
|
+
export declare const isWeakSet: <T extends object>(x: any) => x is WeakSet<T>;
|
|
149
|
+
/** Check if value is a `WeakMap` type. */
|
|
150
|
+
export declare const isWeakMap: <K extends object, V>(x: any) => x is WeakMap<K, V>;
|
|
132
151
|
/**
|
|
133
152
|
* Returns the number of elements in a collection type.
|
|
134
153
|
*
|
package/core/globals/index.js
CHANGED
|
@@ -122,14 +122,21 @@ export function type(value) {
|
|
|
122
122
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString | Object.toString }
|
|
123
123
|
*/
|
|
124
124
|
export const str = (obj) => (obj != null ? obj.toString() : '');
|
|
125
|
+
export function hasOwnProperty(obj, prop) {
|
|
126
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
127
|
+
}
|
|
125
128
|
/** Check if value is a boolean type. */
|
|
126
129
|
export const isBool = (x) => type(x) === 'boolean';
|
|
130
|
+
/** Check if value is an `Error` type. */
|
|
131
|
+
export const isError = (x) => x instanceof Error;
|
|
127
132
|
/** Check if value is an iterable type. */
|
|
128
133
|
export const isIterable = (x) => {
|
|
129
134
|
if (x == null)
|
|
130
135
|
return false;
|
|
131
136
|
return typeof x[Symbol.iterator] === 'function';
|
|
132
137
|
};
|
|
138
|
+
/** Check if value is a native `Date` type. */
|
|
139
|
+
export const isDate = (x) => x instanceof Date;
|
|
133
140
|
/** Check if value is an object type. */
|
|
134
141
|
export const isObject = (x) => typeof x === 'object' && type(x) === 'object';
|
|
135
142
|
/** Check if value is a string type. */
|
|
@@ -144,30 +151,46 @@ export const isArrayLike = (x) => {
|
|
|
144
151
|
const T = type(x);
|
|
145
152
|
return T === 'array' || (T === 'object' && isNumber(x.length));
|
|
146
153
|
};
|
|
147
|
-
/** Check if value is a function type. */
|
|
148
|
-
export const isFunc = (x) => x?.constructor === Function;
|
|
149
154
|
/** Check if value is a number type. */
|
|
150
155
|
export const isNumber = (x) => type(x) === 'number';
|
|
156
|
+
/** Check if value is an integer number type. */
|
|
157
|
+
export const isInteger = (x) => type(x) === 'number' && Math.floor(x) === x;
|
|
151
158
|
/** Check if value is a bigint type. */
|
|
152
159
|
export const isBigint = (x) => type(x) === 'bigint';
|
|
153
160
|
/** Check if value is NaN based on `Number.isNaN`. */
|
|
154
161
|
export const isNaN = (x) => Number.isNaN(x);
|
|
155
162
|
/** Check if value is a Promise type. */
|
|
156
163
|
export const isPromise = (x) => type(x) === 'Promise';
|
|
164
|
+
/** Check if value is a function type. */
|
|
165
|
+
export const isFunction = (x) => x?.constructor === Function;
|
|
157
166
|
/** Check if value is an async function type. */
|
|
158
|
-
export const
|
|
167
|
+
export const isAsyncFunction = (x) => x?.constructor.name === 'AsyncFunction';
|
|
159
168
|
/** Check if value is a generator function type. */
|
|
160
169
|
export const isGenerator = (x) => {
|
|
161
170
|
return x?.constructor.constructor?.name === 'GeneratorFunction';
|
|
162
171
|
};
|
|
163
172
|
/** Check if value is `null` or `undefined`. */
|
|
164
173
|
export const isNull = (x) => x == null;
|
|
174
|
+
/** Check if value === `undefined`. */
|
|
175
|
+
export function isUndefined(o) {
|
|
176
|
+
return typeof o === 'undefined';
|
|
177
|
+
}
|
|
165
178
|
/** Check if value is not `null` or `undefined`. */
|
|
166
179
|
export const notNull = (x) => x != null;
|
|
167
180
|
/** Returns `true` for objects without length or falsy values. */
|
|
168
181
|
export const isEmpty = (x) => (len(x) === 0 ? true : !x);
|
|
182
|
+
/** Check if value is a `RegExp` type */
|
|
183
|
+
export const isRegExp = (x) => x instanceof RegExp;
|
|
169
184
|
/** Check if value is a `Symbol` type */
|
|
170
185
|
export const isSymbol = (x) => type(x) === 'symbol';
|
|
186
|
+
/** Check if value is a `Set` type. */
|
|
187
|
+
export const isSet = (x) => x instanceof Set;
|
|
188
|
+
/** Check if value is a `Map` type. */
|
|
189
|
+
export const isMap = (x) => x instanceof Map;
|
|
190
|
+
/** Check if value is a `WeakSet` type. */
|
|
191
|
+
export const isWeakSet = (x) => x instanceof WeakSet;
|
|
192
|
+
/** Check if value is a `WeakMap` type. */
|
|
193
|
+
export const isWeakMap = (x) => x instanceof WeakMap;
|
|
171
194
|
/**
|
|
172
195
|
* Returns the number of elements in a collection type.
|
|
173
196
|
*
|
|
@@ -182,7 +205,7 @@ export function len(value) {
|
|
|
182
205
|
if (isNumber(value.length)) {
|
|
183
206
|
return value.length;
|
|
184
207
|
}
|
|
185
|
-
if (
|
|
208
|
+
if (isFunction(value.size)) {
|
|
186
209
|
return value.size();
|
|
187
210
|
}
|
|
188
211
|
if (isNumber(value.size)) {
|
|
@@ -229,7 +252,7 @@ export const uuid = () => {
|
|
|
229
252
|
* @return `obj.key(...args)` or `undefined`.
|
|
230
253
|
*/
|
|
231
254
|
export function call(obj, key, ...args) {
|
|
232
|
-
if (
|
|
255
|
+
if (isFunction(get(key, obj))) {
|
|
233
256
|
return obj[key](...args);
|
|
234
257
|
}
|
|
235
258
|
}
|
package/core/globals/index.ts
CHANGED
|
@@ -142,15 +142,25 @@ export function type(value) {
|
|
|
142
142
|
*/
|
|
143
143
|
export const str = (obj) => (obj != null ? obj.toString() : '')
|
|
144
144
|
|
|
145
|
+
export function hasOwnProperty(obj, prop) {
|
|
146
|
+
return Object.prototype.hasOwnProperty.call(obj, prop)
|
|
147
|
+
}
|
|
148
|
+
|
|
145
149
|
/** Check if value is a boolean type. */
|
|
146
150
|
export const isBool = (x): x is boolean => type(x) === 'boolean'
|
|
147
151
|
|
|
152
|
+
/** Check if value is an `Error` type. */
|
|
153
|
+
export const isError = (x): x is Error => x instanceof Error
|
|
154
|
+
|
|
148
155
|
/** Check if value is an iterable type. */
|
|
149
156
|
export const isIterable = (x): x is IterableIterator<any> => {
|
|
150
157
|
if (x == null) return false
|
|
151
158
|
return typeof x[Symbol.iterator] === 'function'
|
|
152
159
|
}
|
|
153
160
|
|
|
161
|
+
/** Check if value is a native `Date` type. */
|
|
162
|
+
export const isDate = (x): x is Date => x instanceof Date
|
|
163
|
+
|
|
154
164
|
/** Check if value is an object type. */
|
|
155
165
|
export const isObject = (x): x is Object => typeof x === 'object' && type(x) === 'object'
|
|
156
166
|
|
|
@@ -169,12 +179,12 @@ export const isArrayLike = (x) => {
|
|
|
169
179
|
return T === 'array' || (T === 'object' && isNumber(x.length))
|
|
170
180
|
}
|
|
171
181
|
|
|
172
|
-
/** Check if value is a function type. */
|
|
173
|
-
export const isFunc = (x): x is Function => x?.constructor === Function
|
|
174
|
-
|
|
175
182
|
/** Check if value is a number type. */
|
|
176
183
|
export const isNumber = (x): x is number => type(x) === 'number'
|
|
177
184
|
|
|
185
|
+
/** Check if value is an integer number type. */
|
|
186
|
+
export const isInteger = (x): x is number => type(x) === 'number' && Math.floor(x) === x
|
|
187
|
+
|
|
178
188
|
/** Check if value is a bigint type. */
|
|
179
189
|
export const isBigint = (x): x is BigInt => type(x) === 'bigint'
|
|
180
190
|
|
|
@@ -184,8 +194,11 @@ export const isNaN = (x): x is typeof NaN => Number.isNaN(x)
|
|
|
184
194
|
/** Check if value is a Promise type. */
|
|
185
195
|
export const isPromise = (x): x is Promise<any> => type(x) === 'Promise'
|
|
186
196
|
|
|
197
|
+
/** Check if value is a function type. */
|
|
198
|
+
export const isFunction = (x): x is Function => x?.constructor === Function
|
|
199
|
+
|
|
187
200
|
/** Check if value is an async function type. */
|
|
188
|
-
export const
|
|
201
|
+
export const isAsyncFunction = (x) => x?.constructor.name === 'AsyncFunction'
|
|
189
202
|
|
|
190
203
|
/** Check if value is a generator function type. */
|
|
191
204
|
export const isGenerator = (x): x is Generator => {
|
|
@@ -195,15 +208,35 @@ export const isGenerator = (x): x is Generator => {
|
|
|
195
208
|
/** Check if value is `null` or `undefined`. */
|
|
196
209
|
export const isNull = (x): x is null | undefined => x == null
|
|
197
210
|
|
|
211
|
+
/** Check if value === `undefined`. */
|
|
212
|
+
export function isUndefined(o) {
|
|
213
|
+
return typeof o === 'undefined'
|
|
214
|
+
}
|
|
215
|
+
|
|
198
216
|
/** Check if value is not `null` or `undefined`. */
|
|
199
217
|
export const notNull = (x) => x != null
|
|
200
218
|
|
|
201
219
|
/** Returns `true` for objects without length or falsy values. */
|
|
202
220
|
export const isEmpty = (x) => (len(x) === 0 ? true : !x)
|
|
203
221
|
|
|
222
|
+
/** Check if value is a `RegExp` type */
|
|
223
|
+
export const isRegExp = (x): x is RegExp => x instanceof RegExp
|
|
224
|
+
|
|
204
225
|
/** Check if value is a `Symbol` type */
|
|
205
226
|
export const isSymbol = (x): x is symbol => type(x) === 'symbol'
|
|
206
227
|
|
|
228
|
+
/** Check if value is a `Set` type. */
|
|
229
|
+
export const isSet = <T>(x): x is Set<T> => x instanceof Set
|
|
230
|
+
|
|
231
|
+
/** Check if value is a `Map` type. */
|
|
232
|
+
export const isMap = <K, V>(x): x is Map<K, V> => x instanceof Map
|
|
233
|
+
|
|
234
|
+
/** Check if value is a `WeakSet` type. */
|
|
235
|
+
export const isWeakSet = <T extends object>(x): x is WeakSet<T> => x instanceof WeakSet
|
|
236
|
+
|
|
237
|
+
/** Check if value is a `WeakMap` type. */
|
|
238
|
+
export const isWeakMap = <K extends object, V>(x): x is WeakMap<K, V> => x instanceof WeakMap
|
|
239
|
+
|
|
207
240
|
/**
|
|
208
241
|
* Returns the number of elements in a collection type.
|
|
209
242
|
*
|
|
@@ -217,7 +250,7 @@ export function len(value) {
|
|
|
217
250
|
if (isNumber(value.length)) {
|
|
218
251
|
return value.length
|
|
219
252
|
}
|
|
220
|
-
if (
|
|
253
|
+
if (isFunction(value.size)) {
|
|
221
254
|
return value.size()
|
|
222
255
|
}
|
|
223
256
|
if (isNumber(value.size)) {
|
|
@@ -267,7 +300,7 @@ export const uuid = () => {
|
|
|
267
300
|
* @return `obj.key(...args)` or `undefined`.
|
|
268
301
|
*/
|
|
269
302
|
export function call(obj: any, key: PropertyKey, ...args: any[]) {
|
|
270
|
-
if (
|
|
303
|
+
if (isFunction(get(key, obj))) {
|
|
271
304
|
return obj[key](...args)
|
|
272
305
|
}
|
|
273
306
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a new Date from the given arguments.
|
|
3
|
+
* @param {string | number | Date} date The date value
|
|
4
|
+
* @param {?boolean} [utc=false] Interprets the given value as a UTC date
|
|
5
|
+
* @returns {Date} The new date object
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDate(date: string | number | Date, utc?: boolean): Date;
|
|
8
|
+
/**
|
|
9
|
+
* Formats a date using a formatting string in the {@link https://strftime.org/ strftime} format, in any given locale.
|
|
10
|
+
* @param {string} fmt The format string to apply
|
|
11
|
+
* @param {number | Date} date The date value
|
|
12
|
+
* @param {?string} locale The locale to use when formatting (default is system locale).
|
|
13
|
+
* @returns {string} The string representation of date
|
|
14
|
+
* @see {@link https://strftime.org/ strftime format}
|
|
15
|
+
*/
|
|
16
|
+
export declare function format(fmt: string, date: number | Date, locale?: any): string;
|