Comparing version 0.4.1 to 0.5.0
@@ -8,3 +8,5 @@ module.exports = { | ||
curry: require('./src/curry'), | ||
divide: require('./src/divide'), | ||
equals: require('./src/equals'), | ||
filter: require('./src/filter'), | ||
flatten: require('./src/flatten'), | ||
@@ -18,2 +20,3 @@ gt: require('./src/gt'), | ||
multiply: require('./src/multiply'), | ||
none: require('./src/none'), | ||
or: require('./src/or'), | ||
@@ -20,0 +23,0 @@ pipe: require('./src/pipe'), |
{ | ||
"name": "bukk", | ||
"version": "0.4.1", | ||
"description": "A functional library for Norwegians", | ||
"keywords": [ | ||
"functional-programming", | ||
"fp", | ||
"curry", | ||
"data-last", | ||
"library" | ||
], | ||
"version": "0.5.0", | ||
"license": "MIT", | ||
@@ -5,0 +13,0 @@ "repository": "christianhg/bukk", |
@@ -20,3 +20,3 @@ # bukk 🐐 | ||
- **Feature rich**<br> | ||
- **Feature-rich**<br> | ||
*As seen above, `B.map` knows how to handle `Sets`. Similarly, other `B` functions that can operate on Arrays, typically knows how to operate on other data structures as well.* | ||
@@ -38,4 +38,2 @@ | ||
// => true | ||
``` | ||
@@ -42,0 +40,0 @@ |
@@ -7,3 +7,5 @@ const curry = require('./curry') | ||
'Array': () => a.every(p), | ||
'Boolean': () => p(a), | ||
'Map': () => Array.from(a).every(([key, value]) => p(value)), | ||
'Number': () => p(a), | ||
'Object': () => Object.keys(a).every((x) => p(a[x])), | ||
@@ -10,0 +12,0 @@ 'Set': () => all(p, [...a]), |
@@ -7,3 +7,5 @@ const curry = require('./curry') | ||
'Array': () => a.some(p), | ||
'Boolean': () => p(a), | ||
'Map': () => Array.from(a).some(([key, value]) => p(value)), | ||
'Number': () => p(a), | ||
'Object': () => Object.keys(a).some((x) => p(a[x])), | ||
@@ -10,0 +12,0 @@ 'Set': () => any(p, [...a]), |
@@ -6,3 +6,2 @@ const curry = require('./curry') | ||
const m = { | ||
'Array': () => a.map(f), | ||
'Map': () => new Map(Array.from(a).map(([key, value]) => [key, f(value)])), | ||
@@ -16,5 +15,8 @@ 'Object': () => Object.keys(a).reduce((b, key) => { | ||
} | ||
return (m[type(a)] || m['*'])() | ||
return type(a.map) === 'Function' | ||
? a.map(f) | ||
: (m[type(a)] || m['*'])() | ||
} | ||
module.exports = curry(map) |
@@ -9,2 +9,3 @@ import test from 'ava' | ||
const isZero = equals(0) | ||
const isTrue = equals(true) | ||
@@ -19,2 +20,7 @@ test('should test predicate on Array', t => { | ||
test('should test predicate on Boolean', t => { | ||
t.is(all(isTrue, true), true) | ||
t.is(all(isTrue, false), false) | ||
}) | ||
test('should test predicate on Map', t => { | ||
@@ -27,2 +33,7 @@ t.is(all(isFoo, new Map([[1, 'foo'], [2, 'foo'], [3, 'foo']])), true) | ||
test('should test predicate on Number', t => { | ||
t.is(all(isZero, 0), true) | ||
t.is(all(isZero, 1), false) | ||
}) | ||
test('should test predicate on Object', t => { | ||
@@ -29,0 +40,0 @@ t.is(all(isFoo, {a: 'foo', b: 'foo', c: 'foo'}), true) |
@@ -9,2 +9,3 @@ import test from 'ava' | ||
const isZero = equals(0) | ||
const isTrue = equals(true) | ||
@@ -22,2 +23,7 @@ test('should test predicate on Array', t => { | ||
test('should test predicate on Boolean', t => { | ||
t.is(any(isTrue, true), true) | ||
t.is(any(isTrue, false), false) | ||
}) | ||
test('should test predicate on Map', t => { | ||
@@ -30,2 +36,7 @@ t.is(any(isFoo, new Map([[1, 'foo'], [2, 'foo'], [3, 'foo']])), true) | ||
test('should test predicate on Number', t => { | ||
t.is(any(isZero, 0), true) | ||
t.is(any(isZero, 1), false) | ||
}) | ||
test('should test predicate on Object', t => { | ||
@@ -32,0 +43,0 @@ t.is(any(isFoo, {a: 'foo', b: 'foo', c: 'foo'}), true) |
@@ -30,2 +30,6 @@ import test from 'ava' | ||
test('should export B.divide', t => { | ||
t.is(type(B.divide), 'Function') | ||
}) | ||
test('should export B.equals', t => { | ||
@@ -35,2 +39,6 @@ t.is(type(B.equals), 'Function') | ||
test('should export B.filter', t => { | ||
t.is(type(B.filter), 'Function') | ||
}) | ||
test('should export B.flatten', t => { | ||
@@ -68,2 +76,6 @@ t.is(type(B.flatten), 'Function') | ||
test('should export B.none', t => { | ||
t.is(type(B.none), 'Function') | ||
}) | ||
test('should export B.or', t => { | ||
@@ -70,0 +82,0 @@ t.is(type(B.or), 'Function') |
@@ -18,2 +18,12 @@ import test from 'ava' | ||
test('should map any Functor', t => { | ||
const Just = x => ({ | ||
map: f => Just(f(x)), | ||
value: x | ||
}) | ||
t.deepEqual(map(inc, Just(1)).value, 2) | ||
t.deepEqual(map(addBar, Just('foo')).value, 'foobar') | ||
}) | ||
test('should map an Object', t => { | ||
@@ -20,0 +30,0 @@ t.deepEqual(map(inc, {x: 1, y: 2, z: 3}), {x: 2, y: 3, z: 4}) |
@@ -9,2 +9,6 @@ import test from 'ava' | ||
test('should recognize Function', t => { | ||
t.is(type(type), 'Function') | ||
}) | ||
test('should recognize Map', t => { | ||
@@ -11,0 +15,0 @@ t.is(type(new Map().set('one', 1)), 'Map') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144200
49
692
84