Skip to content

Commit 002dd8b

Browse files
committed
update and lock deps, fix lint, generalize seq to reduceAsync and move it from hard => intermediate
1 parent ed3aaa4 commit 002dd8b

File tree

6 files changed

+3607
-28
lines changed

6 files changed

+3607
-28
lines changed

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ module.exports = {
55
"promise"
66
],
77
"rules": {
8-
"import/first": false
8+
"import/first": [0],
9+
"new-parens": [0],
10+
"padded-blocks": [0],
11+
"space-before-function-paren": [0]
912
}
1013
}

coding-harder/seq.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

coding-intermediate/assignDeep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ import { test } from 'ava'
2727
test(t => t.deepEqual(assignDeep({ a: 1 }, {}), { a: 1 }))
2828
test(t => t.deepEqual(assignDeep({ a: 1 }, { a: 2 }), { a: 2 }))
2929
test(t => t.deepEqual(assignDeep({ a: 1 }, { a: { b: 2 } }), { a: { b: 2 } }))
30-
test(t => t.deepEqual(assignDeep({ a: { b: { c: 1 }}}, { a: { b: { d: 2 }}, e: 3 }), { a: { b: { c: 1, d: 2 }}, e: 3 }))
30+
test(t => t.deepEqual(assignDeep({ a: { b: { c: 1 } } }, { a: { b: { d: 2 } }, e: 3 }), { a: { b: { c: 1, d: 2 } }, e: 3 }))

coding-intermediate/reduceAsync.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/// solution
2+
3+
let reduceAsync = async (as, fn, init) => {
4+
for (let a of as) {
5+
init = fn(init, await a())
6+
}
7+
return init
8+
}
9+
10+
/// tests
11+
12+
import { test } from 'ava'
13+
14+
test(async t => {
15+
let a = () => Promise.resolve('a')
16+
let b = () => Promise.resolve('b')
17+
let c = () => Promise.resolve('c')
18+
19+
t.deepEqual(
20+
await reduceAsync([a, b, c], (acc, value) => [...acc, value], []),
21+
['a', 'b', 'c']
22+
)
23+
t.deepEqual(
24+
await reduceAsync([a, c, b], (acc, value) => [...acc, value], ['d']),
25+
['d', 'a', 'c', 'b']
26+
)
27+
})

0 commit comments

Comments
 (0)