forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
knockout-transformations.d.ts
35 lines (31 loc) · 1.66 KB
/
knockout-transformations.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Type definitions for knockout-transformations 2.0.0
// Project: https://github.com/One-com/knockout-transformations
// Definitions by: John Reilly <https://github.com/johnnyreilly>, Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../knockout/knockout.d.ts" />
declare module KnockoutTransformations {
interface Mapping<T, TResult> {
(value: T): TResult;
}
interface MappingOption<T, TResult> {
mapping: Mapping<T, TResult>;
disposeItem?: (item: TResult) => void;
}
interface MappingWithDisposeCallbackOption<T, TResult> {
mappingWithDisposeCallback: (value: T) => {
mappedValue: TResult;
dispose: () => void;
};
}
}
interface KnockoutObservableArrayFunctions<T> {
map<TResult>(mapping: KnockoutTransformations.Mapping<T, TResult>): KnockoutObservableArray<TResult>;
map<TResult>(mapping: KnockoutTransformations.MappingOption<T, TResult>): KnockoutObservableArray<TResult>;
map<TResult>(mapping: KnockoutTransformations.MappingWithDisposeCallbackOption<T, TResult>): KnockoutObservableArray<TResult>;
filter(predicate: (value: T) => boolean): KnockoutObservableArray<T>;
sortBy(sorter: (value: T, descending: (sorter: any) => any) => any): KnockoutObservableArray<T>;
indexBy(indexer: (value: T) => string): KnockoutObservable<{ [index: string]: T[] }>;
indexBy(indexer: (value: T) => string[]): KnockoutObservable<{ [index: string]: T[] }>;
indexBy(indexer: (value: T) => any): KnockoutObservable<any>;
uniqueIndexBy(indexer: (value: T) => string): KnockoutObservable<{ [index: string]: T }>;
}