stdjs
A collection of useful utility functions for JavaScript projects.
Installation
npm install stdjs --save
API
isBoolean(value: any): boolean
;
isCircular(value: any): boolean
;
isFinite(value: any): boolean
;
isNumber(value: any): boolean
;
isObject(value: any): boolean
;
isString(value: any): boolean
;
isUndefined(value: any): boolean
;
stringify(value: any, options?: StringifierOptions = {}): string
This function converts a JavaScript value to a well-formatted JSON string.
;
options
parameter
Type of type StringifierOptions = indentation?: string; newline?: string; onBeforeElement?: Array<string>; onBeforeProperty?: Array<string>;;
options
parameter
Default values for indentation = ' 'newline = '\n'onBeforeElement = onBeforeProperty =
Example
Program:
const jsonString = ; console;
Output:
"a": "foo" // This is a comment for an element! "bar" "baz" // This is a comment for a property! "b": 123
trimBlank(value: string): string
;