immutable-ext
Advanced tools
Comparing version
@@ -6,3 +6,5 @@ const Immutable = require('immutable') | ||
fold : function(empty) { | ||
return this.reduce((acc, x) => acc.concat(x), empty) | ||
return empty != null | ||
? this.reduce((acc, x) => acc.concat(x), empty) | ||
: this.reduce((acc, x) => acc.concat(x)) | ||
}, | ||
@@ -9,0 +11,0 @@ foldMap : function(f, empty) { |
{ | ||
"name": "immutable-ext", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "fantasyland compatible extensions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -84,2 +84,5 @@ const assert = require("assert") | ||
it('works on semigroups (no empty)', () => | ||
assert.deepEqual(List.of([1,2,3], [4,5,6]).fold(), [1,2,3,4,5,6])) | ||
it('foldMaps the list', () => | ||
@@ -86,0 +89,0 @@ assert.deepEqual(List.of(1,2,3).foldMap(x => Sum(x), Sum.empty), Sum(6))) |
152680
0.13%4378
0.09%