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.
@@ -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(5, 9)], [5, 6, 7, 8])
173
- assert.deepEqual([...range(5, 0, -2)], [5, 3, 1])
174
- assert.deepEqual([...range(-3)], [])
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
+ })