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

scale-ts

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scale-ts - npm Package Compare versions

Comparing version 0.2.11 to 0.2.12

2

dist/codecs/fixed-width-ints.d.ts

@@ -12,1 +12,3 @@ import { Codec } from "../types";

export declare const i128: Codec<bigint>;
export declare const u256: Codec<bigint>;
export declare const i256: Codec<bigint>;

@@ -43,2 +43,3 @@ var __defProp = Object.defineProperty;

i16: () => i16,
i256: () => i256,
i32: () => i32,

@@ -50,2 +51,3 @@ i64: () => i64,

u16: () => u16,
u256: () => u256,
u32: () => u32,

@@ -135,3 +137,10 @@ u64: () => u64,

function mapObject(input, mapper) {
return Object.fromEntries(Object.entries(input).map(([key, value]) => [key, mapper(value, key)]));
const keys = Object.keys(input);
const len = keys.length;
const result = {};
for (let i = 0; i < len; i++) {
const key = keys[i];
result[key] = mapper(input[key], key);
}
return result;
}

@@ -182,2 +191,24 @@

var i128 = createCodec(x128Enc, create128Dec("getBigInt64"));
var x256Enc = (value) => {
const result = new Uint8Array(32);
const dv = new DataView(result.buffer);
dv.setBigInt64(0, value, true);
dv.setBigInt64(8, value >> 64n, true);
dv.setBigInt64(16, value >> 128n, true);
dv.setBigInt64(24, value >> 192n, true);
return result;
};
var create256Dec = (method) => toInternalBytes((input) => {
let result = input.v.getBigUint64(input.i, true);
input.i += 8;
result |= input.v.getBigUint64(input.i, true) << 64n;
input.i += 8;
result |= input.v.getBigUint64(input.i, true) << 128n;
input.i += 8;
result |= input.v[method](input.i, true) << 192n;
input.i += 8;
return result;
});
var u256 = createCodec(x256Enc, create256Dec("getBigUint64"));
var i256 = createCodec(x256Enc, create256Dec("getBigInt64"));

@@ -282,3 +313,3 @@ // src/codecs/bool.ts

const len = nBytes !== Infinity ? nBytes : bytes.byteLength - bytes.i;
const result = new Uint8Array(bytes.buffer, bytes.i, len);
const result = new Uint8Array(bytes.buffer.slice(bytes.i, bytes.i + len));
bytes.i += len;

@@ -285,0 +316,0 @@ return result;

2

dist/scale-ts.cjs.production.min.js

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

var E=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var ne=(e,n,t)=>n in e?E(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var te=(e,n)=>{for(var t in n)E(e,t,{get:n[t],enumerable:!0})},oe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of z(n))!ee.call(e,r)&&r!==t&&E(e,r,{get:()=>n[r],enumerable:!(o=Z(n,r))||o.enumerable});return e};var re=e=>oe(E({},"__esModule",{value:!0}),e);var v=(e,n,t)=>(ne(e,typeof n!="symbol"?n+"":n,t),t);var Be={};te(Be,{Bytes:()=>C,Enum:()=>b,Option:()=>w,Result:()=>U,Struct:()=>k,Tuple:()=>O,Vector:()=>B,_void:()=>M,bool:()=>x,compact:()=>f,createCodec:()=>c,enhanceCodec:()=>R,enhanceDecoder:()=>I,enhanceEncoder:()=>T,i128:()=>pe,i16:()=>ae,i32:()=>me,i64:()=>ue,i8:()=>se,str:()=>j,u128:()=>fe,u16:()=>D,u32:()=>l,u64:()=>K,u8:()=>s});module.exports=re(Be);var c=(e,n)=>{let t=[e,n];return t.enc=e,t.dec=n,t},T=(e,n)=>t=>e(n(t)),I=(e,n)=>t=>n(e(t)),R=([e,n],t,o)=>c(T(e,t),I(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 ce(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 d=0;d<o;){let m=t+d*2,p=V[e[m]],g=V[e[m+1]];r[n+d++]=p<<4|g}return r}var A=class extends Uint8Array{constructor(t){super(t);v(this,"i",0);v(this,"v");this.v=new DataView(t)}},i=e=>n=>e(n instanceof A?n:new A(n instanceof Uint8Array?n.buffer:typeof n=="string"?ce(n).buffer:n));var a=(...e)=>{let n=e.length,t=0;for(let r=0;r<n;r++)t+=e[r].byteLength;let o=new Uint8Array(t);for(let r=0,d=0;r<n;r++){let m=e[r];o.set(m,d),d+=m.byteLength}return o};function y(e,n){return Object.fromEntries(Object.entries(e).map(([t,o])=>[t,n(o,t)]))}function de(e,n){return i(t=>{let o=t.v[n](t.i,!0);return t.i+=e,o})}function ie(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(ie(e,t),de(e,n))}var s=u(1,"getUint8","setUint8"),D=u(2,"getUint16","setUint16"),l=u(4,"getUint32","setUint32"),K=u(8,"getBigUint64","setBigUint64"),se=u(1,"getInt8","setInt8"),ae=u(2,"getInt16","setInt16"),me=u(4,"getInt32","setInt32"),ue=u(8,"getBigInt64","setBigInt64"),h=e=>{let n=new Uint8Array(16),t=new DataView(n.buffer);return t.setBigInt64(0,e,!0),t.setBigInt64(8,e>>64n,!0),n},_=e=>i(n=>{let{v:t,i:o}=n,r=t.getBigUint64(o,!0),d=t[e](o+8,!0);return n.i+=16,d<<64n|r}),fe=c(h,_("getBigUint64")),pe=c(h,_("getBigInt64"));var x=R(s,e=>e?1:0,Boolean);var Oe=[s[1],D[1],l[1]],ye=i(e=>{let n=e[e.i],t=n&3;if(t<3)return Oe[t](e)>>>2;let o=(n>>>2)+4;e.i++;let r=0n,d=o/8|0,m=0n;for(let g=0;g<d;g++)r=K[1](e)<<m|r,m+=64n;let p=o%8;return p>3&&(r=BigInt(l[1](e))<<m|r,m+=32n,p-=4),p>1&&(r=BigInt(D[1](e))<<m|r,m+=16n,p-=2),p&&(r=BigInt(s[1](e))<<m|r),r}),De=1n<<56n,le=1<<24,xe=256,ge=4294967295n,Ee=1<<6,Te=1<<14,Ie=1<<30,Ae=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);let n=Number(e)<<2;if(e<Ee)return s[0](n);if(e<Te)return D[0](n|1);if(e<Ie)return l[0](n|2);let t=[new Uint8Array(1)],o=BigInt(e);for(;o>=De;)t.push(K[0](o)),o>>=64n;o>=le&&(t.push(l[0](Number(o&ge))),o>>=32n);let r=Number(o);r>=xe&&(t.push(D[0](r)),r>>=16),r&&t.push(s[0](r));let d=a(...t);return d[0]=d.length-5<<2|3,d},f=c(Ae,ye);var Ke=new TextEncoder,Ce=e=>{let n=Ke.encode(e);return a(f.enc(n.length),n)},be=new TextDecoder,we=i(e=>{let n=f.dec(e),t=new DataView(e.buffer,e.i,n);return e.i+=n,be.decode(t)}),j=c(Ce,we);var Ue=()=>{},ke=new Uint8Array(0),M=c(()=>ke,Ue);var S=e=>n=>n.length===e?n:n.slice(0,e),L=e=>i(n=>{let t=e!==1/0?e:n.byteLength-n.i,o=new Uint8Array(n.buffer,n.i,t);return n.i+=t,o}),C=e=>c(S(e),L(e));C.enc=S;C.dec=L;var N=e=>{let n=Object.keys(e);return({tag:t,value:o})=>a(s.enc(n.indexOf(t)),e[t](o))},P=e=>{let n=Object.entries(e);return i(t=>{let o=s.dec(t),[r,d]=n[o];return{tag:r,value:d(t)}})},b=e=>c(N(y(e,([n])=>n)),P(y(e,([,n])=>n)));b.enc=N;b.dec=P;var Y=e=>i(n=>{let t=s.dec(n);if(t!==0)return e===x[1]?t===1:e(n)}),F=e=>n=>{let t=new Uint8Array(1);return n===void 0?(t[0]=0,t):(t[0]=1,e===x[0]?(t[0]=n?1:2,t):a(t,e(n)))},w=e=>c(F(e[0]),Y(e[1]));w.enc=F;w.dec=Y;var H=(e,n)=>i(t=>{let o=s[1](t)===0,d=(o?e:n)(t);return{success:o,value:d}}),W=(e,n)=>({success:t,value:o})=>a(s[0](t?0:1),(t?e:n)(o)),U=(e,n)=>c(W(e[0],n[0]),H(e[1],n[1]));U.dec=H;U.enc=W;var G=(...e)=>i(n=>e.map(t=>t(n))),X=(...e)=>n=>a(...n.map((t,o)=>e[o](t))),O=(...e)=>c(X(...e.map(([n])=>n)),G(...e.map(([,n])=>n)));O.enc=X;O.dec=G;var $=e=>{let n=Object.keys(e);return T(O.enc(...Object.values(e)),t=>n.map(o=>t[o]))},q=e=>{let n=Object.keys(e);return I(O.dec(...Object.values(e)),t=>Object.fromEntries(t.map((o,r)=>[n[r],o])))},k=e=>c($(y(e,n=>n[0])),q(y(e,n=>n[1])));k.enc=$;k.dec=q;var J=(e,n)=>n>=0?t=>a(...t.map(e)):t=>a(f.enc(t.length),...t.map(e)),Q=(e,n)=>i(t=>{let o=n>=0?n:f.dec(t),r=new Array(o);for(let d=0;d<o;d++)r[d]=e(t);return r}),B=(e,n)=>c(J(e[0],n),Q(e[1],n));B.enc=J;B.dec=Q;
var E=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var re=(t,e,n)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var oe=(t,e)=>{for(var n in e)E(t,n,{get:e[n],enumerable:!0})},ce=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of te(e))!ne.call(t,o)&&o!==n&&E(t,o,{get:()=>e[o],enumerable:!(r=ee(e,o))||r.enumerable});return t};var ie=t=>ce(E({},"__esModule",{value:!0}),t);var v=(t,e,n)=>(re(t,typeof e!="symbol"?e+"":e,n),n);var he={};oe(he,{Bytes:()=>C,Enum:()=>b,Option:()=>B,Result:()=>U,Struct:()=>w,Tuple:()=>g,Vector:()=>k,_void:()=>L,bool:()=>l,compact:()=>f,createCodec:()=>c,enhanceCodec:()=>R,enhanceDecoder:()=>T,enhanceEncoder:()=>I,i128:()=>ye,i16:()=>ue,i256:()=>De,i32:()=>fe,i64:()=>pe,i8:()=>me,str:()=>S,u128:()=>ge,u16:()=>O,u256:()=>Oe,u32:()=>D,u64:()=>K,u8:()=>a});module.exports=ie(he);var c=(t,e)=>{let n=[t,e];return n.enc=t,n.dec=e,n},I=(t,e)=>n=>t(e(n)),T=(t,e)=>n=>e(t(n)),R=([t,e],n,r)=>c(I(t,n),T(e,r));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 de(t){let e=t.length%2,n=(t[1]==="x"?2:0)+e,r=(t.length-n)/2+e,o=new Uint8Array(r);e&&(o[0]=0|V[t[2]]);for(let i=0;i<r;){let s=n+i*2,p=V[t[s]],x=V[t[s+1]];o[e+i++]=p<<4|x}return o}var A=class extends Uint8Array{constructor(n){super(n);v(this,"i",0);v(this,"v");this.v=new DataView(n)}},d=t=>e=>t(e instanceof A?e:new A(e instanceof Uint8Array?e.buffer:typeof e=="string"?de(e).buffer:e));var m=(...t)=>{let e=t.length,n=0;for(let o=0;o<e;o++)n+=t[o].byteLength;let r=new Uint8Array(n);for(let o=0,i=0;o<e;o++){let s=t[o];r.set(s,i),i+=s.byteLength}return r};function y(t,e){let n=Object.keys(t),r=n.length,o={};for(let i=0;i<r;i++){let s=n[i];o[s]=e(t[s],s)}return o}function se(t,e){return d(n=>{let r=n.v[e](n.i,!0);return n.i+=t,r})}function ae(t,e){return n=>{let r=new Uint8Array(t);return new DataView(r.buffer)[e](0,n,!0),r}}function u(t,e,n){return c(ae(t,n),se(t,e))}var a=u(1,"getUint8","setUint8"),O=u(2,"getUint16","setUint16"),D=u(4,"getUint32","setUint32"),K=u(8,"getBigUint64","setBigUint64"),me=u(1,"getInt8","setInt8"),ue=u(2,"getInt16","setInt16"),fe=u(4,"getInt32","setInt32"),pe=u(8,"getBigInt64","setBigInt64"),h=t=>{let e=new Uint8Array(16),n=new DataView(e.buffer);return n.setBigInt64(0,t,!0),n.setBigInt64(8,t>>64n,!0),e},_=t=>d(e=>{let{v:n,i:r}=e,o=n.getBigUint64(r,!0),i=n[t](r+8,!0);return e.i+=16,i<<64n|o}),ge=c(h,_("getBigUint64")),ye=c(h,_("getBigInt64")),j=t=>{let e=new Uint8Array(32),n=new DataView(e.buffer);return n.setBigInt64(0,t,!0),n.setBigInt64(8,t>>64n,!0),n.setBigInt64(16,t>>128n,!0),n.setBigInt64(24,t>>192n,!0),e},M=t=>d(e=>{let n=e.v.getBigUint64(e.i,!0);return e.i+=8,n|=e.v.getBigUint64(e.i,!0)<<64n,e.i+=8,n|=e.v.getBigUint64(e.i,!0)<<128n,e.i+=8,n|=e.v[t](e.i,!0)<<192n,e.i+=8,n}),Oe=c(j,M("getBigUint64")),De=c(j,M("getBigInt64"));var l=R(a,t=>t?1:0,Boolean);var le=[a[1],O[1],D[1]],xe=d(t=>{let e=t[t.i],n=e&3;if(n<3)return le[n](t)>>>2;let r=(e>>>2)+4;t.i++;let o=0n,i=r/8|0,s=0n;for(let x=0;x<i;x++)o=K[1](t)<<s|o,s+=64n;let p=r%8;return p>3&&(o=BigInt(D[1](t))<<s|o,s+=32n,p-=4),p>1&&(o=BigInt(O[1](t))<<s|o,s+=16n,p-=2),p&&(o=BigInt(a[1](t))<<s|o),o}),Ee=1n<<56n,Ie=1<<24,Te=256,Ae=4294967295n,Ke=1<<6,Ce=1<<14,be=1<<30,Be=t=>{if(t<0)throw new Error(`Wrong compact input (${t})`);let e=Number(t)<<2;if(t<Ke)return a[0](e);if(t<Ce)return O[0](e|1);if(t<be)return D[0](e|2);let n=[new Uint8Array(1)],r=BigInt(t);for(;r>=Ee;)n.push(K[0](r)),r>>=64n;r>=Ie&&(n.push(D[0](Number(r&Ae))),r>>=32n);let o=Number(r);o>=Te&&(n.push(O[0](o)),o>>=16),o&&n.push(a[0](o));let i=m(...n);return i[0]=i.length-5<<2|3,i},f=c(Be,xe);var Ue=new TextEncoder,we=t=>{let e=Ue.encode(t);return m(f.enc(e.length),e)},ke=new TextDecoder,ve=d(t=>{let e=f.dec(t),n=new DataView(t.buffer,t.i,e);return t.i+=e,ke.decode(n)}),S=c(we,ve);var Re=()=>{},Ve=new Uint8Array(0),L=c(()=>Ve,Re);var N=t=>e=>e.length===t?e:e.slice(0,t),P=t=>d(e=>{let n=t!==1/0?t:e.byteLength-e.i,r=new Uint8Array(e.buffer.slice(e.i,e.i+n));return e.i+=n,r}),C=t=>c(N(t),P(t));C.enc=N;C.dec=P;var Y=t=>{let e=Object.keys(t);return({tag:n,value:r})=>m(a.enc(e.indexOf(n)),t[n](r))},F=t=>{let e=Object.entries(t);return d(n=>{let r=a.dec(n),[o,i]=e[r];return{tag:o,value:i(n)}})},b=t=>c(Y(y(t,([e])=>e)),F(y(t,([,e])=>e)));b.enc=Y;b.dec=F;var H=t=>d(e=>{let n=a.dec(e);if(n!==0)return t===l[1]?n===1:t(e)}),W=t=>e=>{let n=new Uint8Array(1);return e===void 0?(n[0]=0,n):(n[0]=1,t===l[0]?(n[0]=e?1:2,n):m(n,t(e)))},B=t=>c(W(t[0]),H(t[1]));B.enc=W;B.dec=H;var G=(t,e)=>d(n=>{let r=a[1](n)===0,i=(r?t:e)(n);return{success:r,value:i}}),X=(t,e)=>({success:n,value:r})=>m(a[0](n?0:1),(n?t:e)(r)),U=(t,e)=>c(X(t[0],e[0]),G(t[1],e[1]));U.dec=G;U.enc=X;var $=(...t)=>d(e=>t.map(n=>n(e))),q=(...t)=>e=>m(...e.map((n,r)=>t[r](n))),g=(...t)=>c(q(...t.map(([e])=>e)),$(...t.map(([,e])=>e)));g.enc=q;g.dec=$;var J=t=>{let e=Object.keys(t);return I(g.enc(...Object.values(t)),n=>e.map(r=>n[r]))},Q=t=>{let e=Object.keys(t);return T(g.dec(...Object.values(t)),n=>Object.fromEntries(n.map((r,o)=>[e[o],r])))},w=t=>c(J(y(t,e=>e[0])),Q(y(t,e=>e[1])));w.enc=J;w.dec=Q;var Z=(t,e)=>e>=0?n=>m(...n.map(t)):n=>m(f.enc(n.length),...n.map(t)),z=(t,e)=>d(n=>{let r=e>=0?e:f.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=t(n);return o}),k=(t,e)=>c(Z(t[0],e),z(t[1],e));k.enc=Z;k.dec=z;
//# sourceMappingURL=scale-ts.cjs.production.min.js.map

@@ -86,3 +86,10 @@ var __defProp = Object.defineProperty;

function mapObject(input, mapper) {
return Object.fromEntries(Object.entries(input).map(([key, value]) => [key, mapper(value, key)]));
const keys = Object.keys(input);
const len = keys.length;
const result = {};
for (let i = 0; i < len; i++) {
const key = keys[i];
result[key] = mapper(input[key], key);
}
return result;
}

@@ -133,2 +140,24 @@

var i128 = createCodec(x128Enc, create128Dec("getBigInt64"));
var x256Enc = (value) => {
const result = new Uint8Array(32);
const dv = new DataView(result.buffer);
dv.setBigInt64(0, value, true);
dv.setBigInt64(8, value >> 64n, true);
dv.setBigInt64(16, value >> 128n, true);
dv.setBigInt64(24, value >> 192n, true);
return result;
};
var create256Dec = (method) => toInternalBytes((input) => {
let result = input.v.getBigUint64(input.i, true);
input.i += 8;
result |= input.v.getBigUint64(input.i, true) << 64n;
input.i += 8;
result |= input.v.getBigUint64(input.i, true) << 128n;
input.i += 8;
result |= input.v[method](input.i, true) << 192n;
input.i += 8;
return result;
});
var u256 = createCodec(x256Enc, create256Dec("getBigUint64"));
var i256 = createCodec(x256Enc, create256Dec("getBigInt64"));

@@ -233,3 +262,3 @@ // src/codecs/bool.ts

const len = nBytes !== Infinity ? nBytes : bytes.byteLength - bytes.i;
const result = new Uint8Array(bytes.buffer, bytes.i, len);
const result = new Uint8Array(bytes.buffer.slice(bytes.i, bytes.i + len));
bytes.i += len;

@@ -348,2 +377,3 @@ return result;

i16,
i256,
i32,

@@ -355,2 +385,3 @@ i64,

u16,
u256,
u32,

@@ -357,0 +388,0 @@ u64,

{
"version": "0.2.11",
"version": "0.2.12",
"repository": {

@@ -4,0 +4,0 @@ "type": "git",

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