UNPKG

1.01 kBJavaScriptView Raw
1var _curry1 =
2/*#__PURE__*/
3require("./internal/_curry1");
4/**
5 * Gives a single-word string description of the (native) type of a value,
6 * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
7 * attempt to distinguish user Object types any further, reporting them all as
8 * 'Object'.
9 *
10 * @func
11 * @memberOf R
12 * @since v0.8.0
13 * @category Type
14 * @sig (* -> {*}) -> String
15 * @param {*} val The value to test
16 * @return {String}
17 * @example
18 *
19 * R.type({}); //=> "Object"
20 * R.type(1); //=> "Number"
21 * R.type(false); //=> "Boolean"
22 * R.type('s'); //=> "String"
23 * R.type(null); //=> "Null"
24 * R.type([]); //=> "Array"
25 * R.type(/[A-z]/); //=> "RegExp"
26 * R.type(() => {}); //=> "Function"
27 * R.type(undefined); //=> "Undefined"
28 */
29
30
31var type =
32/*#__PURE__*/
33_curry1(function type(val) {
34 return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
35});
36
37module.exports = type;
\No newline at end of file