diff --git a/types/convert-string/convert-string-tests.ts b/types/convert-string/convert-string-tests.ts new file mode 100644 index 0000000000..1a7403761a --- /dev/null +++ b/types/convert-string/convert-string-tests.ts @@ -0,0 +1,7 @@ +import { convertString } from "convert-string"; + +const utf8Bytes = convertString.UTF8.stringToBytes("Test ♥"); +const utf8Message = convertString.UTF8.bytesToString(utf8Bytes); + +const bytes = convertString.stringToBytes("Hello"); +const message = convertString.bytesToString(bytes); diff --git a/types/convert-string/index.d.ts b/types/convert-string/index.d.ts new file mode 100644 index 0000000000..be5bb4438e --- /dev/null +++ b/types/convert-string/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for convert-string 0.1 +// Project: https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Haseeb Majid +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export namespace convertString { + function stringToBytes(str: string): number[]; + function bytesToString(bytes: number[]): string; + + namespace UTF8 { + function stringToBytes(str: string): number[]; + function bytesToString(bytes: number[]): string; + } +} diff --git a/types/convert-string/tsconfig.json b/types/convert-string/tsconfig.json new file mode 100644 index 0000000000..9e64007203 --- /dev/null +++ b/types/convert-string/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "convert-string-tests.ts"] +} diff --git a/types/convert-string/tslint.json b/types/convert-string/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/convert-string/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }