Comparing version 0.2.4 to 0.2.5
@@ -182,47 +182,42 @@ var __defProp = Object.defineProperty; | ||
// src/codecs/compact.ts | ||
var bytesToIntType = { | ||
[1]: u8[1], | ||
[2]: u16[1], | ||
[4]: u32[1] | ||
}; | ||
var decoders = [u8[1], u16[1], u32[1], u64[1]]; | ||
var compactDec = toInternalBytes((bytes) => { | ||
let usedBytes = bytes.i; | ||
const usedBytes = bytes.i; | ||
const init = bytes[usedBytes]; | ||
const kind = init & 3; | ||
if (kind !== 3) { | ||
const nBytes2 = kind === 2 ? 4 : kind + 1; | ||
return bytesToIntType[nBytes2](bytes) >>> 2; | ||
} | ||
if (kind !== 3) | ||
return decoders[kind](bytes) >>> 2; | ||
const nBytes = (init >>> 2) + 4; | ||
const start = usedBytes + 1; | ||
bytes.i += nBytes + 1; | ||
bytes.i++; | ||
const nU64 = nBytes / 8 | 0; | ||
let nReminders = nBytes % 8; | ||
const nU32 = nReminders / 4 | 0; | ||
nReminders %= 4; | ||
const lengths = [nReminders % 2, nReminders / 2 | 0, nU32, nU64]; | ||
let result = 0n; | ||
for (let i = nBytes - 1; i >= 0; i--) | ||
result = result << 8n | BigInt(bytes[start + i]); | ||
let nBits = 0n; | ||
let inc = 4n; | ||
decoders.forEach((dec, idx) => { | ||
inc *= 2n; | ||
const len = lengths[idx]; | ||
for (let i = 0; i < len; i++) { | ||
result = BigInt(dec(bytes)) << nBits | result; | ||
nBits += inc; | ||
} | ||
}); | ||
return result; | ||
}); | ||
var SINGLE_BYTE_MODE_LIMIT = 1 << 6; | ||
var TWO_BYTE_MODE_LIMIT = 1 << 14; | ||
var FOUR_BYTE_MODE_LIMIT = 1 << 30; | ||
var compactEnc = (input) => { | ||
if (input < 0) { | ||
if (input < 0) | ||
throw new Error(`Wrong Compat input (${input})`); | ||
} | ||
if (input < 1 << 6) { | ||
const temp = new Uint8Array(1); | ||
temp[0] = Number(input) << 2; | ||
return temp; | ||
} | ||
if (input < 1 << 14) { | ||
const temp = new Uint8Array(2); | ||
let pInput = (Number(input) << 2) + 1; | ||
const dv = new DataView(temp.buffer); | ||
dv.setUint16(0, pInput, true); | ||
return temp; | ||
} | ||
if (input < 1 << 30) { | ||
const temp = new Uint8Array(4); | ||
let pInput = (Number(input) << 2) + 2; | ||
const dv = new DataView(temp.buffer); | ||
dv.setUint32(0, pInput, true); | ||
return temp; | ||
} | ||
const result = []; | ||
if (input < SINGLE_BYTE_MODE_LIMIT) | ||
return u8[0](Number(input) << 2); | ||
if (input < TWO_BYTE_MODE_LIMIT) | ||
return u16[0](Number(input) << 2 | 1); | ||
if (input < FOUR_BYTE_MODE_LIMIT) | ||
return u32[0](Number(input) << 2 | 2); | ||
const result = [0]; | ||
let tmp = BigInt(input); | ||
@@ -233,3 +228,3 @@ while (tmp > 0) { | ||
} | ||
result.unshift((result.length - 4 << 2) + 3); | ||
result[0] = result.length - 5 << 2 | 3; | ||
return new Uint8Array(result); | ||
@@ -333,3 +328,3 @@ }; | ||
// src/codecs/Tuple.ts | ||
var TupleDec = (...decoders) => toInternalBytes((bytes) => decoders.map((decoder) => decoder(bytes))); | ||
var TupleDec = (...decoders2) => toInternalBytes((bytes) => decoders2.map((decoder) => decoder(bytes))); | ||
var TupleEnc = (...encoders) => (values) => mergeUint8(...values.map((value, idx) => encoders[idx](value))); | ||
@@ -345,5 +340,5 @@ var Tuple = (...codecs) => createCodec(TupleEnc(...codecs.map(([encoder]) => encoder)), TupleDec(...codecs.map(([, decoder]) => decoder))); | ||
}; | ||
var StructDec = (decoders) => { | ||
const keys = Object.keys(decoders); | ||
return enhanceDecoder(Tuple.dec(...Object.values(decoders)), (tuple) => Object.fromEntries(tuple.map((value, idx) => [keys[idx], value]))); | ||
var StructDec = (decoders2) => { | ||
const keys = Object.keys(decoders2); | ||
return enhanceDecoder(Tuple.dec(...Object.values(decoders2)), (tuple) => Object.fromEntries(tuple.map((value, idx) => [keys[idx], value]))); | ||
}; | ||
@@ -350,0 +345,0 @@ var Struct = (codecs) => createCodec(StructEnc(mapObject(codecs, (x) => x[0])), StructDec(mapObject(codecs, (x) => x[1]))); |
@@ -1,2 +0,2 @@ | ||
var l=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var ee=(e,t,n)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var te=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Z(t))!z.call(e,o)&&o!==n&&l(e,o,{get:()=>t[o],enumerable:!(r=Y(t,o))||r.enumerable});return e};var re=e=>ne(l({},"__esModule",{value:!0}),e);var I=(e,t,n)=>(ee(e,typeof t!="symbol"?t+"":t,n),n);var Ae={};te(Ae,{Bytes:()=>E,Enum:()=>T,Option:()=>A,Result:()=>C,Struct:()=>K,Tuple:()=>y,Vector:()=>w,_void:()=>j,bool:()=>D,compact:()=>f,createCodec:()=>c,enhanceCodec:()=>k,enhanceDecoder:()=>g,enhanceEncoder:()=>x,i128:()=>pe,i16:()=>ae,i32:()=>ue,i64:()=>me,i8:()=>ie,str:()=>h,u128:()=>fe,u16:()=>B,u32:()=>v,u64:()=>se,u8:()=>a});module.exports=re(Ae);var c=(e,t)=>{let n=[e,t];return n.enc=e,n.dec=t,n},x=(e,t)=>n=>e(t(n)),g=(e,t)=>n=>t(e(n)),k=([e,t],n,r)=>c(x(e,n),g(t,r));var U={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function oe(e){let t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|U[e[2]]);for(let d=0;d<r;){let u=n+d*2,p=U[e[u]],Q=U[e[u+1]];o[t+d++]=p<<4|Q}return o}var b=class extends Uint8Array{constructor(n){super(n);I(this,"i",0);I(this,"v");this.v=new DataView(n)}},s=e=>t=>e(t instanceof b?t:new b(typeof t=="string"?oe(t).buffer:t instanceof Uint8Array?t.buffer:t));var i=(...e)=>{let t=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){let d=e[r];n.set(d,o),o+=d.byteLength}return n};function O(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}function ce(e,t){return s(n=>{let r=n.v[t](n.i,!0);return n.i+=e,r})}function de(e,t){return n=>{let r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function m(e,t,n){return c(de(e,n),ce(e,t))}var a=m(1,"getUint8","setUint8"),B=m(2,"getUint16","setUint16"),v=m(4,"getUint32","setUint32"),se=m(8,"getBigUint64","setBigUint64"),ie=m(1,"getInt8","setInt8"),ae=m(2,"getInt16","setInt16"),ue=m(4,"getInt32","setInt32"),me=m(8,"getBigInt64","setBigInt64"),R=e=>{let t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},V=e=>s(t=>{let{v:n,i:r}=t,o=n.getBigUint64(r,!0),d=n[e?"getBigInt64":"getBigUint64"](r+8,!0);return t.i+=16,d<<64n|o}),fe=c(R,V()),pe=c(R,V(1));var ye=e=>e?1:0,D=k(a,ye,Boolean);var Oe={[1]:a[1],[2]:B[1],[4]:v[1]},De=s(e=>{let t=e.i,n=e[t],r=n&3;if(r!==3){let p=r===2?4:r+1;return Oe[p](e)>>>2}let o=(n>>>2)+4,d=t+1;e.i+=o+1;let u=0n;for(let p=o-1;p>=0;p--)u=u<<8n|BigInt(e[d+p]);return u}),le=e=>{if(e<0)throw new Error(`Wrong Compat input (${e})`);if(e<1<<6){let r=new Uint8Array(1);return r[0]=Number(e)<<2,r}if(e<1<<14){let r=new Uint8Array(2),o=(Number(e)<<2)+1;return new DataView(r.buffer).setUint16(0,o,!0),r}if(e<1<<30){let r=new Uint8Array(4),o=(Number(e)<<2)+2;return new DataView(r.buffer).setUint32(0,o,!0),r}let t=[],n=BigInt(e);for(;n>0;)t.push(Number(n)),n>>=8n;return t.unshift((t.length-4<<2)+3),new Uint8Array(t)},f=c(le,De);var xe=new TextEncoder,ge=e=>{let t=xe.encode(e);return i(f.enc(t.length),t)},be=new TextDecoder,Ee=s(e=>{let t=f.dec(e),n=new DataView(e.buffer,e.i,t);return e.i+=t,be.decode(n)}),h=c(ge,Ee);var Te=new Uint8Array(0),j=c(()=>Te,Function.prototype);var S=e=>t=>t.length===e?t:t.slice(0,e),P=e=>s(t=>{let n=t.i,r=e!==1/0?e:t.byteLength-n,o=new Uint8Array(t.buffer,n,r);return t.i+=r,o}),E=e=>c(S(e),P(e));E.enc=S;E.dec=P;var N=e=>{let t=Object.keys(e);return({tag:n,value:r})=>{let o=t.indexOf(n);return i(a.enc(o),e[n](r))}},L=e=>{let t=Object.entries(e);return s(n=>{let r=a.dec(n),[o,d]=t[r],u=d(n);return{tag:o,value:u}})},T=e=>c(N(O(e,([t])=>t)),L(O(e,([,t])=>t)));T.enc=N;T.dec=L;var _=e=>s(t=>{let n=a.dec(t);if(n!==0)return e===D[1]?n===1:e(t)}),F=e=>t=>{let n=new Uint8Array(1);return t===void 0?(n[0]=0,n):(n[0]=1,e===D[0]?(n[0]=t?1:2,n):i(n,e(t)))},A=e=>c(F(e[0]),_(e[1]));A.enc=F;A.dec=_;var H=(e,t)=>s(n=>{let o=a[1](n)===0,u=(o?e:t)(n);return{success:o,value:u}}),M=(e,t)=>({success:n,value:r})=>i(a[0](n?0:1),(n?e:t)(r)),C=(e,t)=>c(M(e[0],t[0]),H(e[1],t[1]));C.dec=H;C.enc=M;var W=(...e)=>s(t=>e.map(n=>n(t))),X=(...e)=>t=>i(...t.map((n,r)=>e[r](n))),y=(...e)=>c(X(...e.map(([t])=>t)),W(...e.map(([,t])=>t)));y.enc=X;y.dec=W;var $=e=>{let t=Object.keys(e);return x(y.enc(...Object.values(e)),n=>t.map(r=>n[r]))},q=e=>{let t=Object.keys(e);return g(y.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},K=e=>c($(O(e,t=>t[0])),q(O(e,t=>t[1])));K.enc=$;K.dec=q;var G=(e,t)=>t>0?n=>i(...n.map(e)):n=>i(f.enc(n.length),...n.map(e));function J(e,t){return s(n=>{let r=t>0?t:f.dec(n),o=new Array(r);for(let d=0;d<r;d++){let u=e(n);o[d]=u}return o})}function w(e,t){return c(G(e[0],t),J(e[1],t))}w.enc=G;w.dec=J; | ||
var D=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var ae=(e,n,t)=>n in e?D(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var me=(e,n)=>{for(var t in n)D(e,t,{get:n[t],enumerable:!0})},ue=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of se(n))!ie.call(e,r)&&r!==t&&D(e,r,{get:()=>n[r],enumerable:!(o=de(n,r))||o.enumerable});return e};var fe=e=>ue(D({},"__esModule",{value:!0}),e);var v=(e,n,t)=>(ae(e,typeof n!="symbol"?n+"":n,t),t);var Ve={};me(Ve,{Bytes:()=>b,Enum:()=>A,Option:()=>C,Result:()=>K,Struct:()=>I,Tuple:()=>p,Vector:()=>w,_void:()=>F,bool:()=>O,compact:()=>f,createCodec:()=>c,enhanceCodec:()=>R,enhanceDecoder:()=>x,enhanceEncoder:()=>l,i128:()=>Te,i16:()=>le,i32:()=>xe,i64:()=>ge,i8:()=>De,str:()=>P,u128:()=>Ee,u16:()=>E,u32:()=>T,u64:()=>h,u8:()=>i});module.exports=fe(Ve);var c=(e,n)=>{let t=[e,n];return t.enc=e,t.dec=n,t},l=(e,n)=>t=>e(n(t)),x=(e,n)=>t=>n(e(t)),R=([e,n],t,o)=>c(l(e,t),x(n,o));var V={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function pe(e){let n=e.length%2,t=(e[1]==="x"?2:0)+n,o=(e.length-t)/2+n,r=new Uint8Array(o);n&&(r[0]=0|V[e[2]]);for(let s=0;s<o;){let a=t+s*2,k=V[e[a]],B=V[e[a+1]];r[n+s++]=k<<4|B}return r}var g=class extends Uint8Array{constructor(t){super(t);v(this,"i",0);v(this,"v");this.v=new DataView(t)}},d=e=>n=>e(n instanceof g?n:new g(typeof n=="string"?pe(n).buffer:n instanceof Uint8Array?n.buffer:n));var m=(...e)=>{let n=e.reduce((o,r)=>o+r.byteLength,0),t=new Uint8Array(n);for(let o=0,r=0;o<e.length;o++){let s=e[o];t.set(s,r),r+=s.byteLength}return t};function y(e,n){return Object.fromEntries(Object.entries(e).map(([t,o])=>[t,n(o,t)]))}function ye(e,n){return d(t=>{let o=t.v[n](t.i,!0);return t.i+=e,o})}function Oe(e,n){return t=>{let o=new Uint8Array(e);return new DataView(o.buffer)[n](0,t,!0),o}}function u(e,n,t){return c(Oe(e,t),ye(e,n))}var i=u(1,"getUint8","setUint8"),E=u(2,"getUint16","setUint16"),T=u(4,"getUint32","setUint32"),h=u(8,"getBigUint64","setBigUint64"),De=u(1,"getInt8","setInt8"),le=u(2,"getInt16","setInt16"),xe=u(4,"getInt32","setInt32"),ge=u(8,"getBigInt64","setBigInt64"),S=e=>{let n=new Uint8Array(16),t=new DataView(n.buffer);return t.setBigInt64(0,e,!0),t.setBigInt64(8,e>>64n,!0),n},M=e=>d(n=>{let{v:t,i:o}=n,r=t.getBigUint64(o,!0),s=t[e?"getBigInt64":"getBigUint64"](o+8,!0);return n.i+=16,s<<64n|r}),Ee=c(S,M()),Te=c(S,M(1));var be=e=>e?1:0,O=R(i,be,Boolean);var N=[i[1],E[1],T[1],h[1]],Ae=d(e=>{let n=e.i,t=e[n],o=t&3;if(o!==3)return N[o](e)>>>2;let r=(t>>>2)+4;e.i++;let s=r/8|0,a=r%8,k=a/4|0;a%=4;let B=[a%2,a/2|0,k,s],U=0n,j=0n,_=4n;return N.forEach((oe,re)=>{_*=2n;let ce=B[re];for(let L=0;L<ce;L++)U=BigInt(oe(e))<<j|U,j+=_}),U}),Ce=1<<6,Ke=1<<14,Ie=1<<30,we=e=>{if(e<0)throw new Error(`Wrong Compat input (${e})`);if(e<Ce)return i[0](Number(e)<<2);if(e<Ke)return E[0](Number(e)<<2|1);if(e<Ie)return T[0](Number(e)<<2|2);let n=[0],t=BigInt(e);for(;t>0;)n.push(Number(t)),t>>=8n;return n[0]=n.length-5<<2|3,new Uint8Array(n)},f=c(we,Ae);var ke=new TextEncoder,Be=e=>{let n=ke.encode(e);return m(f.enc(n.length),n)},Ue=new TextDecoder,ve=d(e=>{let n=f.dec(e),t=new DataView(e.buffer,e.i,n);return e.i+=n,Ue.decode(t)}),P=c(Be,ve);var Re=new Uint8Array(0),F=c(()=>Re,Function.prototype);var Y=e=>n=>n.length===e?n:n.slice(0,e),H=e=>d(n=>{let t=n.i,o=e!==1/0?e:n.byteLength-t,r=new Uint8Array(n.buffer,t,o);return n.i+=o,r}),b=e=>c(Y(e),H(e));b.enc=Y;b.dec=H;var W=e=>{let n=Object.keys(e);return({tag:t,value:o})=>{let r=n.indexOf(t);return m(i.enc(r),e[t](o))}},G=e=>{let n=Object.entries(e);return d(t=>{let o=i.dec(t),[r,s]=n[o],a=s(t);return{tag:r,value:a}})},A=e=>c(W(y(e,([n])=>n)),G(y(e,([,n])=>n)));A.enc=W;A.dec=G;var X=e=>d(n=>{let t=i.dec(n);if(t!==0)return e===O[1]?t===1:e(n)}),$=e=>n=>{let t=new Uint8Array(1);return n===void 0?(t[0]=0,t):(t[0]=1,e===O[0]?(t[0]=n?1:2,t):m(t,e(n)))},C=e=>c($(e[0]),X(e[1]));C.enc=$;C.dec=X;var q=(e,n)=>d(t=>{let r=i[1](t)===0,a=(r?e:n)(t);return{success:r,value:a}}),J=(e,n)=>({success:t,value:o})=>m(i[0](t?0:1),(t?e:n)(o)),K=(e,n)=>c(J(e[0],n[0]),q(e[1],n[1]));K.dec=q;K.enc=J;var Q=(...e)=>d(n=>e.map(t=>t(n))),Z=(...e)=>n=>m(...n.map((t,o)=>e[o](t))),p=(...e)=>c(Z(...e.map(([n])=>n)),Q(...e.map(([,n])=>n)));p.enc=Z;p.dec=Q;var z=e=>{let n=Object.keys(e);return l(p.enc(...Object.values(e)),t=>n.map(o=>t[o]))},ee=e=>{let n=Object.keys(e);return x(p.dec(...Object.values(e)),t=>Object.fromEntries(t.map((o,r)=>[n[r],o])))},I=e=>c(z(y(e,n=>n[0])),ee(y(e,n=>n[1])));I.enc=z;I.dec=ee;var ne=(e,n)=>n>0?t=>m(...t.map(e)):t=>m(f.enc(t.length),...t.map(e));function te(e,n){return d(t=>{let o=n>0?n:f.dec(t),r=new Array(o);for(let s=0;s<o;s++){let a=e(t);r[s]=a}return r})}function w(e,n){return c(ne(e[0],n),te(e[1],n))}w.enc=ne;w.dec=te; | ||
//# sourceMappingURL=scale-ts.cjs.production.min.js.map |
@@ -135,47 +135,42 @@ var __defProp = Object.defineProperty; | ||
// src/codecs/compact.ts | ||
var bytesToIntType = { | ||
[1]: u8[1], | ||
[2]: u16[1], | ||
[4]: u32[1] | ||
}; | ||
var decoders = [u8[1], u16[1], u32[1], u64[1]]; | ||
var compactDec = toInternalBytes((bytes) => { | ||
let usedBytes = bytes.i; | ||
const usedBytes = bytes.i; | ||
const init = bytes[usedBytes]; | ||
const kind = init & 3; | ||
if (kind !== 3) { | ||
const nBytes2 = kind === 2 ? 4 : kind + 1; | ||
return bytesToIntType[nBytes2](bytes) >>> 2; | ||
} | ||
if (kind !== 3) | ||
return decoders[kind](bytes) >>> 2; | ||
const nBytes = (init >>> 2) + 4; | ||
const start = usedBytes + 1; | ||
bytes.i += nBytes + 1; | ||
bytes.i++; | ||
const nU64 = nBytes / 8 | 0; | ||
let nReminders = nBytes % 8; | ||
const nU32 = nReminders / 4 | 0; | ||
nReminders %= 4; | ||
const lengths = [nReminders % 2, nReminders / 2 | 0, nU32, nU64]; | ||
let result = 0n; | ||
for (let i = nBytes - 1; i >= 0; i--) | ||
result = result << 8n | BigInt(bytes[start + i]); | ||
let nBits = 0n; | ||
let inc = 4n; | ||
decoders.forEach((dec, idx) => { | ||
inc *= 2n; | ||
const len = lengths[idx]; | ||
for (let i = 0; i < len; i++) { | ||
result = BigInt(dec(bytes)) << nBits | result; | ||
nBits += inc; | ||
} | ||
}); | ||
return result; | ||
}); | ||
var SINGLE_BYTE_MODE_LIMIT = 1 << 6; | ||
var TWO_BYTE_MODE_LIMIT = 1 << 14; | ||
var FOUR_BYTE_MODE_LIMIT = 1 << 30; | ||
var compactEnc = (input) => { | ||
if (input < 0) { | ||
if (input < 0) | ||
throw new Error(`Wrong Compat input (${input})`); | ||
} | ||
if (input < 1 << 6) { | ||
const temp = new Uint8Array(1); | ||
temp[0] = Number(input) << 2; | ||
return temp; | ||
} | ||
if (input < 1 << 14) { | ||
const temp = new Uint8Array(2); | ||
let pInput = (Number(input) << 2) + 1; | ||
const dv = new DataView(temp.buffer); | ||
dv.setUint16(0, pInput, true); | ||
return temp; | ||
} | ||
if (input < 1 << 30) { | ||
const temp = new Uint8Array(4); | ||
let pInput = (Number(input) << 2) + 2; | ||
const dv = new DataView(temp.buffer); | ||
dv.setUint32(0, pInput, true); | ||
return temp; | ||
} | ||
const result = []; | ||
if (input < SINGLE_BYTE_MODE_LIMIT) | ||
return u8[0](Number(input) << 2); | ||
if (input < TWO_BYTE_MODE_LIMIT) | ||
return u16[0](Number(input) << 2 | 1); | ||
if (input < FOUR_BYTE_MODE_LIMIT) | ||
return u32[0](Number(input) << 2 | 2); | ||
const result = [0]; | ||
let tmp = BigInt(input); | ||
@@ -186,3 +181,3 @@ while (tmp > 0) { | ||
} | ||
result.unshift((result.length - 4 << 2) + 3); | ||
result[0] = result.length - 5 << 2 | 3; | ||
return new Uint8Array(result); | ||
@@ -286,3 +281,3 @@ }; | ||
// src/codecs/Tuple.ts | ||
var TupleDec = (...decoders) => toInternalBytes((bytes) => decoders.map((decoder) => decoder(bytes))); | ||
var TupleDec = (...decoders2) => toInternalBytes((bytes) => decoders2.map((decoder) => decoder(bytes))); | ||
var TupleEnc = (...encoders) => (values) => mergeUint8(...values.map((value, idx) => encoders[idx](value))); | ||
@@ -298,5 +293,5 @@ var Tuple = (...codecs) => createCodec(TupleEnc(...codecs.map(([encoder]) => encoder)), TupleDec(...codecs.map(([, decoder]) => decoder))); | ||
}; | ||
var StructDec = (decoders) => { | ||
const keys = Object.keys(decoders); | ||
return enhanceDecoder(Tuple.dec(...Object.values(decoders)), (tuple) => Object.fromEntries(tuple.map((value, idx) => [keys[idx], value]))); | ||
var StructDec = (decoders2) => { | ||
const keys = Object.keys(decoders2); | ||
return enhanceDecoder(Tuple.dec(...Object.values(decoders2)), (tuple) => Object.fromEntries(tuple.map((value, idx) => [keys[idx], value]))); | ||
}; | ||
@@ -303,0 +298,0 @@ var Struct = (codecs) => createCodec(StructEnc(mapObject(codecs, (x) => x[0])), StructDec(mapObject(codecs, (x) => x[1]))); |
{ | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"repository": { | ||
@@ -4,0 +4,0 @@ "type": "git", |
@@ -389,3 +389,3 @@ # scale-ts | ||
[str, compact], | ||
(value: RepeatedString) => [value.repetition[0], value.length], | ||
(value: RepeatedString) => [value.repetition[0], value.repetition.length], | ||
) | ||
@@ -392,0 +392,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159060
1169