source: node_modules/ramda/src/type.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1var _curry1 =
2/*#__PURE__*/
3require("./internal/_curry1.js");
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(async () => {}); //=> "AsyncFunction"
28 * R.type(undefined); //=> "Undefined"
29 */
30
31
32var type =
33/*#__PURE__*/
34_curry1(function type(val) {
35 return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
36});
37
38module.exports = type;
Note: See TracBrowser for help on using the repository browser.