Comparing version 0.1.5 to 0.1.6
@@ -10,1 +10,2 @@ export { default as contains } from './contains'; | ||
export { default as distinct } from './distinct'; | ||
export { default as where } from './where'; |
@@ -20,2 +20,4 @@ "use strict"; | ||
exports.distinct = distinct_1.default; | ||
var where_1 = require("./where"); | ||
exports.where = where_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
export default function mapMany<TL, TR>(l: TL[], selector?: (l: TL) => TR[]): TR[]; | ||
import { ProjectMany } from './types'; | ||
export default function mapMany<TL, TR>(l: TL[], selector?: ProjectMany<TL, TR>): TR[]; |
@@ -0,6 +1,7 @@ | ||
import { ItemPredicate, LeftRightPredicate, ProjectMany } from './types'; | ||
declare global { | ||
interface Array<T> { | ||
qContains<TR>(r: TR[], predicate?: (l: T, r: TR) => boolean): boolean; | ||
qIntersect<TR>(r: TR[], predicate?: (l: T, r: TR) => boolean): T[]; | ||
qSame<TR>(r: TR[], predicate?: (l: T, r: TR) => boolean): boolean; | ||
qContains<TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>): boolean; | ||
qIntersect<TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>): T[]; | ||
qSame<TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>): boolean; | ||
qEmpty(): boolean; | ||
@@ -10,6 +11,6 @@ qFirst(predicate?: (l: T) => boolean): T; | ||
qRotate(offset: number): T[]; | ||
qMapMany<TR>(selector?: (l: T) => TR[]): TR[]; | ||
qMapMany<TR>(selector?: ProjectMany<T, TR>): TR[]; | ||
qDistinct(key?: (l: T) => any): T[]; | ||
qWhere(predicate: ItemPredicate<T>): T[]; | ||
} | ||
} | ||
export {}; |
@@ -48,2 +48,7 @@ "use strict"; | ||
} | ||
if (!Array.prototype.qWhere) { | ||
Array.prototype.qWhere = function (predicate) { | ||
return lib.where(this, predicate); | ||
}; | ||
} | ||
//# sourceMappingURL=prototype.js.map |
@@ -10,1 +10,2 @@ export { default as contains } from './contains'; | ||
export { default as distinct } from './distinct'; | ||
export { default as where } from './where'; |
@@ -1,2 +0,4 @@ | ||
export default function mapMany<TL, TR>(l: TL[], selector?: (l: TL) => TR[]): TR[] { | ||
import { ProjectMany } from './types'; | ||
export default function mapMany<TL, TR>(l: TL[], selector?: ProjectMany<TL, TR>): TR[] { | ||
if (selector) { | ||
@@ -8,2 +10,2 @@ const lists = l.map(selector); | ||
} | ||
} | ||
} |
import * as lib from './index'; | ||
import { ItemPredicate, LeftRightPredicate, Projector, ProjectMany } from './types'; | ||
declare global { | ||
interface Array<T> { | ||
qContains<TR>(r: TR[], predicate?: (l: T, r: TR) => boolean): boolean; | ||
qIntersect<TR>(r: TR[], predicate?: (l: T, r: TR) => boolean): T[]; | ||
qSame<TR>(r: TR[], predicate?: (l: T, r: TR) => boolean): boolean; | ||
qContains<TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>): boolean; | ||
qIntersect<TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>): T[]; | ||
qSame<TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>): boolean; | ||
qEmpty(): boolean; | ||
@@ -12,4 +14,5 @@ qFirst(predicate?: (l: T) => boolean): T; | ||
qRotate(offset: number): T[]; | ||
qMapMany<TR>(selector?: (l: T) => TR[]): TR[]; | ||
qMapMany<TR>(selector?: ProjectMany<T, TR>): TR[]; | ||
qDistinct(key?: (l: T) => any): T[]; | ||
qWhere(predicate: ItemPredicate<T>): T[]; | ||
} | ||
@@ -19,3 +22,3 @@ } | ||
if (!Array.prototype.qContains) { | ||
Array.prototype.qContains = function(r, predicate?) { | ||
Array.prototype.qContains = function<T, TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>) { | ||
return lib.contains(this, r, predicate); | ||
@@ -25,3 +28,3 @@ }; | ||
if (!Array.prototype.qIntersect) { | ||
Array.prototype.qIntersect = function(r, predicate?) { | ||
Array.prototype.qIntersect = function<T, TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>) { | ||
return lib.intersect(this, r, predicate); | ||
@@ -31,3 +34,3 @@ }; | ||
if (!Array.prototype.qSame) { | ||
Array.prototype.qSame = function(r, predicate?) { | ||
Array.prototype.qSame = function<T, TR>(r: TR[], predicate?: LeftRightPredicate<T, TR>) { | ||
return lib.same(this, r, predicate); | ||
@@ -57,3 +60,3 @@ }; | ||
if (!Array.prototype.qMapMany) { | ||
Array.prototype.qMapMany = function(selector?) { | ||
Array.prototype.qMapMany = function<T, TOut>(selector?: ProjectMany<T, TOut>) { | ||
return lib.mapMany(this, selector); | ||
@@ -67,1 +70,6 @@ }; | ||
} | ||
if (!Array.prototype.qWhere) { | ||
Array.prototype.qWhere = function<T>(predicate: ItemPredicate<T>) { | ||
return lib.where(this, predicate); | ||
}; | ||
} |
{ | ||
"name": "arrayq", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Array query methods for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "es6/prototype.js", |
@@ -166,1 +166,10 @@ const assert = require('assert'); | ||
}); | ||
describe('qWhere', function() { | ||
it('should have even numbers', function() { | ||
assert.deepEqual([1,2,3,4,5,6,7,8,9,10].qWhere(x => x%2 === 0), [2,4,6,8,10]); | ||
}); | ||
it('should have every 3rd number', function() { | ||
assert.deepEqual([1,2,3,4,5,6,7,8,9,10].qWhere((x, idx) => (idx+1)%3 === 0), [3,6,9]); | ||
}); | ||
}); |
@@ -10,3 +10,3 @@ { | ||
"declaration": true, | ||
"noImplicitAny": false, | ||
"noImplicitAny": true, | ||
"noImplicitUseStrict": false, | ||
@@ -25,2 +25,2 @@ "removeComments": true, | ||
"buildOnSave": false | ||
} | ||
} |
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
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
75940
59
759