@ethersproject/strings
Advanced tools
Comparing version 5.6.0 to 6.0.0-beta.1
@@ -1,2 +0,2 @@ | ||
export declare const version = "strings/5.6.0"; | ||
export declare const version = "@ethersproject/strings@6.0.0-beta.1"; | ||
//# sourceMappingURL=_version.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "strings/5.6.0"; | ||
export const version = "@ethersproject/strings@6.0.0-beta.1"; | ||
//# sourceMappingURL=_version.js.map |
@@ -1,4 +0,4 @@ | ||
import { BytesLike } from "@ethersproject/bytes"; | ||
import type { BytesLike } from "@ethersproject/logger"; | ||
export declare function formatBytes32String(text: string): string; | ||
export declare function parseBytes32String(bytes: BytesLike): string; | ||
export declare function parseBytes32String(_bytes: BytesLike): string; | ||
//# sourceMappingURL=bytes32.d.ts.map |
@@ -1,10 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseBytes32String = exports.formatBytes32String = void 0; | ||
var constants_1 = require("@ethersproject/constants"); | ||
var bytes_1 = require("@ethersproject/bytes"); | ||
var utf8_1 = require("./utf8"); | ||
function formatBytes32String(text) { | ||
import { zeroPadRight } from "@ethersproject/bytes"; | ||
import { logger } from "./logger.js"; | ||
import { toUtf8Bytes, toUtf8String } from "./utf8.js"; | ||
export function formatBytes32String(text) { | ||
// Get the bytes | ||
var bytes = (0, utf8_1.toUtf8Bytes)(text); | ||
const bytes = toUtf8Bytes(text); | ||
// Check we have room for null-termination | ||
@@ -15,7 +12,6 @@ if (bytes.length > 31) { | ||
// Zero-pad (implicitly null-terminates) | ||
return (0, bytes_1.hexlify)((0, bytes_1.concat)([bytes, constants_1.HashZero]).slice(0, 32)); | ||
return zeroPadRight(bytes, 32); | ||
} | ||
exports.formatBytes32String = formatBytes32String; | ||
function parseBytes32String(bytes) { | ||
var data = (0, bytes_1.arrayify)(bytes); | ||
export function parseBytes32String(_bytes) { | ||
const data = logger.getBytes(_bytes, "bytes"); | ||
// Must be 32 bytes with a null-termination | ||
@@ -29,3 +25,3 @@ if (data.length !== 32) { | ||
// Find the null termination | ||
var length = 31; | ||
let length = 31; | ||
while (data[length - 1] === 0) { | ||
@@ -35,5 +31,4 @@ length--; | ||
// Determine the string value | ||
return (0, utf8_1.toUtf8String)(data.slice(0, length)); | ||
return toUtf8String(data.slice(0, length)); | ||
} | ||
exports.parseBytes32String = parseBytes32String; | ||
//# sourceMappingURL=bytes32.js.map |
export declare function _nameprepTableA1(codepoint: number): boolean; | ||
export declare function _nameprepTableB2(codepoint: number): Array<number>; | ||
export declare function _nameprepTableB2(codepoint: number): null | Array<number>; | ||
export declare function _nameprepTableC(codepoint: number): boolean; | ||
export declare function nameprep(value: string): string; | ||
//# sourceMappingURL=idna.d.ts.map |
103
lib/idna.js
@@ -1,11 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nameprep = exports._nameprepTableC = exports._nameprepTableB2 = exports._nameprepTableA1 = void 0; | ||
var utf8_1 = require("./utf8"); | ||
import { logger } from "./logger.js"; | ||
import { toUtf8CodePoints, _toUtf8String, UnicodeNormalizationForm } from "./utf8.js"; | ||
function bytes2(data) { | ||
if ((data.length % 4) !== 0) { | ||
throw new Error("bad data"); | ||
throw new Error("should not happen; bad data"); | ||
} | ||
var result = []; | ||
for (var i = 0; i < data.length; i += 4) { | ||
let result = []; | ||
for (let i = 0; i < data.length; i += 4) { | ||
result.push(parseInt(data.substring(i, i + 4), 16)); | ||
@@ -15,10 +13,8 @@ } | ||
} | ||
function createTable(data, func) { | ||
if (!func) { | ||
func = function (value) { return [parseInt(value, 16)]; }; | ||
} | ||
var lo = 0; | ||
var result = {}; | ||
data.split(",").forEach(function (pair) { | ||
var comps = pair.split(":"); | ||
function createTable(data, _func) { | ||
const func = _func || function (value) { return [parseInt(value, 16)]; }; | ||
let lo = 0; | ||
let result = {}; | ||
data.split(",").forEach((pair) => { | ||
let comps = pair.split(":"); | ||
lo += parseInt(comps[0], 16); | ||
@@ -30,5 +26,5 @@ result[lo] = func(comps[1]); | ||
function createRangeTable(data) { | ||
var hi = 0; | ||
return data.split(",").map(function (v) { | ||
var comps = v.split("-"); | ||
let hi = 0; | ||
return data.split(",").map((v) => { | ||
let comps = v.split("-"); | ||
if (comps.length === 1) { | ||
@@ -40,3 +36,3 @@ comps[1] = "0"; | ||
} | ||
var lo = hi + parseInt(comps[0], 16); | ||
let lo = hi + parseInt(comps[0], 16); | ||
hi = parseInt(comps[1], 16); | ||
@@ -47,5 +43,5 @@ return { l: lo, h: hi }; | ||
function matchMap(value, ranges) { | ||
var lo = 0; | ||
for (var i = 0; i < ranges.length; i++) { | ||
var range = ranges[i]; | ||
let lo = 0; | ||
for (let i = 0; i < ranges.length; i++) { | ||
let range = ranges[i]; | ||
lo += range.l; | ||
@@ -61,6 +57,6 @@ if (value >= lo && value <= lo + range.h && ((value - lo) % (range.d || 1)) === 0) { | ||
} | ||
var Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"); | ||
const Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"); | ||
// @TODO: Make this relative... | ||
var Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function (v) { return parseInt(v, 16); }); | ||
var Table_B_2_ranges = [ | ||
const Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((v) => parseInt(v, 16)); | ||
const Table_B_2_ranges = [ | ||
{ h: 25, s: 32, l: 65 }, | ||
@@ -109,30 +105,32 @@ { h: 30, s: 32, e: [23], l: 127 }, | ||
]; | ||
var Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"); | ||
var Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"); | ||
var Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2); | ||
var Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); | ||
const Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"); | ||
const Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"); | ||
const Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2); | ||
const Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); | ||
function flatten(values) { | ||
return values.reduce(function (accum, value) { | ||
value.forEach(function (value) { accum.push(value); }); | ||
return values.reduce((accum, value) => { | ||
value.forEach((value) => { accum.push(value); }); | ||
return accum; | ||
}, []); | ||
} | ||
function _nameprepTableA1(codepoint) { | ||
export function _nameprepTableA1(codepoint) { | ||
return !!matchMap(codepoint, Table_A_1_ranges); | ||
} | ||
exports._nameprepTableA1 = _nameprepTableA1; | ||
function _nameprepTableB2(codepoint) { | ||
var range = matchMap(codepoint, Table_B_2_ranges); | ||
export function _nameprepTableB2(codepoint) { | ||
const range = matchMap(codepoint, Table_B_2_ranges); | ||
if (range) { | ||
if (range.s == null) { | ||
throw new Error("should not happenl bad range"); | ||
} | ||
return [codepoint + range.s]; | ||
} | ||
var codes = Table_B_2_lut_abs[codepoint]; | ||
const codes = Table_B_2_lut_abs[codepoint]; | ||
if (codes) { | ||
return codes; | ||
} | ||
var shift = Table_B_2_lut_rel[codepoint]; | ||
const shift = Table_B_2_lut_rel[codepoint]; | ||
if (shift) { | ||
return [codepoint + shift[0]]; | ||
} | ||
var complex = Table_B_2_complex[codepoint]; | ||
const complex = Table_B_2_complex[codepoint]; | ||
if (complex) { | ||
@@ -143,8 +141,6 @@ return complex; | ||
} | ||
exports._nameprepTableB2 = _nameprepTableB2; | ||
function _nameprepTableC(codepoint) { | ||
export function _nameprepTableC(codepoint) { | ||
return !!matchMap(codepoint, Table_C_ranges); | ||
} | ||
exports._nameprepTableC = _nameprepTableC; | ||
function nameprep(value) { | ||
export function nameprep(value) { | ||
// This allows platforms with incomplete normalize to bypass | ||
@@ -157,4 +153,4 @@ // it for very basic names which the built-in toLowerCase | ||
// Get the code points (keeping the current normalization) | ||
var codes = (0, utf8_1.toUtf8CodePoints)(value); | ||
codes = flatten(codes.map(function (code) { | ||
let codes = toUtf8CodePoints(value); | ||
codes = flatten(codes.map((code) => { | ||
// Substitute Table B.1 (Maps to Nothing) | ||
@@ -168,3 +164,3 @@ if (Table_B_1_flags.indexOf(code) >= 0) { | ||
// Substitute Table B.2 (Case Folding) | ||
var codesTableB2 = _nameprepTableB2(code); | ||
let codesTableB2 = _nameprepTableB2(code); | ||
if (codesTableB2) { | ||
@@ -177,28 +173,27 @@ return codesTableB2; | ||
// Normalize using form KC | ||
codes = (0, utf8_1.toUtf8CodePoints)((0, utf8_1._toUtf8String)(codes), utf8_1.UnicodeNormalizationForm.NFKC); | ||
codes = toUtf8CodePoints(_toUtf8String(codes), UnicodeNormalizationForm.NFKC); | ||
// Prohibit Tables C.1.2, C.2.2, C.3, C.4, C.5, C.6, C.7, C.8, C.9 | ||
codes.forEach(function (code) { | ||
codes.forEach((code) => { | ||
if (_nameprepTableC(code)) { | ||
throw new Error("STRINGPREP_CONTAINS_PROHIBITED"); | ||
logger.throwArgumentError("STRINGPREP_CONTAINS_PROHIBITED", "value", value); | ||
} | ||
}); | ||
// Prohibit Unassigned Code Points (Table A.1) | ||
codes.forEach(function (code) { | ||
codes.forEach((code) => { | ||
if (_nameprepTableA1(code)) { | ||
throw new Error("STRINGPREP_CONTAINS_UNASSIGNED"); | ||
logger.throwArgumentError("STRINGPREP_CONTAINS_UNASSIGNED", "value", value); | ||
} | ||
}); | ||
// IDNA extras | ||
var name = (0, utf8_1._toUtf8String)(codes); | ||
let name = _toUtf8String(codes); | ||
// IDNA: 4.2.3.1 | ||
if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") { | ||
throw new Error("invalid hyphen"); | ||
logger.throwArgumentError("invalid hyphen", "value", value); | ||
} | ||
// IDNA: 4.2.4 | ||
if (name.length > 63) { | ||
throw new Error("too long"); | ||
logger.throwArgumentError("too long", "value", value); | ||
} | ||
return name; | ||
} | ||
exports.nameprep = nameprep; | ||
//# sourceMappingURL=idna.js.map |
@@ -1,5 +0,5 @@ | ||
import { formatBytes32String, parseBytes32String } from "./bytes32"; | ||
import { nameprep } from "./idna"; | ||
import { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, UnicodeNormalizationForm, Utf8ErrorFunc, Utf8ErrorFuncs, Utf8ErrorReason } from "./utf8"; | ||
export { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFunc, Utf8ErrorFuncs, Utf8ErrorReason, UnicodeNormalizationForm, formatBytes32String, parseBytes32String, nameprep }; | ||
export { formatBytes32String, parseBytes32String } from "./bytes32.js"; | ||
export { nameprep } from "./idna.js"; | ||
export { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, UnicodeNormalizationForm, Utf8ErrorFuncs, Utf8ErrorReason } from "./utf8.js"; | ||
export type { Utf8ErrorFunc } from "./utf8.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,17 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nameprep = exports.parseBytes32String = exports.formatBytes32String = exports.UnicodeNormalizationForm = exports.Utf8ErrorReason = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports._toEscapedUtf8String = void 0; | ||
var bytes32_1 = require("./bytes32"); | ||
Object.defineProperty(exports, "formatBytes32String", { enumerable: true, get: function () { return bytes32_1.formatBytes32String; } }); | ||
Object.defineProperty(exports, "parseBytes32String", { enumerable: true, get: function () { return bytes32_1.parseBytes32String; } }); | ||
var idna_1 = require("./idna"); | ||
Object.defineProperty(exports, "nameprep", { enumerable: true, get: function () { return idna_1.nameprep; } }); | ||
var utf8_1 = require("./utf8"); | ||
Object.defineProperty(exports, "_toEscapedUtf8String", { enumerable: true, get: function () { return utf8_1._toEscapedUtf8String; } }); | ||
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_1.toUtf8Bytes; } }); | ||
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_1.toUtf8CodePoints; } }); | ||
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_1.toUtf8String; } }); | ||
Object.defineProperty(exports, "UnicodeNormalizationForm", { enumerable: true, get: function () { return utf8_1.UnicodeNormalizationForm; } }); | ||
Object.defineProperty(exports, "Utf8ErrorFuncs", { enumerable: true, get: function () { return utf8_1.Utf8ErrorFuncs; } }); | ||
Object.defineProperty(exports, "Utf8ErrorReason", { enumerable: true, get: function () { return utf8_1.Utf8ErrorReason; } }); | ||
export { formatBytes32String, parseBytes32String } from "./bytes32.js"; | ||
export { nameprep } from "./idna.js"; | ||
export { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, UnicodeNormalizationForm, Utf8ErrorFuncs, Utf8ErrorReason } from "./utf8.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { BytesLike } from "@ethersproject/bytes"; | ||
import type { BytesLike } from "@ethersproject/logger"; | ||
export declare enum UnicodeNormalizationForm { | ||
@@ -3,0 +3,0 @@ current = "", |
@@ -1,10 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toUtf8CodePoints = exports.toUtf8String = exports._toUtf8String = exports._toEscapedUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = exports.Utf8ErrorReason = exports.UnicodeNormalizationForm = void 0; | ||
var bytes_1 = require("@ethersproject/bytes"); | ||
var logger_1 = require("@ethersproject/logger"); | ||
var _version_1 = require("./_version"); | ||
var logger = new logger_1.Logger(_version_1.version); | ||
import { logger } from "./logger.js"; | ||
/////////////////////////////// | ||
var UnicodeNormalizationForm; | ||
export var UnicodeNormalizationForm; | ||
(function (UnicodeNormalizationForm) { | ||
@@ -16,5 +10,5 @@ UnicodeNormalizationForm["current"] = ""; | ||
UnicodeNormalizationForm["NFKD"] = "NFKD"; | ||
})(UnicodeNormalizationForm = exports.UnicodeNormalizationForm || (exports.UnicodeNormalizationForm = {})); | ||
})(UnicodeNormalizationForm || (UnicodeNormalizationForm = {})); | ||
; | ||
var Utf8ErrorReason; | ||
export var Utf8ErrorReason; | ||
(function (Utf8ErrorReason) { | ||
@@ -45,6 +39,6 @@ // A continuation byte was present where there was nothing to continue | ||
Utf8ErrorReason["OVERLONG"] = "overlong representation"; | ||
})(Utf8ErrorReason = exports.Utf8ErrorReason || (exports.Utf8ErrorReason = {})); | ||
})(Utf8ErrorReason || (Utf8ErrorReason = {})); | ||
; | ||
function errorFunc(reason, offset, bytes, output, badCodepoint) { | ||
return logger.throwArgumentError("invalid codepoint at offset " + offset + "; " + reason, "bytes", bytes); | ||
return logger.throwArgumentError(`invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes); | ||
} | ||
@@ -54,4 +48,4 @@ function ignoreFunc(reason, offset, bytes, output, badCodepoint) { | ||
if (reason === Utf8ErrorReason.BAD_PREFIX || reason === Utf8ErrorReason.UNEXPECTED_CONTINUE) { | ||
var i = 0; | ||
for (var o = offset + 1; o < bytes.length; o++) { | ||
let i = 0; | ||
for (let o = offset + 1; o < bytes.length; o++) { | ||
if (bytes[o] >> 6 !== 0x02) { | ||
@@ -75,3 +69,3 @@ break; | ||
if (reason === Utf8ErrorReason.OVERLONG) { | ||
output.push(badCodepoint); | ||
output.push((badCodepoint != null) ? badCodepoint : -1); | ||
return 0; | ||
@@ -85,3 +79,3 @@ } | ||
// Common error handing strategies | ||
exports.Utf8ErrorFuncs = Object.freeze({ | ||
export const Utf8ErrorFuncs = Object.freeze({ | ||
error: errorFunc, | ||
@@ -92,12 +86,12 @@ ignore: ignoreFunc, | ||
// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 | ||
function getUtf8CodePoints(bytes, onError) { | ||
function getUtf8CodePoints(_bytes, onError) { | ||
if (onError == null) { | ||
onError = exports.Utf8ErrorFuncs.error; | ||
onError = Utf8ErrorFuncs.error; | ||
} | ||
bytes = (0, bytes_1.arrayify)(bytes); | ||
var result = []; | ||
var i = 0; | ||
const bytes = logger.getBytes(_bytes, "bytes"); | ||
const result = []; | ||
let i = 0; | ||
// Invalid bytes are ignored | ||
while (i < bytes.length) { | ||
var c = bytes[i++]; | ||
const c = bytes[i++]; | ||
// 0xxx xxxx | ||
@@ -109,4 +103,4 @@ if (c >> 7 === 0) { | ||
// Multibyte; how many bytes left for this character? | ||
var extraLength = null; | ||
var overlongMask = null; | ||
let extraLength = null; | ||
let overlongMask = null; | ||
// 110x xxxx 10xx xxxx | ||
@@ -142,5 +136,5 @@ if ((c & 0xe0) === 0xc0) { | ||
// Remove the length prefix from the char | ||
var res = c & ((1 << (8 - extraLength - 1)) - 1); | ||
for (var j = 0; j < extraLength; j++) { | ||
var nextChar = bytes[i]; | ||
let res = c & ((1 << (8 - extraLength - 1)) - 1); | ||
for (let j = 0; j < extraLength; j++) { | ||
let nextChar = bytes[i]; | ||
// Invalid continuation byte | ||
@@ -180,11 +174,10 @@ if ((nextChar & 0xc0) != 0x80) { | ||
// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array | ||
function toUtf8Bytes(str, form) { | ||
if (form === void 0) { form = UnicodeNormalizationForm.current; } | ||
export function toUtf8Bytes(str, form = UnicodeNormalizationForm.current) { | ||
if (form != UnicodeNormalizationForm.current) { | ||
logger.checkNormalize(); | ||
logger.assertNormalize(form); | ||
str = str.normalize(form); | ||
} | ||
var result = []; | ||
for (var i = 0; i < str.length; i++) { | ||
var c = str.charCodeAt(i); | ||
let result = []; | ||
for (let i = 0; i < str.length; i++) { | ||
const c = str.charCodeAt(i); | ||
if (c < 0x80) { | ||
@@ -199,3 +192,3 @@ result.push(c); | ||
i++; | ||
var c2 = str.charCodeAt(i); | ||
const c2 = str.charCodeAt(i); | ||
if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) { | ||
@@ -205,3 +198,3 @@ throw new Error("invalid utf-8 string"); | ||
// Surrogate Pair | ||
var pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); | ||
const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); | ||
result.push((pair >> 18) | 0xf0); | ||
@@ -218,12 +211,11 @@ result.push(((pair >> 12) & 0x3f) | 0x80); | ||
} | ||
return (0, bytes_1.arrayify)(result); | ||
return new Uint8Array(result); | ||
} | ||
exports.toUtf8Bytes = toUtf8Bytes; | ||
; | ||
function escapeChar(value) { | ||
var hex = ("0000" + value.toString(16)); | ||
const hex = ("0000" + value.toString(16)); | ||
return "\\u" + hex.substring(hex.length - 4); | ||
} | ||
function _toEscapedUtf8String(bytes, onError) { | ||
return '"' + getUtf8CodePoints(bytes, onError).map(function (codePoint) { | ||
export function _toEscapedUtf8String(bytes, onError) { | ||
return '"' + getUtf8CodePoints(bytes, onError).map((codePoint) => { | ||
if (codePoint < 256) { | ||
@@ -249,5 +241,4 @@ switch (codePoint) { | ||
} | ||
exports._toEscapedUtf8String = _toEscapedUtf8String; | ||
function _toUtf8String(codePoints) { | ||
return codePoints.map(function (codePoint) { | ||
export function _toUtf8String(codePoints) { | ||
return codePoints.map((codePoint) => { | ||
if (codePoint <= 0xffff) { | ||
@@ -260,12 +251,8 @@ return String.fromCharCode(codePoint); | ||
} | ||
exports._toUtf8String = _toUtf8String; | ||
function toUtf8String(bytes, onError) { | ||
export function toUtf8String(bytes, onError) { | ||
return _toUtf8String(getUtf8CodePoints(bytes, onError)); | ||
} | ||
exports.toUtf8String = toUtf8String; | ||
function toUtf8CodePoints(str, form) { | ||
if (form === void 0) { form = UnicodeNormalizationForm.current; } | ||
export function toUtf8CodePoints(str, form = UnicodeNormalizationForm.current) { | ||
return getUtf8CodePoints(toUtf8Bytes(str, form)); | ||
} | ||
exports.toUtf8CodePoints = toUtf8CodePoints; | ||
//# sourceMappingURL=utf8.js.map |
{ | ||
"author": "Richard Moore <me@ricmoo.com>", | ||
"dependencies": { | ||
"@ethersproject/bytes": "^5.6.0", | ||
"@ethersproject/constants": "^5.6.0", | ||
"@ethersproject/logger": "^5.6.0" | ||
"@ethersproject/bytes": "^6.0.0-beta.1", | ||
"@ethersproject/logger": "^6.0.0-beta.1" | ||
}, | ||
"description": "String utility functions.", | ||
"engines": { | ||
"node": ">=12.17.0" | ||
}, | ||
"ethereum": "donations.ethers.eth", | ||
"funding": [ | ||
{ | ||
"type": "individual", | ||
"url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" | ||
}, | ||
{ | ||
"type": "individual", | ||
"url": "https://www.buymeacoffee.com/ricmoo" | ||
} | ||
], | ||
"gitHead": "b8cda5dffdcb688e38d7c6a0aec4c7b8b59c1af5", | ||
"gitHead": "77f691b3bc3a6387a5184ec9b1779faab4bcb30d", | ||
"keywords": [ | ||
"Ethereum", | ||
"ethers", | ||
"strings", | ||
"utf8" | ||
"ethers" | ||
], | ||
"license": "MIT", | ||
"main": "./lib/index.js", | ||
"module": "./lib.esm/index.js", | ||
"name": "@ethersproject/strings", | ||
"publishConfig": { | ||
"access": "public" | ||
"access": "public", | ||
"tag": "beta" | ||
}, | ||
@@ -43,5 +33,6 @@ "repository": { | ||
"sideEffects": false, | ||
"tarballHash": "0xc7a78eb215851a58f66ee9d71e42107a20f712dcd80dd32a004f3daca3ca9b79", | ||
"tarballHash": "0x7384ab5b2d3212ff5cc0290b905e115e0253d44158b6e58958874c7aaefb3aa2", | ||
"type": "module", | ||
"types": "./lib/index.d.ts", | ||
"version": "5.6.0" | ||
"version": "6.0.0-beta.1" | ||
} |
@@ -1,1 +0,1 @@ | ||
export const version = "strings/5.6.0"; | ||
export const version = "@ethersproject/strings@6.0.0-beta.1"; |
@@ -1,9 +0,10 @@ | ||
"use strict"; | ||
import { HashZero } from "@ethersproject/constants"; | ||
import { arrayify, BytesLike, concat, hexlify } from "@ethersproject/bytes"; | ||
import { zeroPadRight } from "@ethersproject/bytes"; | ||
import { toUtf8Bytes, toUtf8String } from "./utf8"; | ||
import { logger } from "./logger.js"; | ||
import { toUtf8Bytes, toUtf8String } from "./utf8.js"; | ||
import type { BytesLike } from "@ethersproject/logger"; | ||
export function formatBytes32String(text: string): string { | ||
@@ -18,7 +19,7 @@ | ||
// Zero-pad (implicitly null-terminates) | ||
return hexlify(concat([ bytes, HashZero ]).slice(0, 32)); | ||
return zeroPadRight(bytes, 32); | ||
} | ||
export function parseBytes32String(bytes: BytesLike): string { | ||
const data = arrayify(bytes); | ||
export function parseBytes32String(_bytes: BytesLike): string { | ||
const data = logger.getBytes(_bytes, "bytes"); | ||
@@ -25,0 +26,0 @@ // Must be 32 bytes with a null-termination |
@@ -1,5 +0,4 @@ | ||
"use strict"; | ||
import { logger } from "./logger.js"; | ||
import { toUtf8CodePoints, _toUtf8String, UnicodeNormalizationForm } from "./utf8.js"; | ||
import { toUtf8CodePoints, _toUtf8String, UnicodeNormalizationForm } from "./utf8"; | ||
type Ranged = { | ||
@@ -16,3 +15,5 @@ l: number, // Lo value | ||
function bytes2(data: string): Array<number> { | ||
if ((data.length % 4) !== 0) { throw new Error("bad data"); } | ||
if ((data.length % 4) !== 0) { | ||
throw new Error("should not happen; bad data"); | ||
} | ||
let result = []; | ||
@@ -25,6 +26,4 @@ for (let i = 0; i < data.length; i += 4) { | ||
function createTable(data: string, func?: (value: string) => Array<number>): Table { | ||
if (!func) { | ||
func = function(value: string) { return [ parseInt(value, 16) ]; } | ||
} | ||
function createTable(data: string, _func?: (value: string) => Array<number>): Table { | ||
const func = _func || function(value: string) { return [ parseInt(value, 16) ]; } | ||
@@ -59,3 +58,3 @@ let lo = 0; | ||
function matchMap(value: number, ranges: Array<Ranged>): Ranged { | ||
function matchMap(value: number, ranges: Array<Ranged>): null | Ranged { | ||
let lo = 0; | ||
@@ -140,13 +139,16 @@ for (let i = 0; i < ranges.length; i++) { | ||
export function _nameprepTableB2(codepoint: number): Array<number> { | ||
let range = matchMap(codepoint, Table_B_2_ranges); | ||
if (range) { return [ codepoint + range.s ]; } | ||
export function _nameprepTableB2(codepoint: number): null | Array<number> { | ||
const range = matchMap(codepoint, Table_B_2_ranges); | ||
if (range) { | ||
if (range.s == null) { throw new Error("should not happenl bad range"); } | ||
return [ codepoint + range.s ]; | ||
} | ||
let codes = Table_B_2_lut_abs[codepoint]; | ||
const codes = Table_B_2_lut_abs[codepoint]; | ||
if (codes) { return codes; } | ||
let shift = Table_B_2_lut_rel[codepoint]; | ||
const shift = Table_B_2_lut_rel[codepoint]; | ||
if (shift) { return [ codepoint + shift[0] ]; } | ||
let complex = Table_B_2_complex[codepoint]; | ||
const complex = Table_B_2_complex[codepoint]; | ||
if (complex) { return complex; } | ||
@@ -190,3 +192,3 @@ | ||
if (_nameprepTableC(code)) { | ||
throw new Error("STRINGPREP_CONTAINS_PROHIBITED"); | ||
logger.throwArgumentError("STRINGPREP_CONTAINS_PROHIBITED", "value", value); | ||
} | ||
@@ -198,3 +200,3 @@ }); | ||
if (_nameprepTableA1(code)) { | ||
throw new Error("STRINGPREP_CONTAINS_UNASSIGNED"); | ||
logger.throwArgumentError("STRINGPREP_CONTAINS_UNASSIGNED", "value", value); | ||
} | ||
@@ -208,12 +210,12 @@ }); | ||
if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") { | ||
throw new Error("invalid hyphen"); | ||
logger.throwArgumentError("invalid hyphen", "value", value); | ||
} | ||
// IDNA: 4.2.4 | ||
if (name.length > 63) { throw new Error("too long"); } | ||
if (name.length > 63) { | ||
logger.throwArgumentError("too long", "value", value); | ||
} | ||
return name; | ||
} | ||
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
import { formatBytes32String, parseBytes32String } from "./bytes32"; | ||
import { nameprep } from "./idna"; | ||
import { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, UnicodeNormalizationForm, Utf8ErrorFunc, Utf8ErrorFuncs, Utf8ErrorReason } from "./utf8"; | ||
export { formatBytes32String, parseBytes32String } from "./bytes32.js"; | ||
export { nameprep } from "./idna.js"; | ||
export { | ||
@@ -13,12 +9,7 @@ _toEscapedUtf8String, | ||
Utf8ErrorFunc, | ||
UnicodeNormalizationForm, | ||
Utf8ErrorFuncs, | ||
Utf8ErrorReason, | ||
Utf8ErrorReason | ||
} from "./utf8.js"; | ||
UnicodeNormalizationForm, | ||
formatBytes32String, | ||
parseBytes32String, | ||
nameprep | ||
} | ||
export type { Utf8ErrorFunc } from "./utf8.js"; |
@@ -1,9 +0,7 @@ | ||
"use strict"; | ||
import { arrayify, BytesLike } from "@ethersproject/bytes"; | ||
import type { BytesLike } from "@ethersproject/logger"; | ||
import { Logger } from "@ethersproject/logger"; | ||
import { version } from "./_version"; | ||
const logger = new Logger(version); | ||
import { logger } from "./logger.js"; | ||
/////////////////////////////// | ||
@@ -85,3 +83,3 @@ | ||
if (reason === Utf8ErrorReason.OVERLONG) { | ||
output.push(badCodepoint); | ||
output.push((badCodepoint != null) ? badCodepoint: -1); | ||
return 0; | ||
@@ -105,6 +103,6 @@ } | ||
// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 | ||
function getUtf8CodePoints(bytes: BytesLike, onError?: Utf8ErrorFunc): Array<number> { | ||
function getUtf8CodePoints(_bytes: BytesLike, onError?: Utf8ErrorFunc): Array<number> { | ||
if (onError == null) { onError = Utf8ErrorFuncs.error; } | ||
bytes = arrayify(bytes); | ||
const bytes = logger.getBytes(_bytes, "bytes"); | ||
@@ -160,3 +158,3 @@ const result: Array<number> = []; | ||
// Remove the length prefix from the char | ||
let res = c & ((1 << (8 - extraLength - 1)) - 1); | ||
let res: null | number = c & ((1 << (8 - extraLength - 1)) - 1); | ||
@@ -208,3 +206,3 @@ for (let j = 0; j < extraLength; j++) { | ||
if (form != UnicodeNormalizationForm.current) { | ||
logger.checkNormalize(); | ||
logger.assertNormalize(form); | ||
str = str.normalize(form); | ||
@@ -246,3 +244,3 @@ } | ||
return arrayify(result); | ||
return new Uint8Array(result); | ||
}; | ||
@@ -249,0 +247,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
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
2
2
Yes
69707
32
993
3
1
0
+ Added@ethersproject/bytes@6.0.0-beta.3(transitive)
+ Added@ethersproject/logger@6.0.0-beta.7(transitive)
- Removed@ethersproject/constants@^5.6.0
- Removed@ethersproject/bignumber@5.7.0(transitive)
- Removed@ethersproject/bytes@5.7.0(transitive)
- Removed@ethersproject/constants@5.7.0(transitive)
- Removed@ethersproject/logger@5.7.0(transitive)
- Removedbn.js@5.2.1(transitive)