source: node_modules/ramda-adjunct/src/isPrimitive.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.5 KB
Line 
1import { both, anyPass } from 'ramda';
2
3import isNotObj from './isNotObj';
4import isString from './isString';
5import isNumber from './isNumber';
6import isBigInt from './isBigInt';
7import isBoolean from './isBoolean';
8import isUndefined from './isUndefined';
9import isNull from './isNull';
10import isSymbol from './isSymbol';
11
12/**
13 * Checks if value is a primitive data type. There are 6 primitive data types: `string`, `number`, `bigint`, `boolean`, `undefined`, `symbol` and a special case of `null`.
14 * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Primitive_values
15 * for definition of what sub-types comprise a primitive.
16 *
17 * @func isPrimitive
18 * @memberOf RA
19 * @category Type
20 * @sig * -> Boolean
21 * @since {@link https://char0n.github.io/ramda-adjunct/2.32.0|v2.32.0}
22 * @param {*} val The value to test
23 * @return {boolean}
24 * @see {@link RA.isNotPrimitive|isNotPrimitive}, {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#primitive_values|MDN Primitive values}, {@link https://developer.mozilla.org/en-US/docs/Glossary/Primitive|MDN Primitive}
25 * @example
26 *
27 * RA.isPrimitive("string"); //=> true
28 * RA.isPrimitive(1); //=> true
29 * RA.isPrimitive(new String("string")); //=> false
30 * RA.isPrimitive(new Number(1)); //=> false
31 */
32
33const isPrimitive = both(
34 isNotObj,
35 anyPass([
36 isString,
37 isNumber,
38 isBigInt,
39 isBoolean,
40 isUndefined,
41 isNull,
42 isSymbol,
43 ])
44);
45
46export default isPrimitive;
Note: See TracBrowser for help on using the repository browser.