atomic-fns 0.3.1 → 0.3.3-beta

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.
Files changed (84) hide show
  1. package/.esdoc.json +2 -2
  2. package/README.md +62 -13
  3. package/core/collections/BTree.d.ts +229 -0
  4. package/core/collections/BTree.js +1165 -0
  5. package/core/collections/BTree.ts +1340 -0
  6. package/core/collections/Heap.d.ts +69 -0
  7. package/core/collections/Heap.js +181 -0
  8. package/core/collections/Heap.ts +189 -0
  9. package/core/collections/LRUCache.d.ts +152 -0
  10. package/core/collections/LRUCache.js +409 -0
  11. package/core/collections/LRUCache.ts +486 -0
  12. package/core/collections/SortedMap.d.ts +92 -0
  13. package/core/collections/SortedMap.js +130 -0
  14. package/core/collections/SortedMap.ts +146 -0
  15. package/core/collections/SortedSet.d.ts +69 -0
  16. package/core/collections/SortedSet.js +99 -0
  17. package/core/collections/SortedSet.ts +110 -0
  18. package/core/collections/SortedTree.d.ts +103 -0
  19. package/core/collections/SortedTree.js +141 -0
  20. package/core/collections/SortedTree.ts +160 -0
  21. package/core/collections/SplayTree.d.ts +105 -0
  22. package/core/collections/SplayTree.js +338 -0
  23. package/core/collections/SplayTree.ts +354 -0
  24. package/core/collections/abc.d.ts +152 -0
  25. package/core/collections/abc.js +39 -0
  26. package/core/collections/abc.ts +176 -0
  27. package/core/collections/deque.d.ts +110 -0
  28. package/core/collections/deque.js +285 -0
  29. package/core/collections/deque.ts +329 -0
  30. package/core/collections/frozenset.d.ts +19 -0
  31. package/core/collections/frozenset.js +33 -0
  32. package/core/collections/frozenset.ts +37 -0
  33. package/{src → core}/collections/index.d.ts +43 -162
  34. package/{src → core}/collections/index.js +59 -165
  35. package/{src → core}/collections/index.ts +64 -226
  36. package/core/collections/test.html +10 -0
  37. package/core/collections/typedArrays.d.ts +31 -0
  38. package/core/collections/typedArrays.js +143 -0
  39. package/core/collections/typedArrays.ts +163 -0
  40. package/{src → core}/functools/index.d.ts +2 -2
  41. package/{src → core}/functools/index.js +2 -2
  42. package/{src → core}/functools/index.ts +2 -2
  43. package/{src → core}/globals/index.d.ts +2 -7
  44. package/{src → core}/globals/index.js +5 -2
  45. package/{src → core}/globals/index.ts +6 -9
  46. package/{src → core}/index.d.ts +0 -1
  47. package/{src → core}/index.js +0 -1
  48. package/{src → core}/index.ts +0 -1
  49. package/{src → core}/itertools/index.d.ts +9 -7
  50. package/{src → core}/itertools/index.js +25 -9
  51. package/{src → core}/itertools/index.ts +39 -16
  52. package/{src → core}/math/index.d.ts +0 -0
  53. package/{src → core}/math/index.js +0 -0
  54. package/{src → core}/math/index.ts +0 -0
  55. package/core/operators/index.d.ts +148 -0
  56. package/core/operators/index.js +271 -0
  57. package/core/operators/index.ts +282 -0
  58. package/{src → core}/random/index.d.ts +0 -0
  59. package/{src → core}/random/index.js +0 -0
  60. package/{src → core}/random/index.ts +0 -0
  61. package/package.json +6 -6
  62. package/tests/BTree.spec.ts +143 -0
  63. package/tests/Cache.spec.ts +161 -0
  64. package/tests/Heap.spec.ts +66 -0
  65. package/tests/SortedMap.spec.ts +144 -0
  66. package/tests/SortedSet.spec.ts +84 -0
  67. package/tests/SortedTree.spec.ts +164 -0
  68. package/tests/SplayTree.spec.ts +121 -0
  69. package/tests/collections.spec.ts +1 -1
  70. package/tests/deque.spec.ts +107 -0
  71. package/tests/globals.spec.ts +2 -2
  72. package/tests/itertools.spec.ts +2 -2
  73. package/tests/math.spec.ts +1 -1
  74. package/tests/operators.spec.ts +5 -5
  75. package/tests/random.spec.ts +10 -10
  76. package/tsconfig.json +10 -10
  77. package/tsconfig.node.json +2 -2
  78. package/tsconfig.xo.json +2 -2
  79. package/src/datetime/index.d.ts +0 -6
  80. package/src/datetime/index.js +0 -6
  81. package/src/datetime/index.ts +0 -7
  82. package/src/operators/index.d.ts +0 -31
  83. package/src/operators/index.js +0 -171
  84. package/src/operators/index.ts +0 -175
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Generic operations for both values and objects.
3
+ *
4
+ * @module Operators
5
+ */
6
+ import { call, isObject } from '../globals/index.js';
7
+ /** This is the identity function. It always returns the same value that was passed in */
8
+ export const id = (x) => x;
9
+ /**
10
+ * Called to implement truth value testing.
11
+ * @param x
12
+ * @returns {boolean} `x.bool()` if exists or `!!x`.
13
+ */
14
+ export const bool = (x) => {
15
+ const r = call(x, 'bool');
16
+ if (r != null)
17
+ return r;
18
+ return !!x;
19
+ };
20
+ /**
21
+ * Returns `true` if `x` is a falsy value.
22
+ * @see {@link bool}
23
+ */
24
+ export const not = (x) => !bool(x);
25
+ /**
26
+ * Returns `true` if `x` is an instance of class `y`
27
+ * @param x The instance object
28
+ * @param y The parent class
29
+ * @returns {boolean}
30
+ */
31
+ export const isinstance = (x, y) => x instanceof y;
32
+ /**
33
+ * Checks whether `x` is a comparable type and returns the result of `x.compare(y)`.
34
+ * Otherwise the return value of the compare function is equivalent to `obj === other ? 0 : obj < other ? -1 : 1`
35
+ * @param {*} x An initial value
36
+ * @param {*} y Other value to compare
37
+ * @returns {number} The comparison result
38
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#parameters Array.sort()}
39
+ * @see {@link eq}
40
+ * @see {@link lt}
41
+ */
42
+ export function compare(x, y) {
43
+ if (x === y || eq(x, y))
44
+ return 0;
45
+ const op = call(x, 'compare', y);
46
+ if (typeof op === 'number')
47
+ return op;
48
+ if (x < y || lt(x, y))
49
+ return -1;
50
+ return 1;
51
+ }
52
+ /**
53
+ * Compares two values to check if they are the same. If `x` is an object with an `eq` method, it returns `x.eq(y)`.
54
+ * Otherwise it returns the result of `x === y`.
55
+ * @param {*} x
56
+ * @param {*} y
57
+ * @returns {boolean} `true` if `x` and `y` are equal or `false` otherwise.
58
+ */
59
+ export function eq(x, y) {
60
+ return x === y || call(x, 'eq', y) != null;
61
+ }
62
+ /**
63
+ * Compares two values to check if `x` is strictly less than `y`. If `x` is an object with a `lt` method, it returns `x.lt(y)`.
64
+ * Otherwise it returns the result of `x < y`.
65
+ * @param {*} x
66
+ * @param {*} y
67
+ * @returns {boolean} `true` if `x` is strictly less than `y` or `false` otherwise.
68
+ */
69
+ export function lt(x, y) {
70
+ return x < y || call(x, 'lt', y) != null;
71
+ }
72
+ /**
73
+ * Compares two values to check if `x <= y`. If `x` is an object with a `lte` method, it returns `x.lte(y)`, also checks `x.eq(y)` and `x.lt(y)`.
74
+ * Otherwise it returns the result of `x <= y`.
75
+ * @param {*} x
76
+ * @param {*} y
77
+ * @returns {boolean} `true` if `x` is less than or equal to `y` or `false` otherwise.
78
+ * @see {@link eq}
79
+ * @see {@link lt}
80
+ */
81
+ export function lte(x, y) {
82
+ if (x <= y || call(x, 'lte', y))
83
+ return true;
84
+ if (x === y || eq(x, y))
85
+ return true;
86
+ if (x < y || lt(x, y))
87
+ return true;
88
+ return false;
89
+ }
90
+ /**
91
+ * Compares two values to check if `x` is strictly greater than `y`. If `x` is an object with a `gt` method, it returns `x.gt(y)`.
92
+ * Otherwise it returns the result of `x > y`.
93
+ * @param {*} x
94
+ * @param {*} y
95
+ * @returns {boolean} `true` if `x` is strictly greater than `y` or `false` otherwise.
96
+ */
97
+ export function gt(x, y) {
98
+ return x > y || call(x, 'gt', y);
99
+ }
100
+ /**
101
+ * Compares two values to check if `x >= y`. If `x` is an object with a `gte` method, it returns `x.gte(y)`, also checks `x.eq(y)` and `x.gt(y)`.
102
+ * Otherwise it returns the result of `x >= y`.
103
+ * @param {*} x
104
+ * @param {*} y
105
+ * @returns {boolean} `true` if `x` is less greater than or equal to `y` or `false` otherwise.
106
+ * @see {@link eq}
107
+ * @see {@link gt}
108
+ */
109
+ export function gte(x, y) {
110
+ if (x <= y || call(x, 'gte', y))
111
+ return true;
112
+ if (x === y || eq(x, y))
113
+ return true;
114
+ if (x > y || gt(x, y))
115
+ return true;
116
+ return false;
117
+ }
118
+ /**
119
+ * The addition (+) operator. If `x` is an object with an `add` method, it returns `x.add(y)`.
120
+ * Otherwise it returns the result of `x + y`.
121
+ * @param {*} x
122
+ * @param {*} y
123
+ * @returns {*} x + y
124
+ */
125
+ export function add(x, y) {
126
+ const op = call(x, 'add', y);
127
+ if (op != null)
128
+ return op;
129
+ return x + y;
130
+ }
131
+ /**
132
+ * The subtraction (-) operator. If `x` is an object with a `sub` method, it returns `x.sub(y)`.
133
+ * Otherwise it returns the result of `x - y`.
134
+ * @param {*} x
135
+ * @param {*} y
136
+ * @returns {*} x - y
137
+ */
138
+ export function sub(x, y) {
139
+ const op = call(x, 'sub', y);
140
+ if (op != null)
141
+ return op;
142
+ return x - y;
143
+ }
144
+ /**
145
+ * The multiplication (*) operator. If `x` is an object with an `mul` method, it returns `x.mul(y)`.
146
+ * Otherwise it returns the result of `x * y`.
147
+ * @param {*} x
148
+ * @param {*} y
149
+ * @returns {*} x * y
150
+ */
151
+ export function mul(x, y) {
152
+ const op = call(x, 'mul', y);
153
+ if (op != null)
154
+ return op;
155
+ return x * y;
156
+ }
157
+ /**
158
+ * The division (/) operator. If `x` is an object with a `div` method, it returns `x.div(y)`.
159
+ * Otherwise it returns the result of `x / y`.
160
+ * @param {*} x
161
+ * @param {*} y
162
+ * @returns {*} x / y
163
+ */
164
+ export function div(x, y) {
165
+ const op = call(x, 'div', y);
166
+ if (op != null)
167
+ return op;
168
+ return x / y;
169
+ }
170
+ /**
171
+ * The modulo (%) operator. If `x` is an object with a `mod` method, it returns `x.mod(y)`.
172
+ * Otherwise it returns the result of `x % y`.
173
+ * @param {*} x
174
+ * @param {*} y
175
+ * @returns {*} x % y
176
+ */
177
+ export function mod(x, y) {
178
+ const op = call(x, 'mod', y);
179
+ if (op != null)
180
+ return op;
181
+ return x % y;
182
+ }
183
+ /**
184
+ * The power (**) operator. If `x` is an object with a `pow` method, it returns `x.pow(y)`.
185
+ * Otherwise it returns the result of `x ** y`.
186
+ * @param {*} x
187
+ * @param {*} y
188
+ * @returns {*} x ** y
189
+ */
190
+ export function pow(x, y) {
191
+ const op = call(x, 'pow', y);
192
+ if (op != null)
193
+ return op;
194
+ return x ** y;
195
+ }
196
+ /**
197
+ * Performs a shallow comparison of two objects or arrays to check if they have the same keys, length and values.
198
+ * @param obj
199
+ * @param other
200
+ * @returns `true` if the objects are considered equal.
201
+ * @see {@link deepEqual}
202
+ */
203
+ export function shallowEqual(obj, other) {
204
+ if (obj === other)
205
+ return true;
206
+ if (!obj || !other)
207
+ return false;
208
+ if (Array.isArray(obj)) {
209
+ // compare the arrays
210
+ if (obj.length !== other.length)
211
+ return false;
212
+ for (let i = 0; i < obj.length; i++) {
213
+ if (obj[i] !== other[i]) {
214
+ return false;
215
+ }
216
+ }
217
+ return true;
218
+ }
219
+ else if (isObject(obj)) {
220
+ // compare the object keys
221
+ const objKeys = Object.keys(obj);
222
+ const otherKeys = Object.keys(other);
223
+ if (objKeys.length !== otherKeys.length)
224
+ return false;
225
+ for (const key of objKeys) {
226
+ if (!Object.prototype.hasOwnProperty.call(other, key) || obj[key] !== other[key]) {
227
+ return false;
228
+ }
229
+ }
230
+ return true;
231
+ }
232
+ return false;
233
+ }
234
+ /**
235
+ * Performs a recursive comparison of two objects or arrays to check if they have the same keys, length and values. Unlike {@link shallowEqual} this method compares nested values also.
236
+ * @param obj
237
+ * @param other
238
+ * @returns `true` if the objects are considered equal.
239
+ */
240
+ export function deepEqual(obj, other, checker = eq) {
241
+ if (checker(obj, other))
242
+ return true;
243
+ if (!obj || !other)
244
+ return false;
245
+ if (Array.isArray(obj)) {
246
+ // compare the arrays
247
+ if (obj.length !== other.length)
248
+ return false;
249
+ for (let i = 0; i < obj.length; i++) {
250
+ if (!deepEqual(obj[i], other[i], checker)) {
251
+ return false;
252
+ }
253
+ }
254
+ return true;
255
+ }
256
+ else if (isObject(obj)) {
257
+ // compare the object keys
258
+ const objKeys = Object.keys(obj);
259
+ const otherKeys = Object.keys(other);
260
+ if (objKeys.length !== otherKeys.length)
261
+ return false;
262
+ for (const key of objKeys) {
263
+ if (!Object.prototype.hasOwnProperty.call(other, key) ||
264
+ !deepEqual(obj[key], other[key], checker)) {
265
+ return false;
266
+ }
267
+ }
268
+ return true;
269
+ }
270
+ return false;
271
+ }
@@ -0,0 +1,282 @@
1
+ /**
2
+ * Generic operations for both values and objects.
3
+ *
4
+ * @module Operators
5
+ */
6
+
7
+ import { call, isObject } from '../globals/index.js'
8
+
9
+ /** This is the identity function. It always returns the same value that was passed in */
10
+ export const id = (x) => x
11
+
12
+ /**
13
+ * Called to implement truth value testing.
14
+ * @param x
15
+ * @returns {boolean} `x.bool()` if exists or `!!x`.
16
+ */
17
+ export const bool = (x) => {
18
+ const r = call(x, 'bool')
19
+ if (r != null) return r
20
+ return !!x
21
+ }
22
+
23
+ /**
24
+ * Returns `true` if `x` is a falsy value.
25
+ * @see {@link bool}
26
+ */
27
+ export const not = (x) => !bool(x)
28
+
29
+ /**
30
+ * Returns `true` if `x` is an instance of class `y`
31
+ * @param x The instance object
32
+ * @param y The parent class
33
+ * @returns {boolean}
34
+ */
35
+ export const isinstance = (x, y) => x instanceof y
36
+
37
+ /** Describes a function used to compare two values.
38
+ *
39
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#parameters Array.sort()}
40
+ */
41
+ export type Comparer<T = any> = (x: T, y: T) => number
42
+
43
+ /**
44
+ * Checks whether `x` is a comparable type and returns the result of `x.compare(y)`.
45
+ * Otherwise the return value of the compare function is equivalent to `obj === other ? 0 : obj < other ? -1 : 1`
46
+ * @param {*} x An initial value
47
+ * @param {*} y Other value to compare
48
+ * @returns {number} The comparison result
49
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#parameters Array.sort()}
50
+ * @see {@link eq}
51
+ * @see {@link lt}
52
+ */
53
+ export function compare(x, y): number {
54
+ if (x === y || eq(x, y)) return 0
55
+ const op = call(x, 'compare', y)
56
+ if (typeof op === 'number') return op
57
+ if (x < y || lt(x, y)) return -1
58
+ return 1
59
+ }
60
+
61
+ /**
62
+ * Compares two values to check if they are the same. If `x` is an object with an `eq` method, it returns `x.eq(y)`.
63
+ * Otherwise it returns the result of `x === y`.
64
+ * @param {*} x
65
+ * @param {*} y
66
+ * @returns {boolean} `true` if `x` and `y` are equal or `false` otherwise.
67
+ */
68
+ export function eq(x, y) {
69
+ return x === y || call(x, 'eq', y) != null
70
+ }
71
+
72
+ /**
73
+ * Compares two values to check if `x` is strictly less than `y`. If `x` is an object with a `lt` method, it returns `x.lt(y)`.
74
+ * Otherwise it returns the result of `x < y`.
75
+ * @param {*} x
76
+ * @param {*} y
77
+ * @returns {boolean} `true` if `x` is strictly less than `y` or `false` otherwise.
78
+ */
79
+ export function lt(x, y) {
80
+ return x < y || call(x, 'lt', y) != null
81
+ }
82
+
83
+ /**
84
+ * Compares two values to check if `x <= y`. If `x` is an object with a `lte` method, it returns `x.lte(y)`, also checks `x.eq(y)` and `x.lt(y)`.
85
+ * Otherwise it returns the result of `x <= y`.
86
+ * @param {*} x
87
+ * @param {*} y
88
+ * @returns {boolean} `true` if `x` is less than or equal to `y` or `false` otherwise.
89
+ * @see {@link eq}
90
+ * @see {@link lt}
91
+ */
92
+ export function lte(x, y) {
93
+ if (x <= y || call(x, 'lte', y)) return true
94
+ if (x === y || eq(x, y)) return true
95
+ if (x < y || lt(x, y)) return true
96
+ return false
97
+ }
98
+
99
+ /**
100
+ * Compares two values to check if `x` is strictly greater than `y`. If `x` is an object with a `gt` method, it returns `x.gt(y)`.
101
+ * Otherwise it returns the result of `x > y`.
102
+ * @param {*} x
103
+ * @param {*} y
104
+ * @returns {boolean} `true` if `x` is strictly greater than `y` or `false` otherwise.
105
+ */
106
+ export function gt(x, y) {
107
+ return x > y || call(x, 'gt', y)
108
+ }
109
+
110
+ /**
111
+ * Compares two values to check if `x >= y`. If `x` is an object with a `gte` method, it returns `x.gte(y)`, also checks `x.eq(y)` and `x.gt(y)`.
112
+ * Otherwise it returns the result of `x >= y`.
113
+ * @param {*} x
114
+ * @param {*} y
115
+ * @returns {boolean} `true` if `x` is less greater than or equal to `y` or `false` otherwise.
116
+ * @see {@link eq}
117
+ * @see {@link gt}
118
+ */
119
+ export function gte(x, y) {
120
+ if (x <= y || call(x, 'gte', y)) return true
121
+ if (x === y || eq(x, y)) return true
122
+ if (x > y || gt(x, y)) return true
123
+ return false
124
+ }
125
+
126
+ /**
127
+ * The addition (+) operator. If `x` is an object with an `add` method, it returns `x.add(y)`.
128
+ * Otherwise it returns the result of `x + y`.
129
+ * @param {*} x
130
+ * @param {*} y
131
+ * @returns {*} x + y
132
+ */
133
+ export function add(x, y) {
134
+ const op = call(x, 'add', y)
135
+ if (op != null) return op
136
+ return x + y
137
+ }
138
+
139
+ /**
140
+ * The subtraction (-) operator. If `x` is an object with a `sub` method, it returns `x.sub(y)`.
141
+ * Otherwise it returns the result of `x - y`.
142
+ * @param {*} x
143
+ * @param {*} y
144
+ * @returns {*} x - y
145
+ */
146
+ export function sub(x, y) {
147
+ const op = call(x, 'sub', y)
148
+ if (op != null) return op
149
+ return x - y
150
+ }
151
+
152
+ /**
153
+ * The multiplication (*) operator. If `x` is an object with an `mul` method, it returns `x.mul(y)`.
154
+ * Otherwise it returns the result of `x * y`.
155
+ * @param {*} x
156
+ * @param {*} y
157
+ * @returns {*} x * y
158
+ */
159
+ export function mul(x, y) {
160
+ const op = call(x, 'mul', y)
161
+ if (op != null) return op
162
+ return x * y
163
+ }
164
+ /**
165
+ * The division (/) operator. If `x` is an object with a `div` method, it returns `x.div(y)`.
166
+ * Otherwise it returns the result of `x / y`.
167
+ * @param {*} x
168
+ * @param {*} y
169
+ * @returns {*} x / y
170
+ */
171
+ export function div(x, y) {
172
+ const op = call(x, 'div', y)
173
+ if (op != null) return op
174
+ return x / y
175
+ }
176
+ /**
177
+ * The modulo (%) operator. If `x` is an object with a `mod` method, it returns `x.mod(y)`.
178
+ * Otherwise it returns the result of `x % y`.
179
+ * @param {*} x
180
+ * @param {*} y
181
+ * @returns {*} x % y
182
+ */
183
+ export function mod(x, y) {
184
+ const op = call(x, 'mod', y)
185
+ if (op != null) return op
186
+ return x % y
187
+ }
188
+
189
+ /**
190
+ * The power (**) operator. If `x` is an object with a `pow` method, it returns `x.pow(y)`.
191
+ * Otherwise it returns the result of `x ** y`.
192
+ * @param {*} x
193
+ * @param {*} y
194
+ * @returns {*} x ** y
195
+ */
196
+ export function pow(x, y) {
197
+ const op = call(x, 'pow', y)
198
+ if (op != null) return op
199
+ return x ** y
200
+ }
201
+
202
+ /**
203
+ * Performs a shallow comparison of two objects or arrays to check if they have the same keys, length and values.
204
+ * @param obj
205
+ * @param other
206
+ * @returns `true` if the objects are considered equal.
207
+ * @see {@link deepEqual}
208
+ */
209
+ export function shallowEqual(obj, other) {
210
+ if (obj === other) return true
211
+
212
+ if (!obj || !other) return false
213
+
214
+ if (Array.isArray(obj)) {
215
+ // compare the arrays
216
+ if (obj.length !== other.length) return false
217
+
218
+ for (let i = 0; i < obj.length; i++) {
219
+ if (obj[i] !== other[i]) {
220
+ return false
221
+ }
222
+ }
223
+ return true
224
+ } else if (isObject(obj)) {
225
+ // compare the object keys
226
+ const objKeys = Object.keys(obj)
227
+ const otherKeys = Object.keys(other)
228
+
229
+ if (objKeys.length !== otherKeys.length) return false
230
+
231
+ for (const key of objKeys) {
232
+ if (!Object.prototype.hasOwnProperty.call(other, key) || obj[key] !== other[key]) {
233
+ return false
234
+ }
235
+ }
236
+ return true
237
+ }
238
+
239
+ return false
240
+ }
241
+
242
+ /**
243
+ * Performs a recursive comparison of two objects or arrays to check if they have the same keys, length and values. Unlike {@link shallowEqual} this method compares nested values also.
244
+ * @param obj
245
+ * @param other
246
+ * @returns `true` if the objects are considered equal.
247
+ */
248
+ export function deepEqual(obj, other, checker = eq) {
249
+ if (checker(obj, other)) return true
250
+
251
+ if (!obj || !other) return false
252
+
253
+ if (Array.isArray(obj)) {
254
+ // compare the arrays
255
+ if (obj.length !== other.length) return false
256
+
257
+ for (let i = 0; i < obj.length; i++) {
258
+ if (!deepEqual(obj[i], other[i], checker)) {
259
+ return false
260
+ }
261
+ }
262
+ return true
263
+ } else if (isObject(obj)) {
264
+ // compare the object keys
265
+ const objKeys = Object.keys(obj)
266
+ const otherKeys = Object.keys(other)
267
+
268
+ if (objKeys.length !== otherKeys.length) return false
269
+
270
+ for (const key of objKeys) {
271
+ if (
272
+ !Object.prototype.hasOwnProperty.call(other, key) ||
273
+ !deepEqual(obj[key], other[key], checker)
274
+ ) {
275
+ return false
276
+ }
277
+ }
278
+ return true
279
+ }
280
+
281
+ return false
282
+ }
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,11 +1,11 @@
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.1",
5
- "main": "src/index.js",
4
+ "version": "0.3.3-beta",
5
+ "main": "core/index.js",
6
6
  "type": "module",
7
- "types": "src/index.d.ts",
8
- "module": "src/index.js",
7
+ "types": "core/index.d.ts",
8
+ "module": "core/index.js",
9
9
  "sideEffects": false,
10
10
  "devDependencies": {
11
11
  "@types/jasmine": "^4.3.0",
@@ -32,8 +32,8 @@
32
32
  "test": "NODE_OPTIONS=--loader=ts-node/esm jasmine --config=jasmine.json",
33
33
  "tsc": "tsc -p ./tsconfig.xo.json --declaration",
34
34
  "tsc:w": "tsc -p ./tsconfig.xo.json --declaration --watch",
35
- "lint": "eslint src/**",
36
- "lint:fix": "eslint src/** --fix",
35
+ "lint": "eslint core/**/*.ts",
36
+ "lint:fix": "eslint core/**/*.ts --fix",
37
37
  "build": "npm run lint:fix && npm run tsc && npm run docs",
38
38
  "docs": "typedoc"
39
39
  },