@polkadot-api/utils
Advanced tools
Comparing version 0.0.1-21b8c0015b8cbc2d1861d4d1b54224173bf1b513.1.0 to 0.0.1-22330754eb2765dd817c0015f63e4cb99d4a05e7.1.0
@@ -27,5 +27,3 @@ "use strict"; | ||
noop: () => noop, | ||
toHex: () => toHex, | ||
utf16StrToUtf8Bytes: () => utf16StrToUtf8Bytes, | ||
utf8BytesToUtf16Str: () => utf8BytesToUtf16Str | ||
toHex: () => toHex | ||
}); | ||
@@ -108,52 +106,2 @@ module.exports = __toCommonJS(src_exports); | ||
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 |
@@ -10,6 +10,2 @@ declare function toHex(bytes: Uint8Array): string; | ||
declare function utf16StrToUtf8Bytes(str: string): Uint8Array; | ||
declare function utf8BytesToUtf16Str(input: Uint8Array): string; | ||
export { fromHex, mapObject, mergeUint8, noop, toHex, utf16StrToUtf8Bytes, utf8BytesToUtf16Str }; | ||
export { fromHex, mapObject, mergeUint8, noop, toHex }; |
@@ -27,5 +27,3 @@ "use strict"; | ||
noop: () => noop, | ||
toHex: () => toHex, | ||
utf16StrToUtf8Bytes: () => utf16StrToUtf8Bytes, | ||
utf8BytesToUtf16Str: () => utf8BytesToUtf16Str | ||
toHex: () => toHex | ||
}); | ||
@@ -108,52 +106,2 @@ module.exports = __toCommonJS(src_exports); | ||
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 |
@@ -10,6 +10,2 @@ declare function toHex(bytes: Uint8Array): string; | ||
declare function utf16StrToUtf8Bytes(str: string): Uint8Array; | ||
declare function utf8BytesToUtf16Str(input: Uint8Array): string; | ||
export { fromHex, mapObject, mergeUint8, noop, toHex, utf16StrToUtf8Bytes, utf8BytesToUtf16Str }; | ||
export { fromHex, mapObject, 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 l=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var A=(t,n)=>{for(var r in n)s(t,r,{get:n[r],enumerable:!0})},K=(t,n,r,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of O(n))!g.call(t,o)&&o!==r&&s(t,o,{get:()=>n[o],enumerable:!(e=l(n,o))||e.enumerable});return t};var U=t=>K(s({},"__esModule",{value:!0}),t);var j={};A(j,{fromHex:()=>f,mapObject:()=>b,mergeUint8:()=>d,noop:()=>u,toHex:()=>p});module.exports=U(j);var m="0123456789abcdef";function p(t){let n=new Array(t.length+1);n[0]="0x";for(let r=0;r<t.length;){let e=t[r++];n[r]=m[e>>4]+m[e&15]}return n.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 f(t){let n=t.length%2,r=(t[1]==="x"?2:0)+n,e=(t.length-r)/2+n,o=new Uint8Array(e);n&&(o[0]=0|a[t[2]]);for(let c=0;c<e;){let i=r+c*2,x=a[t[i]],y=a[t[i+1]];o[n+c++]=x<<4|y}return o}function b(t,n){return Object.fromEntries(Object.entries(t).map(([r,e])=>[r,n(e,r)]))}var d=(...t)=>{let n=t.reduce((e,o)=>e+o.byteLength,0),r=new Uint8Array(n);for(let e=0,o=0;e<t.length;e++){let c=t[e];r.set(c,o),o+=c.byteLength}return r};var u=Function.prototype; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@polkadot-api/utils", | ||
"version": "0.0.1-21b8c0015b8cbc2d1861d4d1b54224173bf1b513.1.0", | ||
"version": "0.0.1-22330754eb2765dd817c0015f63e4cb99d4a05e7.1.0", | ||
"author": "Josep M Sobrepere (https://github.com/josepot)", | ||
@@ -5,0 +5,0 @@ "repository": { |
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
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
25376
371