@autoplay/utils
Advanced tools
Comparing version 0.0.22 to 0.0.23
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
// Invariant errors with stack trace fixing | ||
tslib_1.__exportStar(require("./internal/invariant.js"), exports); | ||
tslib_1.__exportStar(require("./internal/DevError.js"), exports); | ||
tslib_1.__exportStar(require("./internal/devStringify.js"), exports); | ||
tslib_1.__exportStar(require("./internal/DevString.js"), exports); | ||
tslib_1.__exportStar(require("./internal/match.js"), exports); | ||
tslib_1.__exportStar(require("./internal/parseJSON.js"), exports); | ||
tslib_1.__exportStar(require("./internal/createErrorObj.js"), exports); | ||
tslib_1.__exportStar(require("./internal/staticCheck.js"), exports); | ||
tslib_1.__exportStar(require("./internal/tightJsonStringify.js"), exports); | ||
tslib_1.__exportStar(require("./internal/tightObjectDebug.js"), exports); | ||
tslib_1.__exportStar(require("./internal/UsrString.js"), exports); | ||
__exportStar(require("./internal/invariant.js"), exports); | ||
__exportStar(require("./internal/DevError.js"), exports); | ||
__exportStar(require("./internal/devStringify.js"), exports); | ||
__exportStar(require("./internal/DevString.js"), exports); | ||
__exportStar(require("./internal/match.js"), exports); | ||
__exportStar(require("./internal/parseJSON.js"), exports); | ||
__exportStar(require("./internal/createErrorObj.js"), exports); | ||
__exportStar(require("./internal/staticCheck.js"), exports); | ||
__exportStar(require("./internal/tightJsonStringify.js"), exports); | ||
__exportStar(require("./internal/tightObjectDebug.js"), exports); | ||
__exportStar(require("./internal/UsrString.js"), exports); | ||
// functional pipe used for many sdk builders | ||
tslib_1.__exportStar(require("./internal/pipe.js"), exports); | ||
__exportStar(require("./internal/pipe.js"), exports); | ||
// zod for runtime parsing for type validators (accepted and output cannot be different types) | ||
// This also includes ZodChoice type | ||
tslib_1.__exportStar(require("./internal/z/index.js"), exports); | ||
__exportStar(require("./internal/z/index.js"), exports); |
@@ -31,15 +31,19 @@ "use strict"; | ||
else { | ||
const json = (0, tightJsonStringify_js_1.tightJsonStringify)(input, (key, value) => { | ||
if (value.toJSON === undefined) { | ||
if (value instanceof Error) { | ||
return { | ||
// // @ts-ignore | ||
// cause: value.cause ?? null, | ||
error: value.toString(), | ||
stack: value.stack ?? null, | ||
}; | ||
const replacer = (_key, value) => { | ||
try { | ||
if (value && value.toJSON === undefined) { | ||
if (value instanceof Error) { | ||
return { | ||
error: value.toString(), | ||
stack: value.stack ?? null, | ||
// @ts-ignore | ||
cause: value.cause ? replacer("cause", value.cause) : undefined, | ||
}; | ||
} | ||
} | ||
} | ||
catch { } | ||
return value; | ||
}); | ||
}; | ||
const json = (0, tightJsonStringify_js_1.tightJsonStringify)(input, replacer); | ||
return display ? cleanNewlinesAndStacks(json.replace(/(\\?")([^"]+)\1:/g, "$2:")) : json; | ||
@@ -46,0 +50,0 @@ } |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.z = void 0; | ||
const tslib_1 = require("tslib"); | ||
exports.z = require("./z.js"); | ||
// Extra invariant assertion | ||
tslib_1.__exportStar(require("./invariantChoiceIs.js"), exports); | ||
__exportStar(require("./invariantChoiceIs.js"), exports); | ||
// Error stringification including Zod types | ||
tslib_1.__exportStar(require("./errorToString.js"), exports); | ||
__exportStar(require("./errorToString.js"), exports); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.or = exports.unchecked = exports.obj = exports.option = exports.ZodChoiceContainer = exports.choice = void 0; | ||
const tslib_1 = require("tslib"); | ||
const staticCheck_js_1 = require("../staticCheck.js"); | ||
const z = require("zod"); | ||
tslib_1.__exportStar(require("zod"), exports); | ||
__exportStar(require("zod"), exports); | ||
// Custom Zod types | ||
@@ -9,0 +22,0 @@ var zchoice_js_1 = require("./zchoice.js"); |
@@ -28,15 +28,19 @@ import { DevString } from "./DevString.js"; | ||
else { | ||
const json = tightJsonStringify(input, (key, value) => { | ||
if (value.toJSON === undefined) { | ||
if (value instanceof Error) { | ||
return { | ||
// // @ts-ignore | ||
// cause: value.cause ?? null, | ||
error: value.toString(), | ||
stack: value.stack ?? null, | ||
}; | ||
const replacer = (_key, value) => { | ||
try { | ||
if (value && value.toJSON === undefined) { | ||
if (value instanceof Error) { | ||
return { | ||
error: value.toString(), | ||
stack: value.stack ?? null, | ||
// @ts-ignore | ||
cause: value.cause ? replacer("cause", value.cause) : undefined, | ||
}; | ||
} | ||
} | ||
} | ||
catch { } | ||
return value; | ||
}); | ||
}; | ||
const json = tightJsonStringify(input, replacer); | ||
return display ? cleanNewlinesAndStacks(json.replace(/(\\?")([^"]+)\1:/g, "$2:")) : json; | ||
@@ -43,0 +47,0 @@ } |
{ | ||
"name": "@autoplay/utils", | ||
"version": "0.0.22", | ||
"version": "0.0.23", | ||
"description": "Utilities designed for error management, parsing, and TypeScript domain modeling.", | ||
"keywords": [], | ||
"type": "module", | ||
"main": "cjs/index.js", | ||
@@ -7,0 +8,0 @@ "module": "esm/index.js", |
@@ -67,3 +67,11 @@ import { dev } from "./DevString.js"; | ||
`); | ||
// expect(devStringify(dev1)).toMatchInlineSnapshot(); | ||
expect( | ||
devStringify({ | ||
tr: true, | ||
fa: false, | ||
obj: JSON, | ||
undef: undefined, | ||
null: null, | ||
}), | ||
).toMatchInlineSnapshot(`"[object Object]"`); | ||
}); | ||
@@ -70,0 +78,0 @@ }); |
@@ -25,16 +25,19 @@ import { DevString } from "./DevString.js"; | ||
} else { | ||
const json = tightJsonStringify(input, (key, value) => { | ||
if (value.toJSON === undefined) { | ||
if (value instanceof Error) { | ||
return { | ||
// // @ts-ignore | ||
// cause: value.cause ?? null, | ||
error: value.toString(), | ||
stack: value.stack ?? null, | ||
}; | ||
const replacer = (_key: string, value: any): any => { | ||
try { | ||
if (value && value.toJSON === undefined) { | ||
if (value instanceof Error) { | ||
return { | ||
error: value.toString(), | ||
stack: value.stack ?? null, | ||
// @ts-ignore | ||
cause: value.cause ? replacer("cause", value.cause) : undefined, | ||
}; | ||
} | ||
} | ||
} | ||
} catch {} | ||
return value; | ||
}); | ||
}; | ||
const json = tightJsonStringify(input, replacer); | ||
return display ? cleanNewlinesAndStacks(json.replace(/(\\?")([^"]+)\1:/g, "$2:")) : json; | ||
@@ -41,0 +44,0 @@ } |
@@ -24,3 +24,9 @@ import { tightJsonStringify } from "./tightJsonStringify.js"; | ||
`); | ||
expect( | ||
tightJsonStringify({ | ||
null: null, | ||
undef: undefined, | ||
}), | ||
).toMatchInlineSnapshot(`"{ "null": null }"`); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
184261
3558
0
Yes