typeson
Version:
Preserves types over JSON, BSON or socket.io
99 lines • 2.45 kB
TypeScript
export type Primitive = null | boolean | number | string;
export type JSON = Primitive | Primitive[] | {
[key: string]: JSON;
};
export type NestedObject = {
[key: string]: NestedObject | any;
};
export type ObjectTypeString = "null" | "array" | "undefined" | "boolean" | "number" | "string" | "object" | "symbol" | "bigint" | "function";
/**
*
* @param {any} val
* @returns {boolean}
*/
export function isPlainObject(val: any): boolean;
/**
*
* @param {any} v
* @returns {boolean}
*/
export function isObject(v: any): boolean;
/**
*
* @param {any} val
* @returns {boolean}
*/
export function isUserObject(val: any): boolean;
/**
* This function is dependent on both constructors
* being identical so any minimization is expected of both.
* @param {any} a
* @param {({__typeson__type__?: string} & Function)|null} b
* @returns {boolean}
*/
export function hasConstructorOf(a: any, b: ({
__typeson__type__?: string;
} & Function) | null): boolean;
/**
* Second argument not in use internally, but provided for utility.
* @param {any} v
* @param {boolean} [catchCheck]
* @returns {boolean}
*/
export function isThenable(v: any, catchCheck?: boolean): boolean;
/**
*
* @param {any} val
* @returns {string}
*/
export function toStringTag(val: any): string;
/**
*
* @param {string} keyPathComponent
* @returns {string}
*/
export function escapeKeyPathComponent(keyPathComponent: string): string;
/**
*
* @param {string} keyPathComponent
* @returns {string}
*/
export function unescapeKeyPathComponent(keyPathComponent: string): string;
/**
* @typedef {null|boolean|number|string} Primitive
*/
/**
* @typedef {Primitive|Primitive[]|{[key: string]: JSON}} JSON
*/
/**
* @param {any} obj
* @param {string} keyPath
* @throws {TypeError}
* @returns {any}
*/
export function getByKeyPath(obj: any, keyPath: string): any;
/**
* @typedef {{
* [key: string]: NestedObject|any
* }} NestedObject
*/
/**
*
* @param {unknown} obj
* @param {string} keyPath
* @param {any} value
* @throws {TypeError}
* @returns {any}
*/
export function setAtKeyPath(obj: unknown, keyPath: string, value: any): any;
/**
* @typedef {"null"|"array"|"undefined"|"boolean"|"number"|"string"|
* "object"|"symbol"|"bigint"|"function"} ObjectTypeString
*/
/**
*
* @param {any} value
* @returns {ObjectTypeString}
*/
export function getJSONType(value: any): ObjectTypeString;
//# sourceMappingURL=classMethods.d.ts.map