is-callable
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -0,1 +1,15 @@ | ||
1.2.4 / 2021-08-05 | ||
================= | ||
* [Fix] use `has-tostringtag` approach to behave correctly in the presence of symbol shams | ||
* [readme] fix repo URLs | ||
* [readme] add actions and codecov badges | ||
* [readme] remove defunct badges | ||
* [meta] ignore eclint checking coverage output | ||
* [meta] use `prepublishOnly` script for npm 7+ | ||
* [actions] use `node/install` instead of `node/run`; use `codecov` action | ||
* [actions] remove unused workflow file | ||
* [Tests] run `nyc` on all tests; use `tape` runner | ||
* [Tests] use `available-typed-arrays`, `for-each`, `has-symbols`, `object-inspect` | ||
* [Dev Deps] update `available-typed-arrays`, `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` | ||
1.2.3 / 2021-01-31 | ||
@@ -2,0 +16,0 @@ ================= |
@@ -48,3 +48,3 @@ 'use strict'; | ||
var genClass = '[object GeneratorFunction]'; | ||
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; | ||
var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag` | ||
/* globals document: false */ | ||
@@ -51,0 +51,0 @@ var documentDotAll = typeof document === 'object' && typeof document.all === 'undefined' && document.all !== undefined ? document.all : {}; |
{ | ||
"name": "is-callable", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"author": { | ||
@@ -23,17 +23,8 @@ "name": "Jordan Harband", | ||
"scripts": { | ||
"prepublish": "safe-publish-latest", | ||
"prepublishOnly": "safe-publish-latest", | ||
"prepublish": "not-in-publish || npm run prepublishOnly", | ||
"pretest": "npm run --silent lint", | ||
"test": "npm run --silent tests-only", | ||
"posttest": "npx aud --production", | ||
"tests-only": "npm run --silent test:stock && npm run --silent test:staging", | ||
"test:stock": "node test", | ||
"test:staging": "node --es-staging test", | ||
"coverage": "npm run --silent istanbul", | ||
"covert": "covert test", | ||
"covert:quiet": "covert test --quiet", | ||
"istanbul": "npm run --silent istanbul:clean && npm run --silent istanbul:std && npm run --silent istanbul:harmony && npm run --silent istanbul:merge && istanbul check", | ||
"istanbul:clean": "rimraf coverage coverage-std coverage-harmony", | ||
"istanbul:merge": "istanbul-merge --out coverage/coverage.raw.json coverage-harmony/coverage.raw.json coverage-std/coverage.raw.json && istanbul report html", | ||
"istanbul:harmony": "node --harmony ./node_modules/istanbul/lib/cli.js cover test --dir coverage-harmony", | ||
"istanbul:std": "istanbul cover test --report html --dir coverage-std", | ||
"test": "npm run tests-only --", | ||
"posttest": "aud --production", | ||
"tests-only": "nyc tape 'test/**/*.js'", | ||
"prelint": "eclint check *", | ||
@@ -44,3 +35,3 @@ "lint": "eslint ." | ||
"type": "git", | ||
"url": "git://github.com/ljharb/is-callable.git" | ||
"url": "git://github.com/inspect-js/is-callable.git" | ||
}, | ||
@@ -59,18 +50,19 @@ "keywords": [ | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^17.5.0", | ||
"aud": "^1.1.3", | ||
"covert": "^1.1.1", | ||
"@ljharb/eslint-config": "^17.6.0", | ||
"aud": "^1.1.5", | ||
"available-typed-arrays": "^1.0.4", | ||
"eclint": "^2.8.1", | ||
"eslint": "^7.19.0", | ||
"foreach": "^2.0.5", | ||
"istanbul": "1.1.0-alpha.1", | ||
"istanbul-merge": "^1.1.1", | ||
"es-value-fixtures": "^1.2.1", | ||
"eslint": "^7.32.0", | ||
"for-each": "^0.3.3", | ||
"has-tostringtag": "^1.0.0", | ||
"make-arrow-function": "^1.2.0", | ||
"make-async-function": "^1.0.0", | ||
"make-generator-function": "^2.0.0", | ||
"nyc": "^10.3.2", | ||
"object-inspect": "^1.11.0", | ||
"rimraf": "^2.7.1", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^5.1.1" | ||
"tape": "^5.3.0" | ||
}, | ||
@@ -77,0 +69,0 @@ "testling": { |
# is-callable <sup>[![Version Badge][2]][1]</sup> | ||
[![Build Status][3]][4] | ||
[![github actions][actions-image]][actions-url] | ||
[![coverage][codecov-image]][codecov-url] | ||
[![dependency status][5]][6] | ||
@@ -11,4 +12,2 @@ [![dev dependency status][7]][8] | ||
[![browser support][9]][10] | ||
Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag. | ||
@@ -56,15 +55,15 @@ | ||
[1]: https://npmjs.org/package/is-callable | ||
[2]: http://versionbadg.es/ljharb/is-callable.svg | ||
[3]: https://travis-ci.org/ljharb/is-callable.svg | ||
[4]: https://travis-ci.org/ljharb/is-callable | ||
[5]: https://david-dm.org/ljharb/is-callable.svg | ||
[6]: https://david-dm.org/ljharb/is-callable | ||
[7]: https://david-dm.org/ljharb/is-callable/dev-status.svg | ||
[8]: https://david-dm.org/ljharb/is-callable#info=devDependencies | ||
[9]: https://ci.testling.com/ljharb/is-callable.png | ||
[10]: https://ci.testling.com/ljharb/is-callable | ||
[2]: https://versionbadg.es/inspect-js/is-callable.svg | ||
[5]: https://david-dm.org/inspect-js/is-callable.svg | ||
[6]: https://david-dm.org/inspect-js/is-callable | ||
[7]: https://david-dm.org/inspect-js/is-callable/dev-status.svg | ||
[8]: https://david-dm.org/inspect-js/is-callable#info=devDependencies | ||
[11]: https://nodei.co/npm/is-callable.png?downloads=true&stars=true | ||
[license-image]: http://img.shields.io/npm/l/is-callable.svg | ||
[license-image]: https://img.shields.io/npm/l/is-callable.svg | ||
[license-url]: LICENSE | ||
[downloads-image]: http://img.shields.io/npm/dm/is-callable.svg | ||
[downloads-url]: http://npm-stat.com/charts.html?package=is-callable | ||
[downloads-image]: https://img.shields.io/npm/dm/is-callable.svg | ||
[downloads-url]: https://npm-stat.com/charts.html?package=is-callable | ||
[codecov-image]: https://codecov.io/gh/inspect-js/is-callable/branch/main/graphs/badge.svg | ||
[codecov-url]: https://app.codecov.io/gh/inspect-js/is-callable/ | ||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-callable | ||
[actions-url]: https://github.com/inspect-js/is-callable/actions |
@@ -8,3 +8,7 @@ 'use strict'; | ||
var isCallable = require('../'); | ||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; | ||
var hasToStringTag = require('has-tostringtag/shams')(); | ||
var v = require('es-value-fixtures'); | ||
var forEach = require('for-each'); | ||
var inspect = require('object-inspect'); | ||
var typedArrayNames = require('available-typed-arrays')(); | ||
var generators = require('make-generator-function')(); | ||
@@ -19,3 +23,2 @@ var arrows = require('make-arrow-function').list(); | ||
} catch (e) { /**/ } | ||
var forEach = require('foreach'); | ||
@@ -68,35 +71,21 @@ var noop = function () {}; | ||
test('not callables', function (t) { | ||
t.test('non-number/string primitives', function (st) { | ||
st.notOk(isCallable(), 'undefined is not callable'); | ||
st.notOk(isCallable(null), 'null is not callable'); | ||
st.notOk(isCallable(false), 'false is not callable'); | ||
st.notOk(isCallable(true), 'true is not callable'); | ||
st.end(); | ||
}); | ||
t.notOk(isCallable(), 'implicit undefined is not callable'); | ||
t.notOk(isCallable([]), 'array is not callable'); | ||
t.notOk(isCallable({}), 'object is not callable'); | ||
t.notOk(isCallable(/a/g), 'regex literal is not callable'); | ||
t.notOk(isCallable(new RegExp('a', 'g')), 'regex object is not callable'); | ||
t.notOk(isCallable(new Date()), 'new Date() is not callable'); | ||
t.test('numbers', function (st) { | ||
st.notOk(isCallable(42), 'number is not callable'); | ||
st.notOk(isCallable(Object(42)), 'number object is not callable'); | ||
st.notOk(isCallable(NaN), 'NaN is not callable'); | ||
st.notOk(isCallable(Infinity), 'Infinity is not callable'); | ||
st.end(); | ||
forEach(v.nonFunctions.concat([ | ||
Object(42), | ||
Object('foo'), | ||
NaN, | ||
[], | ||
/a/g, | ||
new RegExp('a', 'g'), | ||
new Date() | ||
]), function (nonFunction) { | ||
t.equal(isCallable(nonFunction), false, inspect(nonFunction) + ' is not callable'); | ||
}); | ||
t.test('strings', function (st) { | ||
st.notOk(isCallable('foo'), 'string primitive is not callable'); | ||
st.notOk(isCallable(Object('foo')), 'string object is not callable'); | ||
st.end(); | ||
}); | ||
t.test('non-function with function in its [[Prototype]] chain', function (st) { | ||
var Foo = function Bar() {}; | ||
Foo.prototype = noop; | ||
st.equal(true, isCallable(Foo), 'sanity check: Foo is callable'); | ||
st.equal(false, isCallable(new Foo()), 'instance of Foo is not callable'); | ||
st.equal(isCallable(Foo), true, 'sanity check: Foo is callable'); | ||
st.equal(isCallable(new Foo()), false, 'instance of Foo is not callable'); | ||
st.end(); | ||
@@ -108,3 +97,3 @@ }); | ||
test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) { | ||
test('@@toStringTag', { skip: !hasToStringTag }, function (t) { | ||
var fakeFunction = { | ||
@@ -121,14 +110,2 @@ toString: function () { return String(return3); }, | ||
var typedArrayNames = [ | ||
'Int8Array', | ||
'Uint8Array', | ||
'Uint8ClampedArray', | ||
'Int16Array', | ||
'Uint16Array', | ||
'Int32Array', | ||
'Uint32Array', | ||
'Float32Array', | ||
'Float64Array' | ||
]; | ||
test('Functions', function (t) { | ||
@@ -142,10 +119,5 @@ t.ok(isCallable(noop), 'function is callable'); | ||
test('Typed Arrays', function (st) { | ||
test('Typed Arrays', { skip: typedArrayNames.length === 0 }, function (st) { | ||
forEach(typedArrayNames, function (typedArray) { | ||
/* istanbul ignore if : covered in node 0.6 */ | ||
if (typeof global[typedArray] === 'undefined') { | ||
st.comment('# SKIP typed array "' + typedArray + '" not supported'); | ||
} else { | ||
st.ok(isCallable(global[typedArray]), typedArray + ' is callable'); | ||
} | ||
st.ok(isCallable(global[typedArray]), typedArray + ' is callable'); | ||
}); | ||
@@ -152,0 +124,0 @@ st.end(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
0
20069
16
12
217
68