Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 14x 484x | // from https://github.com/ramda/ramda/blob/master/source/type.js /** * Gives a single-word string description of the (native) type of a value, returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not attempt to distinguish user Object types any further, reporting them all as 'Object'. * @param val * @signature * P.type(obj) * @example * P.type({}); //=> "Object" * P.type(1); //=> "Number" * P.type(false); //=> "Boolean" * P.type('s'); //=> "String" * P.type(null); //=> "Null" * P.type([]); //=> "Array" * P.type(/[A-z]/); //=> "RegExp" * P.type(() => {}); //=> "Function" * P.type(undefined); //=> "Undefined" * P.type(new Date()); //=> "Date" * P.type(new MyClass()); // => "MyClass" * @category Utility */ export function type(val: any): string { return (val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1)); } |