mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[fast-json-stable-stringify] Add types
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import stringify = require('fast-json-stable-stringify');
|
||||
|
||||
const obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 };
|
||||
|
||||
stringify(obj); // $ExpectType string
|
||||
// $ExpectType string
|
||||
stringify(obj, (a, b) => {
|
||||
a; // $ExpectType CompareDescriptor
|
||||
b; // $ExpectType CompareDescriptor
|
||||
return a.key < b.key ? 1 : -1;
|
||||
});
|
||||
// $ExpectType string
|
||||
stringify(obj, {
|
||||
cmp(a, b) {
|
||||
a; // $ExpectType CompareDescriptor
|
||||
b; // $ExpectType CompareDescriptor
|
||||
return a.key < b.key ? 1 : -1;
|
||||
},
|
||||
});
|
||||
stringify(obj, { cycles: true }); // $ExpectType string
|
||||
22
types/fast-json-stable-stringify/index.d.ts
vendored
Normal file
22
types/fast-json-stable-stringify/index.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Type definitions for fast-json-stable-stringify 2.0
|
||||
// Project: https://github.com/epoberezkin/fast-json-stable-stringify
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = stringify;
|
||||
|
||||
declare function stringify(obj: any, options?: stringify.Options | stringify.Comparator): string;
|
||||
|
||||
declare namespace stringify {
|
||||
interface Options {
|
||||
cmp?: (a: CompareDescriptor, b: CompareDescriptor) => number;
|
||||
cycles?: boolean;
|
||||
}
|
||||
|
||||
type Comparator = (a: CompareDescriptor, b: CompareDescriptor) => number;
|
||||
|
||||
interface CompareDescriptor {
|
||||
key: string;
|
||||
value: any;
|
||||
}
|
||||
}
|
||||
23
types/fast-json-stable-stringify/tsconfig.json
Normal file
23
types/fast-json-stable-stringify/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",
|
||||
"fast-json-stable-stringify-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/fast-json-stable-stringify/tslint.json
Normal file
1
types/fast-json-stable-stringify/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user