-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add functional auto-curried syntax support
- Loading branch information
Showing
5 changed files
with
151 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const test = require('ava') | ||
const {map, reduce, filter, forEach} = require('..') | ||
const obj = { foo: 'bar', doge: 'wow' } | ||
|
||
test('forEach', (t) => { | ||
t.plan(2) | ||
const fn = forEach((v, k) => t.truthy(obj[k] === v)) | ||
fn(obj) | ||
}) | ||
|
||
test('map', (t) => { | ||
const fn = map((v, k) => v.toUpperCase()) | ||
const mapped = fn(obj) | ||
t.truthy(mapped.foo === 'BAR') | ||
t.truthy(mapped.doge === 'WOW') | ||
}) | ||
|
||
test('filter', (t) => { | ||
const fn = filter((v, k) => k !== 'doge') | ||
const filtered = fn(obj) | ||
t.truthy(filtered.foo === 'bar') | ||
t.falsy(filtered.doge === 'wow') | ||
}) | ||
|
||
test('reduce', (t) => { | ||
const fn = reduce((m, v, k) => m.push(v) && m, []) | ||
const reduced = fn(obj) | ||
t.truthy(reduced.length === 2) | ||
t.truthy(reduced[0] === 'bar') | ||
t.truthy(reduced[1] === 'wow') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const test = require('ava') | ||
const {map, reduce, filter, forEach} = require('..') | ||
const obj = { foo: 'bar', doge: 'wow' } | ||
|
||
test('forEach', (t) => { | ||
t.plan(2) | ||
forEach((v, k) => t.truthy(obj[k] === v), obj) | ||
}) | ||
|
||
test('map', (t) => { | ||
const mapped = map((v, k) => v.toUpperCase(), obj) | ||
t.truthy(mapped.foo === 'BAR') | ||
t.truthy(mapped.doge === 'WOW') | ||
}) | ||
|
||
test('filter', (t) => { | ||
const filtered = filter((v, k) => k !== 'doge', obj) | ||
t.truthy(filtered.foo === 'bar') | ||
t.falsy(filtered.doge === 'wow') | ||
}) | ||
|
||
test('reduce', (t) => { | ||
const reduced = reduce((m, v, k) => m.push(v) && m, [], obj) | ||
t.truthy(reduced.length === 2) | ||
t.truthy(reduced[0] === 'bar') | ||
t.truthy(reduced[1] === 'wow') | ||
}) |
File renamed without changes.