Navigation Menu

Skip to content

Commit

Permalink
fix: replace fast-safe-stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Dec 16, 2022
1 parent fe9d1b5 commit 1cd87c2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -7,7 +7,6 @@
"dependencies": {
"concat-stream": "^2.0.0",
"es6-error": "^4.1.1",
"fast-safe-stringify": "^2.1.1",
"get-stack-trace": "^2.1.1",
"hyperid": "^2.3.1",
"is-plain-object": "^5.0.0",
Expand All @@ -22,6 +21,7 @@
"postgres-array": "^3.0.1",
"postgres-interval": "^4.0.0",
"roarr": "^7.14.0",
"safe-stable-stringify": "^2.4.1",
"serialize-error": "^8.0.0",
"through2": "^4.0.2",
"zod": "^3.19.1"
Expand Down
4 changes: 3 additions & 1 deletion src/factories/createPrimitiveValueExpressions.ts
@@ -1,4 +1,3 @@
import safeStringify from 'fast-safe-stringify';
import {
Logger,
} from '../Logger';
Expand All @@ -8,6 +7,9 @@ import {
import {
type PrimitiveValueExpression,
} from '../types';
import {
safeStringify,
} from '../utilities';

const log = Logger.child({
namespace: 'createPrimitiveValueExpressions',
Expand Down
2 changes: 1 addition & 1 deletion src/factories/createSqlTag.ts
@@ -1,4 +1,3 @@
import safeStringify from 'fast-safe-stringify';
import {
z,
type ZodTypeAny,
Expand Down Expand Up @@ -43,6 +42,7 @@ import {
type ValueExpression,
} from '../types';
import {
safeStringify,
escapeLiteralValue,
isPrimitiveValueExpression,
isSqlToken,
Expand Down
4 changes: 3 additions & 1 deletion src/sqlFragmentFactories/createJsonSqlFragment.ts
@@ -1,4 +1,3 @@
import safeStringify from 'fast-safe-stringify';
import {
isPlainObject,
} from 'is-plain-object';
Expand All @@ -16,6 +15,9 @@ import {
type JsonSqlToken,
type SqlFragment,
} from '../types';
import {
safeStringify,
} from '../utilities';

const log = Logger.child({
namespace: 'createJsonSqlFragment',
Expand Down
3 changes: 3 additions & 0 deletions src/utilities/index.ts
Expand Up @@ -28,6 +28,9 @@ export {
export {
parseDsn,
} from './parseDsn';
export {
safeStringify,
} from './safeStringify';
export {
stringifyDsn,
} from './stringifyDsn';
Expand Down
19 changes: 19 additions & 0 deletions src/utilities/safeStringify.ts
@@ -0,0 +1,19 @@
import stringify from 'safe-stable-stringify';

export const safeStringify = (
subject: unknown,
replacer?:
| Array<number | string>
| ((key: string, value: unknown) => unknown)
| null
| undefined,
space?: number | string,
): string => {
const result = stringify(subject, replacer, space);

if (result === undefined) {
throw new Error('Expected result to be string');
}

return result;
};

0 comments on commit 1cd87c2

Please sign in to comment.