get-internal-type demo

node v10.24.1
version: 1.5.2
endpointsharetweet
var getInternalType = require("get-internal-type"); console.log(getInternalType(undefined)) // expected "undefined" console.log(getInternalType(null)) // expected "null" console.log(getInternalType(false)) // expected "boolean" console.log(getInternalType(Symbol("123"))) // expected "symbol" console.log(getInternalType(123)) // expected "number" console.log(getInternalType(BigInt(9007199254740991))) // expected "bigint"
console.log(getInternalType("hello")) // expected "string" console.log(getInternalType(/s+/gi)) // expected "regexp" console.log(getInternalType(new Date())) // expected "date" console.log(getInternalType(new Error("A mistake"))) // expected "error" console.log(getInternalType({})) // expected "object" console.log(getInternalType(new (class SomeCustomClass {}))) // expected "object" console.log(getInternalType(() => {})) // expected "function" console.log(getInternalType(function(){})) // expected "function" console.log(getInternalType(class Simple {})) // expected "function" console.log(getInternalType([1,2,3])) // expected "array"
console.log(getInternalType(new Set())) // expected "set" console.log(getInternalType(new WeakSet())) // expected "set" console.log(getInternalType(new Map())) // expected "map" console.log(getInternalType(new WeakMap())) // expected "map"
console.log(getInternalType(new Int8Array(8))) // expected "typedarray" console.log(getInternalType(new Uint8Array())) // expected "typedarray" console.log(getInternalType(new Uint8ClampedArray())) // expected "typedarray" console.log(getInternalType(new Int16Array())) // expected "typedarray" console.log(getInternalType(new Uint16Array())) // expected "typedarray" console.log(getInternalType(new Int32Array())) // expected "typedarray" console.log(getInternalType(new Uint32Array())) // expected "typedarray" console.log(getInternalType(new Float32Array())) // expected "typedarray" console.log(getInternalType(new Float64Array())) // expected "typedarray" console.log(getInternalType(new BigInt64Array())) // expected "typedarray" console.log(getInternalType(new BigUint64Array())) // expected "typedarray"
console.log(getInternalType(Promise.resolve('any'))) // expected "promise" console.log(getInternalType(function* () {})) // expected "generatorfunction" (ES6) console.log(getInternalType((function* () {})())) // expected "generator" console.log(getInternalType(new ArrayBuffer(16))) // expected "arraybuffer" console.log(getInternalType(new DataView(new ArrayBuffer(16)))) // expected "dataview"
Loading…

no comments

    sign in to comment