1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 04:10:04 +02:00

add some babel stuff

This commit is contained in:
s2
2018-05-05 15:35:25 +02:00
parent d17c4fe70c
commit e76e795120
604 changed files with 103725 additions and 62 deletions

5
node_modules/is-callable/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"root": true,
"extends": "@ljharb"
}

163
node_modules/is-callable/.jscs.json generated vendored Normal file
View File

@@ -0,0 +1,163 @@
{
"es3": true,
"additionalRules": [],
"requireSemicolons": true,
"disallowMultipleSpaces": true,
"disallowIdentifierNames": [],
"requireCurlyBraces": {
"allExcept": [],
"keywords": ["if", "else", "for", "while", "do", "try", "catch"]
},
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],
"disallowSpaceAfterKeywords": [],
"disallowSpaceBeforeComma": true,
"disallowSpaceAfterComma": false,
"disallowSpaceBeforeSemicolon": true,
"disallowNodeTypes": [
"DebuggerStatement",
"ForInStatement",
"LabeledStatement",
"SwitchCase",
"SwitchStatement",
"WithStatement"
],
"requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] },
"requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
"requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },
"disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true },
"requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true },
"disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true },
"requireSpaceBetweenArguments": true,
"disallowSpacesInsideParentheses": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowQuotedKeysInObjects": "allButReserved",
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"requireSpaceAfterPrefixUnaryOperators": [],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforePostfixUnaryOperators": [],
"disallowSpaceBeforeBinaryOperators": [],
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"disallowSpaceAfterBinaryOperators": [],
"disallowImplicitTypeConversion": ["binary", "string"],
"disallowKeywords": ["with", "eval"],
"requireKeywordsOnNewLine": [],
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"excludeFiles": ["node_modules/**", "vendor/**"],
"disallowMultipleLineStrings": true,
"requireDotNotation": { "allExcept": ["keywords"] },
"requireParenthesesAroundIIFE": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": {
"escape": true,
"mark": "'"
},
"disallowOperatorBeforeLineBreak": [],
"requireSpaceBeforeKeywords": [
"do",
"for",
"if",
"else",
"switch",
"case",
"try",
"catch",
"finally",
"while",
"with",
"return"
],
"validateAlignedFunctionParameters": {
"lineBreakAfterOpeningBraces": true,
"lineBreakBeforeClosingBraces": true
},
"requirePaddingNewLinesBeforeExport": true,
"validateNewlineAfterArrayElements": {
"maximum": 1
},
"requirePaddingNewLinesAfterUseStrict": true,
"disallowArrowFunctions": true,
"disallowMultiLineTernary": true,
"validateOrderInObjectKeys": "asc-insensitive",
"disallowIdenticalDestructuringNames": true,
"disallowNestedTernaries": { "maxLevel": 1 },
"requireSpaceAfterComma": { "allExcept": ["trailing"] },
"requireAlignedMultilineParams": false,
"requireSpacesInGenerator": {
"afterStar": true
},
"disallowSpacesInGenerator": {
"beforeStar": true
},
"disallowVar": false,
"requireArrayDestructuring": false,
"requireEnhancedObjectLiterals": false,
"requireObjectDestructuring": false,
"requireEarlyReturn": false,
"requireCapitalizedConstructorsNew": {
"allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"]
},
"requireImportAlphabetized": false,
"disallowSpacesInsideTemplateStringPlaceholders": true
}

28
node_modules/is-callable/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,28 @@
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
# Users Environment Variables
.lock-wscript

79
node_modules/is-callable/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,79 @@
language: node_js
node_js:
- "5.7"
- "5.6"
- "5.5"
- "5.4"
- "5.3"
- "5.2"
- "5.1"
- "5.0"
- "4.3"
- "4.2"
- "4.1"
- "4.0"
- "iojs-v3.3"
- "iojs-v3.2"
- "iojs-v3.1"
- "iojs-v3.0"
- "iojs-v2.5"
- "iojs-v2.4"
- "iojs-v2.3"
- "iojs-v2.2"
- "iojs-v2.1"
- "iojs-v2.0"
- "iojs-v1.8"
- "iojs-v1.7"
- "iojs-v1.6"
- "iojs-v1.5"
- "iojs-v1.4"
- "iojs-v1.3"
- "iojs-v1.2"
- "iojs-v1.1"
- "iojs-v1.0"
- "0.12"
- "0.11"
- "0.10"
- "0.9"
- "0.8"
- "0.6"
- "0.4"
before_install:
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi'
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi'
script:
- 'if [ "${TRAVIS_NODE_VERSION}" != "4.3" ]; then npm run tests-only ; else npm test ; fi'
sudo: false
matrix:
fast_finish: true
allow_failures:
- node_js: "5.6"
- node_js: "5.5"
- node_js: "5.4"
- node_js: "5.3"
- node_js: "5.2"
- node_js: "5.1"
- node_js: "5.0"
- node_js: "4.2"
- node_js: "4.1"
- node_js: "4.0"
- node_js: "iojs-v3.2"
- node_js: "iojs-v3.1"
- node_js: "iojs-v3.0"
- node_js: "iojs-v2.4"
- node_js: "iojs-v2.3"
- node_js: "iojs-v2.2"
- node_js: "iojs-v2.1"
- node_js: "iojs-v2.0"
- node_js: "iojs-v1.7"
- node_js: "iojs-v1.6"
- node_js: "iojs-v1.5"
- node_js: "iojs-v1.4"
- node_js: "iojs-v1.3"
- node_js: "iojs-v1.2"
- node_js: "iojs-v1.1"
- node_js: "iojs-v1.0"
- node_js: "0.11"
- node_js: "0.9"
- node_js: "0.6"
- node_js: "0.4"

50
node_modules/is-callable/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,50 @@
1.1.3 / 2016-02-27
=================
* [Fix] ensure “class “ doesnt screw up “class” detection
* [Tests] up to `node` `v5.7`, `v4.3`
* [Dev Deps] update to `eslint` v2, `@ljharb/eslint-config`, `jscs`
1.1.2 / 2016-01-15
=================
* [Fix] Make sure comments dont screw up “class” detection (#4)
* [Tests] up to `node` `v5.3`
* [Tests] Add `parallelshell`, run both `--es-staging` and stock tests at once
* [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`
* [Refactor] convert `isNonES6ClassFn` into `isES6ClassFn`
1.1.1 / 2015-11-30
=================
* [Fix] do not throw when a non-function has a function in its [[Prototype]] (#2)
* [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config`, `jscs`, `nsp`, `semver`
* [Tests] up to `node` `v5.1`
* [Tests] no longer allow node 0.8 to fail.
* [Tests] fix npm upgrades in older nodes
1.1.0 / 2015-10-02
=================
* [Fix] Some browsers report TypedArray constructors as `typeof object`
* [New] return false for "class" constructors, when possible.
* [Tests] up to `io.js` `v3.3`, `node` `v4.1`
* [Dev Deps] update `eslint`, `editorconfig-tools`, `nsp`, `tape`, `semver`, `jscs`, `covert`, `make-arrow-function`
* [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG
1.0.4 / 2015-01-30
=================
* If @@toStringTag is not present, use the old-school Object#toString test.
1.0.3 / 2015-01-29
=================
* Add tests to ensure arrow functions are callable.
* Refactor to aid optimization of non-try/catch code.
1.0.2 / 2015-01-29
=================
* Fix broken package.json
1.0.1 / 2015-01-29
=================
* Add early exit for typeof not "function"
1.0.0 / 2015-01-29
=================
* Initial release.

22
node_modules/is-callable/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Jordan Harband
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.

61
node_modules/is-callable/Makefile generated vendored Normal file
View File

@@ -0,0 +1,61 @@
# Since we rely on paths relative to the makefile location, abort if make isn't being run from there.
$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in))
# The files that need updating when incrementing the version number.
VERSIONED_FILES := *.js *.json README*
# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly.
# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment
# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests.
export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH")
UTILS := semver
# Make sure that all required utilities can be located.
UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS)))
# Default target (by virtue of being the first non '.'-prefixed in the file).
.PHONY: _no-target-specified
_no-target-specified:
$(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests)
# Lists all targets defined in this makefile.
.PHONY: list
list:
@$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
.PHONY: test
test:
@npm test
.PHONY: _ensure-tag
_ensure-tag:
ifndef TAG
$(error Please invoke with `make TAG=<new-version> release`, where <new-version> is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number)
endif
CHANGELOG_ERROR = $(error No CHANGELOG specified)
.PHONY: _ensure-changelog
_ensure-changelog:
@ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2)
# Ensures that the git workspace is clean.
.PHONY: _ensure-clean
_ensure-clean:
@[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; }
# Makes a release; invoke with `make TAG=<versionOrIncrementSpec> release`.
.PHONY: release
release: _ensure-tag _ensure-changelog _ensure-clean
@old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
if printf "$$new_ver" | command grep -q '^[0-9]'; then \
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
else \
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
fi; \
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \
git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \
git tag -a -m "v$$new_ver" "v$$new_ver"

59
node_modules/is-callable/README.md generated vendored Normal file
View File

@@ -0,0 +1,59 @@
# is-callable <sup>[![Version Badge][2]][1]</sup>
[![Build Status][3]][4]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][11]][1]
[![browser support][9]][10]
Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.
## Example
```js
var isCallable = require('is-callable');
var assert = require('assert');
assert.notOk(isCallable(undefined));
assert.notOk(isCallable(null));
assert.notOk(isCallable(false));
assert.notOk(isCallable(true));
assert.notOk(isCallable([]));
assert.notOk(isCallable({}));
assert.notOk(isCallable(/a/g));
assert.notOk(isCallable(new RegExp('a', 'g')));
assert.notOk(isCallable(new Date()));
assert.notOk(isCallable(42));
assert.notOk(isCallable(NaN));
assert.notOk(isCallable(Infinity));
assert.notOk(isCallable(new Number(42)));
assert.notOk(isCallable('foo'));
assert.notOk(isCallable(Object('foo')));
assert.ok(isCallable(function () {}));
assert.ok(isCallable(function* () {}));
assert.ok(isCallable(x => x * x));
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[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
[11]: https://nodei.co/npm/is-callable.png?downloads=true&stars=true
[license-image]: http://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

39
node_modules/is-callable/index.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
'use strict';
var fnToStr = Function.prototype.toString;
var constructorRegex = /^\s*class /;
var isES6ClassFn = function isES6ClassFn(value) {
try {
var fnStr = fnToStr.call(value);
var singleStripped = fnStr.replace(/\/\/.*\n/g, '');
var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, '');
var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' ');
return constructorRegex.test(spaceStripped);
} catch (e) {
return false; // not a function
}
};
var tryFunctionObject = function tryFunctionObject(value) {
try {
if (isES6ClassFn(value)) { return false; }
fnToStr.call(value);
return true;
} catch (e) {
return false;
}
};
var toStr = Object.prototype.toString;
var fnClass = '[object Function]';
var genClass = '[object GeneratorFunction]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
module.exports = function isCallable(value) {
if (!value) { return false; }
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
if (hasToStringTag) { return tryFunctionObject(value); }
if (isES6ClassFn(value)) { return false; }
var strClass = toStr.call(value);
return strClass === fnClass || strClass === genClass;
};

114
node_modules/is-callable/package.json generated vendored Normal file
View File

@@ -0,0 +1,114 @@
{
"_from": "is-callable@^1.1.3",
"_id": "is-callable@1.1.3",
"_inBundle": false,
"_integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI=",
"_location": "/is-callable",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "is-callable@^1.1.3",
"name": "is-callable",
"escapedName": "is-callable",
"rawSpec": "^1.1.3",
"saveSpec": null,
"fetchSpec": "^1.1.3"
},
"_requiredBy": [
"/es-abstract",
"/es-to-primitive"
],
"_resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz",
"_shasum": "86eb75392805ddc33af71c92a0eedf74ee7604b2",
"_spec": "is-callable@^1.1.3",
"_where": "/home/s2/Documents/Code/minifyfromhtml/node_modules/es-abstract",
"author": {
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
},
"bugs": {
"url": "https://github.com/ljharb/is-callable/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
}
],
"dependencies": {},
"deprecated": false,
"description": "Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.",
"devDependencies": {
"@ljharb/eslint-config": "^2.1.1",
"covert": "^1.1.0",
"editorconfig-tools": "^0.1.1",
"eslint": "^2.2.0",
"foreach": "^2.0.5",
"jscs": "^2.10.1",
"make-arrow-function": "^1.1.0",
"make-generator-function": "^1.1.0",
"nsp": "^2.2.0",
"parallelshell": "^2.0.0",
"semver": "^5.1.0",
"tape": "^4.4.0"
},
"engines": {
"node": ">= 0.4"
},
"homepage": "https://github.com/ljharb/is-callable#readme",
"keywords": [
"Function",
"function",
"callable",
"generator",
"generator function",
"arrow",
"arrow function",
"ES6",
"toStringTag",
"@@toStringTag"
],
"license": "MIT",
"main": "index.js",
"name": "is-callable",
"repository": {
"type": "git",
"url": "git://github.com/ljharb/is-callable.git"
},
"scripts": {
"coverage": "covert test.js",
"coverage-quiet": "covert test.js --quiet",
"eccheck": "editorconfig-tools check *.js **/*.js > /dev/null",
"eslint": "eslint *.js",
"jscs": "jscs *.js",
"lint": "npm run jscs && npm run eslint",
"security": "nsp check",
"test": "npm run lint && npm run tests-only && npm run security",
"test:staging": "node --es-staging test.js",
"test:stock": "node test.js",
"tests-only": "parallelshell 'npm run test:stock' 'npm run test:staging'"
},
"testling": {
"files": "test.js",
"browsers": [
"iexplore/6.0..latest",
"firefox/3.0..6.0",
"firefox/15.0..latest",
"firefox/nightly",
"chrome/4.0..10.0",
"chrome/20.0..latest",
"chrome/canary",
"opera/10.0..latest",
"opera/next",
"safari/4.0..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2"
]
},
"version": "1.1.3"
}

121
node_modules/is-callable/test.js generated vendored Normal file
View File

@@ -0,0 +1,121 @@
'use strict';
/* eslint no-magic-numbers: 1 */
var test = require('tape');
var isCallable = require('./');
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
var genFn = require('make-generator-function');
var arrowFn = require('make-arrow-function')();
var forEach = require('foreach');
var invokeFunction = function invokeFunction(str) {
var result;
try {
/* eslint-disable no-new-func */
var fn = Function(str);
/* eslint-enable no-new-func */
result = fn();
} catch (e) { /**/ }
return result;
};
var classConstructor = invokeFunction('"use strict"; return class Foo {}');
var commentedClass = invokeFunction('"use strict"; return class/*kkk*/\n\/\/blah\n Bar\n\/\/blah\n {}');
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([]), '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();
});
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 = function () {};
st.equal(true, isCallable(Foo), 'sanity check: Foo is callable');
st.equal(false, isCallable(new Foo()), 'instance of Foo is not callable');
st.end();
});
t.end();
});
test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) {
var fn = function () { return 3; };
var fakeFunction = {
toString: function () { return String(fn); },
valueOf: function () { return fn; }
};
fakeFunction[Symbol.toStringTag] = 'Function';
t.notOk(isCallable(fakeFunction), 'fake Function with @@toStringTag "Function" is not callable');
t.end();
});
var typedArrayNames = [
'Int8Array',
'Uint8Array',
'Uint8ClampedArray',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
];
test('Functions', function (t) {
t.ok(isCallable(function () {}), 'function is callable');
t.ok(isCallable(function classFake() { }), 'function with name containing "class" is callable');
t.ok(isCallable(function () { return ' class '; }), 'function with string " class " is callable');
t.ok(isCallable(isCallable), 'isCallable is callable');
t.end();
});
test('Typed Arrays', function (st) {
forEach(typedArrayNames, function (typedArray) {
if (typeof global[typedArray] !== 'undefined') {
st.ok(isCallable(global[typedArray]), typedArray + ' is callable');
}
});
st.end();
});
test('Generators', { skip: !genFn }, function (t) {
t.ok(isCallable(genFn), 'generator function is callable');
t.end();
});
test('Arrow functions', { skip: !arrowFn }, function (t) {
t.ok(isCallable(arrowFn), 'arrow function is callable');
t.end();
});
test('"Class" constructors', { skip: !classConstructor || !commentedClass }, function (t) {
t.notOk(isCallable(classConstructor), 'class constructors are not callable');
t.notOk(isCallable(commentedClass), 'class constructors with comments in the signature are not callable');
t.end();
});