diff --git a/types/react-native-uuid/index.d.ts b/types/react-native-uuid/index.d.ts new file mode 100644 index 0000000000..78d98b6d7e --- /dev/null +++ b/types/react-native-uuid/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for react-native-uuid 1.4 +// Project: https://github.com/eugenehp/react-native-uuid +// Definitions by: hmajid2301 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 + +interface v1 { + node: number[]; + clockseq: number; + msecs: number | Date; + nsecs: number; +} + +interface v4 { + random?: number[]; + rng?: (...args: any) => void; +} + +interface uuid { + v1: (options?: v1, buffer?: ArrayBuffer, offset?: number) => string; + v4: (options?: v4, buffer?: ArrayBuffer, offset?: number) => string; + parse: (id: string, buffer?: ArrayBuffer, offset?: number) => ArrayBuffer; + unparse: (buffer?: ArrayBuffer, offset?: number) => string; + noConflict: () => string; +} + +declare const uuid: uuid; +export = uuid; diff --git a/types/react-native-uuid/react-native-uuid-tests.ts b/types/react-native-uuid/react-native-uuid-tests.ts new file mode 100644 index 0000000000..aadeba34f2 --- /dev/null +++ b/types/react-native-uuid/react-native-uuid-tests.ts @@ -0,0 +1,19 @@ +import uuid from 'react-native-uuid'; + +uuid.v1({ + node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab], + clockseq: 0x1234, + msecs: new Date('2011-11-01').getTime(), + nsecs: 5678 +}); + +uuid.v4({ + random: [ + 0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea, + 0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36 + ] +}); + +const bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); +const string = uuid.unparse(bytes); +const myUuid = uuid.noConflict(); diff --git a/types/react-native-uuid/tsconfig.json b/types/react-native-uuid/tsconfig.json new file mode 100644 index 0000000000..61edf9448d --- /dev/null +++ b/types/react-native-uuid/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "allowSyntheticDefaultImports": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-native-uuid-tests.ts" + ] +} \ No newline at end of file diff --git a/types/react-native-uuid/tslint.json b/types/react-native-uuid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-uuid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }