You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@proem/array

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@proem/array - npm Package Compare versions

Comparing version

to
0.0.4

11

lib/array.d.ts

@@ -5,2 +5,13 @@ export declare const map: {

};
export declare function filter<A, B extends A>(array: A[], guard: (value: A) => value is B): B[];
export declare namespace filter {
var partial: typeof filterPartial;
}
export declare function filter<A>(array: A[], predicate: (value: A) => boolean): A[];
export declare namespace filter {
var partial: typeof filterPartial;
}
declare function filterPartial<A, B extends A>(predicate: (value: A) => value is B): (array: A[]) => B[];
declare function filterPartial<A>(predicate: (value: A) => boolean): (array: A[]) => A[];
export {};
//# sourceMappingURL=array.d.ts.map

@@ -11,2 +11,16 @@ export var map = function (array, mapfn) {

}; };
export function filter(array, predicate) {
var result = [];
for (var i = 0; i < array.length; i++) {
var value = array[i];
if (predicate(value)) {
result.push(value);
}
}
return result;
}
function filterPartial(predicate) {
return function (array) { return filter(array, predicate); };
}
filter.partial = filterPartial;
//# sourceMappingURL=array.js.map

20

lib/array.test.js

@@ -1,2 +0,2 @@

import { map } from './array';
import { map, filter } from './array';
describe('map', function () {

@@ -8,2 +8,20 @@ it('should transform items', function () {

});
describe('filter', function () {
it('should remove items not matching predicate', function () {
var filtered = filter(['a', 'bb', 'cc', 'ddd'], function (s) { return s.length !== 2; });
expect(filtered).toEqual(['a', 'ddd']);
});
var isString = function (s) { return typeof s === 'string'; };
it('should return items matching guard as type of guard', function () {
var filtered = filter([11, 'a', 'bb', 12, 'ddd', 33], isString);
expect(filtered).toEqual(['a', 'bb', 'ddd']);
});
describe('filter.partial', function () {
it('should return items matching guard as type of guard', function () {
var items = [11, 'a', 'bb', 12, 'ddd', 33];
var filtered = filter.partial(isString)(items);
expect(filtered).toEqual(['a', 'bb', 'ddd']);
});
});
});
//# sourceMappingURL=array.test.js.map

4

package.json
{
"name": "@proem/array",
"version": "0.0.3",
"version": "0.0.4",
"description": "Typescript array utilities",

@@ -29,3 +29,3 @@ "keywords": [

},
"gitHead": "f44c106730503498c9795b1e1d60967f8adb81cb",
"gitHead": "5227cdd309d08eac3674506c2e4e5c9f622cbece",
"devDependencies": {

@@ -32,0 +32,0 @@ "typescript": "^3.1.4"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet