🤖 Merge PR #58055 b2a: added base64url encode/decode function types (v1.1.0) by @Merlinio

* b2a: added base64url encode/decode function types

* b2a: added base64url encode/decode function types (indent.fix)
This commit is contained in:
Martin Rubáš
2022-01-07 23:14:17 +01:00
committed by GitHub
parent a7b0f2cce1
commit 95ff90d628
2 changed files with 27 additions and 6 deletions

View File

@@ -1,4 +1,12 @@
import { btoa, atob } from "b2a";
import { atob, atobu, btoa, btoau } from "b2a";
const b64 = btoa ("foo");
const text = atob (b64);
// Conversion to Base64 and back
const encoded = btoa('中文'); // $ExpectType string
const decoded = atob('5Lit5paH'); // $ExpectType string
// Conversion to Base64url and back
const encoded_url = btoau('μπορούμε'); // $ExpectType string
const decoded_url = atobu('zrzPgM6_z4HOv8-NzrzOtQ=='); // $ExpectedType string

23
types/b2a/index.d.ts vendored
View File

@@ -1,6 +1,7 @@
// Type definitions for b2a 1.0
// Type definitions for b2a 1.1
// Project: https://github.com/kaelzhang/b2a#readme
// Definitions by: PatPL <https://github.com/PatPL>
// Merlinio <https://github.com/Merlinio>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
@@ -8,12 +9,24 @@
*/
declare function atob(base64: string): string;
/**
* Converts text into base64 string
*/
/**
* Converts base64url string back into original text
*/
declare function atobu(base64: string): string;
/**
* Converts text into base64 string
*/
declare function btoa(text: string): string;
/**
* Converts text into base64url string
*/
declare function btoau(text: string): string;
export {
atob,
btoa
atobu,
btoa,
btoau
};