diff --git a/ejson/ejson-tests.ts b/ejson/ejson-tests.ts new file mode 100644 index 0000000000..ef9b940bb8 --- /dev/null +++ b/ejson/ejson-tests.ts @@ -0,0 +1,57 @@ +/// + +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); +} \ No newline at end of file diff --git a/ejson/ejson.d.ts b/ejson/ejson.d.ts new file mode 100644 index 0000000000..029222239c --- /dev/null +++ b/ejson/ejson.d.ts @@ -0,0 +1,26 @@ +// Type definitions for ejson v2.1.2 +// Project: https://www.npmjs.com/package/ejson +// Definitions by: Shantanu Bhadoria +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare module "ejson" { + interface StringifyOptions { + canonical: boolean; + indent: boolean|number|string; + } + + interface CloneOptions { + keyOrderSensitive: boolean; + } + + function clone(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; +}