@azure-tools/linq
Advanced tools
Comparing version 3.1.219 to 3.1.222
@@ -11,2 +11,4 @@ export interface Index<T> { | ||
export declare type IndexOf<T> = T extends Map<T, infer V> ? T : T extends Array<infer V> ? number : string; | ||
/** performs a truthy check on the value, and calls onTrue when the condition is true,and onFalse when it's not */ | ||
export declare function when<T>(value: T, onTrue: (value: NonNullable<T>) => void, onFalse?: () => void): void; | ||
//# sourceMappingURL=common.d.ts.map |
@@ -12,2 +12,7 @@ "use strict"; | ||
exports.ToDictionary = ToDictionary; | ||
/** performs a truthy check on the value, and calls onTrue when the condition is true,and onFalse when it's not */ | ||
function when(value, onTrue, onFalse = () => { }) { | ||
return value ? onTrue(value) : onFalse(); | ||
} | ||
exports.when = when; | ||
//# sourceMappingURL=common.js.map |
@@ -9,2 +9,3 @@ import { IndexOf, Dictionary } from './common'; | ||
distinct(selector?: (each: T) => any): IterableWithLinq<T>; | ||
duplicates(selector?: (each: T) => any): IterableWithLinq<T>; | ||
first(predicate?: (each: T) => boolean): T | undefined; | ||
@@ -11,0 +12,0 @@ selectNonNullable<V>(selector: (each: T) => V): IterableWithLinq<NonNullable<V>>; |
@@ -20,2 +20,3 @@ "use strict"; | ||
distinct: distinct.bind(iterable), | ||
duplicates: duplicates.bind(iterable), | ||
first: first.bind(iterable), | ||
@@ -299,2 +300,22 @@ select: select.bind(iterable), | ||
} | ||
function duplicates(selector) { | ||
const hash = new common_1.Dictionary(); | ||
return linqify(function* () { | ||
if (!selector) { | ||
selector = i => i; | ||
} | ||
for (const each of this) { | ||
const k = JSON.stringify(selector(each)); | ||
if (hash[k] === undefined) { | ||
hash[k] = false; | ||
} | ||
else { | ||
if (hash[k] === false) { | ||
hash[k] = true; | ||
yield each; | ||
} | ||
} | ||
} | ||
}.bind(this)()); | ||
} | ||
//# sourceMappingURL=new-linq.js.map |
{ | ||
"name": "@azure-tools/linq", | ||
"version": "3.1.219", | ||
"version": "3.1.222", | ||
"patchOffset": 100, | ||
@@ -5,0 +5,0 @@ "description": "LINQ-like functionality for Typescript.", |
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
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
82499
1082