@fre4x/benchmark 1.1.3 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +133 -42
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw mod = 0, e;
|
|
14
|
+
}
|
|
11
15
|
};
|
|
12
16
|
var __export = (target, all) => {
|
|
13
17
|
for (var name in all)
|
|
@@ -3106,6 +3110,9 @@ var require_utils = __commonJS({
|
|
|
3106
3110
|
"use strict";
|
|
3107
3111
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
3108
3112
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
3113
|
+
var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
3114
|
+
var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
3115
|
+
var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
|
|
3109
3116
|
function stringArrayToHexStripped(input) {
|
|
3110
3117
|
let acc = "";
|
|
3111
3118
|
let code = 0;
|
|
@@ -3298,27 +3305,77 @@ var require_utils = __commonJS({
|
|
|
3298
3305
|
}
|
|
3299
3306
|
return output.join("");
|
|
3300
3307
|
}
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3308
|
+
var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
|
|
3309
|
+
var HOST_DELIM_RE = /[@/?#:]/g;
|
|
3310
|
+
var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
|
|
3311
|
+
function reescapeHostDelimiters(host, isIP) {
|
|
3312
|
+
const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
|
|
3313
|
+
re.lastIndex = 0;
|
|
3314
|
+
return host.replace(re, (ch) => HOST_DELIMS[ch]);
|
|
3315
|
+
}
|
|
3316
|
+
function normalizePercentEncoding(input, decodeUnreserved = false) {
|
|
3317
|
+
if (input.indexOf("%") === -1) {
|
|
3318
|
+
return input;
|
|
3311
3319
|
}
|
|
3312
|
-
|
|
3313
|
-
|
|
3320
|
+
let output = "";
|
|
3321
|
+
for (let i = 0; i < input.length; i++) {
|
|
3322
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3323
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3324
|
+
if (isHexPair(hex3)) {
|
|
3325
|
+
const normalizedHex = hex3.toUpperCase();
|
|
3326
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3327
|
+
if (decodeUnreserved && isUnreserved(decoded)) {
|
|
3328
|
+
output += decoded;
|
|
3329
|
+
} else {
|
|
3330
|
+
output += "%" + normalizedHex;
|
|
3331
|
+
}
|
|
3332
|
+
i += 2;
|
|
3333
|
+
continue;
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
output += input[i];
|
|
3314
3337
|
}
|
|
3315
|
-
|
|
3316
|
-
|
|
3338
|
+
return output;
|
|
3339
|
+
}
|
|
3340
|
+
function normalizePathEncoding(input) {
|
|
3341
|
+
let output = "";
|
|
3342
|
+
for (let i = 0; i < input.length; i++) {
|
|
3343
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3344
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3345
|
+
if (isHexPair(hex3)) {
|
|
3346
|
+
const normalizedHex = hex3.toUpperCase();
|
|
3347
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3348
|
+
if (decoded !== "." && isUnreserved(decoded)) {
|
|
3349
|
+
output += decoded;
|
|
3350
|
+
} else {
|
|
3351
|
+
output += "%" + normalizedHex;
|
|
3352
|
+
}
|
|
3353
|
+
i += 2;
|
|
3354
|
+
continue;
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
if (isPathCharacter(input[i])) {
|
|
3358
|
+
output += input[i];
|
|
3359
|
+
} else {
|
|
3360
|
+
output += escape(input[i]);
|
|
3361
|
+
}
|
|
3317
3362
|
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3363
|
+
return output;
|
|
3364
|
+
}
|
|
3365
|
+
function escapePreservingEscapes(input) {
|
|
3366
|
+
let output = "";
|
|
3367
|
+
for (let i = 0; i < input.length; i++) {
|
|
3368
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3369
|
+
const hex3 = input.slice(i + 1, i + 3);
|
|
3370
|
+
if (isHexPair(hex3)) {
|
|
3371
|
+
output += "%" + hex3.toUpperCase();
|
|
3372
|
+
i += 2;
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
output += escape(input[i]);
|
|
3320
3377
|
}
|
|
3321
|
-
return
|
|
3378
|
+
return output;
|
|
3322
3379
|
}
|
|
3323
3380
|
function recomposeAuthority(component) {
|
|
3324
3381
|
const uriTokens = [];
|
|
@@ -3333,7 +3390,7 @@ var require_utils = __commonJS({
|
|
|
3333
3390
|
if (ipV6res.isIPV6 === true) {
|
|
3334
3391
|
host = `[${ipV6res.escapedHost}]`;
|
|
3335
3392
|
} else {
|
|
3336
|
-
host =
|
|
3393
|
+
host = reescapeHostDelimiters(host, false);
|
|
3337
3394
|
}
|
|
3338
3395
|
}
|
|
3339
3396
|
uriTokens.push(host);
|
|
@@ -3347,7 +3404,10 @@ var require_utils = __commonJS({
|
|
|
3347
3404
|
module.exports = {
|
|
3348
3405
|
nonSimpleDomain,
|
|
3349
3406
|
recomposeAuthority,
|
|
3350
|
-
|
|
3407
|
+
reescapeHostDelimiters,
|
|
3408
|
+
normalizePercentEncoding,
|
|
3409
|
+
normalizePathEncoding,
|
|
3410
|
+
escapePreservingEscapes,
|
|
3351
3411
|
removeDotSegments,
|
|
3352
3412
|
isIPv4,
|
|
3353
3413
|
isUUID,
|
|
@@ -3571,12 +3631,12 @@ var require_schemes = __commonJS({
|
|
|
3571
3631
|
var require_fast_uri = __commonJS({
|
|
3572
3632
|
"../node_modules/fast-uri/index.js"(exports, module) {
|
|
3573
3633
|
"use strict";
|
|
3574
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority,
|
|
3634
|
+
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
3575
3635
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
3576
3636
|
function normalize(uri, options) {
|
|
3577
3637
|
if (typeof uri === "string") {
|
|
3578
3638
|
uri = /** @type {T} */
|
|
3579
|
-
|
|
3639
|
+
normalizeString(uri, options);
|
|
3580
3640
|
} else if (typeof uri === "object") {
|
|
3581
3641
|
uri = /** @type {T} */
|
|
3582
3642
|
parse3(serialize(uri, options), options);
|
|
@@ -3643,19 +3703,9 @@ var require_fast_uri = __commonJS({
|
|
|
3643
3703
|
return target;
|
|
3644
3704
|
}
|
|
3645
3705
|
function equal(uriA, uriB, options) {
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
} else if (typeof uriA === "object") {
|
|
3650
|
-
uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
|
|
3651
|
-
}
|
|
3652
|
-
if (typeof uriB === "string") {
|
|
3653
|
-
uriB = unescape(uriB);
|
|
3654
|
-
uriB = serialize(normalizeComponentEncoding(parse3(uriB, options), true), { ...options, skipEscape: true });
|
|
3655
|
-
} else if (typeof uriB === "object") {
|
|
3656
|
-
uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
|
|
3657
|
-
}
|
|
3658
|
-
return uriA.toLowerCase() === uriB.toLowerCase();
|
|
3706
|
+
const normalizedA = normalizeComparableURI(uriA, options);
|
|
3707
|
+
const normalizedB = normalizeComparableURI(uriB, options);
|
|
3708
|
+
return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
|
|
3659
3709
|
}
|
|
3660
3710
|
function serialize(cmpts, opts) {
|
|
3661
3711
|
const component = {
|
|
@@ -3680,12 +3730,12 @@ var require_fast_uri = __commonJS({
|
|
|
3680
3730
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
3681
3731
|
if (component.path !== void 0) {
|
|
3682
3732
|
if (!options.skipEscape) {
|
|
3683
|
-
component.path =
|
|
3733
|
+
component.path = escapePreservingEscapes(component.path);
|
|
3684
3734
|
if (component.scheme !== void 0) {
|
|
3685
3735
|
component.path = component.path.split("%3A").join(":");
|
|
3686
3736
|
}
|
|
3687
3737
|
} else {
|
|
3688
|
-
component.path =
|
|
3738
|
+
component.path = normalizePercentEncoding(component.path);
|
|
3689
3739
|
}
|
|
3690
3740
|
}
|
|
3691
3741
|
if (options.reference !== "suffix" && component.scheme) {
|
|
@@ -3720,7 +3770,16 @@ var require_fast_uri = __commonJS({
|
|
|
3720
3770
|
return uriTokens.join("");
|
|
3721
3771
|
}
|
|
3722
3772
|
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
3723
|
-
function
|
|
3773
|
+
function getParseError(parsed, matches) {
|
|
3774
|
+
if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
|
|
3775
|
+
return 'URI path must start with "/" when authority is present.';
|
|
3776
|
+
}
|
|
3777
|
+
if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
|
|
3778
|
+
return "URI port is malformed.";
|
|
3779
|
+
}
|
|
3780
|
+
return void 0;
|
|
3781
|
+
}
|
|
3782
|
+
function parseWithStatus(uri, opts) {
|
|
3724
3783
|
const options = Object.assign({}, opts);
|
|
3725
3784
|
const parsed = {
|
|
3726
3785
|
scheme: void 0,
|
|
@@ -3731,6 +3790,7 @@ var require_fast_uri = __commonJS({
|
|
|
3731
3790
|
query: void 0,
|
|
3732
3791
|
fragment: void 0
|
|
3733
3792
|
};
|
|
3793
|
+
let malformedAuthorityOrPort = false;
|
|
3734
3794
|
let isIP = false;
|
|
3735
3795
|
if (options.reference === "suffix") {
|
|
3736
3796
|
if (options.scheme) {
|
|
@@ -3751,6 +3811,11 @@ var require_fast_uri = __commonJS({
|
|
|
3751
3811
|
if (isNaN(parsed.port)) {
|
|
3752
3812
|
parsed.port = matches[5];
|
|
3753
3813
|
}
|
|
3814
|
+
const parseError = getParseError(parsed, matches);
|
|
3815
|
+
if (parseError !== void 0) {
|
|
3816
|
+
parsed.error = parsed.error || parseError;
|
|
3817
|
+
malformedAuthorityOrPort = true;
|
|
3818
|
+
}
|
|
3754
3819
|
if (parsed.host) {
|
|
3755
3820
|
const ipv4result = isIPv4(parsed.host);
|
|
3756
3821
|
if (ipv4result === false) {
|
|
@@ -3789,14 +3854,18 @@ var require_fast_uri = __commonJS({
|
|
|
3789
3854
|
parsed.scheme = unescape(parsed.scheme);
|
|
3790
3855
|
}
|
|
3791
3856
|
if (parsed.host !== void 0) {
|
|
3792
|
-
parsed.host = unescape(parsed.host);
|
|
3857
|
+
parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
|
|
3793
3858
|
}
|
|
3794
3859
|
}
|
|
3795
3860
|
if (parsed.path) {
|
|
3796
|
-
parsed.path =
|
|
3861
|
+
parsed.path = normalizePathEncoding(parsed.path);
|
|
3797
3862
|
}
|
|
3798
3863
|
if (parsed.fragment) {
|
|
3799
|
-
|
|
3864
|
+
try {
|
|
3865
|
+
parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
|
|
3866
|
+
} catch {
|
|
3867
|
+
parsed.error = parsed.error || "URI malformed";
|
|
3868
|
+
}
|
|
3800
3869
|
}
|
|
3801
3870
|
}
|
|
3802
3871
|
if (schemeHandler && schemeHandler.parse) {
|
|
@@ -3805,7 +3874,29 @@ var require_fast_uri = __commonJS({
|
|
|
3805
3874
|
} else {
|
|
3806
3875
|
parsed.error = parsed.error || "URI can not be parsed.";
|
|
3807
3876
|
}
|
|
3808
|
-
return parsed;
|
|
3877
|
+
return { parsed, malformedAuthorityOrPort };
|
|
3878
|
+
}
|
|
3879
|
+
function parse3(uri, opts) {
|
|
3880
|
+
return parseWithStatus(uri, opts).parsed;
|
|
3881
|
+
}
|
|
3882
|
+
function normalizeString(uri, opts) {
|
|
3883
|
+
return normalizeStringWithStatus(uri, opts).normalized;
|
|
3884
|
+
}
|
|
3885
|
+
function normalizeStringWithStatus(uri, opts) {
|
|
3886
|
+
const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
|
|
3887
|
+
return {
|
|
3888
|
+
normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
|
|
3889
|
+
malformedAuthorityOrPort
|
|
3890
|
+
};
|
|
3891
|
+
}
|
|
3892
|
+
function normalizeComparableURI(uri, opts) {
|
|
3893
|
+
if (typeof uri === "string") {
|
|
3894
|
+
const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
|
|
3895
|
+
return malformedAuthorityOrPort ? void 0 : normalized;
|
|
3896
|
+
}
|
|
3897
|
+
if (typeof uri === "object") {
|
|
3898
|
+
return serialize(uri, opts);
|
|
3899
|
+
}
|
|
3809
3900
|
}
|
|
3810
3901
|
var fastUri = {
|
|
3811
3902
|
SCHEMES,
|