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-077f33dd312fa43cb24285ec6ea773edab118af8.1.0 to 0.0.1-0859a66faeb1bdb5389d3561c08c0a381db1a369.1.0

12

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,2 @@ declare const mergeUint8: (...inputs: Array<Uint8Array>) => Uint8Array;

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

@@ -25,7 +25,6 @@ "use strict";

mapObject: () => mapObject,
mapStringRecord: () => mapStringRecord,
mergeUint8: () => mergeUint8,
noop: () => noop,
toHex: () => toHex,
utf16StrToUtf8Bytes: () => utf16StrToUtf8Bytes,
utf8BytesToUtf16Str: () => utf8BytesToUtf16Str
toHex: () => toHex
});

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

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

@@ -109,52 +111,2 @@ // src/mergeUint8.ts

var noop = Function.prototype;
// 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
);
}
}
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,2 @@ declare const mergeUint8: (...inputs: Array<Uint8Array>) => Uint8Array;

declare function utf16StrToUtf8Bytes(str: string): Uint8Array;
declare function utf8BytesToUtf16Str(input: Uint8Array): string;
export { fromHex, mapObject, mergeUint8, noop, toHex, utf16StrToUtf8Bytes, utf8BytesToUtf16Str };
export { 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 s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var A=(t,r)=>{for(var e in r)s(t,e,{get:r[e],enumerable:!0})},I=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of l(r))!R.call(t,o)&&o!==e&&s(t,o,{get:()=>r[o],enumerable:!(n=x(r,o))||n.enumerable});return t};var j=t=>I(s({},"__esModule",{value:!0}),t);var K={};A(K,{fromHex:()=>d,mapObject:()=>b,mapStringRecord:()=>f,mergeUint8:()=>g,noop:()=>u,toHex:()=>p});module.exports=j(K);var m="0123456789abcdef";function p(t){let r=new Array(t.length+1);r[0]="0x";for(let e=0;e<t.length;){let n=t[e++];r[e]=m[n>>4]+m[n&15]}return r.join("")}var i={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(t){let r=t.length%2,e=(t[1]==="x"?2:0)+r,n=(t.length-e)/2+r,o=new Uint8Array(n);r&&(o[0]=0|i[t[2]]);for(let c=0;c<n;){let a=e+c*2,y=i[t[a]],O=i[t[a+1]];o[r+c++]=y<<4|O}return o}function b(t,r){return Object.fromEntries(Object.entries(t).map(([e,n])=>[e,r(n,e)]))}var f=(t,r)=>Object.fromEntries(Object.entries(t).map(([e,n])=>[e,r(n,e)]));var g=(...t)=>{let r=t.reduce((n,o)=>n+o.byteLength,0),e=new Uint8Array(r);for(let n=0,o=0;n<t.length;n++){let c=t[n];e.set(c,o),o+=c.byteLength}return e};var u=Function.prototype;
//# sourceMappingURL=index.js.map
{
"name": "@polkadot-api/utils",
"version": "0.0.1-077f33dd312fa43cb24285ec6ea773edab118af8.1.0",
"version": "0.0.1-0859a66faeb1bdb5389d3561c08c0a381db1a369.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