Socket
Socket
Sign inDemoInstall

@arktype/util

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arktype/util - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

__tests__/hkt.test.ts

143

dist/main.d.ts

@@ -1,15 +0,128 @@

export * from "./domain.js";
export * from "./errors.js";
export * from "./functions.js";
export * from "./generics.js";
export * from "./hkt.js";
export * from "./intersections.js";
export * from "./lazily.js";
export * from "./lists.js";
export * from "./numericLiterals.js";
export * from "./objectKinds.js";
export * from "./records.js";
export * from "./serialize.js";
export * from "./trait.js";
export * from "./unionToTuple.js";
//# sourceMappingURL=main.d.ts.map
export { hasDomain_alias_1 as hasDomain } from './_tsup-dts-rollup';
export { inferDomain_alias_1 as inferDomain } from './_tsup-dts-rollup';
export { Domain_alias_1 as Domain } from './_tsup-dts-rollup';
export { NullishDomain_alias_1 as NullishDomain } from './_tsup-dts-rollup';
export { NonNullishDomain_alias_1 as NonNullishDomain } from './_tsup-dts-rollup';
export { PrimitiveDomain_alias_1 as PrimitiveDomain } from './_tsup-dts-rollup';
export { Primitive_alias_1 as Primitive } from './_tsup-dts-rollup';
export { domainOf_alias_1 as domainOf } from './_tsup-dts-rollup';
export { InternalArktypeError_alias_1 as InternalArktypeError } from './_tsup-dts-rollup';
export { throwInternalError_alias_1 as throwInternalError } from './_tsup-dts-rollup';
export { ParseError_alias_1 as ParseError } from './_tsup-dts-rollup';
export { throwParseError_alias_1 as throwParseError } from './_tsup-dts-rollup';
export { ZeroWidthSpace_alias_1 as ZeroWidthSpace } from './_tsup-dts-rollup';
export { ErrorMessage_alias_1 as ErrorMessage } from './_tsup-dts-rollup';
export { Completion_alias_1 as Completion } from './_tsup-dts-rollup';
export { Fn_alias_1 as Fn } from './_tsup-dts-rollup';
export { paramsOf_alias_1 as paramsOf } from './_tsup-dts-rollup';
export { returnOf_alias_1 as returnOf } from './_tsup-dts-rollup';
export { cached_alias_1 as cached } from './_tsup-dts-rollup';
export { isThunk_alias_1 as isThunk } from './_tsup-dts-rollup';
export { Thunk_alias_1 as Thunk } from './_tsup-dts-rollup';
export { thunkable_alias_1 as thunkable } from './_tsup-dts-rollup';
export { CompiledFunction_alias_1 as CompiledFunction } from './_tsup-dts-rollup';
export { Stringifiable_alias_1 as Stringifiable } from './_tsup-dts-rollup';
export { evaluate_alias_1 as evaluate } from './_tsup-dts-rollup';
export { exact_alias_1 as exact } from './_tsup-dts-rollup';
export { exactMessageOnError_alias_1 as exactMessageOnError } from './_tsup-dts-rollup';
export { defer_alias_1 as defer } from './_tsup-dts-rollup';
export { merge_alias_1 as merge } from './_tsup-dts-rollup';
export { mergeAll_alias_1 as mergeAll } from './_tsup-dts-rollup';
export { and_alias_1 as and } from './_tsup-dts-rollup';
export { andPreserveUnknown_alias_1 as andPreserveUnknown } from './_tsup-dts-rollup';
export { isAny_alias_1 as isAny } from './_tsup-dts-rollup';
export { isNever_alias_1 as isNever } from './_tsup-dts-rollup';
export { isUnknown_alias_1 as isUnknown } from './_tsup-dts-rollup';
export { conform_alias_1 as conform } from './_tsup-dts-rollup';
export { equals_alias_1 as equals } from './_tsup-dts-rollup';
export { id_alias_1 as id } from './_tsup-dts-rollup';
export { nominal_alias_1 as nominal } from './_tsup-dts-rollup';
export { satisfy_alias_1 as satisfy } from './_tsup-dts-rollup';
export { extend_alias_1 as extend } from './_tsup-dts-rollup';
export { defined_alias_1 as defined } from './_tsup-dts-rollup';
export { autocomplete_alias_1 as autocomplete } from './_tsup-dts-rollup';
export { widen_alias_1 as widen } from './_tsup-dts-rollup';
export { Hkt_alias_1 as Hkt } from './_tsup-dts-rollup';
export { AndPreserveUnknown_alias_1 as AndPreserveUnknown } from './_tsup-dts-rollup';
export { intersectArrays_alias_1 as intersectArrays } from './_tsup-dts-rollup';
export { intersectParameters_alias_1 as intersectParameters } from './_tsup-dts-rollup';
export { isDisjoint_alias_1 as isDisjoint } from './_tsup-dts-rollup';
export { lazily_alias_1 as lazily } from './_tsup-dts-rollup';
export { pathToString_alias_1 as pathToString } from './_tsup-dts-rollup';
export { join_alias_1 as join } from './_tsup-dts-rollup';
export { split_alias_1 as split } from './_tsup-dts-rollup';
export { getPath_alias_1 as getPath } from './_tsup-dts-rollup';
export { intersectUniqueLists_alias_1 as intersectUniqueLists } from './_tsup-dts-rollup';
export { List_alias_1 as List } from './_tsup-dts-rollup';
export { listable_alias_1 as listable } from './_tsup-dts-rollup';
export { NonEmptyList_alias_1 as NonEmptyList } from './_tsup-dts-rollup';
export { CollapsingList_alias_1 as CollapsingList } from './_tsup-dts-rollup';
export { arraySubclassToReadonly_alias_1 as arraySubclassToReadonly } from './_tsup-dts-rollup';
export { listFrom_alias_1 as listFrom } from './_tsup-dts-rollup';
export { spliterate_alias_1 as spliterate } from './_tsup-dts-rollup';
export { ReadonlyArray_alias_1 as ReadonlyArray } from './_tsup-dts-rollup';
export { includes_alias_1 as includes } from './_tsup-dts-rollup';
export { range_alias_1 as range } from './_tsup-dts-rollup';
export { Digit } from './_tsup-dts-rollup';
export { BigintLiteral } from './_tsup-dts-rollup';
export { NumberLiteral } from './_tsup-dts-rollup';
export { IntegerLiteral } from './_tsup-dts-rollup';
export { wellFormedNumberMatcher } from './_tsup-dts-rollup';
export { isWellFormedNumber } from './_tsup-dts-rollup';
export { wellFormedIntegerMatcher } from './_tsup-dts-rollup';
export { isWellFormedInteger } from './_tsup-dts-rollup';
export { writeMalformedNumericLiteralMessage } from './_tsup-dts-rollup';
export { tryParseNumber } from './_tsup-dts-rollup';
export { tryParseInteger } from './_tsup-dts-rollup';
export { NumericParseOptions } from './_tsup-dts-rollup';
export { tryParseWellFormedBigint } from './_tsup-dts-rollup';
export { builtinObjectKinds } from './_tsup-dts-rollup';
export { ObjectKindSet } from './_tsup-dts-rollup';
export { BuiltinObjectConstructors } from './_tsup-dts-rollup';
export { BuiltinObjectKind } from './_tsup-dts-rollup';
export { BuiltinObjects } from './_tsup-dts-rollup';
export { objectKindOf } from './_tsup-dts-rollup';
export { objectKindOrDomainOf } from './_tsup-dts-rollup';
export { hasObjectKind } from './_tsup-dts-rollup';
export { isArray } from './_tsup-dts-rollup';
export { objectKindDescriptions } from './_tsup-dts-rollup';
export { getExactBuiltinConstructorName } from './_tsup-dts-rollup';
export { Constructor } from './_tsup-dts-rollup';
export { instanceOf } from './_tsup-dts-rollup';
export { prototypeKeysOf } from './_tsup-dts-rollup';
export { getBaseDomainKeys } from './_tsup-dts-rollup';
export { constructorExtends } from './_tsup-dts-rollup';
export { Dict } from './_tsup-dts-rollup';
export { propwiseXor } from './_tsup-dts-rollup';
export { requireKeys } from './_tsup-dts-rollup';
export { PartialRecord } from './_tsup-dts-rollup';
export { keySet } from './_tsup-dts-rollup';
export { mutable } from './_tsup-dts-rollup';
export { entryOf } from './_tsup-dts-rollup';
export { entriesOf } from './_tsup-dts-rollup';
export { fromEntries } from './_tsup-dts-rollup';
export { transform } from './_tsup-dts-rollup';
export { keysOf } from './_tsup-dts-rollup';
export { isKeyOf } from './_tsup-dts-rollup';
export { requiredKeyOf } from './_tsup-dts-rollup';
export { optionalKeyOf } from './_tsup-dts-rollup';
export { optionalizeKeys } from './_tsup-dts-rollup';
export { replaceKey } from './_tsup-dts-rollup';
export { valueOf } from './_tsup-dts-rollup';
export { DynamicBase } from './_tsup-dts-rollup';
export { CastableBase } from './_tsup-dts-rollup';
export { shallowClone } from './_tsup-dts-rollup';
export { SerializationOptions } from './_tsup-dts-rollup';
export { Json } from './_tsup-dts-rollup';
export { JsonData } from './_tsup-dts-rollup';
export { snapshot } from './_tsup-dts-rollup';
export { print } from './_tsup-dts-rollup';
export { printable } from './_tsup-dts-rollup';
export { SerializedPrimitives } from './_tsup-dts-rollup';
export { SerializedPrimitive } from './_tsup-dts-rollup';
export { SerializablePrimitive } from './_tsup-dts-rollup';
export { serializePrimitive } from './_tsup-dts-rollup';
export { stringifyUnion } from './_tsup-dts-rollup';
export { unionToTuple } from './_tsup-dts-rollup';
export { intersectUnion } from './_tsup-dts-rollup';
export { overloadOf } from './_tsup-dts-rollup';

@@ -1,15 +0,406 @@

export * from "./domain.js";
export * from "./errors.js";
export * from "./functions.js";
export * from "./generics.js";
export * from "./hkt.js";
export * from "./intersections.js";
export * from "./lazily.js";
export * from "./lists.js";
export * from "./numericLiterals.js";
export * from "./objectKinds.js";
export * from "./records.js";
export * from "./serialize.js";
export * from "./trait.js";
export * from "./unionToTuple.js";
//# sourceMappingURL=main.js.map
// domain.ts
var hasDomain = (data, kind) => domainOf(data) === kind;
var domainOf = (data) => {
const builtinType = typeof data;
return builtinType === "object" ? data === null ? "null" : "object" : builtinType === "function" ? "object" : builtinType;
};
// errors.ts
var InternalArktypeError = class extends Error {
};
var throwInternalError = (message) => {
throw new InternalArktypeError(message);
};
var ParseError = class extends Error {
};
var throwParseError = (message) => {
throw new ParseError(message);
};
// functions.ts
var cached = (thunk) => {
let isCached = false;
let result;
return () => {
if (!isCached) {
result = thunk();
isCached = true;
}
return result;
};
};
var isThunk = (value) => typeof value === "function" && value.length === 0;
var CompiledFunction = class extends Function {
constructor(...args) {
const params = args.slice(0, -1);
const body = args.at(-1);
try {
super(...params, body);
} catch (e) {
return throwInternalError(
`Encountered an unexpected error while compiling your definition:
Message: ${e}
Source: (${args.slice(0, -1)}) => {
${args.at(-1)}
}`
);
}
}
};
// generics.ts
var id = Symbol("id");
// hkt.ts
var Hkt;
((Hkt2) => {
class Kind {
}
Hkt2.Kind = Kind;
Hkt2.reify = (def) => def.f;
})(Hkt || (Hkt = {}));
// lazily.ts
var lazily = (thunk) => {
let cached2;
return new Proxy({}, {
get: (_, prop) => {
if (!cached2) {
cached2 = thunk();
}
return cached2[prop];
},
set: (_, prop, value) => {
if (!cached2) {
cached2 = thunk();
}
cached2[prop] = value;
return true;
}
});
};
// lists.ts
var getPath = (root, path) => {
let result = root;
for (const segment of path) {
if (typeof result !== "object" || result === null) {
return void 0;
}
result = result[segment];
}
return result;
};
var intersectUniqueLists = (l, r) => {
const intersection = [...l];
for (const item of r) {
if (!l.includes(item)) {
intersection.push(item);
}
}
return intersection;
};
var listFrom = (data) => Array.isArray(data) ? data : [data];
var spliterate = (list, by) => {
const result = [
[],
[]
];
for (const item of list) {
if (by(item)) {
result[0].push(item);
} else {
result[1].push(item);
}
}
return result;
};
var ReadonlyArray = Array;
var includes = (array, element) => array.includes(element);
var range = (length) => [...new Array(length)].map((_, i) => i);
// numericLiterals.ts
var wellFormedNumberMatcher = /^(?!^-0$)-?(?:0|[1-9]\d*)(?:\.\d*[1-9])?$/;
var isWellFormedNumber = (s) => wellFormedNumberMatcher.test(s);
var numberLikeMatcher = /^-?\d*\.?\d*$/;
var isNumberLike = (s) => s.length !== 0 && numberLikeMatcher.test(s);
var wellFormedIntegerMatcher = /^(?:0|(?:-?[1-9]\d*))$/;
var isWellFormedInteger = (s) => wellFormedIntegerMatcher.test(s);
var integerLikeMatcher = /^-?\d+$/;
var isIntegerLike = (s) => integerLikeMatcher.test(s);
var numericLiteralDescriptions = {
number: "a number",
bigint: "a bigint",
integer: "an integer"
};
var writeMalformedNumericLiteralMessage = (def, kind) => `'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`;
var isWellFormed = (def, kind) => kind === "number" ? isWellFormedNumber(def) : isWellFormedInteger(def);
var parseKind = (def, kind) => kind === "number" ? Number(def) : Number.parseInt(def);
var isKindLike = (def, kind) => kind === "number" ? isNumberLike(def) : isIntegerLike(def);
var tryParseNumber = (token, options) => parseNumeric(token, "number", options);
var tryParseInteger = (token, options) => parseNumeric(token, "integer", options);
var parseNumeric = (token, kind, options) => {
const value = parseKind(token, kind);
if (!Number.isNaN(value)) {
if (isKindLike(token, kind)) {
if (options?.strict) {
return isWellFormed(token, kind) ? value : throwParseError(writeMalformedNumericLiteralMessage(token, kind));
}
return value;
}
}
return options?.errorOnFail ? throwParseError(
options?.errorOnFail === true ? `Failed to parse ${numericLiteralDescriptions[kind]} from '${token}'` : options?.errorOnFail
) : void 0;
};
var tryParseWellFormedBigint = (def) => {
if (def[def.length - 1] !== "n") {
return;
}
const maybeIntegerLiteral = def.slice(0, -1);
let value;
try {
value = BigInt(maybeIntegerLiteral);
} catch {
return;
}
if (wellFormedIntegerMatcher.test(maybeIntegerLiteral)) {
return value;
}
if (integerLikeMatcher.test(maybeIntegerLiteral)) {
return throwParseError(writeMalformedNumericLiteralMessage(def, "bigint"));
}
};
// records.ts
var entriesOf = (o) => Object.entries(o);
var fromEntries = (entries) => Object.fromEntries(entries);
var transform = (o, flatMapEntry) => Object.fromEntries(
entriesOf(o).flatMap((entry) => {
const result = flatMapEntry(...entry);
return isArray(result[0]) || result.length === 0 ? (
// if we have an empty array (for filtering) or an array with
// another array as its first element, treat it as a list of
result
) : (
// otherwise, it should be a single entry, so nest it in a tuple
// so it doesn't get spread when the result is flattened
[result]
);
})
);
var keysOf = (o) => Object.keys(o);
var isKeyOf = (k, obj) => k in obj;
var ShallowClone = class {
constructor(properties) {
Object.assign(this, properties);
}
};
var DynamicBase = class extends ShallowClone {
};
var NoopBase = class {
};
var CastableBase = class extends NoopBase {
};
var shallowClone = (input) => Object.create(
Object.getPrototypeOf(input),
Object.getOwnPropertyDescriptors(input)
);
// objectKinds.ts
var builtinObjectKinds = {
Array,
Date,
Error,
Function,
Map,
RegExp,
Set,
String,
Number,
Boolean,
WeakMap,
WeakSet,
Promise
};
var objectKindOf = (data, kinds) => {
const kindSet = kinds ?? builtinObjectKinds;
let prototype = Object.getPrototypeOf(data);
while (prototype?.constructor && (!kindSet[prototype.constructor.name] || !(data instanceof kindSet[prototype.constructor.name]))) {
prototype = Object.getPrototypeOf(prototype);
}
const name = prototype?.constructor?.name;
if (name === void 0 || name === "Object") {
return void 0;
}
return name;
};
var objectKindOrDomainOf = (data, kinds) => typeof data === "object" && data !== null ? objectKindOf(data, kinds) ?? "object" : domainOf(data);
var hasObjectKind = (data, kind, kinds) => objectKindOf(data, kinds) === kind;
var isArray = (data) => Array.isArray(data);
var objectKindDescriptions = {
Array: "an array",
Function: "a function",
Date: "a Date",
RegExp: "a RegExp",
Error: "an Error",
Map: "a Map",
Set: "a Set",
String: "a String object",
Number: "a Number object",
Boolean: "a Boolean object",
Promise: "a Promise",
WeakMap: "a WeakMap",
WeakSet: "a WeakSet"
};
var getExactBuiltinConstructorName = (constructor) => {
const constructorName = Object(constructor).name;
return constructorName && isKeyOf(constructorName, builtinObjectKinds) && builtinObjectKinds[constructorName] === constructor ? constructorName : void 0;
};
var prototypeKeysOf = (value) => {
const result = [];
while (value !== Object.prototype && value !== null && value !== void 0) {
for (const k of Object.getOwnPropertyNames(value)) {
if (k !== "constructor" && !result.includes(k)) {
result.push(k);
}
}
for (const symbol of Object.getOwnPropertySymbols(value)) {
if (!result.includes(symbol)) {
result.push(symbol);
}
}
value = Object.getPrototypeOf(value);
}
return result;
};
var baseKeysByDomain = {
bigint: prototypeKeysOf(0n),
boolean: prototypeKeysOf(false),
null: [],
number: prototypeKeysOf(0),
// TS doesn't include the Object prototype in keyof, so keyof object is never
object: [],
string: prototypeKeysOf(""),
symbol: prototypeKeysOf(Symbol()),
undefined: []
};
var getBaseDomainKeys = (domain) => [
...baseKeysByDomain[domain]
];
var constructorExtends = (constructor, base) => {
let current = constructor.prototype;
while (current !== null) {
if (current === base.prototype) {
return true;
}
current = Object.getPrototypeOf(current);
}
return false;
};
// serialize.ts
var snapshot = (data, opts = { onUndefined: "(undefined)" }) => serializeRecurse(data, opts, []);
var print = (data, indent) => console.log(printable(data, indent));
var printable = (data, indent) => {
switch (domainOf(data)) {
case "object":
return data instanceof Date ? data.toDateString() : JSON.stringify(
serializeRecurse(data, printableOpts, []),
null,
indent
);
case "symbol":
return printableOpts.onSymbol(data);
default:
return serializePrimitive(data);
}
};
var printableOpts = {
onCycle: () => "(cycle)",
onSymbol: (v) => `(symbol ${v.description ?? "anonymous"})`,
onFunction: (v) => `(function ${v.name ?? "anonymous"})`
};
var serializeRecurse = (data, opts, seen) => {
switch (domainOf(data)) {
case "object":
if (typeof data === "function") {
return printableOpts.onFunction(data);
}
if (seen.includes(data)) {
return "(cycle)";
}
const nextSeen = [...seen, data];
if (Array.isArray(data)) {
return data.map((item) => serializeRecurse(item, opts, nextSeen));
}
if (data instanceof Date) {
return data.toDateString();
}
const result = {};
for (const k in data) {
result[k] = serializeRecurse(data[k], opts, nextSeen);
}
return result;
case "symbol":
return printableOpts.onSymbol(data);
case "bigint":
return `${data}n`;
case "undefined":
return opts.onUndefined ?? "undefined";
default:
return data;
}
};
var serializePrimitive = (value) => typeof value === "string" ? JSON.stringify(value) : typeof value === "bigint" ? `${value}n` : `${value}`;
export {
CastableBase,
CompiledFunction,
DynamicBase,
Hkt,
InternalArktypeError,
ParseError,
ReadonlyArray,
builtinObjectKinds,
cached,
constructorExtends,
domainOf,
entriesOf,
fromEntries,
getBaseDomainKeys,
getExactBuiltinConstructorName,
getPath,
hasDomain,
hasObjectKind,
id,
includes,
intersectUniqueLists,
isArray,
isKeyOf,
isThunk,
isWellFormedInteger,
isWellFormedNumber,
keysOf,
lazily,
listFrom,
objectKindDescriptions,
objectKindOf,
objectKindOrDomainOf,
print,
printable,
prototypeKeysOf,
range,
serializePrimitive,
shallowClone,
snapshot,
spliterate,
throwInternalError,
throwParseError,
transform,
tryParseInteger,
tryParseNumber,
tryParseWellFormedBigint,
wellFormedIntegerMatcher,
wellFormedNumberMatcher,
writeMalformedNumericLiteralMessage
};

@@ -105,1 +105,4 @@ export type pathToString<

): element is array[number] => array.includes(element)
export const range = (length: number): number[] =>
[...new Array(length)].map((_, i) => i)

1

main.ts

@@ -13,3 +13,2 @@ export * from "./domain.js"

export * from "./serialize.js"
export * from "./trait.js"
export * from "./unionToTuple.js"
{
"name": "@arktype/util",
"version": "0.0.5",
"version": "0.0.6",
"author": {

@@ -10,12 +10,15 @@ "name": "David Blass",

"type": "module",
"main": "./dist/main.cjs",
"types": "./dist/main.d.cts",
"exports": {
".": {
"arktype-repo": "./main.js",
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
},
"./internal/*": {
"arktype-repo": "./*",
"types": "./dist/*",
"default": "./dist/*"
"import": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
},
"default": {
"types": "./dist/main.d.cts",
"default": "./dist/main.cjs"
}
}

@@ -25,10 +28,9 @@ },

"dist",
"**/*.ts",
"!**/*.tsBuildInfo",
"!__tests__"
"!__tests__",
"**/*.ts"
],
"scripts": {
"build": "tsc --build ./tsconfig.build.json",
"build": "tsup --config ../repo/tsup.config.ts",
"test": "ts ../repo/testPackage.ts"
}
}

@@ -23,3 +23,3 @@ import type { Fn } from "./functions.js"

export type PartialRecord<k extends string = string, v = unknown> = {
export type PartialRecord<k extends PropertyKey = PropertyKey, v = unknown> = {
[_ in k]?: v

@@ -82,8 +82,14 @@ }

o: o,
flatMapEntry: (entry: entryOf<o>) => transformed
flatMapEntry: (...entry: entryOf<o>) => transformed
) =>
Object.fromEntries(
entriesOf(o).flatMap((entry) => {
const result = flatMapEntry(entry)
return isArray(result[0]) ? (result as never) : [result]
const result = flatMapEntry(...entry)
return isArray(result[0]) || result.length === 0
? // if we have an empty array (for filtering) or an array with
// another array as its first element, treat it as a list of
(result as never)
: // otherwise, it should be a single entry, so nest it in a tuple
// so it doesn't get spread when the result is flattened
[result]
})

@@ -121,4 +127,4 @@ ) as evaluate<

export type optionalizeKeys<o, keys extends keyof o> = evaluate<
{ [k in Exclude<keyof o, keys>]: o[k] } & {
[k in keys]?: o[k]
{ [k in Exclude<requiredKeyOf<o>, keys>]: o[k] } & {
[k in optionalKeyOf<o> | keys]?: o[k]
}

@@ -125,0 +131,0 @@ >

@@ -51,5 +51,5 @@ import { domainOf, type inferDomain, type Primitive } from "./domain.js"

export const print = (data: unknown, indent?: number) =>
console.log(stringify(data, indent))
console.log(printable(data, indent))
export const stringify = (data: unknown, indent?: number) => {
export const printable = (data: unknown, indent?: number) => {
switch (domainOf(data)) {

@@ -60,3 +60,3 @@ case "object":

: JSON.stringify(
serializeRecurse(data, stringifyOpts, []),
serializeRecurse(data, printableOpts, []),
null,

@@ -66,3 +66,3 @@ indent

case "symbol":
return stringifyOpts.onSymbol(data as symbol)
return printableOpts.onSymbol(data as symbol)
default:

@@ -73,3 +73,3 @@ return serializePrimitive(data as SerializablePrimitive)

const stringifyOpts = {
const printableOpts = {
onCycle: () => "(cycle)",

@@ -88,3 +88,3 @@ onSymbol: (v) => `(symbol ${v.description ?? "anonymous"})`,

if (typeof data === "function") {
return stringifyOpts.onFunction(data)
return printableOpts.onFunction(data)
}

@@ -107,3 +107,3 @@ if (seen.includes(data)) {

case "symbol":
return stringifyOpts.onSymbol(data as symbol)
return printableOpts.onSymbol(data as symbol)
case "bigint":

@@ -110,0 +110,0 @@ return `${data}n`

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