Comparing version 0.1.1 to 0.2.0
@@ -87,4 +87,13 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var _map = __webpack_require__(1); | ||
var _filter = __webpack_require__(1); | ||
Object.defineProperty(exports, 'filter', { | ||
enumerable: true, | ||
get: function get() { | ||
return _filter.filter; | ||
} | ||
}); | ||
var _map = __webpack_require__(2); | ||
Object.defineProperty(exports, 'map', { | ||
@@ -107,2 +116,18 @@ enumerable: true, | ||
}); | ||
var filter = exports.filter = function filter(input, predicate) { | ||
return input.reduce(function (acc, curr) { | ||
return predicate(curr) ? acc.concat([curr]) : acc; | ||
}, []); | ||
}; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var map = exports.map = function map(input, func) { | ||
@@ -109,0 +134,0 @@ return input.reduce(function (acc, curr) { |
{ | ||
"name": "absurdum", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Reductio Ad Absurdum - The Riduculous Application of Reduce", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -0,1 +1,2 @@ | ||
export { filter } from './filter'; | ||
export { map } from './map'; |
@@ -5,2 +5,11 @@ const test = require('tape'); | ||
test('filter(arr, predicate) - should filter out values based on the result of the predicate', (t) => { | ||
let result = arrays.filter([1, 2, 3, 4], (x) => x % 2 === 0); | ||
let expect = [2, 4]; | ||
t.equal(Object.prototype.toString.call(result), '[object Array]', 'type'); | ||
t.equal(result.length, 2, 'length'); | ||
t.deepEqual(result, expect, 'value'); | ||
t.end(); | ||
}); | ||
test('map(arr, func) - should map over and apply the function to each value', (t) => { | ||
@@ -7,0 +16,0 @@ let result = arrays.map([1, 2, 3, 4], (x) => x + 2); |
Sorry, the diff of this file is not supported yet
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
14187
10
182
7