mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-05 01:30:17 +00:00
Merge pull request #11928 from shantanubhadoria/master
new types for npm ejson library
This commit is contained in:
57
ejson/ejson-tests.ts
Normal file
57
ejson/ejson-tests.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
/// <reference path="./ejson.d.ts" />
|
||||
|
||||
import {
|
||||
clone as importedClone,
|
||||
parse as importedParse,
|
||||
stringify as importedStringify,
|
||||
toJSONValue as importedToJSONValue,
|
||||
fromJSONValue as importedFromJSONValue,
|
||||
isBinary as importedIsBinary,
|
||||
newBinary as importedNewBinary,
|
||||
equals as importedEquals
|
||||
} from "ejson";
|
||||
|
||||
function testImportedClone() {
|
||||
var obj: Object = {
|
||||
a: "a"
|
||||
};
|
||||
var retval: Object = importedClone(obj);
|
||||
|
||||
var str: string = "as";
|
||||
var retval2: string = importedClone(str);
|
||||
}
|
||||
|
||||
function testParse() {
|
||||
var str: string = '{a:"a"}';
|
||||
importedParse(str);
|
||||
}
|
||||
|
||||
function testStringify() {
|
||||
var obj: any = {a:"a"};
|
||||
var retval: string = importedStringify(obj);
|
||||
}
|
||||
|
||||
function testToJSONValue() {
|
||||
var obj: any = {a:"a"};
|
||||
var retval: string = importedToJSONValue(obj);
|
||||
}
|
||||
|
||||
function testFromJSONValue() {
|
||||
var str: string = '{a:"a"}';
|
||||
importedFromJSONValue(str);
|
||||
}
|
||||
|
||||
function testIsBinary() {
|
||||
var val: any = 'sasda';
|
||||
var retval: boolean = importedIsBinary(val);
|
||||
}
|
||||
|
||||
function testNewBinary() {
|
||||
var retval: Uint8Array = importedNewBinary(3);
|
||||
}
|
||||
|
||||
function testEquals() {
|
||||
var a: any;
|
||||
var b: any;
|
||||
var retval: boolean = importedEquals(a,b);
|
||||
}
|
||||
26
ejson/ejson.d.ts
vendored
Normal file
26
ejson/ejson.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for ejson v2.1.2
|
||||
// Project: https://www.npmjs.com/package/ejson
|
||||
// Definitions by: Shantanu Bhadoria <https://github.com/shantanubhadoria>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare module "ejson" {
|
||||
interface StringifyOptions {
|
||||
canonical: boolean;
|
||||
indent: boolean|number|string;
|
||||
}
|
||||
|
||||
interface CloneOptions {
|
||||
keyOrderSensitive: boolean;
|
||||
}
|
||||
|
||||
function clone<T>(obj: T): T;
|
||||
function parse(str: string): any;
|
||||
function stringify(obj: any, options?: StringifyOptions): string;
|
||||
|
||||
function toJSONValue(obj: any): string;
|
||||
function fromJSONValue(obj: string): any;
|
||||
function isBinary(value: any): boolean;
|
||||
function newBinary(len: number): Uint8Array;
|
||||
function equals(a: any, b: any, options?: CloneOptions): boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user