From 16842558c2b62b48527ecccd1edc7642ff05f1ea Mon Sep 17 00:00:00 2001 From: Dolan Date: Wed, 30 Nov 2016 11:30:45 +0000 Subject: [PATCH 1/8] base-64 typings --- base-64/index.d.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 base-64/index.d.ts diff --git a/base-64/index.d.ts b/base-64/index.d.ts new file mode 100644 index 0000000000..bd44e9239c --- /dev/null +++ b/base-64/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for base-64 0.1.0 +// Project: https://github.com/mathiasbynens/base64 +// Definitions by: Dolan Miu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'base-64' { +interface base64static { + /** + * A string representing the semantic version number. + */ + version: string; + + /** + * This function takes a byte string (the input parameter) and encodes it according to base64. + * The input data must be in the form of a string containing only characters + * in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. + * The base64.encode() function is designed to be fully compatible + * with btoa() as described in the HTML Standard. + * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa + */ + encode(input: string): string; + + /** + * This function takes a base64-encoded string (the input parameter) and decodes it. + * The return value is in the form of a string containing only characters in + * the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. + * The base64.decode() function is designed to be fully compatible + * with atob() as described in the HTML Standard. + * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob + */ + decode(input: string): string; +} + +var base64: base64static; + +export = base64; +} From 47623d23102c51f0b40caa6e0363bc1c8f61a89c Mon Sep 17 00:00:00 2001 From: Dolan Date: Wed, 30 Nov 2016 11:50:58 +0000 Subject: [PATCH 2/8] formatting and indenting --- base-64/index.d.ts | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/base-64/index.d.ts b/base-64/index.d.ts index bd44e9239c..5265a07594 100644 --- a/base-64/index.d.ts +++ b/base-64/index.d.ts @@ -4,34 +4,34 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'base-64' { -interface base64static { - /** - * A string representing the semantic version number. - */ - version: string; - - /** - * This function takes a byte string (the input parameter) and encodes it according to base64. - * The input data must be in the form of a string containing only characters - * in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. - * The base64.encode() function is designed to be fully compatible - * with btoa() as described in the HTML Standard. - * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa - */ - encode(input: string): string; - - /** - * This function takes a base64-encoded string (the input parameter) and decodes it. - * The return value is in the form of a string containing only characters in - * the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. - * The base64.decode() function is designed to be fully compatible - * with atob() as described in the HTML Standard. - * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob - */ - decode(input: string): string; -} + interface base64static { + /** + * A string representing the semantic version number. + */ + version: string; -var base64: base64static; + /** + * This function takes a byte string (the input parameter) and encodes it according to base64. + * The input data must be in the form of a string containing only characters + * in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. + * The base64.encode() function is designed to be fully compatible + * with btoa() as described in the HTML Standard. + * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa + */ + encode(input: string): string; -export = base64; + /** + * This function takes a base64-encoded string (the input parameter) and decodes it. + * The return value is in the form of a string containing only characters in + * the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. + * The base64.decode() function is designed to be fully compatible + * with atob() as described in the HTML Standard. + * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob + */ + decode(input: string): string; + } + + var base64: base64static; + + export = base64; } From beb8ed8d531f478a7d8d841884c6998ee1b61462 Mon Sep 17 00:00:00 2001 From: Dolan Date: Tue, 6 Dec 2016 16:28:47 +0000 Subject: [PATCH 3/8] added tsconfig and tslint --- base-64/tsconfig.json | 18 ++++++++++++++++++ base-64/tslint.json | 1 + 2 files changed, 19 insertions(+) create mode 100644 base-64/tsconfig.json create mode 100644 base-64/tslint.json diff --git a/base-64/tsconfig.json b/base-64/tsconfig.json new file mode 100644 index 0000000000..0f2be78cfb --- /dev/null +++ b/base-64/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} \ No newline at end of file diff --git a/base-64/tslint.json b/base-64/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/base-64/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 100752ac635f3e1ccb74d7dd3b8fc8af23bca81d Mon Sep 17 00:00:00 2001 From: Dolan Date: Tue, 6 Dec 2016 16:43:14 +0000 Subject: [PATCH 4/8] removed patch number --- base-64/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base-64/index.d.ts b/base-64/index.d.ts index 5265a07594..17537ac371 100644 --- a/base-64/index.d.ts +++ b/base-64/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for base-64 0.1.0 +// Type definitions for base-64 0.1 // Project: https://github.com/mathiasbynens/base64 // Definitions by: Dolan Miu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 11e3fea84f703087d4cb99dd665c9e70cc7e2798 Mon Sep 17 00:00:00 2001 From: Dolan Date: Tue, 6 Dec 2016 16:45:25 +0000 Subject: [PATCH 5/8] added tests --- base-64/base-64-tests.ts | 11 +++++++++++ base-64/tsconfig.json | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 base-64/base-64-tests.ts diff --git a/base-64/base-64-tests.ts b/base-64/base-64-tests.ts new file mode 100644 index 0000000000..0f33ff9700 --- /dev/null +++ b/base-64/base-64-tests.ts @@ -0,0 +1,11 @@ +import * as base64 from 'base-64'; +import * as utf8 from 'utf8'; + +let text = 'foo © bar 𝌆 baz'; +let bytes = utf8.encode(text); +let encoded = base64.encode(bytes); +// → 'Zm9vIMKpIGJhciDwnYyGIGJheg==' + +encoded = 'Zm9vIMKpIGJhciDwnYyGIGJheg=='; +bytes = base64.decode(encoded); +text = utf8.decode(bytes); diff --git a/base-64/tsconfig.json b/base-64/tsconfig.json index 0f2be78cfb..e12b07da98 100644 --- a/base-64/tsconfig.json +++ b/base-64/tsconfig.json @@ -13,6 +13,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "base-64-tests.ts" ] } \ No newline at end of file From 0925cd553519072d6d1124ce96043feffba5de87 Mon Sep 17 00:00:00 2001 From: Dolan Date: Tue, 6 Dec 2016 16:53:12 +0000 Subject: [PATCH 6/8] made it export like base64-js --- base-64/base-64-tests.ts | 2 ++ base-64/index.d.ts | 55 ++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/base-64/base-64-tests.ts b/base-64/base-64-tests.ts index 0f33ff9700..a0f85f09aa 100644 --- a/base-64/base-64-tests.ts +++ b/base-64/base-64-tests.ts @@ -9,3 +9,5 @@ let encoded = base64.encode(bytes); encoded = 'Zm9vIMKpIGJhciDwnYyGIGJheg=='; bytes = base64.decode(encoded); text = utf8.decode(bytes); + +let version = base64.version; diff --git a/base-64/index.d.ts b/base-64/index.d.ts index 17537ac371..ba72735406 100644 --- a/base-64/index.d.ts +++ b/base-64/index.d.ts @@ -3,35 +3,36 @@ // Definitions by: Dolan Miu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module 'base-64' { - interface base64static { - /** - * A string representing the semantic version number. - */ - version: string; +export interface base64static { + /** + * A string representing the semantic version number. + */ + version: string; - /** - * This function takes a byte string (the input parameter) and encodes it according to base64. - * The input data must be in the form of a string containing only characters - * in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. - * The base64.encode() function is designed to be fully compatible - * with btoa() as described in the HTML Standard. - * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa - */ - encode(input: string): string; - /** - * This function takes a base64-encoded string (the input parameter) and decodes it. - * The return value is in the form of a string containing only characters in - * the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. - * The base64.decode() function is designed to be fully compatible - * with atob() as described in the HTML Standard. - * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob - */ - decode(input: string): string; - } + encode(input: string): string; - var base64: base64static; - export = base64; + decode(input: string): string; } + +export const version: string; + + /** + * This function takes a byte string (the input parameter) and encodes it according to base64. + * The input data must be in the form of a string containing only characters + * in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. + * The base64.encode() function is designed to be fully compatible + * with btoa() as described in the HTML Standard. + * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa + */ +export function encode(input: string): string; + /** + * This function takes a base64-encoded string (the input parameter) and decodes it. + * The return value is in the form of a string containing only characters in + * the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. + * The base64.decode() function is designed to be fully compatible + * with atob() as described in the HTML Standard. + * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob + */ +export function decode(input: string): string; \ No newline at end of file From 90147825b9c2d0782c42b2e40e6802d456ef6827 Mon Sep 17 00:00:00 2001 From: Dolan Date: Tue, 6 Dec 2016 16:53:35 +0000 Subject: [PATCH 7/8] removed old code --- base-64/index.d.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/base-64/index.d.ts b/base-64/index.d.ts index ba72735406..d78ef47761 100644 --- a/base-64/index.d.ts +++ b/base-64/index.d.ts @@ -3,19 +3,6 @@ // Definitions by: Dolan Miu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export interface base64static { - /** - * A string representing the semantic version number. - */ - version: string; - - - encode(input: string): string; - - - decode(input: string): string; -} - export const version: string; /** From cd60261ec8791a6e89c3054099ab58f054f87dcb Mon Sep 17 00:00:00 2001 From: Dolan Date: Tue, 6 Dec 2016 16:53:49 +0000 Subject: [PATCH 8/8] formatted code --- base-64/index.d.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/base-64/index.d.ts b/base-64/index.d.ts index d78ef47761..3d6fd885d2 100644 --- a/base-64/index.d.ts +++ b/base-64/index.d.ts @@ -5,21 +5,21 @@ export const version: string; - /** - * This function takes a byte string (the input parameter) and encodes it according to base64. - * The input data must be in the form of a string containing only characters - * in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. - * The base64.encode() function is designed to be fully compatible - * with btoa() as described in the HTML Standard. - * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa - */ +/** + * This function takes a byte string (the input parameter) and encodes it according to base64. + * The input data must be in the form of a string containing only characters + * in the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. + * The base64.encode() function is designed to be fully compatible + * with btoa() as described in the HTML Standard. + * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-btoa + */ export function encode(input: string): string; - /** - * This function takes a base64-encoded string (the input parameter) and decodes it. - * The return value is in the form of a string containing only characters in - * the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. - * The base64.decode() function is designed to be fully compatible - * with atob() as described in the HTML Standard. - * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob - */ +/** + * This function takes a base64-encoded string (the input parameter) and decodes it. + * The return value is in the form of a string containing only characters in + * the range from U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF. + * The base64.decode() function is designed to be fully compatible + * with atob() as described in the HTML Standard. + * see: https://html.spec.whatwg.org/multipage/webappapis.html#dom-windowbase64-atob + */ export function decode(input: string): string; \ No newline at end of file