@appolo/utils
Advanced tools
Comparing version 8.0.24 to 8.0.25
@@ -23,3 +23,3 @@ import {Arrays} from "./arrays"; | ||
public removeBy(criteria: (value: K, i?: number) => boolean): this { | ||
public removeBy<S = K>(criteria: (value: S, i?: number) => boolean): this { | ||
Arrays.removeBy(this._value, criteria); | ||
@@ -40,13 +40,13 @@ return this; | ||
public flat(): this { | ||
public flat<S = K>(): Chain<S> { | ||
this._value = Arrays.flat(this._value); | ||
return this; | ||
return this as any; | ||
} | ||
public flatDeep(depth: number = 1): this { | ||
public flatDeep<S = K>(depth: number = 1): Chain<S> { | ||
this._value = Arrays.flatDeep(this._value, depth); | ||
return this; | ||
return this as any; | ||
} | ||
public sortBy(criteria: (value: K) => any): this { | ||
public sortBy<S = K>(criteria: (value: S) => any): this { | ||
this._value = Arrays.sortBy(this._value, criteria); | ||
@@ -56,3 +56,3 @@ return this; | ||
public sort<T>(): this { | ||
public sort(): this { | ||
this._value = Arrays.sort(this._value); | ||
@@ -68,3 +68,3 @@ return this; | ||
public uniqBy<T>(criteria: (value: T, i?: number) => any): this { | ||
public uniqBy<S = K>(criteria: (value: S, i?: number) => any): this { | ||
this._value = Arrays.uniqBy(this._value, criteria); | ||
@@ -79,3 +79,3 @@ return this | ||
public difference<T>(arr2: T[]): this { | ||
public difference<S = K>(arr2: S[]): this { | ||
this._value = Arrays.difference(this._value, arr2); | ||
@@ -85,3 +85,3 @@ return this | ||
public differenceBy<T>(arr2: T[], criteria: (value: T, i?: number) => any): this { | ||
public differenceBy<S = K>(arr2: S[], criteria: (value: S, i?: number) => any): this { | ||
this._value = Arrays.differenceBy(this._value, arr2, criteria); | ||
@@ -91,8 +91,8 @@ return this | ||
public map<U>(predicate: (value: K, index: number, array: K[]) => U): this { | ||
public map<U, S = K>(predicate: (value: S, index: number, array: S[]) => U): Chain<U> { | ||
this._value = this._value.map(predicate); | ||
return this | ||
return this as any | ||
} | ||
public filter<S extends K>(predicate: (value: K, index?: number, array?: K[]) => boolean): this { | ||
public filter<S = K>(predicate: (value: S, index?: number, array?: S[]) => boolean): this { | ||
this._value = this._value.filter(predicate); | ||
@@ -102,23 +102,23 @@ return this | ||
public find<S extends K>(predicate: (value: K, index?: number, array?: K[]) => boolean): S | undefined { | ||
public find<S = K>(predicate: (value: S, index?: number, array?: S[]) => boolean): S | undefined { | ||
return this._value.find(predicate); | ||
} | ||
public forEach<S extends K>(predicate: (value: K, index?: number, array?: K[]) => void): void { | ||
public forEach<S = K>(predicate: (value: S, index?: number, array?: S[]) => void): void { | ||
this._value.forEach(predicate); | ||
} | ||
public includes(searchElement: K, fromIndex?: number): boolean { | ||
public includes<S = K>(searchElement: S, fromIndex?: number): boolean { | ||
return this._value.includes(searchElement, fromIndex); | ||
} | ||
public indexOf(searchElement: K, fromIndex?: number): number { | ||
public indexOf<S = K>(searchElement: S, fromIndex?: number): number { | ||
return this._value.indexOf(searchElement, fromIndex); | ||
} | ||
public every<S extends K>(predicate: (value: K, index: number, array: K[]) => boolean): boolean { | ||
public every<S = K>(predicate: (value: S, index: number, array: S[]) => boolean): boolean { | ||
return this._value.every(predicate); | ||
} | ||
public some<S extends K>(predicate: (value: K, index: number, array: K[]) => boolean): boolean { | ||
public some<S = K>(predicate: (value: S, index: number, array: S[]) => boolean): boolean { | ||
return this._value.some(predicate); | ||
@@ -133,8 +133,8 @@ } | ||
public shift<T = K>() { | ||
return this._value.shift() as T | ||
public shift<S = K>(): S { | ||
return this._value.shift() as S | ||
} | ||
public pop<T = K>() { | ||
return this._value.pop() as T | ||
public pop<S = K>(): S { | ||
return this._value.pop() as S | ||
} | ||
@@ -146,3 +146,3 @@ | ||
public push(...items: K[]): this { | ||
public push<S = K>(...items: S[]): this { | ||
@@ -154,3 +154,3 @@ this._value.push(...items); | ||
public unshift(...items: K[]): this { | ||
public unshift<S = K>(...items: S[]): this { | ||
@@ -162,7 +162,7 @@ this._value.unshift(...items); | ||
public keyBy(key?: string | ((item: K, index: number) => string)): { [index: string]: K } { | ||
public keyBy<S = K>(key?: string | ((item: S, index: number) => string)): { [index: string]: S } { | ||
return Arrays.keyBy(this._value, key) | ||
} | ||
public groupBy(key: string | number | ((item: K) => string | number)): { [index: string]: K[] } { | ||
public groupBy<S = K>(key: string | number | ((item: S) => string | number)): { [index: string]: S[] } { | ||
@@ -172,13 +172,13 @@ return Arrays.groupBy(this._value, key); | ||
public random<T>(arr: T[]): T { | ||
public random<S = K>(arr: S[]): S { | ||
return Arrays.random(this._value); | ||
} | ||
public value<T = K>(): T[] { | ||
return this._value as T[] | ||
public value<S = K>(): S[] { | ||
return this._value as S[] | ||
} | ||
} | ||
export function _<T>(arr: T[]): Chain<T> { | ||
export function _<K>(arr: K[]): Chain<K> { | ||
return new Chain(arr); | ||
} |
@@ -20,3 +20,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.24", | ||
"version": "8.0.25", | ||
"license": "MIT", | ||
@@ -23,0 +23,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
207673