atomic-fns 0.2.3 → 0.3.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/.firebaserc +5 -0
- package/README.md +5 -2
- package/firebase.json +10 -0
- package/package.json +4 -3
- package/src/collections/index.d.ts +14 -0
- package/src/collections/index.js +23 -0
- package/src/collections/index.ts +24 -0
- package/src/functools/index.d.ts +78 -12
- package/src/functools/index.js +147 -12
- package/src/functools/index.ts +174 -14
- package/src/globals/index.d.ts +36 -41
- package/src/globals/index.js +28 -31
- package/src/globals/index.ts +41 -46
- package/src/itertools/index.d.ts +1 -30
- package/src/itertools/index.js +4 -40
- package/src/itertools/index.ts +3 -43
- package/src/math/index.d.ts +76 -0
- package/src/math/index.js +53 -0
- package/src/math/index.ts +110 -2
- package/src/operators/index.d.ts +3 -3
- package/src/operators/index.js +8 -8
- package/src/operators/index.ts +8 -8
- package/tests/globals.spec.ts +8 -16
- package/tests/itertools.spec.ts +6 -20
- package/tests/math.spec.ts +25 -0
package/tests/itertools.spec.ts
CHANGED
|
@@ -15,20 +15,18 @@ import {
|
|
|
15
15
|
imap,
|
|
16
16
|
islice,
|
|
17
17
|
itake,
|
|
18
|
-
max,
|
|
19
|
-
min,
|
|
20
18
|
partition,
|
|
21
19
|
range,
|
|
22
20
|
reduce,
|
|
23
21
|
reversed,
|
|
24
22
|
sort,
|
|
25
23
|
sorted,
|
|
26
|
-
sum,
|
|
27
24
|
take,
|
|
28
25
|
takeWhile,
|
|
29
26
|
times,
|
|
30
27
|
zip
|
|
31
28
|
} from '../src/itertools/index.js'
|
|
29
|
+
import { max } from '../src/math/index.js'
|
|
32
30
|
|
|
33
31
|
const Falsy = (x) => !x
|
|
34
32
|
|
|
@@ -153,14 +151,6 @@ describe('operators', () => {
|
|
|
153
151
|
assert.deepEqual(it, [false, 0, ''])
|
|
154
152
|
})
|
|
155
153
|
|
|
156
|
-
it('min', () => {
|
|
157
|
-
assert(min([5, 4, 3, 1, 2]) === 1)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it('max', () => {
|
|
161
|
-
assert(max([7, 9, 3, 11]) === 11)
|
|
162
|
-
})
|
|
163
|
-
|
|
164
154
|
it('partition', () => {
|
|
165
155
|
let [A, B] = partition([false, 0, '', true, '', []], Falsy)
|
|
166
156
|
assert.deepEqual(A, [false, 0, '', ''])
|
|
@@ -168,10 +158,12 @@ describe('operators', () => {
|
|
|
168
158
|
})
|
|
169
159
|
|
|
170
160
|
it('range', () => {
|
|
161
|
+
assert.deepEqual([...range(0)], [])
|
|
171
162
|
assert.deepEqual([...range(4)], [0, 1, 2, 3])
|
|
172
|
-
assert.deepEqual([...range(
|
|
173
|
-
assert.deepEqual([...range(
|
|
174
|
-
assert.deepEqual([...range(
|
|
163
|
+
assert.deepEqual([...range(-4)], [0, -1, -2, -3])
|
|
164
|
+
assert.deepEqual([...range(0, -4, -1)], [0, -1, -2, -3])
|
|
165
|
+
assert.deepEqual([...range(1, 5)], [1, 2, 3, 4])
|
|
166
|
+
assert.deepEqual([...range(0, 20, 5)], [0, 5, 10, 15])
|
|
175
167
|
})
|
|
176
168
|
|
|
177
169
|
it('reduce', () => {
|
|
@@ -239,12 +231,6 @@ describe('operators', () => {
|
|
|
239
231
|
)
|
|
240
232
|
})
|
|
241
233
|
|
|
242
|
-
it('sum', () => {
|
|
243
|
-
assert(sum([]) === 0)
|
|
244
|
-
assert(sum([1, 2, 3, 4]) === 10)
|
|
245
|
-
assert(sum([1, 2, 3, 4], 5) === 15)
|
|
246
|
-
})
|
|
247
|
-
|
|
248
234
|
it('times', () => {
|
|
249
235
|
let arr = [...times(5, (x) => x)]
|
|
250
236
|
assert.deepEqual(arr, [0, 1, 2, 3, 4])
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { max, min, round, sum } from '../src/math/index.js'
|
|
3
|
+
|
|
4
|
+
describe('math', () => {
|
|
5
|
+
it('min', () => {
|
|
6
|
+
assert(min([5, 4, 3, 1, 2]) === 1)
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it('max', () => {
|
|
10
|
+
assert(max([7, 9, 3, 11]) === 11)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('round', () => {
|
|
14
|
+
assert(round(0.5) === 1)
|
|
15
|
+
assert(round(-0.5) === 0)
|
|
16
|
+
assert(round(1.5) === 2)
|
|
17
|
+
assert(round(1.54, 2) === 1.54)
|
|
18
|
+
assert(round(1.545, 3) === 1.545)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('sum', () => {
|
|
22
|
+
assert(sum([]) === 0)
|
|
23
|
+
assert(sum([1, 2, 3, 4]) === 10)
|
|
24
|
+
})
|
|
25
|
+
})
|