• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..18-Dec-2021-

LICENSEH A D18-Dec-20211.1 KiB2217

README.mdH A D18-Dec-20214 KiB12483

package.jsonH A D18-Dec-20211.3 KiB6665

README.md

1# is-primitive [![NPM version](https://img.shields.io/npm/v/is-primitive.svg?style=flat)](https://www.npmjs.com/package/is-primitive) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-primitive.svg?style=flat)](https://npmjs.org/package/is-primitive) [![NPM total downloads](https://img.shields.io/npm/dt/is-primitive.svg?style=flat)](https://npmjs.org/package/is-primitive) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-primitive.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-primitive)
2
3> Returns `true` if the value is a primitive.
4
5Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
6
7## Install
8
9Install with [npm](https://www.npmjs.com/):
10
11```sh
12$ npm install --save is-primitive
13```
14
15## Primitive values
16
17The [Mozilla docs for "Primitive values"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Primitive_values) defines specifies six data types that are primitives:
18
19* `Boolean`
20* `Null`
21* `Undefined`
22* `Number`
23* `String`
24* `Symbol` (new in ECMAScript 6)
25
26## Usage
27
28```js
29var isPrimitive = require('is-primitive');
30```
31
32## true
33
34All of the following return `true`:
35
36```js
37console.log(isPrimitive(false));
38console.log(isPrimitive(true));
39console.log(isPrimitive(null));
40console.log(isPrimitive());
41console.log(isPrimitive(42));
42console.log(isPrimitive('abc'));
43console.log(isPrimitive(Symbol()));
44//=> true
45```
46
47## false
48
49Everything else returns `false`:
50
51```js
52console.log(isPrimitive({}));
53console.log(isPrimitive([]));
54console.log(isPrimitive(function(){}));
55console.log(isPrimitive(new Date()));
56// et cetera...
57//=> false
58```
59
60## About
61
62<details>
63<summary><strong>Contributing</strong></summary>
64
65Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
66
67</details>
68
69<details>
70<summary><strong>Running Tests</strong></summary>
71
72Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
73
74```sh
75$ npm install && npm test
76```
77
78</details>
79
80<details>
81<summary><strong>Building docs</strong></summary>
82
83_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
84
85To generate the readme, run the following command:
86
87```sh
88$ npm install -g verbose/verb#dev verb-generate-readme && verb
89```
90
91</details>
92
93### Related projects
94
95You might also be interested in these projects:
96
97* [is-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
98* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the `Object` constructor.")
99* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
100
101### Contributors
102
103| **Commits** | **Contributor** |
104| --- | --- |
105| 11 | [jonschlinkert](https://github.com/jonschlinkert) |
106| 1 | [ljharb](https://github.com/ljharb) |
107| 1 | [bttmly](https://github.com/bttmly) |
108| 1 | [hemanth](https://github.com/hemanth) |
109
110### Author
111
112**Jon Schlinkert**
113
114* [github/jonschlinkert](https://github.com/jonschlinkert)
115* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
116
117### License
118
119Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
120Released under the [MIT License](LICENSE).
121
122***
123
124_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 23, 2017._