Comparing version 1.4.0 to 1.5.0
{ | ||
"name": "quizas", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "A sort-of monad for reading values from objects", | ||
@@ -5,0 +5,0 @@ "main": "src/quizas", |
@@ -207,2 +207,20 @@ "use strict"; | ||
} | ||
}, | ||
'filter': { | ||
value: function(func){ | ||
if(!result.found || !Array.isArray(result.value)){ | ||
return []; | ||
} | ||
return result.value.filter(func); | ||
} | ||
}, | ||
'map': { | ||
value: function(func){ | ||
if(!result.found || !Array.isArray(result.value)){ | ||
return []; | ||
} | ||
return result.value.map(func); | ||
} | ||
} | ||
@@ -209,0 +227,0 @@ }); |
@@ -147,2 +147,18 @@ 'use strict'; | ||
it('Should be able to filter a value if it\'s an array', function() { | ||
var filterFunc = function(h){ return h.isListed; }; | ||
var expected = fixtures.esResults.hits.hits.filter(filterFunc); | ||
var result = quizas(fixtures.esResults, 'hits.hits').filter(filterFunc); | ||
expect(result).to.be.an('array'); | ||
expect(result).to.deep.equal(expected); | ||
}); | ||
it('Should be able to map a value if it\'s an array', function() { | ||
var mapFunc = function(h){ return h._id; }; | ||
var expected = fixtures.esResults.hits.hits.map(mapFunc); | ||
var result = quizas(fixtures.esResults, 'hits.hits').map(mapFunc); | ||
expect(result).to.be.an('array'); | ||
expect(result).to.deep.equal(expected); | ||
}); | ||
describe('Bugs', function() { | ||
@@ -149,0 +165,0 @@ |
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
981331
30820