pax_global_header 0000666 0000000 0000000 00000000064 13307305202 0014505 g ustar 00root root 0000000 0000000 52 comment=b22c524da5cbac075f14145780ec4b3637afd7dc
is-primitive-3.0.1/ 0000775 0000000 0000000 00000000000 13307305202 0014127 5 ustar 00root root 0000000 0000000 is-primitive-3.0.1/.editorconfig 0000664 0000000 0000000 00000000441 13307305202 0016603 0 ustar 00root root 0000000 0000000 # http://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[{**/{actual,fixtures,expected,templates}/**,*.md}]
trim_trailing_whitespace = false
insert_final_newline = false
is-primitive-3.0.1/.eslintrc.json 0000664 0000000 0000000 00000007325 13307305202 0016732 0 ustar 00root root 0000000 0000000 {
"extends": [
"eslint:recommended"
],
"env": {
"browser": false,
"es6": true,
"node": true,
"mocha": true
},
"parserOptions":{
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true
}
},
"globals": {
"document": false,
"navigator": false,
"window": false
},
"rules": {
"accessor-pairs": 2,
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"comma-dangle": [2, "never"],
"comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": [2, "allow-null"],
"generator-star-spacing": [2, { "before": true, "after": true }],
"handle-callback-err": [2, "^(err|error)$" ],
"indent": [2, 2, { "SwitchCase": 1 }],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [2, { "before": true, "after": true }],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-native-reassign": 0,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-proto": 0,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 0,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
"no-useless-call": 0,
"no-with": 2,
"one-var": [0, { "initialized": "never" }],
"operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": [0, "never"],
"quotes": [2, "single", "avoid-escape"],
"radix": 2,
"semi": [2, "always"],
"semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any"],
"yoda": [2, "never"]
}
}
is-primitive-3.0.1/.gitattributes 0000664 0000000 0000000 00000000177 13307305202 0017027 0 ustar 00root root 0000000 0000000 # Enforce Unix newlines
* text eol=lf
# binaries
*.ai binary
*.psd binary
*.jpg binary
*.gif binary
*.png binary
*.jpeg binary is-primitive-3.0.1/.gitignore 0000664 0000000 0000000 00000000456 13307305202 0016124 0 ustar 00root root 0000000 0000000 # always ignore files
*.DS_Store
.idea
.vscode
*.sublime-*
# test related, or directories generated by tests
test/actual
actual
coverage
.nyc*
# npm
node_modules
npm-debug.log
# yarn
yarn.lock
yarn-error.log
# misc
_gh_pages
_draft
_drafts
bower_components
vendor
temp
tmp
TODO.md
package-lock.json is-primitive-3.0.1/.npmrc 0000664 0000000 0000000 00000000022 13307305202 0015241 0 ustar 00root root 0000000 0000000 package-lock=false is-primitive-3.0.1/.travis.yml 0000664 0000000 0000000 00000000225 13307305202 0016237 0 ustar 00root root 0000000 0000000 sudo: false
os:
- linux
- osx
language: node_js
node_js:
- node
- '10'
- '9'
- '8'
- '7'
- '6'
- '5'
- '4'
- '0.12'
- '0.10'
is-primitive-3.0.1/.verb.md 0000664 0000000 0000000 00000001550 13307305202 0015466 0 ustar 00root root 0000000 0000000 ## Primitive values
The [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:
- `Boolean`
- `Null`
- `Undefined`
- `Number`
- `String`
- `Symbol` (new in ECMAScript 6)
## Usage
```js
var isPrimitive = require('{%= name %}');
```
## true
All of the following return `true`:
```js
console.log(isPrimitive(false));
console.log(isPrimitive(true));
console.log(isPrimitive(null));
console.log(isPrimitive());
console.log(isPrimitive(42));
console.log(isPrimitive('abc'));
console.log(isPrimitive(Symbol()));
//=> true
```
## false
Everything else returns `false`:
```js
console.log(isPrimitive({}));
console.log(isPrimitive([]));
console.log(isPrimitive(function(){}));
console.log(isPrimitive(new Date()));
// et cetera...
//=> false
```
is-primitive-3.0.1/LICENSE 0000664 0000000 0000000 00000002103 13307305202 0015130 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2014-present, Jon Schlinkert.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
is-primitive-3.0.1/README.md 0000664 0000000 0000000 00000007744 13307305202 0015422 0 ustar 00root root 0000000 0000000 # is-primitive [](https://www.npmjs.com/package/is-primitive) [](https://npmjs.org/package/is-primitive) [](https://npmjs.org/package/is-primitive) [](https://travis-ci.org/jonschlinkert/is-primitive)
> Returns `true` if the value is a primitive.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save is-primitive
```
## Primitive values
The [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:
* `Boolean`
* `Null`
* `Undefined`
* `Number`
* `String`
* `Symbol` (new in ECMAScript 6)
## Usage
```js
var isPrimitive = require('is-primitive');
```
## true
All of the following return `true`:
```js
console.log(isPrimitive(false));
console.log(isPrimitive(true));
console.log(isPrimitive(null));
console.log(isPrimitive());
console.log(isPrimitive(42));
console.log(isPrimitive('abc'));
console.log(isPrimitive(Symbol()));
//=> true
```
## false
Everything else returns `false`:
```js
console.log(isPrimitive({}));
console.log(isPrimitive([]));
console.log(isPrimitive(function(){}));
console.log(isPrimitive(new Date()));
// et cetera...
//=> false
```
## About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests
Running 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:
```sh
$ npm install && npm test
```
Building docs
_(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.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Related projects
You might also be interested in these projects:
* [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.")
* [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.")
* [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.")
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 11 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [ljharb](https://github.com/ljharb) |
| 1 | [bttmly](https://github.com/bttmly) |
| 1 | [hemanth](https://github.com/hemanth) |
### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 23, 2017._ is-primitive-3.0.1/bench.js 0000664 0000000 0000000 00000006445 13307305202 0015555 0 ustar 00root root 0000000 0000000 const Benchmark = require('benchmark');
const suite = new Benchmark.Suite();
const array = { boolean: true, number: true, string: true, symbol: true, undefined: true };
const object = ['boolean', 'number', 'string', 'symbol', 'undefined'];
const values = [
'foo',
1,
function() {},
{},
new Date(),
/foo/,
Symbol('foo'),
null,
undefined,
void 0,
true,
false,
NaN,
Infinity
];
suite
.add('current', () => values.forEach(v => current(v)))
.add('if', () => values.forEach(v => isPrimitiveIf(v)))
.add('negation', () => values.forEach(v => negation(v)))
.add('equals', () => values.forEach(v => isPrimitiveEquals(v)))
.add('equalsNot', () => values.forEach(v => isPrimitiveEqualsNot(v)))
.add('switch', () => values.forEach(v => isPrimitiveSwitch(v)))
.add('object', () => values.forEach(v => isPrimitiveObjectLookup(v)))
.add('object - in', () => values.forEach(v => isPrimitiveObjectIn(v)))
.add('object - own', () => values.forEach(v => isPrimitiveObjectOwn(v)))
.add('array', () => values.forEach(v => isPrimitiveArray(v)))
.on('cycle', event => console.log(String(event.target)))
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
.run();
function current(val) {
if (typeof val === 'object') {
return val === null;
}
return typeof val !== 'function';
}
function negation(val) {
if (val === null) {
return true;
}
if (typeof val === 'object') {
return false;
}
if (typeof val === 'function') {
return false;
}
return true;
}
function isPrimitiveEquals(val) {
return val === null || val === void 0
|| typeof val === 'string'
|| typeof val === 'number'
|| typeof val === 'boolean'
|| typeof val === 'symbol';
}
function isPrimitiveEqualsNot(val) {
return val === null || val === void 0 || (typeof val !== 'function' && typeof val !== 'object');
}
function isPrimitiveIf(val) {
if (val === null
|| typeof val === 'boolean'
|| typeof val === 'number'
|| typeof val === 'string'
|| typeof val === 'symbol'
|| typeof val === 'undefined') {
return true;
}
return false;
}
function isPrimitiveArray(val) {
return val === null || object.indexOf(typeof val) > -1;
}
function isPrimitiveObjectOwn(val) {
return val === null || array.hasOwnProperty(typeof val);
}
function isPrimitiveObjectLookup(val) {
return val === null || !!array[typeof val];
}
function isPrimitiveObjectIn(val) {
return val === null || (typeof val) in array;
}
function isPrimitiveSwitch(val) {
switch (typeof val) {
case 'boolean':
case 'number':
case 'string':
case 'symbol':
case 'undefined':
return true;
default: {
return val === null;
}
}
}
// current x 95,057,831 ops/sec ±1.38% (83 runs sampled)
// if x 24,990,261 ops/sec ±1.07% (88 runs sampled)
// negation x 23,214,623 ops/sec ±1.01% (89 runs sampled)
// equals x 33,166,854 ops/sec ±1.21% (90 runs sampled)
// equalsNot x 47,536,829 ops/sec ±1.32% (86 runs sampled)
// switch x 17,489,344 ops/sec ±1.10% (88 runs sampled)
// object x 4,395,957 ops/sec ±1.05% (89 runs sampled)
// object - in x 5,003,896 ops/sec ±1.19% (87 runs sampled)
// object - own x 6,124,839 ops/sec ±1.16% (88 runs sampled)
// array x 4,725,232 ops/sec ±1.14% (89 runs sampled)
// Fastest is current
is-primitive-3.0.1/index.js 0000664 0000000 0000000 00000000477 13307305202 0015604 0 ustar 00root root 0000000 0000000 /*!
* is-primitive
*
* Copyright (c) 2014-present, Jon Schlinkert.
* Released under the MIT License.
*/
'use strict';
module.exports = function isPrimitive(val) {
if (typeof val === 'object') {
return val === null;
}
return typeof val !== 'function';
};
is-primitive-3.0.1/package.json 0000664 0000000 0000000 00000002445 13307305202 0016422 0 ustar 00root root 0000000 0000000 {
"name": "is-primitive",
"description": "Returns `true` if the value is a primitive. ",
"version": "3.0.1",
"homepage": "https://github.com/jonschlinkert/is-primitive",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"contributors": [
"hemanth.hm (http://h3manth.com)",
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
"Jordan Harband (https://twitter.com/ljharb)",
"Nick Bottomley (https://github.com/bttmly)"
],
"repository": "jonschlinkert/is-primitive",
"bugs": {
"url": "https://github.com/jonschlinkert/is-primitive/issues"
},
"license": "MIT",
"files": [
"index.js"
],
"main": "index.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"devDependencies": {
"benchmark": "^2.1.4",
"gulp-format-md": "^1.0.0",
"mocha": "^3.5.3"
},
"keywords": [
"boolean",
"check",
"is",
"number",
"primitive",
"string",
"symbol",
"type",
"typeof",
"util"
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"list": [
"is-number",
"is-plain-object",
"kind-of"
]
},
"lint": {
"reflinks": true
}
}
}
is-primitive-3.0.1/test.js 0000664 0000000 0000000 00000002271 13307305202 0015446 0 ustar 00root root 0000000 0000000 /*!
* is-primitive
*
* Copyright (c) 2014-2019, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
require('mocha');
const assert = require('assert');
const isPrimitive = require('./');
describe('isPrimitive', function() {
it('should return true when primitive value', function() {
assert(isPrimitive());
assert(isPrimitive(undefined));
assert(isPrimitive(null));
assert(isPrimitive(0));
assert(isPrimitive(1));
assert(isPrimitive('foo'));
assert(isPrimitive(true));
assert(isPrimitive(false));
assert(isPrimitive(NaN));
assert(isPrimitive(Infinity));
if (typeof Symbol !== 'undefined') {
assert(isPrimitive(Symbol()));
}
if (typeof BigInt !== 'undefined') {
assert(isPrimitive(BigInt(0)));
}
});
it('should return false when not primitive value', function() {
assert(!isPrimitive({}));
assert(!isPrimitive([]));
assert(!isPrimitive(/./));
assert(!isPrimitive(function() {}));
assert(!isPrimitive(new Date()));
assert(!isPrimitive(new Number()));
assert(!isPrimitive(new String()));
assert(!isPrimitive(new Boolean()));
});
});