foxts 4.0.0-beta.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
declare function stringToUint8Array(str: string): Uint8Array;
|
|
2
|
-
declare function uint8ArrayToString(array:
|
|
2
|
+
declare function uint8ArrayToString(array: ArrayBuffer | ArrayBufferView, encoding?: string): string;
|
|
3
3
|
declare function base64ToUint8Array(base64String: string): Uint8Array;
|
|
4
4
|
declare function uint8ArrayToBase64(array: Uint8Array, urlSafe?: boolean): string;
|
|
5
|
+
declare function concatUint8Arrays(arrays: Uint8Array[], totalLength?: number): Uint8Array;
|
|
6
|
+
declare function toUint8Array(value: ArrayBuffer | ArrayBufferView): Uint8Array<ArrayBufferLike>;
|
|
5
7
|
|
|
6
|
-
export { base64ToUint8Array, stringToUint8Array, uint8ArrayToBase64, uint8ArrayToString };
|
|
8
|
+
export { base64ToUint8Array, concatUint8Arrays, stringToUint8Array, toUint8Array, uint8ArrayToBase64, uint8ArrayToString };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=new TextEncoder,
|
|
1
|
+
"use strict";var r=require("../guard/index.js");const e=new TextEncoder,t={utf8:new TextDecoder("utf8")};exports.base64ToUint8Array=function(r){return Uint8Array.from(atob(function(r){const e=r.replaceAll("-","+").replaceAll("_","/"),t=(4-e.length%4)%4;return e+"=".repeat(t)}(r)),r=>r.charCodeAt(0))},exports.concatUint8Arrays=function(r,e){if(0===r.length)return new Uint8Array(0);const t=new Uint8Array(e??=r.reduce((r,e)=>r+e.length,0));let n=0;for(let e=0,o=r.length;e<o;e++){const o=r[e];t.set(o,n),n+=o.length}return t},exports.stringToUint8Array=function(r){return e.encode(r)},exports.toUint8Array=function(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):void r.never(e,"value must be ArrayBuffer or ArrayBufferView")},exports.uint8ArrayToBase64=function(r,e=!1){let t="";for(let e=0;e<r.length;e+=65535){const n=r.subarray(e,e+65535);t+=globalThis.btoa(String.fromCharCode.apply(void 0,n))}return e?t.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""):t},exports.uint8ArrayToString=function(r,e="utf8"){return t[e]??=new TextDecoder(e),t[e].decode(r)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=new TextEncoder;function
|
|
1
|
+
import{never as r}from"../guard/index.mjs";const e=new TextEncoder;function t(r){return e.encode(r)}const n={utf8:new TextDecoder("utf8")};function o(r,e="utf8"){return n[e]??=new TextDecoder(e),n[e].decode(r)}function a(r){return Uint8Array.from(atob(function(r){const e=r.replaceAll("-","+").replaceAll("_","/"),t=(4-e.length%4)%4;return e+"=".repeat(t)}(r)),r=>r.charCodeAt(0))}function i(r,e=!1){let t="";for(let e=0;e<r.length;e+=65535){const n=r.subarray(e,e+65535);t+=globalThis.btoa(String.fromCharCode.apply(void 0,n))}return e?t.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""):t}function u(r,e){if(0===r.length)return new Uint8Array(0);const t=new Uint8Array(e??=r.reduce((r,e)=>r+e.length,0));let n=0;for(let e=0,o=r.length;e<o;e++){const o=r[e];t.set(o,n),n+=o.length}return t}function f(e){return e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):void r(e,"value must be ArrayBuffer or ArrayBufferView")}export{a as base64ToUint8Array,u as concatUint8Arrays,t as stringToUint8Array,f as toUint8Array,i as uint8ArrayToBase64,o as uint8ArrayToString};
|