5 lines
34 KiB
JavaScript
5 lines
34 KiB
JavaScript
|
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpfsUnixfs = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
||
|
|
"use strict";var IpfsUnixfs=(()=>{var lt=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var p=(r,t)=>{for(var e in t)lt(r,e,{get:t[e],enumerable:!0})},_e=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Oe(t))!Ve.call(r,i)&&i!==e&<(r,i,{get:()=>t[i],enumerable:!(n=ve(t,i))||n.enumerable});return r};var $e=r=>_e(lt({},"__esModule",{value:!0}),r);var hn={};p(hn,{InvalidTypeError:()=>O,InvalidUnixFSMessageError:()=>q,UnixFS:()=>Jt});var O=class r extends Error{static name="InvalidTypeError";static code="ERR_INVALID_TYPE";name=r.name;code=r.code;constructor(t="Invalid type"){super(t)}},q=class r extends Error{static name="InvalidUnixFSMessageError";static code="ERR_INVALID_MESSAGE";name=r.name;code=r.code;constructor(t="Invalid message"){super(t)}};function M(r=0){return new Uint8Array(r)}var Ge=Math.pow(2,7),Pe=Math.pow(2,14),Xe=Math.pow(2,21),Wt=Math.pow(2,28),Qt=Math.pow(2,35),Kt=Math.pow(2,42),Zt=Math.pow(2,49),l=128,T=127;function H(r){if(r<Ge)return 1;if(r<Pe)return 2;if(r<Xe)return 3;if(r<Wt)return 4;if(r<Qt)return 5;if(r<Kt)return 6;if(r<Zt)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function jt(r,t,e=0){switch(H(r)){case 8:t[e++]=r&255|l,r/=128;case 7:t[e++]=r&255|l,r/=128;case 6:t[e++]=r&255|l,r/=128;case 5:t[e++]=r&255|l,r/=128;case 4:t[e++]=r&255|l,r>>>=7;case 3:t[e++]=r&255|l,r>>>=7;case 2:t[e++]=r&255|l,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Yt(r,t){let e=r[t],n=0;if(n+=e&T,e<l||(e=r[t+1],n+=(e&T)<<7,e<l)||(e=r[t+2],n+=(e&T)<<14,e<l)||(e=r[t+3],n+=(e&T)<<21,e<l)||(e=r[t+4],n+=(e&T)*Wt,e<l)||(e=r[t+5],n+=(e&T)*Qt,e<l)||(e=r[t+6],n+=(e&T)*Kt,e<l)||(e=r[t+7],n+=(e&T)*Zt,e<l))return n;throw new RangeError("Could not decode varint")}var ft=new Float32Array([-0]),B=new Uint8Array(ft.buffer);function te(r,t,e){ft[0]=r,t[e]=B[0],t[e+1]=B[1],t[e+2]=B[2],t[e+3]=B[3]}function ee(r,t){return B[0]=r[t],B[1]=r[t+1],B[2]=r[t+2],B[3]=r[t+3],ft[0]}var pt=new Float64Array([-0]),u=new Uint8Array(pt.buffer);function re(r,t,e){pt[0]=r,t[e]=u[0],t[e+1]=u[1],t[e+2]=u[2],t[e+3]=u[3],t[e+4]=u[4],t[e+5]=u[5],t[e+6]=u[6],t[e+7]=u[7]}function ne(r,t){return u[0]=r[t],u[1]=r[t+1],u[2]=r[t+2],u[3]=r[t+3],u[4]=r[t+4],u[5]=r[t+5],u[6]=r[t+6],u[7]=r[t+7],pt[0]}var qe=BigInt(Number.MAX_SAFE_INTEGER),He=BigInt(Number.MIN_SAFE_INTEGER),m=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return U;if(t<qe&&t>He)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,i=t-(n<<32n);return e&&(n=~n|0n,i=~i|0n,++i>ie&&(i=0n,++n>ie&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(t){if(t===0)return U;let e=t<0;e&&(t=-t);let n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):U}},U=new m(0,0);U.toBigInt=function(){return 0n};U.zzEncode=U.zzDecode=function(){return this};U.length=function(){return
|
||
|
|
return IpfsUnixfs}));
|
||
|
|
//# sourceMappingURL=index.min.js.map
|