mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 12:41:54 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/type.js
|
|
|
|
|
|
import _curry1 from './internal/_curry1.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'.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.8.0
|
|
* @category Type
|
|
* @sig (* -> {*}) -> String
|
|
* @param {*} val The value to test
|
|
* @return {String}
|
|
* @example
|
|
*
|
|
* R.type({}); //=> "Object"
|
|
* R.type(1); //=> "Number"
|
|
* R.type(false); //=> "Boolean"
|
|
* R.type('s'); //=> "String"
|
|
* R.type(null); //=> "Null"
|
|
* R.type([]); //=> "Array"
|
|
* R.type(/[A-z]/); //=> "RegExp"
|
|
* R.type(() => {}); //=> "Function"
|
|
* R.type(undefined); //=> "Undefined"
|
|
*/
|
|
var type = _curry1(function type(val) {
|
|
return val === null
|
|
? 'Null'
|
|
: val === undefined
|
|
? 'Undefined'
|
|
: Object.prototype.toString.call(val).slice(8, -1);
|
|
});
|
|
export default type;
|