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

@polkadot-api/utils

Package Overview
Dependencies
Maintainers
2
Versions
590
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polkadot-api/utils - npm Package Compare versions

Comparing version 0.0.1-d117b58ba16af4434c2ea17552bd052dcd75f2c3.1.0 to 0.0.1-d12b47c6a5577909bc6073e56bda6cf3eaec68eb.1.0

14

dist/index.d.ts

@@ -5,2 +5,8 @@ declare function toHex(bytes: Uint8Array): string;

declare function mapObject<K extends string | number | symbol, I, O>(input: Record<K, I>, mapper: (i: I, k: K) => O): Record<K, O>;
type StringRecord<T> = {
[Sym: symbol]: never;
[Num: number]: never;
[Str: string]: T;
};
declare const mapStringRecord: <I, O>(input: StringRecord<I>, mapper: (value: I, key: string) => O) => StringRecord<O>;

@@ -11,6 +17,6 @@ declare const mergeUint8: (...inputs: Array<Uint8Array>) => Uint8Array;

declare function utf16StrToUtf8Bytes(str: string): Uint8Array;
declare class AbortError extends Error {
constructor();
}
declare function utf8BytesToUtf16Str(input: Uint8Array): string;
export { fromHex, mapObject, mergeUint8, noop, toHex, utf16StrToUtf8Bytes, utf8BytesToUtf16Str };
export { AbortError, fromHex, mapObject, mapStringRecord, mergeUint8, noop, toHex };

@@ -23,9 +23,9 @@ "use strict";

__export(src_exports, {
AbortError: () => AbortError,
fromHex: () => fromHex,
mapObject: () => mapObject,
mapStringRecord: () => mapStringRecord,
mergeUint8: () => mergeUint8,
noop: () => noop,
toHex: () => toHex,
utf16StrToUtf8Bytes: () => utf16StrToUtf8Bytes,
utf8BytesToUtf16Str: () => utf8BytesToUtf16Str
toHex: () => toHex
});

@@ -93,2 +93,5 @@ module.exports = __toCommonJS(src_exports);

}
var mapStringRecord = (input, mapper) => Object.fromEntries(
Object.entries(input).map(([key, value]) => [key, mapper(value, key)])
);

@@ -110,51 +113,9 @@ // src/mergeUint8.ts

// src/utf16StrToUtf8Bytes.ts
function utf16StrToUtf8Bytes(str) {
const result = [];
for (let i = 0; i < str.length; i++) {
let currentCode = str.charCodeAt(i);
if (currentCode < 128)
result.push(currentCode);
else if (currentCode < 2048) {
result.push(192 | currentCode >> 6, 128 | currentCode & 63);
} else if (currentCode > 55295 && currentCode < 57344) {
currentCode = 65536 + ((currentCode & 1023) << 10 | str.charCodeAt(++i) & 1023);
result.push(
240 | currentCode >> 18,
128 | currentCode >> 12 & 63,
128 | currentCode >> 6 & 63,
128 | currentCode & 63
);
} else {
result.push(
224 | currentCode >> 12,
128 | currentCode >> 6 & 63,
128 | currentCode & 63
);
}
// src/AbortError.ts
var AbortError = class extends Error {
constructor() {
super("Abort Error");
this.name = "AbortError";
}
return new Uint8Array(result);
}
// src/utf8BytesToUtf16Str.ts
function utf8BytesToUtf16Str(input) {
const result = [];
for (let i = 0; i < input.length; i++) {
let current = input[i];
if (current < 128) {
result.push(current);
} else if (current < 224) {
result.push((current & 63) << 6 | input[++i] & 63);
} else if (current <= 238) {
result.push(
(current & 31) << 12 | (input[++i] & 63) << 6 | input[++i] & 63
);
} else {
const doubleCharCode = ((current & 15) << 18 | (input[++i] & 63) << 12 | (input[++i] & 63) << 6 | input[++i] & 63) - 65536;
result.push(doubleCharCode >> 10 | 55296);
result.push(doubleCharCode & 1023 | 56320);
}
}
return String.fromCharCode(...result);
}
};
//# sourceMappingURL=index.js.map

@@ -5,2 +5,8 @@ declare function toHex(bytes: Uint8Array): string;

declare function mapObject<K extends string | number | symbol, I, O>(input: Record<K, I>, mapper: (i: I, k: K) => O): Record<K, O>;
type StringRecord<T> = {
[Sym: symbol]: never;
[Num: number]: never;
[Str: string]: T;
};
declare const mapStringRecord: <I, O>(input: StringRecord<I>, mapper: (value: I, key: string) => O) => StringRecord<O>;

@@ -11,6 +17,6 @@ declare const mergeUint8: (...inputs: Array<Uint8Array>) => Uint8Array;

declare function utf16StrToUtf8Bytes(str: string): Uint8Array;
declare class AbortError extends Error {
constructor();
}
declare function utf8BytesToUtf16Str(input: Uint8Array): string;
export { fromHex, mapObject, mergeUint8, noop, toHex, utf16StrToUtf8Bytes, utf8BytesToUtf16Str };
export { AbortError, fromHex, mapObject, mapStringRecord, mergeUint8, noop, toHex };

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

"use strict";var f=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var U=(e,r)=>{for(var o in r)f(e,o,{get:r[o],enumerable:!0})},O=(e,r,o,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of g(r))!A.call(e,n)&&n!==o&&f(e,n,{get:()=>r[n],enumerable:!(t=_(r,n))||t.enumerable});return e};var C=e=>O(f({},"__esModule",{value:!0}),e);var K={};U(K,{fromHex:()=>b,mapObject:()=>u,mergeUint8:()=>l,noop:()=>p,toHex:()=>a,utf16StrToUtf8Bytes:()=>d,utf8BytesToUtf16Str:()=>m});module.exports=C(K);var i="0123456789abcdef";function a(e){let r=new Array(e.length+1);r[0]="0x";for(let o=0;o<e.length;){let t=e[o++];r[o]=i[t>>4]+i[t&15]}return r.join("")}var c={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 b(e){let r=e.length%2,o=(e[1]==="x"?2:0)+r,t=(e.length-o)/2+r,n=new Uint8Array(t);r&&(n[0]=0|c[e[2]]);for(let s=0;s<t;){let x=o+s*2,y=c[e[x]],h=c[e[x+1]];n[r+s++]=y<<4|h}return n}function u(e,r){return Object.fromEntries(Object.entries(e).map(([o,t])=>[o,r(t,o)]))}var l=(...e)=>{let r=e.reduce((t,n)=>t+n.byteLength,0),o=new Uint8Array(r);for(let t=0,n=0;t<e.length;t++){let s=e[t];o.set(s,n),n+=s.byteLength}return o};var p=Function.prototype;function d(e){let r=[];for(let o=0;o<e.length;o++){let t=e.charCodeAt(o);t<128?r.push(t):t<2048?r.push(192|t>>6,128|t&63):t>55295&&t<57344?(t=65536+((t&1023)<<10|e.charCodeAt(++o)&1023),r.push(240|t>>18,128|t>>12&63,128|t>>6&63,128|t&63)):r.push(224|t>>12,128|t>>6&63,128|t&63)}return new Uint8Array(r)}function m(e){let r=[];for(let o=0;o<e.length;o++){let t=e[o];if(t<128)r.push(t);else if(t<224)r.push((t&63)<<6|e[++o]&63);else if(t<=238)r.push((t&31)<<12|(e[++o]&63)<<6|e[++o]&63);else{let n=((t&15)<<18|(e[++o]&63)<<12|(e[++o]&63)<<6|e[++o]&63)-65536;r.push(n>>10|55296),r.push(n&1023|56320)}}return String.fromCharCode(...r)}
"use strict";var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var I=(r,t)=>{for(var e in t)i(r,e,{get:t[e],enumerable:!0})},j=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of A(t))!R.call(r,o)&&o!==e&&i(r,o,{get:()=>t[o],enumerable:!(n=l(t,o))||n.enumerable});return r};var E=r=>j(i({},"__esModule",{value:!0}),r);var K={};I(K,{AbortError:()=>s,fromHex:()=>d,mapObject:()=>u,mapStringRecord:()=>x,mergeUint8:()=>f,noop:()=>g,toHex:()=>b});module.exports=E(K);var p="0123456789abcdef";function b(r){let t=new Array(r.length+1);t[0]="0x";for(let e=0;e<r.length;){let n=r[e++];t[e]=p[n>>4]+p[n&15]}return t.join("")}var a={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 d(r){let t=r.length%2,e=(r[1]==="x"?2:0)+t,n=(r.length-e)/2+t,o=new Uint8Array(n);t&&(o[0]=0|a[r[2]]);for(let c=0;c<n;){let m=e+c*2,y=a[r[m]],O=a[r[m+1]];o[t+c++]=y<<4|O}return o}function u(r,t){return Object.fromEntries(Object.entries(r).map(([e,n])=>[e,t(n,e)]))}var x=(r,t)=>Object.fromEntries(Object.entries(r).map(([e,n])=>[e,t(n,e)]));var f=(...r)=>{let t=r.reduce((n,o)=>n+o.byteLength,0),e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let c=r[n];e.set(c,o),o+=c.byteLength}return e};var g=Function.prototype;var s=class extends Error{constructor(){super("Abort Error"),this.name="AbortError"}};
//# sourceMappingURL=index.js.map
{
"name": "@polkadot-api/utils",
"version": "0.0.1-d117b58ba16af4434c2ea17552bd052dcd75f2c3.1.0",
"version": "0.0.1-d12b47c6a5577909bc6073e56bda6cf3eaec68eb.1.0",
"author": "Josep M Sobrepere (https://github.com/josepot)",

@@ -43,7 +43,7 @@ "repository": {

"scripts": {
"build": "tsup-node src/index.ts --clean --sourcemap --platform neutral --target=es2020 --format esm,cjs --dts && tsup-node src/index.ts --clean --sourcemap --platform neutral --target=es2020 --format cjs --dts --minify --out-dir dist/min",
"build": "tsc --noEmit && tsup-node src/index.ts --clean --sourcemap --platform neutral --target=es2020 --format esm,cjs --dts && tsup-node src/index.ts --clean --sourcemap --platform neutral --target=es2020 --format cjs --dts --minify --out-dir dist/min",
"test": "echo 'no tests'",
"lint": "tsc --noEmit && prettier --check README.md \"src/**/*.{js,jsx,ts,tsx,json,md}\"",
"lint": "prettier --check README.md \"src/**/*.{js,jsx,ts,tsx,json,md}\"",
"format": "prettier --write README.md \"src/**/*.{js,jsx,ts,tsx,json,md}\""
}
}

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