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

fast-check

Package Overview
Dependencies
Maintainers
1
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-check - npm Package Compare versions

Comparing version 3.23.0 to 3.23.1

9

CHANGELOG.md

@@ -0,1 +1,10 @@

# 3.23.1
_Faster instantiation of internet-related arbitraries_
[[Code](https://github.com/dubzzz/fast-check/tree/v3.23.1)][[Diff](https://github.com/dubzzz/fast-check/compare/v3.23.0...v3.23.1)]
## Fixes
- ([PR#5402](https://github.com/dubzzz/fast-check/pull/5402)) Performance: Faster instantiation of internet-related arbitraries
# 3.23.0

@@ -2,0 +11,0 @@

53

lib/arbitrary/_internals/builders/CharacterRangeArbitraryBuilder.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildAlphaNumericPercentArbitrary = exports.buildAlphaNumericArbitrary = exports.buildLowerAlphaNumericArbitrary = exports.buildLowerAlphaArbitrary = void 0;
exports.getOrCreateLowerAlphaArbitrary = getOrCreateLowerAlphaArbitrary;
exports.getOrCreateLowerAlphaNumericArbitrary = getOrCreateLowerAlphaNumericArbitrary;
exports.getOrCreateAlphaNumericPercentArbitrary = getOrCreateAlphaNumericPercentArbitrary;
const fullUnicode_1 = require("../../fullUnicode");

@@ -8,2 +10,3 @@ const oneof_1 = require("../../oneof");

const globals_1 = require("../../../utils/globals");
const SMap = Map;
const safeStringFromCharCode = String.fromCharCode;

@@ -25,9 +28,41 @@ const lowerCaseMapper = { num: 26, build: (v) => safeStringFromCharCode(v + 0x61) };

const percentCharArb = (0, fullUnicode_1.fullUnicode)().map(percentCharArbMapper, percentCharArbUnmapper);
const buildLowerAlphaArbitrary = (others) => (0, mapToConstant_1.mapToConstant)(lowerCaseMapper, { num: others.length, build: (v) => others[v] });
exports.buildLowerAlphaArbitrary = buildLowerAlphaArbitrary;
const buildLowerAlphaNumericArbitrary = (others) => (0, mapToConstant_1.mapToConstant)(lowerCaseMapper, numericMapper, { num: others.length, build: (v) => others[v] });
exports.buildLowerAlphaNumericArbitrary = buildLowerAlphaNumericArbitrary;
const buildAlphaNumericArbitrary = (others) => (0, mapToConstant_1.mapToConstant)(lowerCaseMapper, upperCaseMapper, numericMapper, { num: others.length, build: (v) => others[v] });
exports.buildAlphaNumericArbitrary = buildAlphaNumericArbitrary;
const buildAlphaNumericPercentArbitrary = (others) => (0, oneof_1.oneof)({ weight: 10, arbitrary: (0, exports.buildAlphaNumericArbitrary)(others) }, { weight: 1, arbitrary: percentCharArb });
exports.buildAlphaNumericPercentArbitrary = buildAlphaNumericPercentArbitrary;
let lowerAlphaArbitrary = undefined;
function getOrCreateLowerAlphaArbitrary() {
if (lowerAlphaArbitrary === undefined) {
lowerAlphaArbitrary = (0, mapToConstant_1.mapToConstant)(lowerCaseMapper);
}
return lowerAlphaArbitrary;
}
let lowerAlphaNumericArbitraries = undefined;
function getOrCreateLowerAlphaNumericArbitrary(others) {
if (lowerAlphaNumericArbitraries === undefined) {
lowerAlphaNumericArbitraries = new SMap();
}
let match = (0, globals_1.safeMapGet)(lowerAlphaNumericArbitraries, others);
if (match === undefined) {
match = (0, mapToConstant_1.mapToConstant)(lowerCaseMapper, numericMapper, {
num: others.length,
build: (v) => others[v],
});
(0, globals_1.safeMapSet)(lowerAlphaNumericArbitraries, others, match);
}
return match;
}
function buildAlphaNumericArbitrary(others) {
return (0, mapToConstant_1.mapToConstant)(lowerCaseMapper, upperCaseMapper, numericMapper, {
num: others.length,
build: (v) => others[v],
});
}
let alphaNumericPercentArbitraries = undefined;
function getOrCreateAlphaNumericPercentArbitrary(others) {
if (alphaNumericPercentArbitraries === undefined) {
alphaNumericPercentArbitraries = new SMap();
}
let match = (0, globals_1.safeMapGet)(alphaNumericPercentArbitraries, others);
if (match === undefined) {
match = (0, oneof_1.oneof)({ weight: 10, arbitrary: buildAlphaNumericArbitrary(others) }, { weight: 1, arbitrary: percentCharArb });
(0, globals_1.safeMapSet)(alphaNumericPercentArbitraries, others, match);
}
return match;
}

5

lib/arbitrary/_internals/builders/UriQueryOrFragmentArbitraryBuilder.js

@@ -5,6 +5,5 @@ "use strict";

const CharacterRangeArbitraryBuilder_1 = require("./CharacterRangeArbitraryBuilder");
const stringOf_1 = require("../../stringOf");
const string_1 = require("../../string");
function buildUriQueryOrFragmentArbitrary(size) {
const others = ['-', '.', '_', '~', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ':', '@', '/', '?'];
return (0, stringOf_1.stringOf)((0, CharacterRangeArbitraryBuilder_1.buildAlphaNumericPercentArbitrary)(others), { size });
return (0, string_1.string)({ unit: (0, CharacterRangeArbitraryBuilder_1.getOrCreateAlphaNumericPercentArbitrary)("-._~!$&'()*+,;=:@/?"), size });
}

@@ -7,3 +7,3 @@ "use strict";

const option_1 = require("./option");
const stringOf_1 = require("./stringOf");
const string_1 = require("./string");
const tuple_1 = require("./tuple");

@@ -27,5 +27,5 @@ const InvalidSubdomainLabelFiIter_1 = require("./_internals/helpers/InvalidSubdomainLabelFiIter");

function subdomainLabel(size) {
const alphaNumericArb = (0, CharacterRangeArbitraryBuilder_1.buildLowerAlphaNumericArbitrary)([]);
const alphaNumericHyphenArb = (0, CharacterRangeArbitraryBuilder_1.buildLowerAlphaNumericArbitrary)(['-']);
return (0, tuple_1.tuple)(alphaNumericArb, (0, option_1.option)((0, tuple_1.tuple)((0, stringOf_1.stringOf)(alphaNumericHyphenArb, { size, maxLength: 61 }), alphaNumericArb)))
const alphaNumericArb = (0, CharacterRangeArbitraryBuilder_1.getOrCreateLowerAlphaNumericArbitrary)('');
const alphaNumericHyphenArb = (0, CharacterRangeArbitraryBuilder_1.getOrCreateLowerAlphaNumericArbitrary)('-');
return (0, tuple_1.tuple)(alphaNumericArb, (0, option_1.option)((0, tuple_1.tuple)((0, string_1.string)({ unit: alphaNumericHyphenArb, size, maxLength: 61 }), alphaNumericArb)))
.map(toSubdomainLabelMapper, toSubdomainLabelUnmapper)

@@ -58,5 +58,5 @@ .filter(InvalidSubdomainLabelFiIter_1.filterInvalidSubdomainLabel);

const resolvedSizeMinusOne = (0, MaxLengthFromMinLength_1.relativeSizeToSize)('-1', resolvedSize);
const alphaNumericArb = (0, CharacterRangeArbitraryBuilder_1.buildLowerAlphaArbitrary)([]);
const publicSuffixArb = (0, stringOf_1.stringOf)(alphaNumericArb, { minLength: 2, maxLength: 63, size: resolvedSizeMinusOne });
const lowerAlphaArb = (0, CharacterRangeArbitraryBuilder_1.getOrCreateLowerAlphaArbitrary)();
const publicSuffixArb = (0, string_1.string)({ unit: lowerAlphaArb, minLength: 2, maxLength: 63, size: resolvedSizeMinusOne });
return ((0, AdapterArbitrary_1.adapter)((0, tuple_1.tuple)((0, array_1.array)(subdomainLabel(resolvedSize), { size: resolvedSizeMinusOne, minLength: 1, maxLength: 127 }), publicSuffixArb), labelsAdapter).map(labelsMapper, labelsUnmapper));
}

@@ -7,3 +7,3 @@ "use strict";

const domain_1 = require("./domain");
const stringOf_1 = require("./stringOf");
const string_1 = require("./string");
const tuple_1 = require("./tuple");

@@ -41,5 +41,5 @@ const AdapterArbitrary_1 = require("./_internals/AdapterArbitrary");

function emailAddress(constraints = {}) {
const others = ['!', '#', '$', '%', '&', "'", '*', '+', '-', '/', '=', '?', '^', '_', '`', '{', '|', '}', '~'];
const atextArb = (0, CharacterRangeArbitraryBuilder_1.buildLowerAlphaNumericArbitrary)(others);
const localPartArb = (0, AdapterArbitrary_1.adapter)((0, array_1.array)((0, stringOf_1.stringOf)(atextArb, {
const atextArb = (0, CharacterRangeArbitraryBuilder_1.getOrCreateLowerAlphaNumericArbitrary)("!#$%&'*+-/=?^_`{|}~");
const localPartArb = (0, AdapterArbitrary_1.adapter)((0, array_1.array)((0, string_1.string)({
unit: atextArb,
minLength: 1,

@@ -46,0 +46,0 @@ maxLength: 64,

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

const option_1 = require("./option");
const stringOf_1 = require("./stringOf");
const string_1 = require("./string");
const tuple_1 = require("./tuple");
function hostUserInfo(size) {
const others = ['-', '.', '_', '~', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ':'];
return (0, stringOf_1.stringOf)((0, CharacterRangeArbitraryBuilder_1.buildAlphaNumericPercentArbitrary)(others), { size });
return (0, string_1.string)({ unit: (0, CharacterRangeArbitraryBuilder_1.getOrCreateAlphaNumericPercentArbitrary)("-._~!$&'()*+,;=:"), size });
}

@@ -20,0 +19,0 @@ function userHostPortMapper([u, h, p]) {

@@ -5,6 +5,5 @@ "use strict";

const CharacterRangeArbitraryBuilder_1 = require("./_internals/builders/CharacterRangeArbitraryBuilder");
const stringOf_1 = require("./stringOf");
const string_1 = require("./string");
function webSegment(constraints = {}) {
const others = ['-', '.', '_', '~', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ':', '@'];
return (0, stringOf_1.stringOf)((0, CharacterRangeArbitraryBuilder_1.buildAlphaNumericPercentArbitrary)(others), { size: constraints.size });
return (0, string_1.string)({ unit: (0, CharacterRangeArbitraryBuilder_1.getOrCreateAlphaNumericPercentArbitrary)("-._~!$&'()*+,;=:@"), size: constraints.size });
}
import { fullUnicode } from '../../fullUnicode.js';
import { oneof } from '../../oneof.js';
import { mapToConstant } from '../../mapToConstant.js';
import { safeCharCodeAt, safeNumberToString, encodeURIComponent } from '../../../utils/globals.js';
import { safeCharCodeAt, safeNumberToString, encodeURIComponent, safeMapGet, safeMapSet } from '../../../utils/globals.js';
const SMap = Map;
const safeStringFromCharCode = String.fromCharCode;

@@ -21,5 +22,41 @@ const lowerCaseMapper = { num: 26, build: (v) => safeStringFromCharCode(v + 0x61) };

const percentCharArb = fullUnicode().map(percentCharArbMapper, percentCharArbUnmapper);
export const buildLowerAlphaArbitrary = (others) => mapToConstant(lowerCaseMapper, { num: others.length, build: (v) => others[v] });
export const buildLowerAlphaNumericArbitrary = (others) => mapToConstant(lowerCaseMapper, numericMapper, { num: others.length, build: (v) => others[v] });
export const buildAlphaNumericArbitrary = (others) => mapToConstant(lowerCaseMapper, upperCaseMapper, numericMapper, { num: others.length, build: (v) => others[v] });
export const buildAlphaNumericPercentArbitrary = (others) => oneof({ weight: 10, arbitrary: buildAlphaNumericArbitrary(others) }, { weight: 1, arbitrary: percentCharArb });
let lowerAlphaArbitrary = undefined;
export function getOrCreateLowerAlphaArbitrary() {
if (lowerAlphaArbitrary === undefined) {
lowerAlphaArbitrary = mapToConstant(lowerCaseMapper);
}
return lowerAlphaArbitrary;
}
let lowerAlphaNumericArbitraries = undefined;
export function getOrCreateLowerAlphaNumericArbitrary(others) {
if (lowerAlphaNumericArbitraries === undefined) {
lowerAlphaNumericArbitraries = new SMap();
}
let match = safeMapGet(lowerAlphaNumericArbitraries, others);
if (match === undefined) {
match = mapToConstant(lowerCaseMapper, numericMapper, {
num: others.length,
build: (v) => others[v],
});
safeMapSet(lowerAlphaNumericArbitraries, others, match);
}
return match;
}
function buildAlphaNumericArbitrary(others) {
return mapToConstant(lowerCaseMapper, upperCaseMapper, numericMapper, {
num: others.length,
build: (v) => others[v],
});
}
let alphaNumericPercentArbitraries = undefined;
export function getOrCreateAlphaNumericPercentArbitrary(others) {
if (alphaNumericPercentArbitraries === undefined) {
alphaNumericPercentArbitraries = new SMap();
}
let match = safeMapGet(alphaNumericPercentArbitraries, others);
if (match === undefined) {
match = oneof({ weight: 10, arbitrary: buildAlphaNumericArbitrary(others) }, { weight: 1, arbitrary: percentCharArb });
safeMapSet(alphaNumericPercentArbitraries, others, match);
}
return match;
}

@@ -1,6 +0,5 @@

import { buildAlphaNumericPercentArbitrary } from './CharacterRangeArbitraryBuilder.js';
import { stringOf } from '../../stringOf.js';
import { getOrCreateAlphaNumericPercentArbitrary } from './CharacterRangeArbitraryBuilder.js';
import { string } from '../../string.js';
export function buildUriQueryOrFragmentArbitrary(size) {
const others = ['-', '.', '_', '~', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ':', '@', '/', '?'];
return stringOf(buildAlphaNumericPercentArbitrary(others), { size });
return string({ unit: getOrCreateAlphaNumericPercentArbitrary("-._~!$&'()*+,;=:@/?"), size });
}
import { array } from './array.js';
import { buildLowerAlphaArbitrary, buildLowerAlphaNumericArbitrary, } from './_internals/builders/CharacterRangeArbitraryBuilder.js';
import { getOrCreateLowerAlphaArbitrary, getOrCreateLowerAlphaNumericArbitrary, } from './_internals/builders/CharacterRangeArbitraryBuilder.js';
import { option } from './option.js';
import { stringOf } from './stringOf.js';
import { string } from './string.js';
import { tuple } from './tuple.js';

@@ -23,5 +23,5 @@ import { filterInvalidSubdomainLabel } from './_internals/helpers/InvalidSubdomainLabelFiIter.js';

function subdomainLabel(size) {
const alphaNumericArb = buildLowerAlphaNumericArbitrary([]);
const alphaNumericHyphenArb = buildLowerAlphaNumericArbitrary(['-']);
return tuple(alphaNumericArb, option(tuple(stringOf(alphaNumericHyphenArb, { size, maxLength: 61 }), alphaNumericArb)))
const alphaNumericArb = getOrCreateLowerAlphaNumericArbitrary('');
const alphaNumericHyphenArb = getOrCreateLowerAlphaNumericArbitrary('-');
return tuple(alphaNumericArb, option(tuple(string({ unit: alphaNumericHyphenArb, size, maxLength: 61 }), alphaNumericArb)))
.map(toSubdomainLabelMapper, toSubdomainLabelUnmapper)

@@ -54,5 +54,5 @@ .filter(filterInvalidSubdomainLabel);

const resolvedSizeMinusOne = relativeSizeToSize('-1', resolvedSize);
const alphaNumericArb = buildLowerAlphaArbitrary([]);
const publicSuffixArb = stringOf(alphaNumericArb, { minLength: 2, maxLength: 63, size: resolvedSizeMinusOne });
const lowerAlphaArb = getOrCreateLowerAlphaArbitrary();
const publicSuffixArb = string({ unit: lowerAlphaArb, minLength: 2, maxLength: 63, size: resolvedSizeMinusOne });
return (adapter(tuple(array(subdomainLabel(resolvedSize), { size: resolvedSizeMinusOne, minLength: 1, maxLength: 127 }), publicSuffixArb), labelsAdapter).map(labelsMapper, labelsUnmapper));
}
import { array } from './array.js';
import { buildLowerAlphaNumericArbitrary } from './_internals/builders/CharacterRangeArbitraryBuilder.js';
import { getOrCreateLowerAlphaNumericArbitrary } from './_internals/builders/CharacterRangeArbitraryBuilder.js';
import { domain } from './domain.js';
import { stringOf } from './stringOf.js';
import { string } from './string.js';
import { tuple } from './tuple.js';

@@ -37,5 +37,5 @@ import { adapter } from './_internals/AdapterArbitrary.js';

export function emailAddress(constraints = {}) {
const others = ['!', '#', '$', '%', '&', "'", '*', '+', '-', '/', '=', '?', '^', '_', '`', '{', '|', '}', '~'];
const atextArb = buildLowerAlphaNumericArbitrary(others);
const localPartArb = adapter(array(stringOf(atextArb, {
const atextArb = getOrCreateLowerAlphaNumericArbitrary("!#$%&'*+-/=?^_`{|}~");
const localPartArb = adapter(array(string({
unit: atextArb,
minLength: 1,

@@ -42,0 +42,0 @@ maxLength: 64,

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

import { buildAlphaNumericPercentArbitrary } from './_internals/builders/CharacterRangeArbitraryBuilder.js';
import { getOrCreateAlphaNumericPercentArbitrary } from './_internals/builders/CharacterRangeArbitraryBuilder.js';
import { constant } from './constant.js';

@@ -10,7 +10,6 @@ import { domain } from './domain.js';

import { option } from './option.js';
import { stringOf } from './stringOf.js';
import { string } from './string.js';
import { tuple } from './tuple.js';
function hostUserInfo(size) {
const others = ['-', '.', '_', '~', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ':'];
return stringOf(buildAlphaNumericPercentArbitrary(others), { size });
return string({ unit: getOrCreateAlphaNumericPercentArbitrary("-._~!$&'()*+,;=:"), size });
}

@@ -17,0 +16,0 @@ function userHostPortMapper([u, h, p]) {

@@ -1,6 +0,5 @@

import { buildAlphaNumericPercentArbitrary } from './_internals/builders/CharacterRangeArbitraryBuilder.js';
import { stringOf } from './stringOf.js';
import { getOrCreateAlphaNumericPercentArbitrary } from './_internals/builders/CharacterRangeArbitraryBuilder.js';
import { string } from './string.js';
export function webSegment(constraints = {}) {
const others = ['-', '.', '_', '~', '!', '$', '&', "'", '(', ')', '*', '+', ',', ';', '=', ':', '@'];
return stringOf(buildAlphaNumericPercentArbitrary(others), { size: constraints.size });
return string({ unit: getOrCreateAlphaNumericPercentArbitrary("-._~!$&'()*+,;=:@"), size: constraints.size });
}

@@ -110,4 +110,4 @@ import { pre } from './check/precondition/Pre.js';

const __type = 'module';
const __version = '3.23.0';
const __commitHash = '7eb6ddd8c54813cf3f0d25c0cc17d58ad3b009e6';
const __version = '3.23.1';
const __commitHash = 'cb330c7baa8700d7fdde4512973ba80f2d2c44c6';
export { __type, __version, __commitHash, sample, statistics, check, assert, pre, PreconditionFailure, property, asyncProperty, boolean, falsy, float, double, integer, nat, maxSafeInteger, maxSafeNat, bigIntN, bigUintN, bigInt, bigUint, char, ascii, char16bits, unicode, fullUnicode, hexa, base64, mixedCase, string, asciiString, string16bits, stringOf, unicodeString, fullUnicodeString, hexaString, base64String, stringMatching, limitShrink, lorem, constant, constantFrom, mapToConstant, option, oneof, clone, noBias, noShrink, shuffledSubarray, subarray, array, sparseArray, infiniteStream, uniqueArray, tuple, record, dictionary, anything, object, json, jsonValue, unicodeJson, unicodeJsonValue, letrec, memo, compareBooleanFunc, compareFunc, func, context, gen, date, ipV4, ipV4Extended, ipV6, domain, webAuthority, webSegment, webFragments, webPath, webQueryParameters, webUrl, emailAddress, ulid, uuid, uuidV, int8Array, uint8Array, uint8ClampedArray, int16Array, uint16Array, int32Array, uint32Array, float32Array, float64Array, bigInt64Array, bigUint64Array, asyncModelRun, modelRun, scheduledModelRun, commands, scheduler, schedulerFor, Arbitrary, Value, cloneMethod, cloneIfNeeded, hasCloneMethod, toStringMethod, hasToStringMethod, asyncToStringMethod, hasAsyncToStringMethod, getDepthContextFor, stringify, asyncStringify, defaultReportMessage, asyncDefaultReportMessage, hash, VerbosityLevel, configureGlobal, readConfigureGlobal, resetConfigureGlobal, ExecutionStatus, Random, Stream, stream, createDepthIdentifier, };

@@ -178,3 +178,3 @@ import { pre } from './check/precondition/Pre.js';

/**
* Version of fast-check used by your project (eg.: 3.23.0)
* Version of fast-check used by your project (eg.: 3.23.1)
* @remarks Since 1.22.0

@@ -185,3 +185,3 @@ * @public

/**
* Commit hash of the current code (eg.: 7eb6ddd8c54813cf3f0d25c0cc17d58ad3b009e6)
* Commit hash of the current code (eg.: cb330c7baa8700d7fdde4512973ba80f2d2c44c6)
* @remarks Since 2.7.0

@@ -188,0 +188,0 @@ * @public

@@ -58,2 +58,4 @@ declare const SArray: typeof Array;

export declare function safeGet<T extends object, U>(instance: WeakMap<T, U>, key: T): U | undefined;
export declare function safeMapSet<T, U>(instance: Map<T, U>, key: T, value: U): Map<T, U>;
export declare function safeMapGet<T, U>(instance: Map<T, U>, key: T): U | undefined;
export declare function safeSplit(instance: string, ...args: [separator: string | RegExp, limit?: number | undefined]): string[];

@@ -60,0 +62,0 @@ export declare function safeStartsWith(instance: string, ...args: [searchString: string, position?: number | undefined]): boolean;

@@ -297,2 +297,32 @@ import { safeApply } from './apply.js';

}
const untouchedMapSet = Map.prototype.set;
const untouchedMapGet = Map.prototype.get;
function extractMapSet(instance) {
try {
return instance.set;
}
catch (err) {
return undefined;
}
}
function extractMapGet(instance) {
try {
return instance.get;
}
catch (err) {
return undefined;
}
}
export function safeMapSet(instance, key, value) {
if (extractMapSet(instance) === untouchedMapSet) {
return instance.set(key, value);
}
return safeApply(untouchedMapSet, instance, [key, value]);
}
export function safeMapGet(instance, key) {
if (extractMapGet(instance) === untouchedMapGet) {
return instance.get(key);
}
return safeApply(untouchedMapGet, instance, [key]);
}
const untouchedSplit = String.prototype.split;

@@ -299,0 +329,0 @@ const untouchedStartsWith = String.prototype.startsWith;

@@ -241,5 +241,5 @@ "use strict";

exports.__type = __type;
const __version = '3.23.0';
const __version = '3.23.1';
exports.__version = __version;
const __commitHash = '7eb6ddd8c54813cf3f0d25c0cc17d58ad3b009e6';
const __commitHash = 'cb330c7baa8700d7fdde4512973ba80f2d2c44c6';
exports.__commitHash = __commitHash;

@@ -178,3 +178,3 @@ import { pre } from './check/precondition/Pre.js';

/**
* Version of fast-check used by your project (eg.: 3.23.0)
* Version of fast-check used by your project (eg.: 3.23.1)
* @remarks Since 1.22.0

@@ -185,3 +185,3 @@ * @public

/**
* Commit hash of the current code (eg.: 7eb6ddd8c54813cf3f0d25c0cc17d58ad3b009e6)
* Commit hash of the current code (eg.: cb330c7baa8700d7fdde4512973ba80f2d2c44c6)
* @remarks Since 2.7.0

@@ -188,0 +188,0 @@ * @public

@@ -58,2 +58,4 @@ declare const SArray: typeof Array;

export declare function safeGet<T extends object, U>(instance: WeakMap<T, U>, key: T): U | undefined;
export declare function safeMapSet<T, U>(instance: Map<T, U>, key: T, value: U): Map<T, U>;
export declare function safeMapGet<T, U>(instance: Map<T, U>, key: T): U | undefined;
export declare function safeSplit(instance: string, ...args: [separator: string | RegExp, limit?: number | undefined]): string[];

@@ -60,0 +62,0 @@ export declare function safeStartsWith(instance: string, ...args: [searchString: string, position?: number | undefined]): boolean;

@@ -21,2 +21,4 @@ "use strict";

exports.safeGet = safeGet;
exports.safeMapSet = safeMapSet;
exports.safeMapGet = safeMapGet;
exports.safeSplit = safeSplit;

@@ -331,2 +333,32 @@ exports.safeStartsWith = safeStartsWith;

}
const untouchedMapSet = Map.prototype.set;
const untouchedMapGet = Map.prototype.get;
function extractMapSet(instance) {
try {
return instance.set;
}
catch (err) {
return undefined;
}
}
function extractMapGet(instance) {
try {
return instance.get;
}
catch (err) {
return undefined;
}
}
function safeMapSet(instance, key, value) {
if (extractMapSet(instance) === untouchedMapSet) {
return instance.set(key, value);
}
return (0, apply_1.safeApply)(untouchedMapSet, instance, [key, value]);
}
function safeMapGet(instance, key) {
if (extractMapGet(instance) === untouchedMapGet) {
return instance.get(key);
}
return (0, apply_1.safeApply)(untouchedMapGet, instance, [key]);
}
const untouchedSplit = String.prototype.split;

@@ -333,0 +365,0 @@ const untouchedStartsWith = String.prototype.startsWith;

{
"name": "fast-check",
"version": "3.23.0",
"version": "3.23.1",
"description": "Property based testing framework for JavaScript (like QuickCheck)",

@@ -72,3 +72,3 @@ "type": "commonjs",

"replace-in-file": "^8.2.0",
"typedoc": "^0.26.10",
"typedoc": "^0.26.11",
"typescript": "~5.6.3",

@@ -75,0 +75,0 @@ "vitest": "^2.1.3"

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