@autoplay/utils
Advanced tools
Comparing version 0.0.18 to 0.0.19
@@ -41,3 +41,3 @@ import { DevString } from "./DevString"; | ||
}); | ||
return display ? cleanNewlinesAndStacks(json.replace(/\\?"([^"]+)\\?":/g, "$1:")) : json; | ||
return display ? cleanNewlinesAndStacks(json.replace(/(\\?")([^"]+)\1:/g, "$2:")) : json; | ||
} | ||
@@ -55,5 +55,12 @@ } | ||
// replace escaped newlines in strings | ||
.replace(/(.+?)"(.*\\n(.(?!\\"))+|\\")*"/gm, (_fullMatch, beforeQuote, inside) => { | ||
return beforeQuote + (inside ? `"${inside.split(/\\n/g).join("\n" + " ".repeat(beforeQuote.length))}"` : '""'); | ||
// .replace(/^(.+?)"(.*\\n(.(?!\\"))+|\\")*"$/gm, (_fullMatch, beforeQuote, inside) => { | ||
.replace(/([^"]+?)"((?:\\.|[^\"])*)"/g, (_fullMatch, beforeQuote, inside) => { | ||
return (beforeQuote + | ||
(inside | ||
? `"${inside | ||
.split(/\\n/g) | ||
// .map((line) => line.replace(/\\"/g, '"')) | ||
.join("\n" + " ".repeat(beforeQuote.length))}"` | ||
: '""')); | ||
})); | ||
} |
{ | ||
"name": "@autoplay/utils", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "Utilities designed for error management, parsing, and TypeScript domain modeling.", | ||
@@ -28,3 +28,3 @@ "keywords": [], | ||
"tslib": "^2.4", | ||
"zod": "^3.17.3" | ||
"zod": "^3" | ||
}, | ||
@@ -31,0 +31,0 @@ "devDependencies": { |
import { dev } from "./DevString"; | ||
import { devStringify } from "./devStringify"; | ||
import { tightJsonStringify } from "./tightJsonStringify"; | ||
import { describe, expect, it, jest } from "@jest/globals"; | ||
@@ -22,8 +23,7 @@ | ||
expectStringWithPaths(devStringify(reason)).toMatchInlineSnapshot(` | ||
"[ "Error resulting from ", | ||
{ error: "TypeError: Unknown type\\" | ||
\\"", | ||
stack: "TypeError: Unknown type\\" | ||
"Error resulting from { error: "TypeError: Unknown type\\" | ||
\\"", | ||
stack: "TypeError: Unknown type\\" | ||
\\" | ||
at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:17:45) | ||
at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:18:47) | ||
at Promise.then.completed (node_modules/jest-circus/build/utils.js:333:28) | ||
@@ -37,27 +37,33 @@ at new Promise (<anonymous>) | ||
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:91:9) | ||
at run (node_modules/jest-circus/build/run.js:31:3)" }, | ||
". This might have been caused by ", | ||
"https://example.com/" ]" | ||
at run (node_modules/jest-circus/build/run.js:31:3)" }. This might have been caused by "https://example.com/"" | ||
`); | ||
expectStringWithPaths(devStringify(reason.causedA`failed to log in`)).toMatchInlineSnapshot(` | ||
const input = dev`the user saw an error`.because(reason); | ||
expectStringWithPaths( | ||
tightJsonStringify(input, (key, err) => (err instanceof Error ? { error: err.message, stack: err.stack } : err)), | ||
).toMatchInlineSnapshot(` | ||
"[ "the user saw an error", | ||
{ cause: [ | ||
{ "cause": [ | ||
"Error resulting from ", | ||
{ error: "TypeError: Unknown type\\" | ||
\\"", | ||
stack: "TypeError: Unknown type\\" | ||
\\" | ||
at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:17:45) | ||
at Promise.then.completed (node_modules/jest-circus/build/utils.js:333:28) | ||
at new Promise (<anonymous>) | ||
at callAsyncCircusFn (node_modules/jest-circus/build/utils.js:259:10) | ||
at _callCircusTest (node_modules/jest-circus/build/run.js:277:40) | ||
at processTicksAndRejections (node:internal/process/task_queues:95:5) | ||
at _runTest (node_modules/jest-circus/build/run.js:209:3) | ||
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:97:9) | ||
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:91:9) | ||
at run (node_modules/jest-circus/build/run.js:31:3)" }, | ||
{ "error": "Unknown type\\"\\n\\"", | ||
"stack": "TypeError: Unknown type\\"\\n\\"\\n at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:18:47)\\n at Promise.then.completed (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/utils.js:333:28)\\n at new Promise (<anonymous>)\\n at callAsyncCircusFn (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/utils.js:259:10)\\n at _callCircusTest (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:277:40)\\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\\n at _runTest (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:209:3)\\n at _runTestsForDescribeBlock (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:97:9)\\n at _runTestsForDescribeBlock (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:91:9)\\n at run (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:31:3)" }, | ||
". This might have been caused by ", | ||
"https://example.com/" ] } ]" | ||
`); | ||
expectStringWithPaths(input.toDisplay()).toMatchInlineSnapshot(` | ||
"the user saw an error | ||
because: Error resulting from { error: "TypeError: Unknown type\\" | ||
\\"", | ||
stack: "TypeError: Unknown type\\" | ||
\\" | ||
at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:18:47) | ||
at Promise.then.completed (node_modules/jest-circus/build/utils.js:333:28) | ||
at new Promise (<anonymous>) | ||
at callAsyncCircusFn (node_modules/jest-circus/build/utils.js:259:10) | ||
at _callCircusTest (node_modules/jest-circus/build/run.js:277:40) | ||
at processTicksAndRejections (node:internal/process/task_queues:95:5) | ||
at _runTest (node_modules/jest-circus/build/run.js:209:3) | ||
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:97:9) | ||
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:91:9) | ||
at run (node_modules/jest-circus/build/run.js:31:3)" }. This might have been caused by "https://example.com/"" | ||
`); | ||
// expect(devStringify(dev1)).toMatchInlineSnapshot(); | ||
@@ -64,0 +70,0 @@ }); |
@@ -39,3 +39,3 @@ import { DevString } from "./DevString"; | ||
}); | ||
return display ? cleanNewlinesAndStacks(json.replace(/\\?"([^"]+)\\?":/g, "$1:")) : json; | ||
return display ? cleanNewlinesAndStacks(json.replace(/(\\?")([^"]+)\1:/g, "$2:")) : json; | ||
} | ||
@@ -54,6 +54,15 @@ } catch (err) { | ||
// replace escaped newlines in strings | ||
.replace(/(.+?)"(.*\\n(.(?!\\"))+|\\")*"/gm, (_fullMatch, beforeQuote, inside) => { | ||
return beforeQuote + (inside ? `"${inside.split(/\\n/g).join("\n" + " ".repeat(beforeQuote.length))}"` : '""'); | ||
// .replace(/^(.+?)"(.*\\n(.(?!\\"))+|\\")*"$/gm, (_fullMatch, beforeQuote, inside) => { | ||
.replace(/([^"]+?)"((?:\\.|[^\"])*)"/g, (_fullMatch, beforeQuote, inside: string | undefined) => { | ||
return ( | ||
beforeQuote + | ||
(inside | ||
? `"${inside | ||
.split(/\\n/g) | ||
// .map((line) => line.replace(/\\"/g, '"')) | ||
.join("\n" + " ".repeat(beforeQuote.length))}"` | ||
: '""') | ||
); | ||
}) | ||
); | ||
} |
@@ -72,3 +72,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (p === OTH) return found === empty ? (cb: (val: unknown) => unknown) => cb(value) : () => found; | ||
if (found === empty && value && p in value) { | ||
if (found === empty && value && p in (value as object)) { | ||
const inner = (value as $IntentionalAny)[p]; | ||
@@ -75,0 +75,0 @@ return (cb: (inner: unknown) => unknown) => { |
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
109728
2330
1