mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
🐣🐇🐣 new package: kind-of 🎅 (#34879)
* npx dts-gen -m kind-of --dt * drafted types for kind-of * reordered overloads * added more overloads * fixed linting issues * npx prettier --write .\types\kind-of\** * updated teste cases * clarified edge-cases * work around banned types
This commit is contained in:
committed by
Pranav Senthilnathan
parent
4d5fbe2383
commit
63477193da
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Type definitions for kind-of 6.0
|
||||
// Project: https://github.com/jonschlinkert/kind-of
|
||||
// Definitions by: Claas Ahlrichs <https://github.com/claasahl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.7
|
||||
/// <reference types="node" />
|
||||
|
||||
export = kind_of;
|
||||
|
||||
declare function kind_of(thing: undefined): "undefined";
|
||||
declare function kind_of(thing: null): "null";
|
||||
declare function kind_of(thing: boolean): "boolean";
|
||||
declare function kind_of(thing: Buffer): "buffer";
|
||||
declare function kind_of(thing: number): "number";
|
||||
declare function kind_of(thing: string): "string";
|
||||
declare function kind_of(thing: typeof arguments): "arguments";
|
||||
declare function kind_of(thing: Date): "date";
|
||||
declare function kind_of(thing: any[]): "array";
|
||||
declare function kind_of(thing: RegExp): "regexp";
|
||||
declare function kind_of(thing: Error): "error";
|
||||
declare function kind_of(
|
||||
thing: Iterator<any>
|
||||
):
|
||||
| "generator"
|
||||
| "stringiterator"
|
||||
| "arrayiterator"
|
||||
| "mapiterator"
|
||||
| "setiterator";
|
||||
declare function kind_of(
|
||||
thing: (...args: any[]) => any
|
||||
): "function" | "generatorfunction";
|
||||
declare function kind_of(thing: symbol): "symbol";
|
||||
declare function kind_of(thing: Promise<any>): "promise";
|
||||
declare function kind_of(thing: Map<any, any>): "map";
|
||||
declare function kind_of(thing: WeakMap<any, any>): "weakmap";
|
||||
declare function kind_of(thing: Set<any>): "set";
|
||||
declare function kind_of(thing: WeakSet<any>): "weakset";
|
||||
declare function kind_of(thing: Int8Array): "int8array";
|
||||
declare function kind_of(thing: Uint8Array): "uint8array";
|
||||
declare function kind_of(thing: Uint8ClampedArray): "uint8clampedarray";
|
||||
declare function kind_of(thing: Int16Array): "int16array";
|
||||
declare function kind_of(thing: Uint16Array): "uint16array";
|
||||
declare function kind_of(thing: Int32Array): "int32array";
|
||||
declare function kind_of(thing: Uint32Array): "uint32array";
|
||||
declare function kind_of(thing: Float32Array): "float32array";
|
||||
declare function kind_of(thing: Float64Array): "float64array";
|
||||
declare function kind_of(thing: any): string;
|
||||
@@ -0,0 +1,59 @@
|
||||
import kindOf from "kind-of";
|
||||
|
||||
function sampleFunction() {
|
||||
kindOf(arguments);
|
||||
// => 'arguments'
|
||||
}
|
||||
|
||||
function* sampleGeneratorFunction() {
|
||||
yield true;
|
||||
}
|
||||
|
||||
kindOf(undefined) === 'undefined';
|
||||
kindOf(null) === 'null';
|
||||
kindOf(true) === 'boolean';
|
||||
kindOf(false) === 'boolean';
|
||||
kindOf(Buffer.alloc(42)) === 'buffer';
|
||||
kindOf(42) === 'number';
|
||||
kindOf(Number.prototype) === 'number';
|
||||
kindOf("str") === 'string';
|
||||
kindOf(String.prototype) === 'string';
|
||||
kindOf(`${42 - 23}`) === 'string';
|
||||
kindOf({}) === 'object';
|
||||
kindOf(Object.create(null)) === 'object';
|
||||
kindOf(Object.prototype) === 'object';
|
||||
kindOf(new class Test {}()) === 'object';
|
||||
kindOf(new Date()) === 'date';
|
||||
kindOf([1, 2, 3]) === 'array';
|
||||
kindOf(/foo/) === 'regexp';
|
||||
kindOf(new RegExp("foo")) === 'regexp';
|
||||
kindOf(new Error("error")) === 'error';
|
||||
kindOf(() => {}) === 'function';
|
||||
kindOf(sampleFunction) === 'function';
|
||||
kindOf(sampleGeneratorFunction) === 'generatorfunction';
|
||||
kindOf(function*(): IterableIterator<any> {}) === 'generatorfunction';
|
||||
kindOf(sampleGeneratorFunction()) === 'generator';
|
||||
kindOf(new Map()[Symbol.iterator]()) === 'mapiterator';
|
||||
kindOf(new Map().values()) === 'mapiterator';
|
||||
kindOf(new Set()[Symbol.iterator]()) === 'setiterator';
|
||||
kindOf(new Set().values()) === 'setiterator';
|
||||
kindOf("text"[Symbol.iterator]()) === 'stringiterator';
|
||||
kindOf([][Symbol.iterator]()) === 'arrayiterator';
|
||||
kindOf([].entries()) === 'arrayiterator';
|
||||
kindOf(Symbol("str")) === 'symbol';
|
||||
kindOf(Symbol.prototype) === 'symbol';
|
||||
kindOf(Promise.resolve(123)) === 'promise';
|
||||
kindOf(Promise.reject(new Error("foo bar")).catch(() => {})) === 'promise';
|
||||
kindOf(new Map()) === 'map';
|
||||
kindOf(new WeakMap()) === 'weakmap';
|
||||
kindOf(new Set()) === 'set';
|
||||
kindOf(new WeakSet()) === 'weakset';
|
||||
kindOf(Int8Array.of(0)) === 'int8array';
|
||||
kindOf(Uint8Array.of(0)) === 'uint8array';
|
||||
kindOf(Uint8ClampedArray.of(0)) === 'uint8clampedarray';
|
||||
kindOf(Int16Array.of(0)) === 'int16array';
|
||||
kindOf(Uint16Array.of(0)) === 'uint16array';
|
||||
kindOf(Int32Array.of(0)) === 'int32array';
|
||||
kindOf(Uint32Array.of(0)) === 'uint32array';
|
||||
kindOf(Float32Array.of(0)) === 'float32array';
|
||||
kindOf(Float64Array.of(0)) === 'float64array';
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": ["index.d.ts", "kind-of-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user