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 | |
---|
1 | import _curry1 from "./internal/_curry1.js";
|
---|
2 | /**
|
---|
3 | * Gives a single-word string description of the (native) type of a value,
|
---|
4 | * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
|
---|
5 | * attempt to distinguish user Object types any further, reporting them all as
|
---|
6 | * 'Object'.
|
---|
7 | *
|
---|
8 | * @func
|
---|
9 | * @memberOf R
|
---|
10 | * @since v0.8.0
|
---|
11 | * @category Type
|
---|
12 | * @sig * -> String
|
---|
13 | * @param {*} val The value to test
|
---|
14 | * @return {String}
|
---|
15 | * @example
|
---|
16 | *
|
---|
17 | * R.type({}); //=> "Object"
|
---|
18 | * R.type(1); //=> "Number"
|
---|
19 | * R.type(false); //=> "Boolean"
|
---|
20 | * R.type('s'); //=> "String"
|
---|
21 | * R.type(null); //=> "Null"
|
---|
22 | * R.type([]); //=> "Array"
|
---|
23 | * R.type(/[A-z]/); //=> "RegExp"
|
---|
24 | * R.type(() => {}); //=> "Function"
|
---|
25 | * R.type(async () => {}); //=> "AsyncFunction"
|
---|
26 | * R.type(undefined); //=> "Undefined"
|
---|
27 | */
|
---|
28 |
|
---|
29 | var type =
|
---|
30 | /*#__PURE__*/
|
---|
31 | _curry1(function type(val) {
|
---|
32 | return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
|
---|
33 | });
|
---|
34 |
|
---|
35 | export default type; |
---|
Note:
See
TracBrowser
for help on using the repository browser.