payload-is
Version:
A comprehensive TypeScript/JavaScript type checking library providing functions to check data types, collections, primitives, and built-in objects
1 lines • 5.44 kB
Source Map (JSON)
{"version":3,"file":"type.cjs","sources":["../../src/type.ts"],"sourcesContent":["export type PrimitiveType =\n | boolean\n | number\n | string\n | bigint\n | symbol\n | null\n | undefined;\nexport type PlainObject = Record<PropertyKey, any>;\nexport type AnyFunction = (...args: any[]) => any;\nexport type AnyAsyncFunction = (...args: any[]) => Promise<any>;\nexport type AnyClass = new (...args: any[]) => any;\n\nexport type DataTypeResult =\n // primitive\n | { type: \"undefined\"; data: undefined }\n | { type: \"number\"; data: number }\n | { type: \"bigint\"; data: bigint }\n | { type: \"boolean\"; data: boolean }\n | { type: \"string\"; data: string }\n | { type: \"symbol\"; data: symbol }\n | { type: \"null\"; data: null }\n // function\n | { type: \"function\"; subtype: \"Function\"; data: AnyFunction }\n | { type: \"function\"; subtype: \"AsyncFunction\"; data: AnyAsyncFunction }\n | { type: \"function\"; subtype: \"GeneratorFunction\"; data: GeneratorFunction }\n | {\n type: \"function\";\n subtype: \"AsyncGeneratorFunction\";\n data: AsyncGeneratorFunction;\n }\n // iterator\n | {\n type: \"object\";\n subtype: \"Segmenter String Iterator\";\n data: Intl.SegmentIterator<Intl.SegmentData>;\n }\n | {\n type: \"object\";\n subtype: \"RegExp String Iterator\";\n data: RegExpStringIterator<RegExpMatchArray>;\n }\n | {\n type: \"object\";\n subtype: \"String Iterator\";\n data: StringIterator<string>;\n }\n | { type: \"object\"; subtype: \"Array Iterator\"; data: ArrayIterator<unknown> }\n | { type: \"object\"; subtype: \"Map Iterator\"; data: MapIterator<unknown> }\n | { type: \"object\"; subtype: \"Set Iterator\"; data: SetIterator<unknown> }\n | { type: \"object\"; subtype: \"Generator\"; data: Generator }\n | { type: \"object\"; subtype: \"Iterator\"; data: Iterator<unknown> }\n | { type: \"object\"; subtype: \"AsyncGenerator\"; data: AsyncGenerator }\n | {\n type: \"object\";\n subtype: \"AsyncIterator\";\n data: AsyncIterator<unknown>;\n }\n // buffer\n | { type: \"object\"; subtype: \"ArrayBuffer\"; data: ArrayBuffer }\n | { type: \"object\"; subtype: \"SharedArrayBuffer\"; data: SharedArrayBuffer }\n | { type: \"object\"; subtype: \"DataView\"; data: DataView }\n | { type: \"object\"; subtype: \"Int8Array\"; data: Int8Array }\n | { type: \"object\"; subtype: \"Uint8Array\"; data: Uint8Array }\n | {\n type: \"object\";\n subtype: \"Uint8ClampedArray\";\n data: Uint8ClampedArray;\n }\n | { type: \"object\"; subtype: \"Int16Array\"; data: Int16Array }\n | { type: \"object\"; subtype: \"Uint16Array\"; data: Uint16Array }\n | { type: \"object\"; subtype: \"Int32Array\"; data: Int32Array }\n | { type: \"object\"; subtype: \"Uint32Array\"; data: Uint32Array }\n | { type: \"object\"; subtype: \"Float32Array\"; data: Float32Array }\n | { type: \"object\"; subtype: \"Float64Array\"; data: Float64Array }\n | { type: \"object\"; subtype: \"BigInt64Array\"; data: BigInt64Array }\n | { type: \"object\"; subtype: \"BigUint64Array\"; data: BigUint64Array }\n // object\n | { type: \"object\"; subtype: \"String\"; data: String }\n | { type: \"object\"; subtype: \"Number\"; data: Number }\n | { type: \"object\"; subtype: \"BigInt\"; data: BigInt }\n | { type: \"object\"; subtype: \"Boolean\"; data: Boolean }\n | { type: \"object\"; subtype: \"Symbol\"; data: Symbol }\n | { type: \"object\"; subtype: \"Error\"; data: Error }\n | { type: \"object\"; subtype: \"Array\"; data: unknown[] }\n | { type: \"object\"; subtype: \"Set\"; data: Set<unknown> }\n | { type: \"object\"; subtype: \"Map\"; data: Map<unknown, unknown> }\n | { type: \"object\"; subtype: \"WeakSet\"; data: WeakSet<WeakKey> }\n | { type: \"object\"; subtype: \"WeakMap\"; data: WeakMap<WeakKey, unknown> }\n | { type: \"object\"; subtype: \"WeakRef\"; data: WeakRef<WeakKey> }\n | { type: \"object\"; subtype: \"Promise\"; data: Promise<unknown> }\n | { type: \"object\"; subtype: \"Date\"; data: Date }\n | { type: \"object\"; subtype: \"RegExp\"; data: RegExp }\n | { type: \"object\"; subtype: \"URL\"; data: URL }\n | { type: \"object\"; subtype: \"URLSearchParams\"; data: URLSearchParams }\n | { type: \"object\"; subtype: \"File\"; data: File }\n | { type: \"object\"; subtype: \"Blob\"; data: Blob }\n | { type: \"object\"; subtype: \"FormData\"; data: FormData }\n | { type: \"object\"; subtype: \"Headers\"; data: Headers }\n | { type: \"object\"; subtype: \"Request\"; data: Request }\n | { type: \"object\"; subtype: \"Response\"; data: Response }\n | { type: \"object\"; subtype: \"Arguments\"; data: IArguments }\n | { type: \"object\"; subtype: \"Atomics\"; data: Atomics }\n | { type: \"object\"; subtype: \"JSON\"; data: JSON }\n | { type: \"object\"; subtype: \"Reflect\"; data: typeof Reflect }\n | {\n type: \"object\";\n subtype: \"FinalizationRegistry\";\n data: FinalizationRegistry<unknown>;\n }\n | { type: \"object\"; subtype: \"Object\"; data: object };\n\nexport function getTag(payload: unknown): string {\n return Object.prototype.toString.call(payload).slice(8, -1);\n}\n\nexport const getType = getTag;\n"],"names":[],"mappings":";;AAgHO,SAAS,OAAO,OAA0B,EAAA;AAC/C,EAAO,OAAA,MAAA,CAAO,UAAU,QAAS,CAAA,IAAA,CAAK,OAAO,CAAE,CAAA,KAAA,CAAM,GAAG,EAAE,CAAA;AAC5D;AAEO,MAAM,OAAU,GAAA;;;;;"}