From 0abde3e92b1ab8d03de0c11f4dcfaebd9b2ff8d0 Mon Sep 17 00:00:00 2001 From: Haseeb Majid Date: Wed, 1 May 2019 05:38:47 +0100 Subject: [PATCH] Added convert-string (#35047) * Updated react-native-dotenv Updated react-native-dotenv * Fixed errors fixed linting error * Added Convert String Added type definitions for convert string * Fixed Errors Fixed linting errors. * Fixed bugs Fixed bugs with incorrect exports. * Fixed test error Fixed error thrown my azure devops. * Updated after code review Updated tsconfig to change noImplicitAny to false. * Updated tsconfig Updated tsconfig. * Added Changess * Removed changes to react-native-dotenv Removed changes from dot-env. * react-native-dotenv This library should not be updated, this is on the wrong branch. --- types/convert-string/convert-string-tests.ts | 7 +++++++ types/convert-string/index.d.ts | 14 ++++++++++++++ types/convert-string/tsconfig.json | 16 ++++++++++++++++ types/convert-string/tslint.json | 1 + 4 files changed, 38 insertions(+) create mode 100644 types/convert-string/convert-string-tests.ts create mode 100644 types/convert-string/index.d.ts create mode 100644 types/convert-string/tsconfig.json create mode 100644 types/convert-string/tslint.json 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" }