mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Add @types/compare-function. (#35702)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
9cf9f56dd4
commit
f506e66ccb
19
types/compare-function/compare-function-tests.ts
Normal file
19
types/compare-function/compare-function-tests.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import compare = require('compare-function');
|
||||
|
||||
const songs = [{
|
||||
artist: 'Joy Division',
|
||||
track: 'Warsaw'
|
||||
}, {
|
||||
artist: 'New Order',
|
||||
track: 'Blue Monday'
|
||||
}, {
|
||||
artist: 'Freebass',
|
||||
track: 'Plan B'
|
||||
}];
|
||||
|
||||
function artist(song: {artist: string}) {
|
||||
return song.artist;
|
||||
}
|
||||
|
||||
songs.sort(compare(artist)).map(artist);
|
||||
songs.sort(compare(-1, artist)).map(artist);
|
||||
8
types/compare-function/index.d.ts
vendored
Normal file
8
types/compare-function/index.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// Type definitions for compare-function 2.0
|
||||
// Project: https://github.com/michaelrhodes/compare-function
|
||||
// Definitions by: Wolfgang Faust <https://github.com/wolfgang42>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function compare<T>(fn: (item: T) => any): (a: T, b: T) => -1 | 0 | 1;
|
||||
declare function compare<T>(sign: number, fn: (item: T) => any): (a: T, b: T) => -1 | 0 | 1;
|
||||
export = compare;
|
||||
23
types/compare-function/tsconfig.json
Normal file
23
types/compare-function/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"compare-function-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/compare-function/tslint.json
Normal file
1
types/compare-function/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user