safe-stable-stringify
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -1,19 +0,1 @@ | ||
export function stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; | ||
export function stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string; | ||
export interface StringifyOptions { | ||
bigint?: boolean, | ||
circularValue?: string | null | TypeErrorConstructor | ErrorConstructor, | ||
deterministic?: boolean, | ||
maximumBreadth?: number, | ||
maximumDepth?: number, | ||
strict?: boolean, | ||
} | ||
export namespace stringify { | ||
export function configure(options: StringifyOptions): typeof stringify; | ||
} | ||
export function configure(options: StringifyOptions): typeof stringify; | ||
export default stringify; | ||
export * from '../index.d' |
@@ -1,4 +0,7 @@ | ||
export function stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; | ||
export function stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string; | ||
export type Replacer = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null) | ||
export function stringify(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer, space?: string | number): undefined | ||
export function stringify(value: string | number | unknown[] | null | boolean | object, replacer?: Replacer, space?: string | number): string | ||
export function stringify(value: unknown, replacer?: ((key: string, value: unknown) => unknown) | (number | string)[] | null | undefined, space?: string | number): string | undefined | ||
export interface StringifyOptions { | ||
@@ -14,7 +17,7 @@ bigint?: boolean, | ||
export namespace stringify { | ||
export function configure(options: StringifyOptions): typeof stringify; | ||
export function configure(options: StringifyOptions): typeof stringify | ||
} | ||
export function configure(options: StringifyOptions): typeof stringify; | ||
export function configure(options: StringifyOptions): typeof stringify | ||
export default stringify; | ||
export default stringify |
11
index.js
@@ -22,5 +22,4 @@ 'use strict' | ||
// eslint-disable-next-line | ||
// eslint-disable-next-line no-control-regex | ||
const strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/ | ||
// eslint-disable-next-line | ||
const strEscapeSequencesReplacer = new RegExp(strEscapeSequencesRegExp, 'g') | ||
@@ -134,3 +133,3 @@ | ||
function getCircularValueOption (options) { | ||
if (options && hasOwnProperty.call(options, 'circularValue')) { | ||
if (hasOwnProperty.call(options, 'circularValue')) { | ||
const circularValue = options.circularValue | ||
@@ -157,3 +156,3 @@ if (typeof circularValue === 'string') { | ||
let value | ||
if (options && hasOwnProperty.call(options, key)) { | ||
if (hasOwnProperty.call(options, key)) { | ||
value = options[key] | ||
@@ -169,3 +168,3 @@ if (typeof value !== 'boolean') { | ||
let value | ||
if (options && hasOwnProperty.call(options, key)) { | ||
if (hasOwnProperty.call(options, key)) { | ||
value = options[key] | ||
@@ -203,3 +202,3 @@ if (typeof value !== 'number') { | ||
function getStrictOption (options) { | ||
if (options && hasOwnProperty.call(options, 'strict')) { | ||
if (hasOwnProperty.call(options, 'strict')) { | ||
const value = options.strict | ||
@@ -206,0 +205,0 @@ if (typeof value !== 'boolean') { |
{ | ||
"name": "safe-stable-stringify", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "Deterministic and safely JSON.stringify to quickly serialize JavaScript objects", | ||
@@ -5,0 +5,0 @@ "exports": { |
31976
655