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
package/core/operators/index.ts
CHANGED
|
@@ -66,7 +66,7 @@ export function compare(x, y): number {
|
|
|
66
66
|
* @returns {boolean} `true` if `x` and `y` are equal or `false` otherwise.
|
|
67
67
|
*/
|
|
68
68
|
export function eq(x, y) {
|
|
69
|
-
return x
|
|
69
|
+
return Object.is(x, y) || call(x, 'eq', y) != null
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -245,10 +245,11 @@ export function shallowEqual(obj, other) {
|
|
|
245
245
|
* @param other
|
|
246
246
|
* @returns `true` if the objects are considered equal.
|
|
247
247
|
*/
|
|
248
|
-
export function deepEqual(obj, other, checker = eq) {
|
|
248
|
+
export function deepEqual(obj, other, checker = eq, seen = new WeakSet()) {
|
|
249
249
|
if (checker(obj, other)) return true
|
|
250
|
-
|
|
251
250
|
if (!obj || !other) return false
|
|
251
|
+
if (obj.prototype !== other.prototype) return false
|
|
252
|
+
if (seen.has(obj) && seen.has(other)) return false
|
|
252
253
|
|
|
253
254
|
if (Array.isArray(obj)) {
|
|
254
255
|
// compare the arrays
|
|
@@ -259,18 +260,45 @@ export function deepEqual(obj, other, checker = eq) {
|
|
|
259
260
|
return false
|
|
260
261
|
}
|
|
261
262
|
}
|
|
263
|
+
|
|
262
264
|
return true
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (obj instanceof Set) {
|
|
268
|
+
if (obj.size !== other.size) return false
|
|
269
|
+
for (const value of obj.values()) {
|
|
270
|
+
if (!other.has(value)) return false
|
|
271
|
+
}
|
|
272
|
+
return true
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (obj instanceof Map) {
|
|
276
|
+
// compare keys and values
|
|
277
|
+
if (obj.size !== other.size) return false
|
|
278
|
+
seen.add(obj)
|
|
279
|
+
seen.add(other)
|
|
280
|
+
for (const key of obj.keys()) {
|
|
281
|
+
if (!other.has(key)) return false
|
|
282
|
+
if (!deepEqual(obj.get(key), other.get(key), checker, seen)) {
|
|
283
|
+
return false
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return true
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (isObject(obj)) {
|
|
290
|
+
// compare the object own enumerable keys
|
|
265
291
|
const objKeys = Object.keys(obj)
|
|
266
292
|
const otherKeys = Object.keys(other)
|
|
267
293
|
|
|
268
294
|
if (objKeys.length !== otherKeys.length) return false
|
|
269
295
|
|
|
296
|
+
seen.add(obj)
|
|
297
|
+
seen.add(other)
|
|
270
298
|
for (const key of objKeys) {
|
|
271
299
|
if (
|
|
272
300
|
!Object.prototype.hasOwnProperty.call(other, key) ||
|
|
273
|
-
!deepEqual(obj[key], other[key], checker)
|
|
301
|
+
!deepEqual(obj[key], other[key], checker, seen)
|
|
274
302
|
) {
|
|
275
303
|
return false
|
|
276
304
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atomic-fns",
|
|
3
3
|
"description": "Like Lodash, but for ESNext and with types. Stop shipping code built for browsers from 2015.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"main": "core/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "core/index.d.ts",
|
|
8
8
|
"module": "core/index.js",
|
|
9
9
|
"sideEffects": false,
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prepublishOnly": "npm test",
|
|
12
|
+
"test": "NODE_OPTIONS=--loader=ts-node/esm jasmine --config=jasmine.json",
|
|
13
|
+
"tsc": "tsc -p ./tsconfig.xo.json --declaration",
|
|
14
|
+
"tsc:w": "tsc -p ./tsconfig.xo.json --declaration --watch",
|
|
15
|
+
"lint": "eslint core/**/*.ts",
|
|
16
|
+
"lint:fix": "eslint core/**/*.ts --fix",
|
|
17
|
+
"build": "npm run lint:fix && npm run tsc && npm run docs",
|
|
18
|
+
"docs": "typedoc"
|
|
19
|
+
},
|
|
10
20
|
"devDependencies": {
|
|
11
21
|
"@types/jasmine": "^4.3.0",
|
|
12
22
|
"@typescript-eslint/eslint-plugin": "^5.39.0",
|
|
@@ -27,16 +37,6 @@
|
|
|
27
37
|
"typedoc": "^0.23.16",
|
|
28
38
|
"typescript": "^4.8.4"
|
|
29
39
|
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"prepublishOnly": "npm test",
|
|
32
|
-
"test": "NODE_OPTIONS=--loader=ts-node/esm jasmine --config=jasmine.json",
|
|
33
|
-
"tsc": "tsc -p ./tsconfig.xo.json --declaration",
|
|
34
|
-
"tsc:w": "tsc -p ./tsconfig.xo.json --declaration --watch",
|
|
35
|
-
"lint": "eslint core/**/*.ts",
|
|
36
|
-
"lint:fix": "eslint core/**/*.ts --fix",
|
|
37
|
-
"build": "npm run lint:fix && npm run tsc && npm run docs",
|
|
38
|
-
"docs": "typedoc"
|
|
39
|
-
},
|
|
40
40
|
"lint-staged": {
|
|
41
41
|
"*.ts": "eslint --fix"
|
|
42
42
|
},
|
package/tests/globals.spec.ts
CHANGED
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
hex,
|
|
13
13
|
isArray,
|
|
14
14
|
isArrayLike,
|
|
15
|
-
|
|
15
|
+
isAsyncFunction,
|
|
16
16
|
isBigint,
|
|
17
17
|
isBool,
|
|
18
18
|
isEmpty,
|
|
19
|
-
|
|
19
|
+
isFunction,
|
|
20
20
|
isNaN,
|
|
21
21
|
isNull,
|
|
22
22
|
isNumber,
|
|
@@ -114,15 +114,15 @@ describe('globals', () => {
|
|
|
114
114
|
assert(!isArrayLike(''))
|
|
115
115
|
})
|
|
116
116
|
|
|
117
|
-
it('
|
|
118
|
-
assert(
|
|
119
|
-
assert(!
|
|
117
|
+
it('isFunction', () => {
|
|
118
|
+
assert(isFunction(_))
|
|
119
|
+
assert(!isFunction([]))
|
|
120
120
|
})
|
|
121
121
|
|
|
122
|
-
it('
|
|
123
|
-
assert(
|
|
124
|
-
assert(
|
|
125
|
-
assert(!
|
|
122
|
+
it('isAsyncFunction', () => {
|
|
123
|
+
assert(isAsyncFunction(async function () {}))
|
|
124
|
+
assert(isAsyncFunction(async () => {}))
|
|
125
|
+
assert(!isAsyncFunction(_))
|
|
126
126
|
})
|
|
127
127
|
|
|
128
128
|
it('isNaN', () => {
|
package/tsconfig.json
CHANGED
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
"./core/collections/index.ts",
|
|
111
111
|
"./core/datetime/index.ts",
|
|
112
112
|
"./core/functools/index.ts",
|
|
113
|
+
"./core/i18n/index.ts",
|
|
113
114
|
"./core/itertools/index.ts",
|
|
114
115
|
"./core/math/index.ts",
|
|
115
116
|
"./core/operators/index.ts",
|
|
@@ -122,4 +123,4 @@
|
|
|
122
123
|
"excludeExternals": true,
|
|
123
124
|
"excludePrivate": true,
|
|
124
125
|
}
|
|
125
|
-
}
|
|
126
|
+
}
|