is-callable
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -0,1 +1,26 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
## [v1.2.5](https://github.com/inspect-js/is-callable/compare/v1.2.4...v1.2.5) - 2022-09-11 | ||
### Commits | ||
- [actions] reuse common workflows [`5bb4b32`](https://github.com/inspect-js/is-callable/commit/5bb4b32dc93987328ab4f396601f751c4a7abd62) | ||
- [meta] better `eccheck` command [`b9bd597`](https://github.com/inspect-js/is-callable/commit/b9bd597322b6e3a24c74c09881ca73e1d9f9f485) | ||
- [meta] use `npmignore` to autogenerate an npmignore file [`3192d38`](https://github.com/inspect-js/is-callable/commit/3192d38527c7fc461d05d5aa93d47628e658bc45) | ||
- [Fix] for HTML constructors, always use `tryFunctionObject` even in pre-toStringTag browsers [`3076ea2`](https://github.com/inspect-js/is-callable/commit/3076ea21d1f6ecc1cb711dcf1da08f257892c72b) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `available-typed-arrays`, `object-inspect`, `safe-publish-latest`, `tape` [`8986746`](https://github.com/inspect-js/is-callable/commit/89867464c42adc5cd375ee074a4574b0295442cb) | ||
- [meta] add `auto-changelog` [`7dda9d0`](https://github.com/inspect-js/is-callable/commit/7dda9d04e670a69ae566c8fa596da4ff4371e615) | ||
- [Fix] properly report `document.all` [`da90b2b`](https://github.com/inspect-js/is-callable/commit/da90b2b68dc4f33702c2e01ad07b4f89bcb60984) | ||
- [actions] update codecov uploader [`c8f847c`](https://github.com/inspect-js/is-callable/commit/c8f847c90e04e54ff73c7cfae86e96e94990e324) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`899ae00`](https://github.com/inspect-js/is-callable/commit/899ae00b6abd10d81fc8bc7f02b345fd885d5f56) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `es-value-fixtures`, `object-inspect`, `tape` [`344e913`](https://github.com/inspect-js/is-callable/commit/344e913b149609bf741aa7345fa32dc0b90d8893) | ||
- [meta] remove greenkeeper config [`737dce5`](https://github.com/inspect-js/is-callable/commit/737dce5590b1abb16183a63cb9d7d26920b3b394) | ||
- [meta] npmignore coverage output [`680a883`](https://github.com/inspect-js/is-callable/commit/680a8839071bf36a419fe66e1ced7a3303c27b28) | ||
<!-- auto-changelog-above --> | ||
1.2.4 / 2021-08-05 | ||
@@ -2,0 +27,0 @@ ================= |
18
index.js
@@ -49,8 +49,16 @@ 'use strict'; | ||
var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag` | ||
/* globals document: false */ | ||
var documentDotAll = typeof document === 'object' && typeof document.all === 'undefined' && document.all !== undefined ? document.all : {}; | ||
var isDDA = typeof document === 'object' ? function isDocumentDotAll(value) { | ||
/* globals document: false */ | ||
// in IE 8, typeof document.all is "object" | ||
if (typeof value === 'undefined' || typeof value === 'object') { | ||
try { | ||
return value('') === null; | ||
} catch (e) { /**/ } | ||
} | ||
return false; | ||
} : function () { return false; }; | ||
module.exports = reflectApply | ||
? function isCallable(value) { | ||
if (value === documentDotAll) { return true; } | ||
if (isDDA(value)) { return true; } | ||
if (!value) { return false; } | ||
@@ -67,3 +75,3 @@ if (typeof value !== 'function' && typeof value !== 'object') { return false; } | ||
: function isCallable(value) { | ||
if (value === documentDotAll) { return true; } | ||
if (isDDA(value)) { return true; } | ||
if (!value) { return false; } | ||
@@ -75,3 +83,3 @@ if (typeof value !== 'function' && typeof value !== 'object') { return false; } | ||
var strClass = toStr.call(value); | ||
return strClass === fnClass || strClass === genClass; | ||
return strClass === fnClass || strClass === genClass || tryFunctionObject(value); | ||
}; |
{ | ||
"name": "is-callable", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"author": { | ||
@@ -23,2 +23,5 @@ "name": "Jordan Harband", | ||
"scripts": { | ||
"prepack": "npmignore --auto --commentLines=autogenerated", | ||
"version": "auto-changelog && git add CHANGELOG.md", | ||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"", | ||
"prepublishOnly": "safe-publish-latest", | ||
@@ -30,4 +33,4 @@ "prepublish": "not-in-publish || npm run prepublishOnly", | ||
"tests-only": "nyc tape 'test/**/*.js'", | ||
"prelint": "eclint check *", | ||
"lint": "eslint ." | ||
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')", | ||
"lint": "eslint --ext=js,mjs ." | ||
}, | ||
@@ -51,8 +54,9 @@ "repository": { | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^17.6.0", | ||
"aud": "^1.1.5", | ||
"available-typed-arrays": "^1.0.4", | ||
"@ljharb/eslint-config": "^21.0.0", | ||
"aud": "^2.0.0", | ||
"auto-changelog": "^2.4.0", | ||
"available-typed-arrays": "^1.0.5", | ||
"eclint": "^2.8.1", | ||
"es-value-fixtures": "^1.2.1", | ||
"eslint": "^7.32.0", | ||
"es-value-fixtures": "^1.4.2", | ||
"eslint": "=8.8.0", | ||
"for-each": "^0.3.3", | ||
@@ -63,7 +67,8 @@ "has-tostringtag": "^1.0.0", | ||
"make-generator-function": "^2.0.0", | ||
"npmignore": "^0.3.0", | ||
"nyc": "^10.3.2", | ||
"object-inspect": "^1.11.0", | ||
"object-inspect": "^1.12.2", | ||
"rimraf": "^2.7.1", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^5.3.0" | ||
"safe-publish-latest": "^2.0.0", | ||
"tape": "^5.6.0" | ||
}, | ||
@@ -91,7 +96,16 @@ "testling": { | ||
}, | ||
"greenkeeper": { | ||
"auto-changelog": { | ||
"output": "CHANGELOG.md", | ||
"template": "keepachangelog", | ||
"unreleased": false, | ||
"commitLimit": false, | ||
"backfillLimit": false, | ||
"hideCredit": true, | ||
"startingVersion": "v1.2.5" | ||
}, | ||
"publishConfig": { | ||
"ignore": [ | ||
"rimraf" | ||
".github/workflows" | ||
] | ||
} | ||
} |
'use strict'; | ||
/* globals Proxy */ | ||
/* eslint no-magic-numbers: 1 */ | ||
@@ -23,2 +22,4 @@ | ||
var isIE68 = !(0 in [undefined]); | ||
var noop = function () {}; | ||
@@ -165,8 +166,28 @@ var classFake = function classFake() { }; // eslint-disable-line func-name-matching | ||
/* globals document: false */ | ||
test('document.all', { skip: typeof document !== 'object' }, function (t) { | ||
t.notOk(isCallable(document), 'document is not callable'); | ||
t.ok(isCallable(document.all), 'document.all is callable'); | ||
test('DOM', function (t) { | ||
/* eslint-env browser */ | ||
t.test('document.all', { skip: typeof document !== 'object' }, function (st) { | ||
st.notOk(isCallable(document), 'document is not callable'); | ||
st.ok(isCallable(document.all), 'document.all is callable'); | ||
st.end(); | ||
}); | ||
forEach([ | ||
'HTMLElement', | ||
'HTMLAnchorElement' | ||
], function (name) { | ||
var constructor = global[name]; | ||
t.test(name, { skip: !constructor }, function (st) { | ||
st.match(typeof constructor, /^(?:function|object)$/, name + ' is a function'); | ||
st.equal(isCallable(constructor), !isIE68, name + ' is ' + (isIE68 ? 'not ' : '') + 'callable'); | ||
st.end(); | ||
}); | ||
}); | ||
t.end(); | ||
}); |
Sorry, the diff of this file is not supported yet
22495
239
18
10