🤖 Merge PR #45070 update(base64-js): v1.3 and UMD support by @peterblazejewicz

- update to v1.3 (no external API change)
- correct module definition to support direct use in browsers as package
  is exported as UMD
- tests updated
- maintainer added

https://unpkg.com/base64-js@1.3.1/base64js.min.js
https://github.com/beatgammit/base64-js#base64-js

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-05-30 13:34:46 +02:00 committed by GitHub
parent 049a947d56
commit ee2ea4e569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 3 deletions

View File

@ -1,8 +1,23 @@
// Type definitions for base64-js 1.2
// Type definitions for base64-js 1.3
// Project: https://github.com/beatgammit/base64-js
// Definitions by: Peter Safranek <https://github.com/pe8ter>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Takes a base64 string and returns length of byte array
*/
export function byteLength(encoded: string): number;
/**
* Takes a base64 string and returns a byte array
*/
export function toByteArray(encoded: string): Uint8Array;
/**
* Takes a byte array and returns a base64 string
*/
export function fromByteArray(bytes: Uint8Array): string;
/**
* base64-js does basic base64 encoding/decoding in pure JS.
*/
export as namespace base64js;

View File

@ -1,4 +1,4 @@
import * as base64js from "base64-js";
import base64js = require("base64-js");
base64js.byteLength(""); // $ExpectType number
base64js.toByteArray(""); // $ExpectType Uint8Array

View File

@ -0,0 +1,3 @@
base64js.byteLength(''); // $ExpectType number
base64js.toByteArray(''); // $ExpectType Uint8Array
base64js.fromByteArray(new Uint8Array(0)); // $ExpectType string

View File

@ -18,6 +18,7 @@
},
"files": [
"index.d.ts",
"base64-js-tests.ts"
"test/base64-js-tests.cjs.ts",
"test/base64-js-tests.global.ts"
]
}