Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
daeefeb
commit 80939a9
Showing
14 changed files
with
277 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
exports.all = require('./lib/all') | ||
exports.backoff = require('./lib/backoff') | ||
exports.convergeP = require('./lib/convergeP') | ||
exports.copyProp = require('./lib/copyProp') | ||
exports.evolveP = require('./lib/evolveP') | ||
exports.juxtP = require('./lib/juxtP') | ||
exports.mapP = require('./lib/mapP') | ||
exports.move = require('./lib/move') | ||
exports.normalizeBy = require('./lib/normalizeBy') | ||
exports.overP = require('./lib/overP') | ||
exports.promisify = require('./lib/promisify') | ||
exports.reject = require('./lib/reject') | ||
exports.rename = require('./lib/rename') | ||
exports.resolve = require('./lib/resolve') | ||
exports.tapP = require('./lib/tapP') | ||
exports.validate = require('./lib/validate') | ||
exports.all = require('./lib/all') | ||
exports.backoff = require('./lib/backoff') | ||
exports.combine = require('./lib/combine') | ||
exports.combineAll = require('./lib/combineAll') | ||
exports.combineAllP = require('./lib/combineAllP') | ||
exports.combineP = require('./lib/combineP') | ||
exports.combineWith = require('./lib/combineWith') | ||
exports.combineWithP = require('./lib/combineWithP') | ||
exports.convergeP = require('./lib/convergeP') | ||
exports.copyProp = require('./lib/copyProp') | ||
exports.evolveP = require('./lib/evolveP') | ||
exports.juxtP = require('./lib/juxtP') | ||
exports.mapP = require('./lib/mapP') | ||
exports.move = require('./lib/move') | ||
exports.normalizeBy = require('./lib/normalizeBy') | ||
exports.overP = require('./lib/overP') | ||
exports.promisify = require('./lib/promisify') | ||
exports.reject = require('./lib/reject') | ||
exports.rename = require('./lib/rename') | ||
exports.resolve = require('./lib/resolve') | ||
exports.tapP = require('./lib/tapP') | ||
exports.validate = require('./lib/validate') |
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,5 @@ | ||
const merge = require('ramda/src/merge') | ||
const combineWith = require('./combineWith') | ||
|
||
// combine : ({ k: v } -> { k: v }) -> { k: v } | ||
module.exports = combineWith(merge) |
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,8 @@ | ||
const compose = require('ramda/src/compose') | ||
const identity = require('ramda/src/identity') | ||
const juxt = require('ramda/src/juxt') | ||
const mergeAll = require('ramda/src/mergeAll') | ||
|
||
// combineAll : [a... -> { k: v }] -> { k: v } -> { k: v } | ||
module.exports = fns => | ||
compose(mergeAll, juxt([ identity, ...fns ])) |
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,9 @@ | ||
const composeP = require('ramda/src/composeP') | ||
const identity = require('ramda/src/identity') | ||
const mergeAll = require('ramda/src/mergeAll') | ||
|
||
const juxtP = require('./juxtP') | ||
|
||
// combineAllP : [a... -> Promise { k: v }] -> { k: v } -> Promise { k: v } | ||
module.exports = fns => | ||
composeP(mergeAll, juxtP([ identity, ...fns ])) |
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,5 @@ | ||
const merge = require('ramda/src/merge') | ||
const combineWithP = require('./combineWithP') | ||
|
||
// combineP : ({ k: v } -> Promise { k: v }) -> Promise { k: v } | ||
module.exports = combineWithP(merge) |
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,9 @@ | ||
const converge = require('ramda/src/converge') | ||
const curry = require('ramda/src/curry') | ||
const identity = require('ramda/src/identity') | ||
|
||
// combineWith : (c -> b -> d) (a -> b) -> c -> d | ||
const combineWith = (mf, f) => | ||
converge(mf, [ identity, f ]) | ||
|
||
module.exports = curry(combineWith) |
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,10 @@ | ||
const curry = require('ramda/src/curry') | ||
const identity = require('ramda/src/identity') | ||
|
||
const convergeP = require('./convergeP') | ||
|
||
// combineWithP : (c -> b -> d) (a -> Promise b) -> Promise c -> Promise d | ||
const combineWithP = (mf, f) => | ||
convergeP(mf, [ identity, f ]) | ||
|
||
module.exports = curry(combineWithP) |
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,22 @@ | ||
const { expect } = require('chai') | ||
const property = require('prop-factory') | ||
const always = require('ramda/src/always') | ||
|
||
const { combine } = require('..') | ||
|
||
const whatevs = combine(always({ foo: 'bar' })) | ||
|
||
describe('combine', () => { | ||
const res = property() | ||
|
||
beforeEach(() => | ||
res(whatevs({ baz: 'bip' })) | ||
) | ||
|
||
it('merges with the results of the function', () => | ||
expect(res()).to.eql({ | ||
foo: 'bar', | ||
baz: 'bip', | ||
}) | ||
) | ||
}) |
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,26 @@ | ||
const { expect } = require('chai') | ||
const property = require('prop-factory') | ||
const always = require('ramda/src/always') | ||
|
||
const { combineAll } = require('..') | ||
|
||
const whatevs = combineAll([ | ||
always({ foo: 1 }), | ||
always({ bar: 2 }), | ||
]) | ||
|
||
describe('combineAll', () => { | ||
const res = property() | ||
|
||
beforeEach(() => | ||
res(whatevs({ baz: 3 })) | ||
) | ||
|
||
it('combines the results of all functions', () => | ||
expect(res()).to.eql({ | ||
foo: 1, | ||
bar: 2, | ||
baz: 3, | ||
}) | ||
) | ||
}) |
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,26 @@ | ||
const { expect } = require('chai') | ||
const property = require('prop-factory') | ||
const always = require('ramda/src/always') | ||
|
||
const { combineAllP } = require('..') | ||
|
||
const whatevs = combineAllP([ | ||
always(Promise.resolve({ foo: 1 })), | ||
always(Promise.resolve({ bar: 2 })), | ||
]) | ||
|
||
describe('combineAll', () => { | ||
const res = property() | ||
|
||
beforeEach(() => | ||
whatevs({ baz: 3 }).then(res) | ||
) | ||
|
||
it('combines the results of all functions', () => | ||
expect(res()).to.eql({ | ||
foo: 1, | ||
bar: 2, | ||
baz: 3, | ||
}) | ||
) | ||
}) |
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,22 @@ | ||
const { expect } = require('chai') | ||
const property = require('prop-factory') | ||
const always = require('ramda/src/always') | ||
|
||
const { combineP } = require('..') | ||
|
||
const whatevs = combineP(always(Promise.resolve({ foo: 'bar' }))) | ||
|
||
describe('combine', () => { | ||
const res = property() | ||
|
||
beforeEach(() => | ||
whatevs({ baz: 'bip' }).then(res) | ||
) | ||
|
||
it('merges with the results of the function', () => | ||
expect(res()).to.eql({ | ||
foo: 'bar', | ||
baz: 'bip', | ||
}) | ||
) | ||
}) |
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,20 @@ | ||
const { expect } = require('chai') | ||
const property = require('prop-factory') | ||
const add = require('ramda/src/add') | ||
const multiply = require('ramda/src/multiply') | ||
|
||
const { combineWith } = require('..') | ||
|
||
const whatevs = combineWith(multiply, add(2)) | ||
|
||
describe('combineWith', () => { | ||
const res = property() | ||
|
||
beforeEach(() => | ||
res(whatevs(3)) | ||
) | ||
|
||
it('combines with the results of the function', () => | ||
expect(res()).to.equal(15) | ||
) | ||
}) |
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,19 @@ | ||
const { expect } = require('chai') | ||
const property = require('prop-factory') | ||
|
||
const { add, mult } = require('./lib/async') | ||
const { combineWithP } = require('..') | ||
|
||
const whatevs = combineWithP(mult, add(2)) | ||
|
||
describe('combineWith', () => { | ||
const res = property() | ||
|
||
beforeEach(() => | ||
whatevs(3).then(res) | ||
) | ||
|
||
it('combines with the results of the function', () => | ||
expect(res()).to.equal(15) | ||
) | ||
}) |