Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

superjson

Package Overview
Dependencies
Maintainers
4
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superjson - npm Package Compare versions

Comparing version 1.9.0-0 to 1.9.0

src/error-props.ts

14

dist/accessDeep.js

@@ -5,2 +5,3 @@ "use strict";

var is_1 = require("./is");
var util_1 = require("./util");
var getNthKey = function (value, n) {

@@ -14,3 +15,15 @@ var keys = value.keys();

};
function validatePath(path) {
if (util_1.includes(path, '__proto__')) {
throw new Error('__proto__ is not allowed as a property');
}
if (util_1.includes(path, 'prototype')) {
throw new Error('prototype is not allowed as a property');
}
if (util_1.includes(path, 'constructor')) {
throw new Error('constructor is not allowed as a property');
}
}
var getDeep = function (object, path) {
validatePath(path);
path.forEach(function (key) {

@@ -23,2 +36,3 @@ object = object[key];

var setDeep = function (object, path, mapper) {
validatePath(path);
if (path.length === 0) {

@@ -25,0 +39,0 @@ return mapper(object);

4

dist/class-registry.d.ts

@@ -7,3 +7,3 @@ import { Registry } from './registry';

}
export declare class ClassRegistry extends Registry<Class> {
declare class _ClassRegistry extends Registry<Class> {
constructor();

@@ -14,1 +14,3 @@ private classToAllowedProps;

}
export declare const ClassRegistry: _ClassRegistry;
export {};

@@ -20,5 +20,5 @@ "use strict";

var registry_1 = require("./registry");
var ClassRegistry = /** @class */ (function (_super) {
__extends(ClassRegistry, _super);
function ClassRegistry() {
var _ClassRegistry = /** @class */ (function (_super) {
__extends(_ClassRegistry, _super);
function _ClassRegistry() {
var _this = _super.call(this, function (c) { return c.name; }) || this;

@@ -28,3 +28,3 @@ _this.classToAllowedProps = new Map();

}
ClassRegistry.prototype.register = function (value, options) {
_ClassRegistry.prototype.register = function (value, options) {
if (typeof options === 'object') {

@@ -40,8 +40,8 @@ if (options.allowProps) {

};
ClassRegistry.prototype.getAllowedProps = function (value) {
_ClassRegistry.prototype.getAllowedProps = function (value) {
return this.classToAllowedProps.get(value);
};
return ClassRegistry;
return _ClassRegistry;
}(registry_1.Registry));
exports.ClassRegistry = ClassRegistry;
exports.ClassRegistry = new _ClassRegistry();
//# sourceMappingURL=class-registry.js.map

@@ -8,7 +8,6 @@ import { JSONValue } from './types';

}
export declare class CustomTransformerRegistry {
private transfomers;
export declare const CustomTransformerRegistry: {
register<I, O extends JSONValue>(transformer: CustomTransfomer<I, O>): void;
findApplicable<T>(v: T): CustomTransfomer<T, JSONValue> | undefined;
findByName(name: string): CustomTransfomer<any, any>;
}
};

@@ -5,20 +5,14 @@ "use strict";

var util_1 = require("./util");
var CustomTransformerRegistry = /** @class */ (function () {
function CustomTransformerRegistry() {
this.transfomers = {};
var transfomers = {};
exports.CustomTransformerRegistry = {
register: function (transformer) {
transfomers[transformer.name] = transformer;
},
findApplicable: function (v) {
return util_1.find(transfomers, function (transformer) { return transformer.isApplicable(v); });
},
findByName: function (name) {
return transfomers[name];
}
CustomTransformerRegistry.prototype.register = function (transformer) {
this.transfomers[transformer.name] = transformer;
};
CustomTransformerRegistry.prototype.findApplicable = function (v) {
return util_1.find(this.transfomers, function (transformer) {
return transformer.isApplicable(v);
});
};
CustomTransformerRegistry.prototype.findByName = function (name) {
return this.transfomers[name];
};
return CustomTransformerRegistry;
}());
exports.CustomTransformerRegistry = CustomTransformerRegistry;
};
//# sourceMappingURL=custom-transformer-registry.js.map
import { isMap, isArray, isPlainObject, isSet } from './is';
import { includes } from './util';
var getNthKey = function (value, n) {

@@ -10,3 +11,15 @@ var keys = value.keys();

};
function validatePath(path) {
if (includes(path, '__proto__')) {
throw new Error('__proto__ is not allowed as a property');
}
if (includes(path, 'prototype')) {
throw new Error('prototype is not allowed as a property');
}
if (includes(path, 'constructor')) {
throw new Error('constructor is not allowed as a property');
}
}
export var getDeep = function (object, path) {
validatePath(path);
path.forEach(function (key) {

@@ -18,2 +31,3 @@ object = object[key];

export var setDeep = function (object, path, mapper) {
validatePath(path);
if (path.length === 0) {

@@ -20,0 +34,0 @@ return mapper(object);

@@ -7,3 +7,3 @@ import { Registry } from './registry';

}
export declare class ClassRegistry extends Registry<Class> {
declare class _ClassRegistry extends Registry<Class> {
constructor();

@@ -14,1 +14,3 @@ private classToAllowedProps;

}
export declare const ClassRegistry: _ClassRegistry;
export {};

@@ -17,5 +17,5 @@ var __extends = (this && this.__extends) || (function () {

import { Registry } from './registry';
var ClassRegistry = /** @class */ (function (_super) {
__extends(ClassRegistry, _super);
function ClassRegistry() {
var _ClassRegistry = /** @class */ (function (_super) {
__extends(_ClassRegistry, _super);
function _ClassRegistry() {
var _this = _super.call(this, function (c) { return c.name; }) || this;

@@ -25,3 +25,3 @@ _this.classToAllowedProps = new Map();

}
ClassRegistry.prototype.register = function (value, options) {
_ClassRegistry.prototype.register = function (value, options) {
if (typeof options === 'object') {

@@ -37,8 +37,8 @@ if (options.allowProps) {

};
ClassRegistry.prototype.getAllowedProps = function (value) {
_ClassRegistry.prototype.getAllowedProps = function (value) {
return this.classToAllowedProps.get(value);
};
return ClassRegistry;
return _ClassRegistry;
}(Registry));
export { ClassRegistry };
export var ClassRegistry = new _ClassRegistry();
//# sourceMappingURL=class-registry.js.map

@@ -8,7 +8,6 @@ import { JSONValue } from './types';

}
export declare class CustomTransformerRegistry {
private transfomers;
export declare const CustomTransformerRegistry: {
register<I, O extends JSONValue>(transformer: CustomTransfomer<I, O>): void;
findApplicable<T>(v: T): CustomTransfomer<T, JSONValue> | undefined;
findByName(name: string): CustomTransfomer<any, any>;
}
};
import { find } from './util';
var CustomTransformerRegistry = /** @class */ (function () {
function CustomTransformerRegistry() {
this.transfomers = {};
var transfomers = {};
export var CustomTransformerRegistry = {
register: function (transformer) {
transfomers[transformer.name] = transformer;
},
findApplicable: function (v) {
return find(transfomers, function (transformer) { return transformer.isApplicable(v); });
},
findByName: function (name) {
return transfomers[name];
}
CustomTransformerRegistry.prototype.register = function (transformer) {
this.transfomers[transformer.name] = transformer;
};
CustomTransformerRegistry.prototype.findApplicable = function (v) {
return find(this.transfomers, function (transformer) {
return transformer.isApplicable(v);
});
};
CustomTransformerRegistry.prototype.findByName = function (name) {
return this.transfomers[name];
};
return CustomTransformerRegistry;
}());
export { CustomTransformerRegistry };
};
//# sourceMappingURL=custom-transformer-registry.js.map
import { SuperJSONResult, SuperJSONValue, Class, JSONValue } from './types';
import { ClassRegistry, RegisterOptions } from './class-registry';
import { Registry } from './registry';
import { CustomTransfomer, CustomTransformerRegistry } from './custom-transformer-registry';
export default class SuperJSON {
serialize(object: SuperJSONValue): SuperJSONResult;
deserialize<T = unknown>(payload: SuperJSONResult): T;
stringify(object: SuperJSONValue): string;
parse<T = unknown>(string: string): T;
readonly classRegistry: ClassRegistry;
registerClass(v: Class, options?: RegisterOptions | string): void;
readonly symbolRegistry: Registry<Symbol>;
registerSymbol(v: Symbol, identifier?: string): void;
readonly customTransformerRegistry: CustomTransformerRegistry;
registerCustom<I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, 'name'>, name: string): void;
readonly allowedErrorProps: string[];
allowErrorProps(...props: string[]): void;
private static defaultInstance;
static serialize: (object: SuperJSONValue) => SuperJSONResult;
static deserialize: <T = unknown>(payload: SuperJSONResult) => T;
static stringify: (object: SuperJSONValue) => string;
static parse: <T = unknown>(string: string) => T;
static registerClass: (v: Class, options?: string | RegisterOptions | undefined) => void;
static registerSymbol: (v: Symbol, identifier?: string | undefined) => void;
static registerCustom: <I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, "name">, name: string) => void;
static allowErrorProps: (...props: string[]) => void;
}
import { RegisterOptions } from './class-registry';
import { CustomTransfomer } from './custom-transformer-registry';
export declare const serialize: (object: SuperJSONValue) => SuperJSONResult;

@@ -32,1 +8,12 @@ export declare const deserialize: <T = unknown>(payload: SuperJSONResult) => T;

export declare const parse: <T = unknown>(string: string) => T;
declare const _default: {
stringify: (object: any) => string;
parse: <T = unknown>(string: string) => T;
serialize: (object: any) => SuperJSONResult;
deserialize: <T_1 = unknown>(payload: SuperJSONResult) => T_1;
registerClass: (v: Class, options?: string | RegisterOptions | undefined) => void;
registerSymbol: (v: Symbol, identifier?: string | undefined) => void;
registerCustom: <I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, "name">, name: string) => void;
allowErrorProps: (...props: string[]) => void;
};
export default _default;

@@ -12,100 +12,59 @@ var __assign = (this && this.__assign) || function () {

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
import { ClassRegistry } from './class-registry';
import { SymbolRegistry } from './symbol-registry';
import { CustomTransformerRegistry, } from './custom-transformer-registry';
import { allowErrorProps } from './error-props';
import { walker, applyReferentialEqualityAnnotations, applyValueAnnotations, generateReferentialEqualityAnnotations, } from './plainer';
import { copy } from 'copy-anything';
export var serialize = function (object) {
var identities = new Map();
var output = walker(object, identities);
var res = {
json: output.transformedValue
};
if (output.annotations) {
res.meta = __assign(__assign({}, res.meta), { values: output.annotations });
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
var equalityAnnotations = generateReferentialEqualityAnnotations(identities);
if (equalityAnnotations) {
res.meta = __assign(__assign({}, res.meta), { referentialEqualities: equalityAnnotations });
}
return ar;
return res;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
export var deserialize = function (payload) {
var json = payload.json, meta = payload.meta;
var result = copy(json);
if (meta === null || meta === void 0 ? void 0 : meta.values) {
result = applyValueAnnotations(result, meta.values);
}
if (meta === null || meta === void 0 ? void 0 : meta.referentialEqualities) {
result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
}
return result;
};
import { ClassRegistry } from './class-registry';
import { Registry } from './registry';
import { CustomTransformerRegistry, } from './custom-transformer-registry';
import { walker, applyReferentialEqualityAnnotations, applyValueAnnotations, generateReferentialEqualityAnnotations, } from './plainer';
import cloneDeep from 'lodash.clonedeep';
var SuperJSON = /** @class */ (function () {
function SuperJSON() {
this.classRegistry = new ClassRegistry();
this.symbolRegistry = new Registry(function (s) { var _a; return (_a = s.description) !== null && _a !== void 0 ? _a : ''; });
this.customTransformerRegistry = new CustomTransformerRegistry();
this.allowedErrorProps = [];
}
SuperJSON.prototype.serialize = function (object) {
var identities = new Map();
var output = walker(object, identities, this);
var res = {
json: output.transformedValue
};
if (output.annotations) {
res.meta = __assign(__assign({}, res.meta), { values: output.annotations });
}
var equalityAnnotations = generateReferentialEqualityAnnotations(identities);
if (equalityAnnotations) {
res.meta = __assign(__assign({}, res.meta), { referentialEqualities: equalityAnnotations });
}
return res;
};
SuperJSON.prototype.deserialize = function (payload) {
var json = payload.json, meta = payload.meta;
var result = cloneDeep(json);
if (meta === null || meta === void 0 ? void 0 : meta.values) {
result = applyValueAnnotations(result, meta.values, this);
}
if (meta === null || meta === void 0 ? void 0 : meta.referentialEqualities) {
result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
}
return result;
};
SuperJSON.prototype.stringify = function (object) {
return JSON.stringify(this.serialize(object));
};
SuperJSON.prototype.parse = function (string) {
return this.deserialize(JSON.parse(string));
};
SuperJSON.prototype.registerClass = function (v, options) {
this.classRegistry.register(v, options);
};
SuperJSON.prototype.registerSymbol = function (v, identifier) {
this.symbolRegistry.register(v, identifier);
};
SuperJSON.prototype.registerCustom = function (transformer, name) {
this.customTransformerRegistry.register(__assign({ name: name }, transformer));
};
SuperJSON.prototype.allowErrorProps = function () {
var _a;
var props = [];
for (var _i = 0; _i < arguments.length; _i++) {
props[_i] = arguments[_i];
}
(_a = this.allowedErrorProps).push.apply(_a, __spreadArray([], __read(props)));
};
SuperJSON.defaultInstance = new SuperJSON();
SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
return SuperJSON;
}());
export default SuperJSON;
export var serialize = SuperJSON.serialize;
export var deserialize = SuperJSON.deserialize;
export var stringify = SuperJSON.stringify;
export var parse = SuperJSON.parse;
export var stringify = function (object) {
return JSON.stringify(serialize(object));
};
export var parse = function (string) {
return deserialize(JSON.parse(string));
};
var registerClass = function (v, options) {
return ClassRegistry.register(v, options);
};
var registerSymbol = function (v, identifier) {
return SymbolRegistry.register(v, identifier);
};
var registerCustom = function (transformer, name) {
return CustomTransformerRegistry.register(__assign({ name: name }, transformer));
};
export default {
stringify: stringify,
parse: parse,
serialize: serialize,
deserialize: deserialize,
registerClass: registerClass,
registerSymbol: registerSymbol,
registerCustom: registerCustom,
allowErrorProps: allowErrorProps
};
//# sourceMappingURL=index.js.map

@@ -13,2 +13,4 @@ var getType = function (payload) {

return true;
if (payload === Object.prototype)
return false;
return (payload.constructor === Object &&

@@ -15,0 +17,0 @@ Object.getPrototypeOf(payload) === Object.prototype);

import { TypeAnnotation } from './transformer';
import SuperJSON from '.';
declare type Tree<T> = InnerNode<T> | Leaf<T>;

@@ -7,3 +6,3 @@ declare type Leaf<T> = [T];

export declare type MinimisedTree<T> = Tree<T> | Record<string, Tree<T>> | undefined;
export declare function applyValueAnnotations(plain: any, annotations: MinimisedTree<TypeAnnotation>, superJson: SuperJSON): any;
export declare function applyValueAnnotations(plain: any, annotations: MinimisedTree<TypeAnnotation>): any;
export declare function applyReferentialEqualityAnnotations(plain: any, annotations: ReferentialEqualityAnnotations): any;

@@ -16,3 +15,3 @@ interface Result {

export declare function generateReferentialEqualityAnnotations(identitites: Map<any, any[][]>): ReferentialEqualityAnnotations | undefined;
export declare const walker: (object: any, identities: Map<any, any[][]>, superJson: SuperJSON, path?: any[], objectsInThisPath?: any[]) => Result;
export declare const walker: (object: any, identities: Map<any, any[][]>, path?: any[], objectsInThisPath?: any[]) => Result;
export {};

@@ -47,5 +47,5 @@ var __read = (this && this.__read) || function (o, n) {

}
export function applyValueAnnotations(plain, annotations, superJson) {
export function applyValueAnnotations(plain, annotations) {
traverse(annotations, function (type, path) {
plain = setDeep(plain, path, function (v) { return untransformValue(v, type, superJson); });
plain = setDeep(plain, path, function (v) { return untransformValue(v, type); });
});

@@ -75,3 +75,3 @@ return plain;

}
var isDeep = function (object, superJson) {
var isDeep = function (object) {
return isPlainObject(object) ||

@@ -81,3 +81,3 @@ isArray(object) ||

isSet(object) ||
isInstanceOfRegisteredClass(object, superJson);
isInstanceOfRegisteredClass(object);
};

@@ -122,3 +122,3 @@ function addIdentity(object, path, identities) {

}
export var walker = function (object, identities, superJson, path, objectsInThisPath) {
export var walker = function (object, identities, path, objectsInThisPath) {
var _a;

@@ -130,4 +130,4 @@ if (path === void 0) { path = []; }

}
if (!isDeep(object, superJson)) {
var transformed_1 = transformValue(object, superJson);
if (!isDeep(object)) {
var transformed_1 = transformValue(object);
if (transformed_1) {

@@ -150,3 +150,3 @@ return {

}
var transformationResult = transformValue(object, superJson);
var transformationResult = transformValue(object);
var transformed = (_a = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a !== void 0 ? _a : object;

@@ -159,3 +159,3 @@ if (!isPrimitive(object)) {

forEach(transformed, function (value, index) {
var recursiveResult = walker(value, identities, superJson, __spreadArray(__spreadArray([], __read(path)), [index]), objectsInThisPath);
var recursiveResult = walker(value, identities, __spreadArray(__spreadArray([], __read(path)), [index]), objectsInThisPath);
transformedValue[index] = recursiveResult.transformedValue;

@@ -162,0 +162,0 @@ if (isArray(recursiveResult.annotations)) {

import { DoubleIndexedKV } from './double-indexed-kv';
import createDebug from 'debug';
var debug = createDebug('superjson');
var Registry = /** @class */ (function () {

@@ -19,3 +17,3 @@ function Registry(generateIdentifier) {

if (alreadyRegistered && alreadyRegistered !== value) {
debug("Ambiguous class \"" + identifier + "\", provide a unique identifier.");
console.debug("Ambiguous class \"" + identifier + "\", provide a unique identifier.");
}

@@ -22,0 +20,0 @@ }

@@ -1,2 +0,1 @@

import SuperJSON from '.';
export declare type PrimitiveTypeAnnotation = 'number' | 'undefined' | 'bigint';

@@ -11,8 +10,8 @@ declare type LeafTypeAnnotation = PrimitiveTypeAnnotation | 'regexp' | 'Date' | 'Error';

export declare type TypeAnnotation = SimpleTypeAnnotation | CompositeTypeAnnotation;
export declare function isInstanceOfRegisteredClass(potentialClass: any, superJson: SuperJSON): potentialClass is any;
export declare const transformValue: (value: any, superJson: SuperJSON) => {
export declare function isInstanceOfRegisteredClass(potentialClass: any): potentialClass is any;
export declare const transformValue: (value: any) => {
value: any;
type: TypeAnnotation;
} | undefined;
export declare const untransformValue: (json: any, type: TypeAnnotation, superJson: SuperJSON) => any;
export declare const untransformValue: (json: any, type: TypeAnnotation) => any;
export {};

@@ -34,2 +34,6 @@ var __assign = (this && this.__assign) || function () {

import { isBigint, isDate, isInfinite, isMap, isNaNValue, isRegExp, isSet, isUndefined, isSymbol, isArray, isError, isTypedArray, } from './is';
import { ClassRegistry } from './class-registry';
import { SymbolRegistry } from './symbol-registry';
import { CustomTransformerRegistry } from './custom-transformer-registry';
import { allowedErrorProps } from './error-props';
import { findArr } from './util';

@@ -54,3 +58,3 @@ function simpleTransformation(isApplicable, annotation, transform, untransform) {

simpleTransformation(isDate, 'Date', function (v) { return v.toISOString(); }, function (v) { return new Date(v); }),
simpleTransformation(isError, 'Error', function (v, superJson) {
simpleTransformation(isError, 'Error', function (v) {
var baseError = {

@@ -60,11 +64,11 @@ name: v.name,

};
superJson.allowedErrorProps.forEach(function (prop) {
allowedErrorProps.forEach(function (prop) {
baseError[prop] = v[prop];
});
return baseError;
}, function (v, superJson) {
}, function (v) {
var e = new Error(v.message);
e.name = v.name;
e.stack = v.stack;
superJson.allowedErrorProps.forEach(function (prop) {
allowedErrorProps.forEach(function (prop) {
e[prop] = v[prop];

@@ -107,13 +111,13 @@ });

}
var symbolRule = compositeTransformation(function (s, superJson) {
var symbolRule = compositeTransformation(function (s) {
if (isSymbol(s)) {
var isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
var isRegistered = !!SymbolRegistry.getIdentifier(s);
return isRegistered;
}
return false;
}, function (s, superJson) {
var identifier = superJson.symbolRegistry.getIdentifier(s);
}, function (s) {
var identifier = SymbolRegistry.getIdentifier(s);
return ['symbol', identifier];
}, function (v) { return v.description; }, function (_, a, superJson) {
var value = superJson.symbolRegistry.getValue(a[1]);
}, function (v) { return v.description; }, function (_, a) {
var value = SymbolRegistry.getValue(a[1]);
if (!value) {

@@ -145,5 +149,5 @@ throw new Error('Trying to deserialize unknown symbol');

});
export function isInstanceOfRegisteredClass(potentialClass, superJson) {
export function isInstanceOfRegisteredClass(potentialClass) {
if (potentialClass === null || potentialClass === void 0 ? void 0 : potentialClass.constructor) {
var isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
var isRegistered = !!ClassRegistry.getIdentifier(potentialClass.constructor);
return isRegistered;

@@ -153,7 +157,7 @@ }

}
var classRule = compositeTransformation(isInstanceOfRegisteredClass, function (clazz, superJson) {
var identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
var classRule = compositeTransformation(isInstanceOfRegisteredClass, function (clazz) {
var identifier = ClassRegistry.getIdentifier(clazz.constructor);
return ['class', identifier];
}, function (clazz, superJson) {
var allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
}, function (clazz) {
var allowedProps = ClassRegistry.getAllowedProps(clazz.constructor);
if (!allowedProps) {

@@ -167,4 +171,4 @@ return __assign({}, clazz);

return result;
}, function (v, a, superJson) {
var clazz = superJson.classRegistry.getValue(a[1]);
}, function (v, a) {
var clazz = ClassRegistry.getValue(a[1]);
if (!clazz) {

@@ -175,12 +179,12 @@ throw new Error('Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564');

});
var customRule = compositeTransformation(function (value, superJson) {
return !!superJson.customTransformerRegistry.findApplicable(value);
}, function (value, superJson) {
var transformer = superJson.customTransformerRegistry.findApplicable(value);
var customRule = compositeTransformation(function (value) {
return !!CustomTransformerRegistry.findApplicable(value);
}, function (value) {
var transformer = CustomTransformerRegistry.findApplicable(value);
return ['custom', transformer.name];
}, function (value, superJson) {
var transformer = superJson.customTransformerRegistry.findApplicable(value);
}, function (value) {
var transformer = CustomTransformerRegistry.findApplicable(value);
return transformer.serialize(value);
}, function (v, a, superJson) {
var transformer = superJson.customTransformerRegistry.findByName(a[1]);
}, function (v, a) {
var transformer = CustomTransformerRegistry.findByName(a[1]);
if (!transformer) {

@@ -192,18 +196,18 @@ throw new Error('Trying to deserialize unknown custom value');

var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
export var transformValue = function (value, superJson) {
export var transformValue = function (value) {
var applicableCompositeRule = findArr(compositeRules, function (rule) {
return rule.isApplicable(value, superJson);
return rule.isApplicable(value);
});
if (applicableCompositeRule) {
return {
value: applicableCompositeRule.transform(value, superJson),
type: applicableCompositeRule.annotation(value, superJson)
value: applicableCompositeRule.transform(value),
type: applicableCompositeRule.annotation(value)
};
}
var applicableSimpleRule = findArr(simpleRules, function (rule) {
return rule.isApplicable(value, superJson);
return rule.isApplicable(value);
});
if (applicableSimpleRule) {
return {
value: applicableSimpleRule.transform(value, superJson),
value: applicableSimpleRule.transform(value),
type: applicableSimpleRule.annotation

@@ -218,13 +222,13 @@ };

});
export var untransformValue = function (json, type, superJson) {
export var untransformValue = function (json, type) {
if (isArray(type)) {
switch (type[0]) {
case 'symbol':
return symbolRule.untransform(json, type, superJson);
return symbolRule.untransform(json, type);
case 'class':
return classRule.untransform(json, type, superJson);
return classRule.untransform(json, type);
case 'custom':
return customRule.untransform(json, type, superJson);
return customRule.untransform(json, type);
case 'typed-array':
return typedArrayRule.untransform(json, type, superJson);
return typedArrayRule.untransform(json, type);
default:

@@ -239,5 +243,5 @@ throw new Error('Unknown transformation: ' + type);

}
return transformation.untransform(json, superJson);
return transformation.untransform(json);
}
};
//# sourceMappingURL=transformer.js.map

@@ -6,4 +6,4 @@ import { TypeAnnotation } from './transformer';

};
export declare type PrimitveJSONValue = string | number | boolean | undefined | null;
export declare type JSONValue = PrimitveJSONValue | JSONArray | JSONObject;
export declare type PrimitiveJSONValue = string | number | boolean | undefined | null;
export declare type JSONValue = PrimitiveJSONValue | JSONArray | JSONObject;
export interface JSONArray extends Array<JSONValue> {

@@ -10,0 +10,0 @@ }

import { SuperJSONResult, SuperJSONValue, Class, JSONValue } from './types';
import { ClassRegistry, RegisterOptions } from './class-registry';
import { Registry } from './registry';
import { CustomTransfomer, CustomTransformerRegistry } from './custom-transformer-registry';
export default class SuperJSON {
serialize(object: SuperJSONValue): SuperJSONResult;
deserialize<T = unknown>(payload: SuperJSONResult): T;
stringify(object: SuperJSONValue): string;
parse<T = unknown>(string: string): T;
readonly classRegistry: ClassRegistry;
registerClass(v: Class, options?: RegisterOptions | string): void;
readonly symbolRegistry: Registry<Symbol>;
registerSymbol(v: Symbol, identifier?: string): void;
readonly customTransformerRegistry: CustomTransformerRegistry;
registerCustom<I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, 'name'>, name: string): void;
readonly allowedErrorProps: string[];
allowErrorProps(...props: string[]): void;
private static defaultInstance;
static serialize: (object: SuperJSONValue) => SuperJSONResult;
static deserialize: <T = unknown>(payload: SuperJSONResult) => T;
static stringify: (object: SuperJSONValue) => string;
static parse: <T = unknown>(string: string) => T;
static registerClass: (v: Class, options?: string | RegisterOptions | undefined) => void;
static registerSymbol: (v: Symbol, identifier?: string | undefined) => void;
static registerCustom: <I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, "name">, name: string) => void;
static allowErrorProps: (...props: string[]) => void;
}
import { RegisterOptions } from './class-registry';
import { CustomTransfomer } from './custom-transformer-registry';
export declare const serialize: (object: SuperJSONValue) => SuperJSONResult;

@@ -32,1 +8,12 @@ export declare const deserialize: <T = unknown>(payload: SuperJSONResult) => T;

export declare const parse: <T = unknown>(string: string) => T;
declare const _default: {
stringify: (object: any) => string;
parse: <T = unknown>(string: string) => T;
serialize: (object: any) => SuperJSONResult;
deserialize: <T_1 = unknown>(payload: SuperJSONResult) => T_1;
registerClass: (v: Class, options?: string | RegisterOptions | undefined) => void;
registerSymbol: (v: Symbol, identifier?: string | undefined) => void;
registerCustom: <I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, "name">, name: string) => void;
allowErrorProps: (...props: string[]) => void;
};
export default _default;

@@ -13,105 +13,65 @@ "use strict";

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
exports.parse = exports.stringify = exports.deserialize = exports.serialize = void 0;
var class_registry_1 = require("./class-registry");
var registry_1 = require("./registry");
var symbol_registry_1 = require("./symbol-registry");
var custom_transformer_registry_1 = require("./custom-transformer-registry");
var error_props_1 = require("./error-props");
var plainer_1 = require("./plainer");
var lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
var SuperJSON = /** @class */ (function () {
function SuperJSON() {
this.classRegistry = new class_registry_1.ClassRegistry();
this.symbolRegistry = new registry_1.Registry(function (s) { var _a; return (_a = s.description) !== null && _a !== void 0 ? _a : ''; });
this.customTransformerRegistry = new custom_transformer_registry_1.CustomTransformerRegistry();
this.allowedErrorProps = [];
var copy_anything_1 = require("copy-anything");
var serialize = function (object) {
var identities = new Map();
var output = plainer_1.walker(object, identities);
var res = {
json: output.transformedValue
};
if (output.annotations) {
res.meta = __assign(__assign({}, res.meta), { values: output.annotations });
}
SuperJSON.prototype.serialize = function (object) {
var identities = new Map();
var output = plainer_1.walker(object, identities, this);
var res = {
json: output.transformedValue
};
if (output.annotations) {
res.meta = __assign(__assign({}, res.meta), { values: output.annotations });
}
var equalityAnnotations = plainer_1.generateReferentialEqualityAnnotations(identities);
if (equalityAnnotations) {
res.meta = __assign(__assign({}, res.meta), { referentialEqualities: equalityAnnotations });
}
return res;
};
SuperJSON.prototype.deserialize = function (payload) {
var json = payload.json, meta = payload.meta;
var result = lodash_clonedeep_1["default"](json);
if (meta === null || meta === void 0 ? void 0 : meta.values) {
result = plainer_1.applyValueAnnotations(result, meta.values, this);
}
if (meta === null || meta === void 0 ? void 0 : meta.referentialEqualities) {
result = plainer_1.applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
}
return result;
};
SuperJSON.prototype.stringify = function (object) {
return JSON.stringify(this.serialize(object));
};
SuperJSON.prototype.parse = function (string) {
return this.deserialize(JSON.parse(string));
};
SuperJSON.prototype.registerClass = function (v, options) {
this.classRegistry.register(v, options);
};
SuperJSON.prototype.registerSymbol = function (v, identifier) {
this.symbolRegistry.register(v, identifier);
};
SuperJSON.prototype.registerCustom = function (transformer, name) {
this.customTransformerRegistry.register(__assign({ name: name }, transformer));
};
SuperJSON.prototype.allowErrorProps = function () {
var _a;
var props = [];
for (var _i = 0; _i < arguments.length; _i++) {
props[_i] = arguments[_i];
}
(_a = this.allowedErrorProps).push.apply(_a, __spreadArray([], __read(props)));
};
SuperJSON.defaultInstance = new SuperJSON();
SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
return SuperJSON;
}());
exports["default"] = SuperJSON;
exports.serialize = SuperJSON.serialize;
exports.deserialize = SuperJSON.deserialize;
exports.stringify = SuperJSON.stringify;
exports.parse = SuperJSON.parse;
var equalityAnnotations = plainer_1.generateReferentialEqualityAnnotations(identities);
if (equalityAnnotations) {
res.meta = __assign(__assign({}, res.meta), { referentialEqualities: equalityAnnotations });
}
return res;
};
exports.serialize = serialize;
var deserialize = function (payload) {
var json = payload.json, meta = payload.meta;
var result = copy_anything_1.copy(json);
if (meta === null || meta === void 0 ? void 0 : meta.values) {
result = plainer_1.applyValueAnnotations(result, meta.values);
}
if (meta === null || meta === void 0 ? void 0 : meta.referentialEqualities) {
result = plainer_1.applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
}
return result;
};
exports.deserialize = deserialize;
var stringify = function (object) {
return JSON.stringify(exports.serialize(object));
};
exports.stringify = stringify;
var parse = function (string) {
return exports.deserialize(JSON.parse(string));
};
exports.parse = parse;
var registerClass = function (v, options) {
return class_registry_1.ClassRegistry.register(v, options);
};
var registerSymbol = function (v, identifier) {
return symbol_registry_1.SymbolRegistry.register(v, identifier);
};
var registerCustom = function (transformer, name) {
return custom_transformer_registry_1.CustomTransformerRegistry.register(__assign({ name: name }, transformer));
};
exports["default"] = {
stringify: exports.stringify,
parse: exports.parse,
serialize: exports.serialize,
deserialize: exports.deserialize,
registerClass: registerClass,
registerSymbol: registerSymbol,
registerCustom: registerCustom,
allowErrorProps: error_props_1.allowErrorProps
};
//# sourceMappingURL=index.js.map

@@ -18,2 +18,4 @@ "use strict";

return true;
if (payload === Object.prototype)
return false;
return (payload.constructor === Object &&

@@ -20,0 +22,0 @@ Object.getPrototypeOf(payload) === Object.prototype);

import { TypeAnnotation } from './transformer';
import SuperJSON from '.';
declare type Tree<T> = InnerNode<T> | Leaf<T>;

@@ -7,3 +6,3 @@ declare type Leaf<T> = [T];

export declare type MinimisedTree<T> = Tree<T> | Record<string, Tree<T>> | undefined;
export declare function applyValueAnnotations(plain: any, annotations: MinimisedTree<TypeAnnotation>, superJson: SuperJSON): any;
export declare function applyValueAnnotations(plain: any, annotations: MinimisedTree<TypeAnnotation>): any;
export declare function applyReferentialEqualityAnnotations(plain: any, annotations: ReferentialEqualityAnnotations): any;

@@ -16,3 +15,3 @@ interface Result {

export declare function generateReferentialEqualityAnnotations(identitites: Map<any, any[][]>): ReferentialEqualityAnnotations | undefined;
export declare const walker: (object: any, identities: Map<any, any[][]>, superJson: SuperJSON, path?: any[], objectsInThisPath?: any[]) => Result;
export declare const walker: (object: any, identities: Map<any, any[][]>, path?: any[], objectsInThisPath?: any[]) => Result;
export {};

@@ -50,5 +50,5 @@ "use strict";

}
function applyValueAnnotations(plain, annotations, superJson) {
function applyValueAnnotations(plain, annotations) {
traverse(annotations, function (type, path) {
plain = accessDeep_1.setDeep(plain, path, function (v) { return transformer_1.untransformValue(v, type, superJson); });
plain = accessDeep_1.setDeep(plain, path, function (v) { return transformer_1.untransformValue(v, type); });
});

@@ -80,3 +80,3 @@ return plain;

exports.applyReferentialEqualityAnnotations = applyReferentialEqualityAnnotations;
var isDeep = function (object, superJson) {
var isDeep = function (object) {
return is_1.isPlainObject(object) ||

@@ -86,3 +86,3 @@ is_1.isArray(object) ||

is_1.isSet(object) ||
transformer_1.isInstanceOfRegisteredClass(object, superJson);
transformer_1.isInstanceOfRegisteredClass(object);
};

@@ -128,3 +128,3 @@ function addIdentity(object, path, identities) {

exports.generateReferentialEqualityAnnotations = generateReferentialEqualityAnnotations;
var walker = function (object, identities, superJson, path, objectsInThisPath) {
var walker = function (object, identities, path, objectsInThisPath) {
var _a;

@@ -136,4 +136,4 @@ if (path === void 0) { path = []; }

}
if (!isDeep(object, superJson)) {
var transformed_1 = transformer_1.transformValue(object, superJson);
if (!isDeep(object)) {
var transformed_1 = transformer_1.transformValue(object);
if (transformed_1) {

@@ -156,3 +156,3 @@ return {

}
var transformationResult = transformer_1.transformValue(object, superJson);
var transformationResult = transformer_1.transformValue(object);
var transformed = (_a = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a !== void 0 ? _a : object;

@@ -165,3 +165,3 @@ if (!is_1.isPrimitive(object)) {

util_1.forEach(transformed, function (value, index) {
var recursiveResult = exports.walker(value, identities, superJson, __spreadArray(__spreadArray([], __read(path)), [index]), objectsInThisPath);
var recursiveResult = exports.walker(value, identities, __spreadArray(__spreadArray([], __read(path)), [index]), objectsInThisPath);
transformedValue[index] = recursiveResult.transformedValue;

@@ -168,0 +168,0 @@ if (is_1.isArray(recursiveResult.annotations)) {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
exports.Registry = void 0;
var double_indexed_kv_1 = require("./double-indexed-kv");
var debug_1 = __importDefault(require("debug"));
var debug = debug_1["default"]('superjson');
var Registry = /** @class */ (function () {

@@ -25,3 +20,3 @@ function Registry(generateIdentifier) {

if (alreadyRegistered && alreadyRegistered !== value) {
debug("Ambiguous class \"" + identifier + "\", provide a unique identifier.");
console.debug("Ambiguous class \"" + identifier + "\", provide a unique identifier.");
}

@@ -28,0 +23,0 @@ }

@@ -1,2 +0,1 @@

import SuperJSON from '.';
export declare type PrimitiveTypeAnnotation = 'number' | 'undefined' | 'bigint';

@@ -11,8 +10,8 @@ declare type LeafTypeAnnotation = PrimitiveTypeAnnotation | 'regexp' | 'Date' | 'Error';

export declare type TypeAnnotation = SimpleTypeAnnotation | CompositeTypeAnnotation;
export declare function isInstanceOfRegisteredClass(potentialClass: any, superJson: SuperJSON): potentialClass is any;
export declare const transformValue: (value: any, superJson: SuperJSON) => {
export declare function isInstanceOfRegisteredClass(potentialClass: any): potentialClass is any;
export declare const transformValue: (value: any) => {
value: any;
type: TypeAnnotation;
} | undefined;
export declare const untransformValue: (json: any, type: TypeAnnotation, superJson: SuperJSON) => any;
export declare const untransformValue: (json: any, type: TypeAnnotation) => any;
export {};

@@ -37,2 +37,6 @@ "use strict";

var is_1 = require("./is");
var class_registry_1 = require("./class-registry");
var symbol_registry_1 = require("./symbol-registry");
var custom_transformer_registry_1 = require("./custom-transformer-registry");
var error_props_1 = require("./error-props");
var util_1 = require("./util");

@@ -57,3 +61,3 @@ function simpleTransformation(isApplicable, annotation, transform, untransform) {

simpleTransformation(is_1.isDate, 'Date', function (v) { return v.toISOString(); }, function (v) { return new Date(v); }),
simpleTransformation(is_1.isError, 'Error', function (v, superJson) {
simpleTransformation(is_1.isError, 'Error', function (v) {
var baseError = {

@@ -63,11 +67,11 @@ name: v.name,

};
superJson.allowedErrorProps.forEach(function (prop) {
error_props_1.allowedErrorProps.forEach(function (prop) {
baseError[prop] = v[prop];
});
return baseError;
}, function (v, superJson) {
}, function (v) {
var e = new Error(v.message);
e.name = v.name;
e.stack = v.stack;
superJson.allowedErrorProps.forEach(function (prop) {
error_props_1.allowedErrorProps.forEach(function (prop) {
e[prop] = v[prop];

@@ -110,13 +114,13 @@ });

}
var symbolRule = compositeTransformation(function (s, superJson) {
var symbolRule = compositeTransformation(function (s) {
if (is_1.isSymbol(s)) {
var isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
var isRegistered = !!symbol_registry_1.SymbolRegistry.getIdentifier(s);
return isRegistered;
}
return false;
}, function (s, superJson) {
var identifier = superJson.symbolRegistry.getIdentifier(s);
}, function (s) {
var identifier = symbol_registry_1.SymbolRegistry.getIdentifier(s);
return ['symbol', identifier];
}, function (v) { return v.description; }, function (_, a, superJson) {
var value = superJson.symbolRegistry.getValue(a[1]);
}, function (v) { return v.description; }, function (_, a) {
var value = symbol_registry_1.SymbolRegistry.getValue(a[1]);
if (!value) {

@@ -148,5 +152,5 @@ throw new Error('Trying to deserialize unknown symbol');

});
function isInstanceOfRegisteredClass(potentialClass, superJson) {
function isInstanceOfRegisteredClass(potentialClass) {
if (potentialClass === null || potentialClass === void 0 ? void 0 : potentialClass.constructor) {
var isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
var isRegistered = !!class_registry_1.ClassRegistry.getIdentifier(potentialClass.constructor);
return isRegistered;

@@ -157,7 +161,7 @@ }

exports.isInstanceOfRegisteredClass = isInstanceOfRegisteredClass;
var classRule = compositeTransformation(isInstanceOfRegisteredClass, function (clazz, superJson) {
var identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
var classRule = compositeTransformation(isInstanceOfRegisteredClass, function (clazz) {
var identifier = class_registry_1.ClassRegistry.getIdentifier(clazz.constructor);
return ['class', identifier];
}, function (clazz, superJson) {
var allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
}, function (clazz) {
var allowedProps = class_registry_1.ClassRegistry.getAllowedProps(clazz.constructor);
if (!allowedProps) {

@@ -171,4 +175,4 @@ return __assign({}, clazz);

return result;
}, function (v, a, superJson) {
var clazz = superJson.classRegistry.getValue(a[1]);
}, function (v, a) {
var clazz = class_registry_1.ClassRegistry.getValue(a[1]);
if (!clazz) {

@@ -179,12 +183,12 @@ throw new Error('Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564');

});
var customRule = compositeTransformation(function (value, superJson) {
return !!superJson.customTransformerRegistry.findApplicable(value);
}, function (value, superJson) {
var transformer = superJson.customTransformerRegistry.findApplicable(value);
var customRule = compositeTransformation(function (value) {
return !!custom_transformer_registry_1.CustomTransformerRegistry.findApplicable(value);
}, function (value) {
var transformer = custom_transformer_registry_1.CustomTransformerRegistry.findApplicable(value);
return ['custom', transformer.name];
}, function (value, superJson) {
var transformer = superJson.customTransformerRegistry.findApplicable(value);
}, function (value) {
var transformer = custom_transformer_registry_1.CustomTransformerRegistry.findApplicable(value);
return transformer.serialize(value);
}, function (v, a, superJson) {
var transformer = superJson.customTransformerRegistry.findByName(a[1]);
}, function (v, a) {
var transformer = custom_transformer_registry_1.CustomTransformerRegistry.findByName(a[1]);
if (!transformer) {

@@ -196,18 +200,18 @@ throw new Error('Trying to deserialize unknown custom value');

var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
var transformValue = function (value, superJson) {
var transformValue = function (value) {
var applicableCompositeRule = util_1.findArr(compositeRules, function (rule) {
return rule.isApplicable(value, superJson);
return rule.isApplicable(value);
});
if (applicableCompositeRule) {
return {
value: applicableCompositeRule.transform(value, superJson),
type: applicableCompositeRule.annotation(value, superJson)
value: applicableCompositeRule.transform(value),
type: applicableCompositeRule.annotation(value)
};
}
var applicableSimpleRule = util_1.findArr(simpleRules, function (rule) {
return rule.isApplicable(value, superJson);
return rule.isApplicable(value);
});
if (applicableSimpleRule) {
return {
value: applicableSimpleRule.transform(value, superJson),
value: applicableSimpleRule.transform(value),
type: applicableSimpleRule.annotation

@@ -223,13 +227,13 @@ };

});
var untransformValue = function (json, type, superJson) {
var untransformValue = function (json, type) {
if (is_1.isArray(type)) {
switch (type[0]) {
case 'symbol':
return symbolRule.untransform(json, type, superJson);
return symbolRule.untransform(json, type);
case 'class':
return classRule.untransform(json, type, superJson);
return classRule.untransform(json, type);
case 'custom':
return customRule.untransform(json, type, superJson);
return customRule.untransform(json, type);
case 'typed-array':
return typedArrayRule.untransform(json, type, superJson);
return typedArrayRule.untransform(json, type);
default:

@@ -244,3 +248,3 @@ throw new Error('Unknown transformation: ' + type);

}
return transformation.untransform(json, superJson);
return transformation.untransform(json);
}

@@ -247,0 +251,0 @@ };

@@ -6,4 +6,4 @@ import { TypeAnnotation } from './transformer';

};
export declare type PrimitveJSONValue = string | number | boolean | undefined | null;
export declare type JSONValue = PrimitveJSONValue | JSONArray | JSONObject;
export declare type PrimitiveJSONValue = string | number | boolean | undefined | null;
export declare type JSONValue = PrimitiveJSONValue | JSONArray | JSONObject;
export interface JSONArray extends Array<JSONValue> {

@@ -10,0 +10,0 @@ }

{
"version": "1.9.0-0",
"version": "1.9.0",
"license": "MIT",

@@ -21,3 +21,5 @@ "main": "dist/index.js",

"prepack": "yarn build",
"prepare": "husky install"
"prepare": "husky install",
"publish-please": "publish-please",
"prepublishOnly": "publish-please guard"
},

@@ -59,4 +61,2 @@ "importSort": {

"@types/debug": "^4.1.5",
"@types/lodash": "^4.14.168",
"@types/lodash.clonedeep": "^4.5.6",
"@types/mongodb": "^3.6.12",

@@ -68,2 +68,3 @@ "benchmark": "^2.1.4",

"mongodb": "^3.6.6",
"publish-please": "^5.5.2",
"tsdx": "^0.14.1",

@@ -73,4 +74,3 @@ "typescript": "^4.2.4"

"dependencies": {
"debug": "^4.3.1",
"lodash.clonedeep": "^4.5.0"
"copy-anything": "^3.0.2"
},

@@ -77,0 +77,0 @@ "resolutions": {

@@ -11,3 +11,3 @@ <p align="center">

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a href="#contributors"><img src="https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square" alt="All Contributors"/></a>
<a href="#contributors"><img src="https://img.shields.io/badge/all_contributors-19-orange.svg?style=flat-square" alt="All Contributors"/></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->

@@ -97,3 +97,3 @@ <a href="https://www.npmjs.com/package/superjson">

timestamp: "2020-06-20T04:56:50.293Z",
test: "/blitz/",
test: "/superjson/",
};

@@ -120,3 +120,3 @@

```sh
yarn add -D babel-plugin-superjson-next
yarn add babel-plugin-superjson-next
```

@@ -202,3 +202,3 @@

Returns **`string`**.
Returns **`your original value`**.

@@ -264,3 +264,3 @@ ---

<td align="center"><a href="https://github.com/jorisre"><img src="https://avatars1.githubusercontent.com/u/7545547?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joris</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/commits?author=jorisre" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/tomhooijenga"><img src="https://avatars0.githubusercontent.com/u/1853235?v=4?s=100" width="100px;" alt=""/><br /><sub><b>tomhooijenga</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/commits?author=tomhooijenga" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/tomhooijenga"><img src="https://avatars0.githubusercontent.com/u/1853235?v=4?s=100" width="100px;" alt=""/><br /><sub><b>tomhooijenga</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/commits?author=tomhooijenga" title="Code">💻</a> <a href="https://github.com/blitz-js/superjson/issues?q=author%3Atomhooijenga" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://twitter.com/ftonato"><img src="https://avatars2.githubusercontent.com/u/5417662?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ademílson F. Tonato</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/commits?author=ftonato" title="Tests">⚠️</a></td>

@@ -280,2 +280,7 @@ </tr>

<td align="center"><a href="http://goleary.com"><img src="https://avatars.githubusercontent.com/u/16123225?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gabe O'Leary</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/commits?author=goleary" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/binajmen"><img src="https://avatars.githubusercontent.com/u/15611419?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Benjamin</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/commits?author=binajmen" title="Documentation">📖</a></td>
<td align="center"><a href="https://www.linkedin.com/in/icflorescu"><img src="https://avatars.githubusercontent.com/u/581999?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ionut-Cristian Florescu</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/issues?q=author%3Aicflorescu" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/chrisj-back2work"><img src="https://avatars.githubusercontent.com/u/68551954?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Johnson</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/commits?author=chrisj-back2work" title="Documentation">📖</a></td>
<td align="center"><a href="https://nicholaschiang.com"><img src="https://avatars.githubusercontent.com/u/20798889?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nicholas Chiang</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/issues?q=author%3Anicholaschiang" title="Bug reports">🐛</a> <a href="https://github.com/blitz-js/superjson/commits?author=nicholaschiang" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/datner"><img src="https://avatars.githubusercontent.com/u/22598347?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Datner</b></sub></a><br /><a href="https://github.com/blitz-js/superjson/commits?author=datner" title="Code">💻</a></td>
</tr>

@@ -282,0 +287,0 @@ </table>

import { isMap, isArray, isPlainObject, isSet } from './is';
import { includes } from './util';

@@ -13,3 +14,17 @@ const getNthKey = (value: Map<any, any> | Set<any>, n: number): any => {

function validatePath(path: (string | number)[]) {
if (includes(path, '__proto__')) {
throw new Error('__proto__ is not allowed as a property');
}
if (includes(path, 'prototype')) {
throw new Error('prototype is not allowed as a property');
}
if (includes(path, 'constructor')) {
throw new Error('constructor is not allowed as a property');
}
}
export const getDeep = (object: object, path: (string | number)[]): object => {
validatePath(path);
path.forEach(key => {

@@ -27,2 +42,4 @@ object = (object as any)[key];

): any => {
validatePath(path);
if (path.length === 0) {

@@ -29,0 +46,0 @@ return mapper(object);

@@ -9,3 +9,3 @@ import { Registry } from './registry';

export class ClassRegistry extends Registry<Class> {
class _ClassRegistry extends Registry<Class> {
constructor() {

@@ -33,1 +33,3 @@ super(c => c.name);

}
export const ClassRegistry = new _ClassRegistry();

@@ -11,18 +11,18 @@ import { JSONValue } from './types';

export class CustomTransformerRegistry {
private transfomers: Record<string, CustomTransfomer<any, any>> = {};
const transfomers: Record<string, CustomTransfomer<any, any>> = {};
export const CustomTransformerRegistry = {
register<I, O extends JSONValue>(transformer: CustomTransfomer<I, O>) {
this.transfomers[transformer.name] = transformer;
}
transfomers[transformer.name] = transformer;
},
findApplicable<T>(v: T) {
return find(this.transfomers, transformer =>
transformer.isApplicable(v)
) as CustomTransfomer<T, JSONValue> | undefined;
}
return find(transfomers, transformer => transformer.isApplicable(v)) as
| CustomTransfomer<T, JSONValue>
| undefined;
},
findByName(name: string) {
return this.transfomers[name];
}
}
return transfomers[name];
},
};

@@ -1004,17 +1004,60 @@ /* eslint-disable es5/no-for-of */

test('superjson instances are independent of one another', () => {
class Car {}
const s1 = new SuperJSON();
s1.registerClass(Car);
test('prototype pollution - __proto__', () => {
expect(() => {
SuperJSON.parse(
JSON.stringify({
json: {
myValue: 1337,
},
meta: {
referentialEqualities: {
myValue: ['__proto__.x'],
},
},
})
);
}).toThrowErrorMatchingInlineSnapshot(
`"__proto__ is not allowed as a property"`
);
expect((Object.prototype as any).x).toBeUndefined();
});
const s2 = new SuperJSON();
test('prototype pollution - prototype', () => {
expect(() => {
SuperJSON.parse(
JSON.stringify({
json: {
myValue: 1337,
},
meta: {
referentialEqualities: {
myValue: ['prototype.x'],
},
},
})
);
}).toThrowErrorMatchingInlineSnapshot(
`"prototype is not allowed as a property"`
);
});
const value = {
car: new Car(),
};
test('prototype pollution - constructor', () => {
expect(() => {
SuperJSON.parse(
JSON.stringify({
json: {
myValue: 1337,
},
meta: {
referentialEqualities: {
myValue: ['constructor.prototype.x'],
},
},
})
);
}).toThrowErrorMatchingInlineSnapshot(
`"prototype is not allowed as a property"`
);
const res1 = s1.serialize(value);
expect(res1.meta?.values).toEqual({ car: [['class', 'Car']] });
const res2 = s2.serialize(value);
expect(res2.json).toEqual(value);
expect((Object.prototype as any).x).toBeUndefined();
});
import { SuperJSONResult, SuperJSONValue, Class, JSONValue } from './types';
import { ClassRegistry, RegisterOptions } from './class-registry';
import { Registry } from './registry';
import { SymbolRegistry } from './symbol-registry';
import {

@@ -8,2 +8,3 @@ CustomTransfomer,

} from './custom-transformer-registry';
import { allowErrorProps } from './error-props';
import {

@@ -15,116 +16,80 @@ walker,

} from './plainer';
import cloneDeep from 'lodash.clonedeep';
import { copy } from 'copy-anything';
export default class SuperJSON {
serialize(object: SuperJSONValue): SuperJSONResult {
const identities = new Map<any, any[][]>();
const output = walker(object, identities, this);
const res: SuperJSONResult = {
json: output.transformedValue,
export const serialize = (object: SuperJSONValue): SuperJSONResult => {
const identities = new Map<any, any[][]>();
const output = walker(object, identities);
const res: SuperJSONResult = {
json: output.transformedValue,
};
if (output.annotations) {
res.meta = {
...res.meta,
values: output.annotations,
};
}
if (output.annotations) {
res.meta = {
...res.meta,
values: output.annotations,
};
}
const equalityAnnotations = generateReferentialEqualityAnnotations(
identities
);
if (equalityAnnotations) {
res.meta = {
...res.meta,
referentialEqualities: equalityAnnotations,
};
}
return res;
const equalityAnnotations = generateReferentialEqualityAnnotations(
identities
);
if (equalityAnnotations) {
res.meta = {
...res.meta,
referentialEqualities: equalityAnnotations,
};
}
deserialize<T = unknown>(payload: SuperJSONResult): T {
const { json, meta } = payload;
return res;
};
let result: T = cloneDeep(json) as any;
export const deserialize = <T = unknown>(payload: SuperJSONResult): T => {
const { json, meta } = payload;
if (meta?.values) {
result = applyValueAnnotations(result, meta.values, this);
}
let result: T = copy(json) as any;
if (meta?.referentialEqualities) {
result = applyReferentialEqualityAnnotations(
result,
meta.referentialEqualities
);
}
return result;
if (meta?.values) {
result = applyValueAnnotations(result, meta.values);
}
stringify(object: SuperJSONValue): string {
return JSON.stringify(this.serialize(object));
if (meta?.referentialEqualities) {
result = applyReferentialEqualityAnnotations(
result,
meta.referentialEqualities
);
}
parse<T = unknown>(string: string): T {
return this.deserialize(JSON.parse(string));
}
return result;
};
readonly classRegistry = new ClassRegistry();
registerClass(v: Class, options?: RegisterOptions | string) {
this.classRegistry.register(v, options);
}
export const stringify = (object: SuperJSONValue): string =>
JSON.stringify(serialize(object));
readonly symbolRegistry = new Registry<Symbol>(s => s.description ?? '');
registerSymbol(v: Symbol, identifier?: string) {
this.symbolRegistry.register(v, identifier);
}
export const parse = <T = unknown>(string: string): T =>
deserialize(JSON.parse(string));
readonly customTransformerRegistry = new CustomTransformerRegistry();
registerCustom<I, O extends JSONValue>(
transformer: Omit<CustomTransfomer<I, O>, 'name'>,
name: string
) {
this.customTransformerRegistry.register({
name,
...transformer,
});
}
const registerClass = (v: Class, options?: RegisterOptions | string) =>
ClassRegistry.register(v, options);
readonly allowedErrorProps: string[] = [];
allowErrorProps(...props: string[]) {
this.allowedErrorProps.push(...props);
}
const registerSymbol = (v: Symbol, identifier?: string) =>
SymbolRegistry.register(v, identifier);
private static defaultInstance = new SuperJSON();
static serialize = SuperJSON.defaultInstance.serialize.bind(
SuperJSON.defaultInstance
);
static deserialize = SuperJSON.defaultInstance.deserialize.bind(
SuperJSON.defaultInstance
);
static stringify = SuperJSON.defaultInstance.stringify.bind(
SuperJSON.defaultInstance
);
static parse = SuperJSON.defaultInstance.parse.bind(
SuperJSON.defaultInstance
);
static registerClass = SuperJSON.defaultInstance.registerClass.bind(
SuperJSON.defaultInstance
);
static registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(
SuperJSON.defaultInstance
);
static registerCustom = SuperJSON.defaultInstance.registerCustom.bind(
SuperJSON.defaultInstance
);
static allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(
SuperJSON.defaultInstance
);
}
const registerCustom = <I, O extends JSONValue>(
transformer: Omit<CustomTransfomer<I, O>, 'name'>,
name: string
) =>
CustomTransformerRegistry.register({
name,
...transformer,
});
export const serialize = SuperJSON.serialize;
export const deserialize = SuperJSON.deserialize;
export const stringify = SuperJSON.stringify;
export const parse = SuperJSON.parse;
export default {
stringify,
parse,
serialize,
deserialize,
registerClass,
registerSymbol,
registerCustom,
allowErrorProps,
};

@@ -14,2 +14,3 @@ const getType = (payload: any): string =>

if (Object.getPrototypeOf(payload) === null) return true;
if (payload === Object.prototype) return false;
return (

@@ -16,0 +17,0 @@ payload.constructor === Object &&

@@ -1,2 +0,1 @@

import SuperJSON from '.';
import { walker } from './plainer';

@@ -11,4 +10,3 @@

},
new Map(),
new SuperJSON()
new Map()
)

@@ -15,0 +13,0 @@ ).toEqual({

@@ -19,3 +19,2 @@ import {

import { getDeep, setDeep } from './accessDeep';
import SuperJSON from '.';

@@ -56,7 +55,6 @@ type Tree<T> = InnerNode<T> | Leaf<T>;

plain: any,
annotations: MinimisedTree<TypeAnnotation>,
superJson: SuperJSON
annotations: MinimisedTree<TypeAnnotation>
) {
traverse(annotations, (type, path) => {
plain = setDeep(plain, path, v => untransformValue(v, type, superJson));
plain = setDeep(plain, path, v => untransformValue(v, type));
});

@@ -95,3 +93,3 @@

const isDeep = (object: any, superJson: SuperJSON): boolean =>
const isDeep = (object: any): boolean =>
isPlainObject(object) ||

@@ -101,3 +99,3 @@ isArray(object) ||

isSet(object) ||
isInstanceOfRegisteredClass(object, superJson);
isInstanceOfRegisteredClass(object);

@@ -160,3 +158,2 @@ function addIdentity(object: any, path: any[], identities: Map<any, any[][]>) {

identities: Map<any, any[][]>,
superJson: SuperJSON,
path: any[] = [],

@@ -169,4 +166,4 @@ objectsInThisPath: any[] = []

if (!isDeep(object, superJson)) {
const transformed = transformValue(object, superJson);
if (!isDeep(object)) {
const transformed = transformValue(object);
if (transformed) {

@@ -190,3 +187,3 @@ return {

const transformationResult = transformValue(object, superJson);
const transformationResult = transformValue(object);
const transformed = transformationResult?.value ?? object;

@@ -205,3 +202,2 @@

identities,
superJson,
[...path, index],

@@ -208,0 +204,0 @@ objectsInThisPath

@@ -1,2 +0,1 @@

import debug from 'debug';
import { Registry } from './registry';

@@ -20,4 +19,3 @@ import { Class } from './types';

debug.enable('superjson');
const warnSpy = jest.spyOn(process.stderr, 'write');
const warnSpy = jest.spyOn(console, 'debug');

@@ -24,0 +22,0 @@ registry.register(class Car {});

import { DoubleIndexedKV } from './double-indexed-kv';
import createDebug from 'debug';
const debug = createDebug('superjson');
export class Registry<T> {

@@ -23,3 +20,5 @@ private kv = new DoubleIndexedKV<string, T>();

if (alreadyRegistered && alreadyRegistered !== value) {
debug(`Ambiguous class "${identifier}", provide a unique identifier.`);
console.debug(
`Ambiguous class "${identifier}", provide a unique identifier.`
);
}

@@ -26,0 +25,0 @@ }

@@ -16,4 +16,7 @@ import {

} from './is';
import { ClassRegistry } from './class-registry';
import { SymbolRegistry } from './symbol-registry';
import { CustomTransformerRegistry } from './custom-transformer-registry';
import { allowedErrorProps } from './error-props';
import { findArr } from './util';
import SuperJSON from '.';

@@ -40,6 +43,6 @@ export type PrimitiveTypeAnnotation = 'number' | 'undefined' | 'bigint';

function simpleTransformation<I, O, A extends SimpleTypeAnnotation>(
isApplicable: (v: any, superJson: SuperJSON) => v is I,
isApplicable: (v: any) => v is I,
annotation: A,
transform: (v: I, superJson: SuperJSON) => O,
untransform: (v: O, superJson: SuperJSON) => I
transform: (v: I) => O,
untransform: (v: O) => I
) {

@@ -85,3 +88,3 @@ return {

'Error',
(v, superJson) => {
v => {
const baseError: any = {

@@ -92,3 +95,3 @@ name: v.name,

superJson.allowedErrorProps.forEach(prop => {
allowedErrorProps.forEach(prop => {
baseError[prop] = (v as any)[prop];

@@ -99,3 +102,3 @@ });

},
(v, superJson) => {
v => {
const e = new Error(v.message);

@@ -105,3 +108,3 @@ e.name = v.name;

superJson.allowedErrorProps.forEach(prop => {
allowedErrorProps.forEach(prop => {
(e as any)[prop] = v[prop];

@@ -168,6 +171,6 @@ });

function compositeTransformation<I, O, A extends CompositeTypeAnnotation>(
isApplicable: (v: any, superJson: SuperJSON) => v is I,
annotation: (v: I, superJson: SuperJSON) => A,
transform: (v: I, superJson: SuperJSON) => O,
untransform: (v: O, a: A, superJson: SuperJSON) => I
isApplicable: (v: any) => v is I,
annotation: (v: I) => A,
transform: (v: I) => O,
untransform: (v: O, a: A) => I
) {

@@ -183,5 +186,5 @@ return {

const symbolRule = compositeTransformation(
(s, superJson): s is Symbol => {
(s): s is Symbol => {
if (isSymbol(s)) {
const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
const isRegistered = !!SymbolRegistry.getIdentifier(s);
return isRegistered;

@@ -191,9 +194,9 @@ }

},
(s, superJson) => {
const identifier = superJson.symbolRegistry.getIdentifier(s);
s => {
const identifier = SymbolRegistry.getIdentifier(s);
return ['symbol', identifier!];
},
v => v.description,
(_, a, superJson) => {
const value = superJson.symbolRegistry.getValue(a[1]);
(_, a) => {
const value = SymbolRegistry.getValue(a[1]);
if (!value) {

@@ -237,7 +240,6 @@ throw new Error('Trying to deserialize unknown symbol');

export function isInstanceOfRegisteredClass(
potentialClass: any,
superJson: SuperJSON
potentialClass: any
): potentialClass is any {
if (potentialClass?.constructor) {
const isRegistered = !!superJson.classRegistry.getIdentifier(
const isRegistered = !!ClassRegistry.getIdentifier(
potentialClass.constructor

@@ -252,10 +254,8 @@ );

isInstanceOfRegisteredClass,
(clazz, superJson) => {
const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
clazz => {
const identifier = ClassRegistry.getIdentifier(clazz.constructor);
return ['class', identifier!];
},
(clazz, superJson) => {
const allowedProps = superJson.classRegistry.getAllowedProps(
clazz.constructor
);
clazz => {
const allowedProps = ClassRegistry.getAllowedProps(clazz.constructor);
if (!allowedProps) {

@@ -271,4 +271,4 @@ return { ...clazz };

},
(v, a, superJson) => {
const clazz = superJson.classRegistry.getValue(a[1]);
(v, a) => {
const clazz = ClassRegistry.getValue(a[1]);

@@ -286,19 +286,15 @@ if (!clazz) {

const customRule = compositeTransformation(
(value, superJson): value is any => {
return !!superJson.customTransformerRegistry.findApplicable(value);
(value): value is any => {
return !!CustomTransformerRegistry.findApplicable(value);
},
(value, superJson) => {
const transformer = superJson.customTransformerRegistry.findApplicable(
value
)!;
value => {
const transformer = CustomTransformerRegistry.findApplicable(value)!;
return ['custom', transformer.name];
},
(value, superJson) => {
const transformer = superJson.customTransformerRegistry.findApplicable(
value
)!;
value => {
const transformer = CustomTransformerRegistry.findApplicable(value)!;
return transformer.serialize(value);
},
(v, a, superJson) => {
const transformer = superJson.customTransformerRegistry.findByName(a[1]);
(v, a) => {
const transformer = CustomTransformerRegistry.findByName(a[1]);
if (!transformer) {

@@ -314,12 +310,11 @@ throw new Error('Trying to deserialize unknown custom value');

export const transformValue = (
value: any,
superJson: SuperJSON
value: any
): { value: any; type: TypeAnnotation } | undefined => {
const applicableCompositeRule = findArr(compositeRules, rule =>
rule.isApplicable(value, superJson)
rule.isApplicable(value)
);
if (applicableCompositeRule) {
return {
value: applicableCompositeRule.transform(value as never, superJson),
type: applicableCompositeRule.annotation(value, superJson),
value: applicableCompositeRule.transform(value as never),
type: applicableCompositeRule.annotation(value),
};

@@ -329,3 +324,3 @@ }

const applicableSimpleRule = findArr(simpleRules, rule =>
rule.isApplicable(value, superJson)
rule.isApplicable(value)
);

@@ -335,3 +330,3 @@

return {
value: applicableSimpleRule.transform(value as never, superJson),
value: applicableSimpleRule.transform(value as never),
type: applicableSimpleRule.annotation,

@@ -349,17 +344,13 @@ };

export const untransformValue = (
json: any,
type: TypeAnnotation,
superJson: SuperJSON
) => {
export const untransformValue = (json: any, type: TypeAnnotation) => {
if (isArray(type)) {
switch (type[0]) {
case 'symbol':
return symbolRule.untransform(json, type, superJson);
return symbolRule.untransform(json, type);
case 'class':
return classRule.untransform(json, type, superJson);
return classRule.untransform(json, type);
case 'custom':
return customRule.untransform(json, type, superJson);
return customRule.untransform(json, type);
case 'typed-array':
return typedArrayRule.untransform(json, type, superJson);
return typedArrayRule.untransform(json, type);
default:

@@ -374,4 +365,4 @@ throw new Error('Unknown transformation: ' + type);

return transformation.untransform(json as never, superJson);
return transformation.untransform(json as never);
}
};

@@ -6,5 +6,5 @@ import { TypeAnnotation } from './transformer';

export type PrimitveJSONValue = string | number | boolean | undefined | null;
export type PrimitiveJSONValue = string | number | boolean | undefined | null;
export type JSONValue = PrimitveJSONValue | JSONArray | JSONObject;
export type JSONValue = PrimitiveJSONValue | JSONArray | JSONObject;

@@ -11,0 +11,0 @@ export interface JSONArray extends Array<JSONValue> {}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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