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