From 3c2deac60735f995c2263f7045b6ea8090a9f39f Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 17 Apr 2024 01:47:55 +0700 Subject: [PATCH] fix the place of `Uint8Array` to / from base64 and hex in the readme --- README.md | 58 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 5ea56a6b8cb4..53444ba34044 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`Array.fromAsync`](#arrayfromasync) - [`JSON.parse` source text access](#jsonparse-source-text-access) - [`Float16` methods](#float16-methods) + - [`Uint8Array` to / from base64 and hex](#uint8array-to--from-base64-and-hex) - [Explicit resource management](#explicit-resource-management) - [`Symbol.metadata` for decorators metadata proposal](#symbolmetadata-for-decorators-metadata-proposal) - [Stage 2.7 proposals](#stage-27-proposals) @@ -173,7 +174,6 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`String.dedent`](#stringdedent) - [`RegExp` escaping](#regexp-escaping) - [`Symbol` predicates](#symbol-predicates) - - [`Uint8Array` to / from base64 and hex](#uint8array-to--from-base64-and-hex) - [Stage 1 proposals](#stage-1-proposals) - [`Observable`](#observable) - [New collections methods](#new-collections-methods) @@ -2423,6 +2423,34 @@ view.setFloat16(0, 1.337); console.log(view.getFloat16(0)); // => 1.3369140625 ``` +##### [`Uint8Array` to / from base64 and hex](https://github.com/tc39/proposal-arraybuffer-base64)[⬆](#index) +Modules [`esnext.uint8-array.from-base64`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.from-base64.js), [`esnext.uint8-array.from-hex`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.from-hex.js), [`esnext.uint8-array.to-base64`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.to-base64.js), [`esnext.uint8-array.to-hex`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.to-hex.js). +```js +class Uint8Array { + static fromBase64(string, options?: { alphabet?: 'base64' | 'base64url', strict?: boolean }): Uint8Array; + static fromHex(string): Uint8Array; + toBase64(options?: { alphabet?: 'base64' | 'base64url' }): string; + toHex(): string; +} +``` +``` +[*CommonJS entry points:*](#commonjs-api) +```js +core-js/proposals/array-buffer-base64 +core-js(-pure)/full/typed-array/from-base64 +core-js(-pure)/full/typed-array/from-hex +core-js(-pure)/full/typed-array/to-base64 +core-js(-pure)/full/typed-array/to-hex +``` +*Example*: +```js +let arr = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]); +console.log(arr.toBase64()); // => 'SGVsbG8gV29ybGQ=' +console.log(arr.toHex()); // => '48656c6c6f20576f726c64' +console.log(Uint8Array.fromBase64('SGVsbG8gV29ybGQ=')); // => Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]) +console.log(Uint8Array.fromHex('48656c6c6f20576f726c64')); // => Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]) +``` + ##### [Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management)[⬆](#index) Note: **This is only built-ins for this proposal, `using` syntax support requires transpiler support.** @@ -2761,34 +2789,6 @@ Symbol.isWellKnownSymbol(Symbol.iterator); // => true Symbol.isWellKnownSymbol(Symbol('key')); // => false ``` -##### [`Uint8Array` to / from base64 and hex](https://github.com/tc39/proposal-arraybuffer-base64)[⬆](#index) -Modules [`esnext.uint8-array.from-base64`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.from-base64.js), [`esnext.uint8-array.from-hex`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.from-hex.js), [`esnext.uint8-array.to-base64`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.to-base64.js), [`esnext.uint8-array.to-hex`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.uint8-array.to-hex.js). -```js -class Uint8Array { - static fromBase64(string, options?: { alphabet?: 'base64' | 'base64url', strict?: boolean }): Uint8Array; - static fromHex(string): Uint8Array; - toBase64(options?: { alphabet?: 'base64' | 'base64url' }): string; - toHex(): string; -} -``` -``` -[*CommonJS entry points:*](#commonjs-api) -```js -core-js/proposals/array-buffer-base64 -core-js(-pure)/full/typed-array/from-base64 -core-js(-pure)/full/typed-array/from-hex -core-js(-pure)/full/typed-array/to-base64 -core-js(-pure)/full/typed-array/to-hex -``` -*Example*: -```js -let arr = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]); -console.log(arr.toBase64()); // => 'SGVsbG8gV29ybGQ=' -console.log(arr.toHex()); // => '48656c6c6f20576f726c64' -console.log(Uint8Array.fromBase64('SGVsbG8gV29ybGQ=')); // => Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]) -console.log(Uint8Array.fromHex('48656c6c6f20576f726c64')); // => Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]) -``` - #### Stage 1 proposals[⬆](#index) [*CommonJS entry points:*](#commonjs-api) ```js