Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

uint8arrays

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uint8arrays - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

alloc

4

cjs/src/concat.js

@@ -5,2 +5,4 @@ 'use strict';

var alloc = require('./alloc.js');
function concat(arrays, length) {

@@ -10,3 +12,3 @@ if (!length) {

}
const output = new Uint8Array(length);
const output = alloc.allocUnsafe(length);
let offset = 0;

@@ -13,0 +15,0 @@ for (const arr of arrays) {

@@ -12,2 +12,5 @@ 'use strict';

}
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
return globalThis.Buffer.from(string, 'utf8');
}
return base.decoder.decode(`${ base.prefix }${ string }`);

@@ -14,0 +17,0 @@ }

@@ -12,2 +12,5 @@ 'use strict';

}
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString('utf8');
}
return base.encoder.encode(array).substring(1);

@@ -14,0 +17,0 @@ }

'use strict';
var basics = require('multiformats/basics');
var alloc = require('../alloc.js');

@@ -32,3 +33,3 @@ function createCodec(name, prefix, encode, decode) {

str = str.substring(1);
const buf = new Uint8Array(str.length);
const buf = alloc.allocUnsafe(str.length);
for (let i = 0; i < str.length; i++) {

@@ -35,0 +36,0 @@ buf[i] = str.charCodeAt(i);

@@ -5,2 +5,4 @@ 'use strict';

var alloc = require('./alloc.js');
function xor(a, b) {

@@ -10,3 +12,3 @@ if (a.length !== b.length) {

}
const result = new Uint8Array(a.length);
const result = alloc.allocUnsafe(a.length);
for (let i = 0; i < a.length; i++) {

@@ -13,0 +15,0 @@ result[i] = a[i] ^ b[i];

@@ -0,1 +1,2 @@

import { allocUnsafe } from './alloc.js';
export function concat(arrays, length) {

@@ -5,3 +6,3 @@ if (!length) {

}
const output = new Uint8Array(length);
const output = allocUnsafe(length);
let offset = 0;

@@ -8,0 +9,0 @@ for (const arr of arrays) {

@@ -7,3 +7,6 @@ import bases from './util/bases.js';

}
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
return globalThis.Buffer.from(string, 'utf8');
}
return base.decoder.decode(`${ base.prefix }${ string }`);
}

@@ -7,3 +7,6 @@ import bases from './util/bases.js';

}
if ((encoding === 'utf8' || encoding === 'utf-8') && globalThis.Buffer != null && globalThis.Buffer.from != null) {
return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString('utf8');
}
return base.encoder.encode(array).substring(1);
}
import { bases } from 'multiformats/basics';
import { allocUnsafe } from '../alloc.js';
function createCodec(name, prefix, encode, decode) {

@@ -29,3 +30,3 @@ return {

str = str.substring(1);
const buf = new Uint8Array(str.length);
const buf = allocUnsafe(str.length);
for (let i = 0; i < str.length; i++) {

@@ -32,0 +33,0 @@ buf[i] = str.charCodeAt(i);

@@ -0,1 +1,2 @@

import { allocUnsafe } from './alloc.js';
export function xor(a, b) {

@@ -5,3 +6,3 @@ if (a.length !== b.length) {

}
const result = new Uint8Array(a.length);
const result = allocUnsafe(a.length);
for (let i = 0; i < a.length; i++) {

@@ -8,0 +9,0 @@ result[i] = a[i] ^ b[i];

(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Uint8arrays = factory()}(typeof self !== 'undefined' ? self : this, function () {
var Uint8arrays=(()=>{var ne=Object.defineProperty;var Te=r=>ne(r,"__esModule",{value:!0});var l=(r,e)=>{Te(r);for(var t in e)ne(r,t,{get:e[t],enumerable:!0})};var qt={};l(qt,{compare:()=>ie,concat:()=>ae,equals:()=>ce,fromString:()=>Le,toString:()=>Me,xor:()=>Ne});function ie(r,e){for(let t=0;t<r.byteLength;t++){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1}return r.byteLength>e.byteLength?1:r.byteLength<e.byteLength?-1:0}function ae(r,e){e||(e=r.reduce((o,n)=>o+n.length,0));let t=new Uint8Array(e),s=0;for(let o of r)t.set(o,s),s+=o.length;return t}function ce(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var X={};l(X,{identity:()=>Re});function Be(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),s=0;s<t.length;s++)t[s]=255;for(var o=0;o<r.length;o++){var n=r.charAt(o),a=n.charCodeAt(0);if(t[a]!==255)throw new TypeError(n+" is ambiguous");t[a]=o}var d=r.length,f=r.charAt(0),U=Math.log(d)/Math.log(256),b=Math.log(256)/Math.log(d);function D(i){if(i instanceof Uint8Array||(ArrayBuffer.isView(i)?i=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):Array.isArray(i)&&(i=Uint8Array.from(i))),!(i instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(i.length===0)return"";for(var p=0,A=0,m=0,g=i.length;m!==g&&i[m]===0;)m++,p++;for(var y=(g-m)*b+1>>>0,u=new Uint8Array(y);m!==g;){for(var x=i[m],E=0,w=y-1;(x!==0||E<A)&&w!==-1;w--,E++)x+=256*u[w]>>>0,u[w]=x%d>>>0,x=x/d>>>0;if(x!==0)throw new Error("Non-zero carry");A=E,m++}for(var j=y-A;j!==y&&u[j]===0;)j++;for(var k=f.repeat(p);j<y;++j)k+=r.charAt(u[j]);return k}function V(i){if(typeof i!="string")throw new TypeError("Expected String");if(i.length===0)return new Uint8Array;var p=0;if(i[p]!==" "){for(var A=0,m=0;i[p]===f;)A++,p++;for(var g=(i.length-p)*U+1>>>0,y=new Uint8Array(g);i[p];){var u=t[i.charCodeAt(p)];if(u===255)return;for(var x=0,E=g-1;(u!==0||x<m)&&E!==-1;E--,x++)u+=d*y[E]>>>0,y[E]=u%256>>>0,u=u/256>>>0;if(u!==0)throw new Error("Non-zero carry");m=x,p++}if(i[p]!==" "){for(var w=g-m;w!==g&&y[w]===0;)w++;for(var j=new Uint8Array(A+(g-w)),k=A;w!==g;)j[k++]=y[w++];return j}}}function Oe(i){var p=V(i);if(p)return p;throw new Error(`Non-${e} character`)}return{encode:D,decodeUnsafe:V,decode:Oe}}var Ve=Be,ke=Ve,de=ke;var Xt=new Uint8Array(0);var he=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},S=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var fe=r=>new TextEncoder().encode(r),pe=r=>new TextDecoder().decode(r);var ue=class{constructor(e,t,s){this.name=e,this.prefix=t,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},le=class{constructor(e,t,s){this.name=e,this.prefix=t,this.baseDecode=s}decode(e){if(typeof e=="string")switch(e[0]){case this.prefix:return this.baseDecode(e.slice(1));default:throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`)}else throw Error("Can only multibase decode strings")}or(e){let t={[this.prefix]:this,...e.decoders||{[e.prefix]:e}};return new q(t)}},q=class{constructor(e){this.decoders=e}or(e){let t=e.decoders||{[e.prefix]:e};return new q({...this.decoders,...t})}decode(e){let t=e[0],s=this.decoders[t];if(s)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},me=class{constructor(e,t,s,o){this.name=e,this.prefix=t,this.baseEncode=s,this.baseDecode=o,this.encoder=new ue(e,t,s),this.decoder=new le(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},$=({name:r,prefix:e,encode:t,decode:s})=>new me(r,e,t,s),C=({prefix:r,name:e,alphabet:t})=>{let{encode:s,decode:o}=de(t,e);return $({prefix:r,name:e,encode:s,decode:n=>S(o(n))})},qe=(r,e,t,s)=>{let o={};for(let b=0;b<e.length;++b)o[e[b]]=b;let n=r.length;for(;r[n-1]==="=";)--n;let a=new Uint8Array(n*t/8|0),d=0,f=0,U=0;for(let b=0;b<n;++b){let D=o[r[b]];if(D===void 0)throw new SyntaxError(`Non-${s} character`);f=f<<t|D,d+=t,d>=8&&(d-=8,a[U++]=255&f>>d)}if(d>=t||255&f<<8-d)throw new SyntaxError("Unexpected end of data");return a},$e=(r,e,t)=>{let s=e[e.length-1]==="=",o=(1<<t)-1,n="",a=0,d=0;for(let f=0;f<r.length;++f)for(d=d<<8|r[f],a+=8;a>t;)a-=t,n+=e[o&d>>a];if(a&&(n+=e[o&d<<t-a]),s)for(;n.length*t&7;)n+="=";return n},c=({name:r,prefix:e,bitsPerChar:t,alphabet:s})=>$({prefix:e,name:r,encode(o){return $e(o,s,t)},decode(o){return qe(o,s,t,r)}});var Re=$({prefix:"\0",name:"identity",encode:r=>pe(r),decode:r=>fe(r)});var G={};l(G,{base2:()=>Pe});var Pe=c({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var K={};l(K,{base8:()=>Fe});var Fe=c({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Q={};l(Q,{base10:()=>Je});var Je=C({prefix:"9",name:"base10",alphabet:"0123456789"});var H={};l(H,{base16:()=>Xe,base16upper:()=>Ge});var Xe=c({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ge=c({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var W={};l(W,{base32:()=>z,base32hex:()=>We,base32hexpad:()=>Ye,base32hexpadupper:()=>_e,base32hexupper:()=>Ze,base32pad:()=>Qe,base32padupper:()=>He,base32upper:()=>Ke,base32z:()=>et});var z=c({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ke=c({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qe=c({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),He=c({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),We=c({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ze=c({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ye=c({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_e=c({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),et=c({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Z={};l(Z,{base36:()=>tt,base36upper:()=>rt});var tt=C({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rt=C({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Y={};l(Y,{base58btc:()=>v,base58flickr:()=>st});var v=C({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),st=C({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _={};l(_,{base64:()=>ot,base64pad:()=>nt,base64url:()=>it,base64urlpad:()=>at});var ot=c({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nt=c({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),it=c({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),at=c({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var te={};l(te,{sha256:()=>At,sha512:()=>Ut});var ct=ge,we=128,dt=127,ht=~dt,ft=Math.pow(2,31);function ge(r,e,t){e=e||[],t=t||0;for(var s=t;r>=ft;)e[t++]=r&255|we,r/=128;for(;r&ht;)e[t++]=r&255|we,r>>>=7;return e[t]=r|0,ge.bytes=t-s+1,e}var pt=ee,bt=128,ye=127;function ee(r,e){var t=0,e=e||0,s=0,o=e,n,a=r.length;do{if(o>=a)throw ee.bytes=0,new RangeError("Could not decode varint");n=r[o++],t+=s<28?(n&ye)<<s:(n&ye)*Math.pow(2,s),s+=7}while(n>=bt);return ee.bytes=o-e,t}var ut=Math.pow(2,7),lt=Math.pow(2,14),mt=Math.pow(2,21),wt=Math.pow(2,28),gt=Math.pow(2,35),yt=Math.pow(2,42),xt=Math.pow(2,49),vt=Math.pow(2,56),jt=Math.pow(2,63),St=function(r){return r<ut?1:r<lt?2:r<mt?3:r<wt?4:r<gt?5:r<yt?6:r<xt?7:r<vt?8:r<jt?9:10},Et={encode:ct,decode:pt,encodingLength:St},Ct=Et,M=Ct;var N=r=>[M.decode(r),M.decode.bytes],I=(r,e,t=0)=>(M.encode(r,e,t),e),L=r=>M.encodingLength(r);var R=(r,e)=>{let t=e.byteLength,s=L(r),o=s+L(t),n=new Uint8Array(o+t);return I(r,n,0),I(t,n,s),n.set(e,o),new O(r,t,e,n)},ve=r=>{let e=S(r),[t,s]=N(e),[o,n]=N(e.subarray(s)),a=e.subarray(s+n);if(a.byteLength!==o)throw new Error("Incorrect length");return new O(t,o,a,e)},je=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&he(r.bytes,e.bytes),O=class{constructor(e,t,s,o){this.code=e,this.size=t,this.digest=s,this.bytes=o}};var T=({name:r,code:e,encode:t})=>new Ee(r,e,t),Ee=class{constructor(e,t,s){this.name=e,this.code=t,this.encode=s}async digest(e){if(e instanceof Uint8Array){let t=await this.encode(e);return R(this.code,t)}else throw Error("Unknown type, must be binary type")}};var Ae=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),At=T({name:"sha2-256",code:18,encode:Ae("SHA-256")}),Ut=T({name:"sha2-512",code:19,encode:Ae("SHA-512")});var re={};l(re,{identity:()=>Dt});var Dt=T({name:"identity",code:0,encode:r=>S(r)});var h=class{constructor(e,t,s,o){this.code=t,this.version=e,this.multihash=s,this.bytes=o,this.byteOffset=o.byteOffset,this.byteLength=o.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:F,byteLength:F,code:P,version:P,multihash:P,bytes:P,_baseCache:F,asCID:F})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==B)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ot)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return h.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,s=R(e,t);return h.createV1(this.code,s)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&je(this.multihash,e.multihash)}toString(e){let{bytes:t,version:s,_baseCache:o}=this;switch(s){case 0:return Mt(t,o,e||v.encoder);default:return Nt(t,o,e||z.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Bt(/^0\.0/,Vt),!!(e&&(e[De]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof h)return e;if(e!=null&&e.asCID===e){let{version:t,code:s,multihash:o,bytes:n}=e;return new h(t,s,o,n||Ue(t,s,o.bytes))}else if(e!=null&&e[De]===!0){let{version:t,multihash:s,code:o}=e,n=ve(s);return h.create(t,o,n)}else return null}static create(e,t,s){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==B)throw new Error(`Version 0 CID must use dag-pb (code: ${B}) block encoding`);return new h(e,t,s,s.bytes)}case 1:{let o=Ue(e,t,s.bytes);return new h(e,t,s,o)}default:throw new Error("Invalid version")}}static createV0(e){return h.create(0,B,e)}static createV1(e,t){return h.create(1,e,t)}static decode(e){let[t,s]=h.decodeFirst(e);if(s.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=h.inspectBytes(e),s=t.size-t.multihashSize,o=S(e.subarray(s,s+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let n=o.subarray(t.multihashSize-t.digestSize),a=new O(t.multihashCode,t.digestSize,n,o);return[t.version===0?h.createV0(a):h.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,s=()=>{let[D,V]=N(e.subarray(t));return t+=V,D},o=s(),n=B;if(o===18?(o=0,t=0):o===1&&(n=s()),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=t,d=s(),f=s(),U=t+f,b=U-a;return{version:o,codec:n,multihashCode:d,digestSize:f,multihashSize:b,size:U}}static parse(e,t){let[s,o]=Lt(e,t),n=h.decode(o);return n._baseCache.set(s,e),n}},Lt=(r,e)=>{switch(r[0]){case"Q":{let t=e||v;return[v.prefix,t.decode(`${v.prefix}${r}`)]}case v.prefix:{let t=e||v;return[v.prefix,t.decode(r)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Mt=(r,e,t)=>{let{prefix:s}=t;if(s!==v.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(s);if(o==null){let n=t.encode(r).slice(1);return e.set(s,n),n}else return o},Nt=(r,e,t)=>{let{prefix:s}=t,o=e.get(s);if(o==null){let n=t.encode(r);return e.set(s,n),n}else return o},B=112,Ot=18,Ue=(r,e,t)=>{let s=L(r),o=s+L(e),n=new Uint8Array(o+t.byteLength);return I(r,n,0),I(e,n,s),n.set(t,o),n},De=Symbol.for("@ipld/js-cid/CID"),P={writable:!1,configurable:!1,enumerable:!0},F={writable:!1,enumerable:!1,configurable:!1},Tt="0.0.0-dev",Bt=(r,e)=>{if(r.test(Tt))console.warn(e);else throw new Error(e)},Vt=`CID.isCID(v) is deprecated and will be removed in the next major release.
var Uint8arrays=(()=>{var ue=Object.defineProperty;var $e=r=>ue(r,"__esModule",{value:!0});var h=(r,e)=>{$e(r);for(var t in e)ue(r,t,{get:e[t],enumerable:!0})};var Yt={};h(Yt,{compare:()=>De,concat:()=>ie,equals:()=>ae,fromString:()=>Me,toString:()=>Ve,xor:()=>Pe});function De(r,e){for(let t=0;t<r.byteLength;t++){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1}return r.byteLength>e.byteLength?1:r.byteLength<e.byteLength?-1:0}function U(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function ie(r,e){e||(e=r.reduce((s,n)=>s+n.length,0));let t=U(e),o=0;for(let s of r)t.set(s,o),o+=s.length;return t}function ae(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var J={};h(J,{identity:()=>Ke});function qe(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),o=0;o<t.length;o++)t[o]=255;for(var s=0;s<r.length;s++){var n=r.charAt(s),D=n.charCodeAt(0);if(t[D]!==255)throw new TypeError(n+" is ambiguous");t[D]=s}var a=r.length,f=r.charAt(0),B=Math.log(a)/Math.log(256),p=Math.log(256)/Math.log(a);function S(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var d=0,j=0,b=0,C=u.length;b!==C&&u[b]===0;)b++,d++;for(var E=(C-b)*p+1>>>0,l=new Uint8Array(E);b!==C;){for(var g=u[b],v=0,m=E-1;(g!==0||v<j)&&m!==-1;m--,v++)g+=256*l[m]>>>0,l[m]=g%a>>>0,g=g/a>>>0;if(g!==0)throw new Error("Non-zero carry");j=v,b++}for(var x=E-j;x!==E&&l[x]===0;)x++;for(var k=f.repeat(d);x<E;++x)k+=r.charAt(l[x]);return k}function P(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var d=0;if(u[d]!==" "){for(var j=0,b=0;u[d]===f;)j++,d++;for(var C=(u.length-d)*B+1>>>0,E=new Uint8Array(C);u[d];){var l=t[u.charCodeAt(d)];if(l===255)return;for(var g=0,v=C-1;(l!==0||g<b)&&v!==-1;v--,g++)l+=a*E[v]>>>0,E[v]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");b=g,d++}if(u[d]!==" "){for(var m=C-b;m!==C&&E[m]===0;)m++;for(var x=new Uint8Array(j+(C-m)),k=j;m!==C;)x[k++]=E[m++];return x}}}function ke(u){var d=P(u);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:S,decodeUnsafe:P,decode:ke}}var Re=qe,Je=Re,ce=Je;var ur=new Uint8Array(0);var fe=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},y=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var de=r=>new TextEncoder().encode(r),he=r=>new TextDecoder().decode(r);var le=class{constructor(e,t,o){this.name=e,this.prefix=t,this.baseEncode=o}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},be=class{constructor(e,t,o){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=o}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ce(this,e)}},me=class{constructor(e){this.decoders=e}or(e){return Ce(this,e)}decode(e){let t=e[0],o=this.decoders[t];if(o)return o.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Ce=(r,e)=>new me({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Ee=class{constructor(e,t,o,s){this.name=e,this.prefix=t,this.baseEncode=o,this.baseDecode=s,this.encoder=new le(e,t,o),this.decoder=new be(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},T=({name:r,prefix:e,encode:t,decode:o})=>new Ee(r,e,t,o),A=({prefix:r,name:e,alphabet:t})=>{let{encode:o,decode:s}=ce(t,e);return T({prefix:r,name:e,encode:o,decode:n=>y(s(n))})},Xe=(r,e,t,o)=>{let s={};for(let p=0;p<e.length;++p)s[e[p]]=p;let n=r.length;for(;r[n-1]==="=";)--n;let D=new Uint8Array(n*t/8|0),a=0,f=0,B=0;for(let p=0;p<n;++p){let S=s[r[p]];if(S===void 0)throw new SyntaxError(`Non-${o} character`);f=f<<t|S,a+=t,a>=8&&(a-=8,D[B++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return D},Ge=(r,e,t)=>{let o=e[e.length-1]==="=",s=(1<<t)-1,n="",D=0,a=0;for(let f=0;f<r.length;++f)for(a=a<<8|r[f],D+=8;D>t;)D-=t,n+=e[s&a>>D];if(D&&(n+=e[s&a<<t-D]),o)for(;n.length*t&7;)n+="=";return n},i=({name:r,prefix:e,bitsPerChar:t,alphabet:o})=>T({prefix:e,name:r,encode(s){return Ge(s,o,t)},decode(s){return Xe(s,o,t,r)}});var Ke=T({prefix:"\0",name:"identity",encode:r=>he(r),decode:r=>de(r)});var X={};h(X,{base2:()=>Qe});var Qe=i({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var G={};h(G,{base8:()=>He});var He=i({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var K={};h(K,{base10:()=>We});var We=A({prefix:"9",name:"base10",alphabet:"0123456789"});var Q={};h(Q,{base16:()=>Ze,base16upper:()=>Ye});var Ze=i({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ye=i({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var H={};h(H,{base32:()=>z,base32hex:()=>rt,base32hexpad:()=>st,base32hexpadupper:()=>nt,base32hexupper:()=>ot,base32pad:()=>et,base32padupper:()=>tt,base32upper:()=>_e,base32z:()=>ut});var z=i({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_e=i({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),et=i({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tt=i({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rt=i({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ot=i({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),st=i({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),nt=i({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ut=i({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var W={};h(W,{base36:()=>Dt,base36upper:()=>it});var Dt=A({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),it=A({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Z={};h(Z,{base58btc:()=>w,base58flickr:()=>at});var w=A({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),at=A({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Y={};h(Y,{base64:()=>ct,base64pad:()=>ft,base64url:()=>dt,base64urlpad:()=>ht});var ct=i({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ft=i({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),dt=i({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ht=i({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var _={};h(_,{base256emoji:()=>Ct});var ge=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),pt=ge.reduce((r,e,t)=>(r[t]=e,r),[]),lt=ge.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function bt(r){return r.reduce((e,t)=>(e+=pt[t],e),"")}function mt(r){let e=[];for(let t of r){let o=lt[t.codePointAt(0)];if(o===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Ct=T({prefix:"\u{1F680}",name:"base256emoji",encode:bt,decode:mt});var re={};h(re,{sha256:()=>Mt,sha512:()=>Vt});var Et=xe,we=128,gt=127,wt=~gt,xt=Math.pow(2,31);function xe(r,e,t){e=e||[],t=t||0;for(var o=t;r>=xt;)e[t++]=r&255|we,r/=128;for(;r&wt;)e[t++]=r&255|we,r>>>=7;return e[t]=r|0,xe.bytes=t-o+1,e}var yt=ee,vt=128,ye=127;function ee(r,e){var t=0,e=e||0,o=0,s=e,n,D=r.length;do{if(s>=D)throw ee.bytes=0,new RangeError("Could not decode varint");n=r[s++],t+=o<28?(n&ye)<<o:(n&ye)*Math.pow(2,o),o+=7}while(n>=vt);return ee.bytes=s-e,t}var At=Math.pow(2,7),jt=Math.pow(2,14),Ft=Math.pow(2,21),Bt=Math.pow(2,28),St=Math.pow(2,35),Ut=Math.pow(2,42),Tt=Math.pow(2,49),zt=Math.pow(2,56),It=Math.pow(2,63),Lt=function(r){return r<At?1:r<jt?2:r<Ft?3:r<Bt?4:r<St?5:r<Ut?6:r<Tt?7:r<zt?8:r<It?9:10},Nt={encode:Et,decode:yt,encodingLength:Lt},Ot=Nt,N=Ot;var O=r=>[N.decode(r),N.decode.bytes],I=(r,e,t=0)=>(N.encode(r,e,t),e),L=r=>N.encodingLength(r);var F=(r,e)=>{let t=e.byteLength,o=L(r),s=o+L(t),n=new Uint8Array(s+t);return I(r,n,0),I(t,n,o),n.set(e,s),new M(r,t,e,n)},Ae=r=>{let e=y(r),[t,o]=O(e),[s,n]=O(e.subarray(o)),D=e.subarray(o+n);if(D.byteLength!==s)throw new Error("Incorrect length");return new M(t,s,D,e)},je=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&fe(r.bytes,e.bytes),M=class{constructor(e,t,o,s){this.code=e,this.size=t,this.digest=o,this.bytes=s}};var te=({name:r,code:e,encode:t})=>new Be(r,e,t),Be=class{constructor(e,t,o){this.name=e,this.code=t,this.encode=o}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?F(this.code,t):t.then(o=>F(this.code,o))}else throw Error("Unknown type, must be binary type")}};var Ue=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Mt=te({name:"sha2-256",code:18,encode:Ue("SHA-256")}),Vt=te({name:"sha2-512",code:19,encode:Ue("SHA-512")});var oe={};h(oe,{identity:()=>$t});var Te=0,Pt="identity",ze=y,kt=r=>F(Te,ze(r)),$t={code:Te,name:Pt,encode:ze,digest:kt};var Ur=new TextEncoder,Tr=new TextDecoder;var c=class{constructor(e,t,o,s){this.code=t,this.version=e,this.multihash=o,this.bytes=s,this.byteOffset=s.byteOffset,this.byteLength=s.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:q,byteLength:q,code:$,version:$,multihash:$,bytes:$,_baseCache:q,asCID:q})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==V)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Kt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return c.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,o=F(e,t);return c.createV1(this.code,o)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&je(this.multihash,e.multihash)}toString(e){let{bytes:t,version:o,_baseCache:s}=this;switch(o){case 0:return Xt(t,s,e||w.encoder);default:return Gt(t,s,e||z.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Ht(/^0\.0/,Wt),!!(e&&(e[Le]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof c)return e;if(e!=null&&e.asCID===e){let{version:t,code:o,multihash:s,bytes:n}=e;return new c(t,o,s,n||Ie(t,o,s.bytes))}else if(e!=null&&e[Le]===!0){let{version:t,multihash:o,code:s}=e,n=Ae(o);return c.create(t,s,n)}else return null}static create(e,t,o){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==V)throw new Error(`Version 0 CID must use dag-pb (code: ${V}) block encoding`);return new c(e,t,o,o.bytes)}case 1:{let s=Ie(e,t,o.bytes);return new c(e,t,o,s)}default:throw new Error("Invalid version")}}static createV0(e){return c.create(0,V,e)}static createV1(e,t){return c.create(1,e,t)}static decode(e){let[t,o]=c.decodeFirst(e);if(o.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=c.inspectBytes(e),o=t.size-t.multihashSize,s=y(e.subarray(o,o+t.multihashSize));if(s.byteLength!==t.multihashSize)throw new Error("Incorrect length");let n=s.subarray(t.multihashSize-t.digestSize),D=new M(t.multihashCode,t.digestSize,n,s);return[t.version===0?c.createV0(D):c.createV1(t.codec,D),e.subarray(t.size)]}static inspectBytes(e){let t=0,o=()=>{let[S,P]=O(e.subarray(t));return t+=P,S},s=o(),n=V;if(s===18?(s=0,t=0):s===1&&(n=o()),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let D=t,a=o(),f=o(),B=t+f,p=B-D;return{version:s,codec:n,multihashCode:a,digestSize:f,multihashSize:p,size:B}}static parse(e,t){let[o,s]=Jt(e,t),n=c.decode(s);return n._baseCache.set(o,e),n}},Jt=(r,e)=>{switch(r[0]){case"Q":{let t=e||w;return[w.prefix,t.decode(`${w.prefix}${r}`)]}case w.prefix:{let t=e||w;return[w.prefix,t.decode(r)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Xt=(r,e,t)=>{let{prefix:o}=t;if(o!==w.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let s=e.get(o);if(s==null){let n=t.encode(r).slice(1);return e.set(o,n),n}else return s},Gt=(r,e,t)=>{let{prefix:o}=t,s=e.get(o);if(s==null){let n=t.encode(r);return e.set(o,n),n}else return s},V=112,Kt=18,Ie=(r,e,t)=>{let o=L(r),s=o+L(e),n=new Uint8Array(s+t.byteLength);return I(r,n,0),I(e,n,o),n.set(t,s),n},Le=Symbol.for("@ipld/js-cid/CID"),$={writable:!1,configurable:!1,enumerable:!0},q={writable:!1,enumerable:!1,configurable:!1},Qt="0.0.0-dev",Ht=(r,e)=>{if(r.test(Qt))console.warn(e);else throw new Error(e)},Wt=`CID.isCID(v) is deprecated and will be removed in the next major release.
Following code pattern:

@@ -16,3 +16,3 @@

}
`;var se={...X,...G,...K,...Q,...H,...W,...Z,...Y,..._},Sr={...te,...re};function ze(r,e,t,s){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:s}}}var Ie=ze("utf8","u",r=>{let e=new TextDecoder("utf8");return"u"+e.decode(r)},r=>new TextEncoder().encode(r.substring(1))),oe=ze("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),kt={utf8:Ie,"utf-8":Ie,hex:se.base16,latin1:oe,ascii:oe,binary:oe,...se},J=kt;function Le(r,e="utf8"){let t=J[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Me(r,e="utf8"){let t=J[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}function Ne(r,e){if(r.length!==e.length)throw new Error("Inputs should have the same length");let t=new Uint8Array(r.length);for(let s=0;s<r.length;s++)t[s]=r[s]^e[s];return t}return qt;})();
`;var se={...J,...X,...G,...K,...Q,...H,...W,...Z,...Y,..._},$r={...re,...oe};function Ne(r,e,t,o){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:o}}}var Oe=Ne("utf8","u",r=>{let e=new TextDecoder("utf8");return"u"+e.decode(r)},r=>new TextEncoder().encode(r.substring(1))),ne=Ne("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=U(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Zt={utf8:Oe,"utf-8":Oe,hex:se.base16,latin1:ne,ascii:ne,binary:ne,...se},R=Zt;function Me(r,e="utf8"){let t=R[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}function Ve(r,e="utf8"){let t=R[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function Pe(r,e){if(r.length!==e.length)throw new Error("Inputs should have the same length");let t=U(r.length);for(let o=0;o<r.length;o++)t[o]=r[o]^e[o];return t}return Yt;})();
return Uint8arrays}));
{
"name": "uint8arrays",
"version": "3.0.0",
"version": "3.1.0",
"description": "Utility functions to make dealing with Uint8Arrays easier",

@@ -27,3 +27,5 @@ "main": "./cjs/src/index.js",

"devDependencies": {
"@types/benchmark": "^2.1.1",
"aegir": "^35.0.0",
"benchmark": "^2.1.4",
"util": "^0.12.4"

@@ -54,2 +56,7 @@ },

},
"./alloc": {
"browser": "./esm/src/alloc.js",
"require": "./cjs/src/alloc.js",
"import": "./esm/src/alloc.js"
},
"./compare": {

@@ -97,2 +104,3 @@ "browser": "./esm/src/compare.js",

".": "./cjs/src/index.js",
"./alloc": "./cjs/src/alloc.js",
"./compare": "./cjs/src/compare.js",

@@ -99,0 +107,0 @@ "./concat": "./cjs/src/concat.js",

@@ -6,17 +6,47 @@ # Uint8Arrays <!-- omit in toc -->

- [API](#api)
- [alloc(size)](#allocsize)
- [Example](#example)
- [allocUnsafe(size)](#allocunsafesize)
- [Example](#example-1)
- [compare(a, b)](#comparea-b)
- [Example](#example)
- [Example](#example-2)
- [concat(arrays, [length])](#concatarrays-length)
- [Example](#example-1)
- [Example](#example-3)
- [equals(a, b)](#equalsa-b)
- [Example](#example-2)
- [Example](#example-4)
- [fromString(string, encoding = 'utf8')](#fromstringstring-encoding--utf8)
- [Example](#example-3)
- [Example](#example-5)
- [toString(array, encoding = 'utf8')](#tostringarray-encoding--utf8)
- [Example](#example-4)
- [Example](#example-6)
- [xor(a, b)](#xora-b)
- [Example](#example-5)
- [Example](#example-7)
## API
### alloc(size)
Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
#### Example
```js
import { alloc } from 'uint8arrays/alloc`
const buf = alloc(100)
```
### allocUnsafe(size)
Create a new `Uint8Array`. If `globalThis.Buffer` is defined, it will be used in preference to `globalThis.Uint8Array`.
On platforms that support it, memory referenced by the returned `Uint8Array` will not be initialized.
#### Example
```js
import { allocUnsafe } from 'uint8arrays/alloc`
const buf = allocUnsafe(100)
```
### compare(a, b)

@@ -23,0 +53,0 @@

export default BASES;
export type MultibaseCodec = import('multiformats/bases/interface').MultibaseCodec<any>;
export type SupportedEncodings = 'utf8' | 'utf-8' | 'hex' | 'latin1' | 'ascii' | 'binary' | keyof {
base64: import("multiformats/bases/base").Codec<string, string>;
base64pad: import("multiformats/bases/base").Codec<string, string>;
base64url: import("multiformats/bases/base").Codec<string, string>;
base64urlpad: import("multiformats/bases/base").Codec<string, string>;
base256emoji: import("multiformats/bases/base").Codec<"base256emoji", "🚀">;
base64: import("multiformats/bases/base").Codec<"base64", "m">;
base64pad: import("multiformats/bases/base").Codec<"base64pad", "M">;
base64url: import("multiformats/bases/base").Codec<"base64url", "u">;
base64urlpad: import("multiformats/bases/base").Codec<"base64urlpad", "U">;
base58btc: import("multiformats/bases/base").Codec<"base58btc", "z">;

@@ -12,16 +13,16 @@ base58flickr: import("multiformats/bases/base").Codec<"base58flickr", "Z">;

base36upper: import("multiformats/bases/base").Codec<"base36upper", "K">;
base32: import("multiformats/bases/base").Codec<string, string>;
base32upper: import("multiformats/bases/base").Codec<string, string>;
base32pad: import("multiformats/bases/base").Codec<string, string>;
base32padupper: import("multiformats/bases/base").Codec<string, string>;
base32hex: import("multiformats/bases/base").Codec<string, string>;
base32hexupper: import("multiformats/bases/base").Codec<string, string>;
base32hexpad: import("multiformats/bases/base").Codec<string, string>;
base32hexpadupper: import("multiformats/bases/base").Codec<string, string>;
base32z: import("multiformats/bases/base").Codec<string, string>;
base16: import("multiformats/bases/base").Codec<string, string>;
base16upper: import("multiformats/bases/base").Codec<string, string>;
base32: import("multiformats/bases/base").Codec<"base32", "b">;
base32upper: import("multiformats/bases/base").Codec<"base32upper", "B">;
base32pad: import("multiformats/bases/base").Codec<"base32pad", "c">;
base32padupper: import("multiformats/bases/base").Codec<"base32padupper", "C">;
base32hex: import("multiformats/bases/base").Codec<"base32hex", "v">;
base32hexupper: import("multiformats/bases/base").Codec<"base32hexupper", "V">;
base32hexpad: import("multiformats/bases/base").Codec<"base32hexpad", "t">;
base32hexpadupper: import("multiformats/bases/base").Codec<"base32hexpadupper", "T">;
base32z: import("multiformats/bases/base").Codec<"base32z", "h">;
base16: import("multiformats/bases/base").Codec<"base16", "f">;
base16upper: import("multiformats/bases/base").Codec<"base16upper", "F">;
base10: import("multiformats/bases/base").Codec<"base10", "9">;
base8: import("multiformats/bases/base").Codec<string, string>;
base2: import("multiformats/bases/base").Codec<string, string>;
base8: import("multiformats/bases/base").Codec<"base8", "7">;
base2: import("multiformats/bases/base").Codec<"base2", "0">;
identity: import("multiformats/bases/base").Codec<"identity", "\0">;

@@ -28,0 +29,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc