UNPKG

2.92 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/serialize-javascript`
3
4# Summary
5This package contains type definitions for serialize-javascript (https://github.com/yahoo/serialize-javascript).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/serialize-javascript.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/serialize-javascript/index.d.ts)
10````ts
11// Type definitions for serialize-javascript 5.0
12// Project: https://github.com/yahoo/serialize-javascript
13// Definitions by: Pochodaydayup <https://github.com/Pochodaydayup>
14// undefined-moe <https://github.com/undefined-moe>
15// Piotr Błażejewicz <https://github.com/peterblazejewicz>
16// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
17
18declare namespace serializeJavascript {
19 interface SerializeJSOptions {
20 /**
21 * This option is the same as the space argument that can be passed to JSON.stringify.
22 * It can be used to add whitespace and indentation to the serialized output to make it more readable.
23 */
24 space?: string | number | undefined;
25 /**
26 * This option is a signal to serialize() that the object being serialized does not contain any function or regexps values.
27 * This enables a hot-path that allows serialization to be over 3x faster.
28 * If you're serializing a lot of data, and know its pure JSON, then you can enable this option for a speed-up.
29 */
30 isJSON?: boolean | undefined;
31 /**
32 * This option is to signal serialize() that we want to do a straight conversion, without the XSS protection.
33 * This options needs to be explicitly set to true. HTML characters and JavaScript line terminators will not be escaped.
34 * You will have to roll your own.
35 */
36 unsafe?: true | undefined;
37 /**
38 * This option is to signal serialize() that we do not want serialize JavaScript function.
39 * Just treat function like JSON.stringify do, but other features will work as expected.
40 */
41 ignoreFunction?: boolean | undefined;
42 }
43}
44
45/**
46 * Serialize JavaScript to a superset of JSON that includes regular expressions and functions.
47 * @param input data to serialize
48 * @param options optional object
49 * @returns serialized data
50 */
51declare function serializeJavascript(
52 input: any,
53 options?: serializeJavascript.SerializeJSOptions | number | string,
54): string;
55
56export = serializeJavascript;
57
58````
59
60### Additional Details
61 * Last updated: Thu, 23 Dec 2021 23:35:48 GMT
62 * Dependencies: none
63 * Global values: none
64
65# Credits
66These definitions were written by [Pochodaydayup](https://github.com/Pochodaydayup), [undefined-moe](https://github.com/undefined-moe), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).
67
\No newline at end of file