UNPKG

surrial

Version:

Serialize anything. This is surreal!

22 lines (21 loc) 1.3 kB
import ClassConstructor from './class-constructor'; export * from './surrializable'; /** * A surrial template tag, useful for building templates strings while enforcing the values to be serialized using surrial. * @param templateLiterals The template literals * @param values The values to be serialized using surrial */ export declare function surrial(templateLiterals: TemplateStringsArray, ...values: unknown[]): string; /** * Deserializes a string into it's javascript equivalent. CAUTION! Evaluates the string in the current javascript engine * (`eval` or one of its friends). Be sure the `serializedThing` comes from a trusted source! * @param serializedThing The string to deserialize * @param knownClasses A list of known classes used to provide as constructor functions */ export declare function deserialize<T = any>(serializedThing: string, knownClasses?: ClassConstructor[]): T; /** * Serializes the thing to a javascript string. This is NOT necessarily a JSON string, but will be valid javascript. * @param thing The thing to be serialized * @param knownClasses the classes of which instances are serialized as constructor calls (for example "new Person('Henry')"). */ export declare function serialize(thing: any, knownClasses?: ReadonlyArray<ClassConstructor>): string;