mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 12:11:47 +00:00
add definitions for serialize-javascript, detect-port, and react-router-config. updated react-helmet
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
// Type definitions for serialize-javascript 1.3
|
||||
// Project: https://github.com/yahoo/serialize-javascript
|
||||
// Definitions by: François Nguyen <https://github.com/lith-light-g>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace serializeJavascript {
|
||||
interface SerializeJSOptions {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
space?: string | number | 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.
|
||||
*/
|
||||
isJSON?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize JavaScript to a superset of JSON that includes regular expressions and functions.
|
||||
* @param {any} input data to serialize
|
||||
* @param {serializeJavascript.SerializeJSOptions} options optional object
|
||||
* @returns {string} serialized data
|
||||
*/
|
||||
declare function serializeJavascript(input: any, options?: serializeJavascript.SerializeJSOptions): string;
|
||||
export = serializeJavascript;
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as serialize from "serialize-javascript";
|
||||
|
||||
const obj: any = {
|
||||
str: "string",
|
||||
num: 0,
|
||||
obj: { foo: "foo" },
|
||||
arr: [1, 2, 3],
|
||||
bool: true,
|
||||
nil: null,
|
||||
undef: undefined,
|
||||
|
||||
fn: function echo(arg: any) { return arg; },
|
||||
re: /([^\s]+)/g
|
||||
};
|
||||
|
||||
serialize(obj);
|
||||
serialize(obj, { space: 2 });
|
||||
serialize(obj, { space: "\t" });
|
||||
serialize(obj, { isJSON: true });
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"serialize-javascript-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user