@types/serialize-javascript

  • Version 5.0.1
  • Published
  • 7.72 kB
  • No dependencies
  • MIT license

Install

npm i @types/serialize-javascript
yarn add @types/serialize-javascript
pnpm add @types/serialize-javascript

Overview

TypeScript definitions for serialize-javascript

Index

Functions

function serializeJavascript

serializeJavascript: (
input: any,
options?: serializeJavascript.SerializeJSOptions | number | string
) => string;
  • Serialize JavaScript to a superset of JSON that includes regular expressions and functions.

    Parameter input

    data to serialize

    Parameter options

    optional object

    Returns

    serialized data

Interfaces

interface SerializeJSOptions

interface SerializeJSOptions {}

    property ignoreFunction

    ignoreFunction?: boolean | undefined;
    • This option is to signal serialize() that we do not want serialize JavaScript function. Just treat function like JSON.stringify do, but other features will work as expected.

    property isJSON

    isJSON?: boolean | undefined;
    • This option is a signal to serialize() that the object being serialized does not contain any function or regexps values. This enables a hot-path that allows serialization to be over 3x faster. If you're serializing a lot of data, and know its pure JSON, then you can enable this option for a speed-up.

    property space

    space?: string | number | undefined;
    • This option is the same as the space argument that can be passed to JSON.stringify. It can be used to add whitespace and indentation to the serialized output to make it more readable.

    property unsafe

    unsafe?: true | undefined;
    • This option is to signal serialize() that we want to do a straight conversion, without the XSS protection. This options needs to be explicitly set to true. HTML characters and JavaScript line terminators will not be escaped. You will have to roll your own.

    Package Files (1)

    Dependencies (0)

    No dependencies.

    Dev Dependencies (0)

    No dev dependencies.

    Peer Dependencies (0)

    No peer dependencies.

    Badge

    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/serialize-javascript.

    • Markdown
      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/serialize-javascript)
    • HTML
      <a href="https://www.jsdocs.io/package/@types/serialize-javascript"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>