pax_global_header 0000666 0000000 0000000 00000000064 13153547613 0014522 g ustar 00root root 0000000 0000000 52 comment=c385a926aaec91ea4f84e47db17d0c830f5c8fbd
make-async-function-1.0.0/ 0000775 0000000 0000000 00000000000 13153547613 0015373 5 ustar 00root root 0000000 0000000 make-async-function-1.0.0/.eslintrc 0000664 0000000 0000000 00000000117 13153547613 0017216 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"rules": {
"no-new-func": 0,
}
}
make-async-function-1.0.0/.gitignore 0000664 0000000 0000000 00000001707 13153547613 0017370 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# Only apps should have lockfiles.
npm-shrinkwrap.json
package-lock.json
yarn.lock
make-async-function-1.0.0/.npmrc 0000664 0000000 0000000 00000000023 13153547613 0016506 0 ustar 00root root 0000000 0000000 package-lock=false
make-async-function-1.0.0/.travis.yml 0000664 0000000 0000000 00000011523 13153547613 0017506 0 ustar 00root root 0000000 0000000 language: node_js
os:
- linux
node_js:
- "8.4"
- "7.10"
- "6.11"
- "5.12"
- "4.8"
- "iojs-v3.3"
- "iojs-v2.5"
- "iojs-v1.8"
- "0.12"
- "0.10"
- "0.8"
before_install:
- 'nvm install-latest-npm'
install:
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
script:
- 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi'
- 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi'
- 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi'
- 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'
sudo: false
env:
- TEST=true
matrix:
fast_finish: true
include:
- node_js: "node"
env: PRETEST=true
- node_js: "node"
env: POSTTEST=true
- node_js: "8.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "8.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "7.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.10"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "6.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.10"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.8"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "5.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "4.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.7"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.5"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.4"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.3"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.2"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.1"
env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.0"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.11"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.9"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.6"
env: TEST=true ALLOW_FAILURE=true
- node_js: "0.4"
env: TEST=true ALLOW_FAILURE=true
allow_failures:
- os: osx
- env: TEST=true ALLOW_FAILURE=true
- env: COVERAGE=true
make-async-function-1.0.0/CHANGELOG.md 0000664 0000000 0000000 00000000071 13153547613 0017202 0 ustar 00root root 0000000 0000000 1.0.0 / 2017-09-05
=================
* Initial release
make-async-function-1.0.0/LICENSE 0000664 0000000 0000000 00000002057 13153547613 0016404 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2017 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.
make-async-function-1.0.0/README.md 0000664 0000000 0000000 00000003362 13153547613 0016656 0 ustar 00root root 0000000 0000000 # make-async-function [![Version Badge][npm-version-svg]][package-url]
[![Build Status][travis-svg]][travis-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
Function that returns an arbitrary `async function`, or undefined if `async function` syntax is unsupported.
## Example
```js
var maybeAsyncFunction = require('make-async-function')();
if (maybeAsyncFunction) {
assert(typeof maybeAsyncFunction === 'function');
} else {
assert(typeof maybeAsyncFunction === 'undefined');
}
var asyncFunctions = require('make-async-function').list();
assert(asyncFunctions.every(function (fn) { return typeof fn === 'function'; }));
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/make-async-function
[npm-version-svg]: http://versionbadg.es/ljharb/make-async-function.svg
[travis-svg]: https://travis-ci.org/ljharb/make-async-function.svg
[travis-url]: https://travis-ci.org/ljharb/make-async-function
[deps-svg]: https://david-dm.org/ljharb/make-async-function.svg
[deps-url]: https://david-dm.org/ljharb/make-async-function
[dev-deps-svg]: https://david-dm.org/ljharb/make-async-function/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/make-async-function#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/make-async-function.png?downloads=true&stars=true
[license-image]: http://img.shields.io/npm/l/make-async-function.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/make-async-function.svg
[downloads-url]: http://npm-stat.com/charts.html?package=make-async-function
make-async-function-1.0.0/index.js 0000664 0000000 0000000 00000000700 13153547613 0017035 0 ustar 00root root 0000000 0000000 'use strict';
var getAsyncs = function getAsyncFunctions() {
return [
Function('return async (a, b) => a * b;')(),
Function('return async () => {};')(),
Function('return async function foo() {}')()
];
};
var asyncFuncs = [];
try {
asyncFuncs = getAsyncs();
} catch (e) { /**/ }
module.exports = function makeAsyncFunction() {
return asyncFuncs[0];
};
module.exports.list = function makeAsyncFunctions() {
return asyncFuncs.slice();
};
make-async-function-1.0.0/package.json 0000664 0000000 0000000 00000002007 13153547613 0017660 0 ustar 00root root 0000000 0000000 {
"name": "make-async-function",
"version": "1.0.0",
"description": "Function that returns an arbitrary `async function`, or undefined if `async function` syntax is unsupported.",
"main": "./",
"scripts": {
"prepublish": "safe-publish-latest",
"lint": "eslint .",
"pretest": "npm run lint",
"tests-only": "node test",
"test": "npm run tests-only",
"posttest": "npm run security",
"security": "nsp check"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ljharb/make-async-function.git"
},
"keywords": [
"async function",
"async",
"function",
"ES2017",
"ES8",
"ES7",
"ES6",
"promise",
"await"
],
"author": "Jordan Harband ",
"license": "MIT",
"bugs": {
"url": "https://github.com/ljharb/make-async-function/issues"
},
"homepage": "https://github.com/ljharb/make-async-function#readme",
"devDependencies": {
"@ljharb/eslint-config": "^12.2.1",
"eslint": "^4.6.1",
"nsp": "^2.7.0",
"safe-publish-latest": "^1.1.1",
"tape": "^4.8.0"
}
}
make-async-function-1.0.0/test/ 0000775 0000000 0000000 00000000000 13153547613 0016352 5 ustar 00root root 0000000 0000000 make-async-function-1.0.0/test/index.js 0000664 0000000 0000000 00000002255 13153547613 0020023 0 ustar 00root root 0000000 0000000 'use strict';
var test = require('tape');
var makeAsyncFunction = require('../');
test('makeAsyncFunction() is undefined or an arrow function', function (t) {
var asyncFunction = makeAsyncFunction();
if (asyncFunction) {
t.equal(typeof asyncFunction, 'function', 'makeArrowFunction is function');
t.equal(String(asyncFunction), 'async (a, b) => a * b', 'asyncFunction has expected source');
} else {
t.comment('async functions not supported');
t.equal(typeof asyncFunction, 'undefined', 'makeArrowFunction is undefined');
}
t.end();
});
test('makeArrowFunction.list() is an array', function (t) {
var funcs = makeAsyncFunction.list();
var expectedSources = [
'async (a, b) => a * b',
'async () => {}',
'async function foo() {}'
];
t.plan(1 + (2 * funcs.length));
t.equal(Object.prototype.toString.call(funcs), '[object Array]', 'list() is an array');
if (funcs.length === 0) {
t.comment('no arrow functions present');
} else {
for (var i = 0; i < funcs.length; ++i) {
t.equal(typeof funcs[i], 'function', funcs[i] + ' is a function');
t.equal(String(funcs[i]), expectedSources[i], '"' + funcs[i] + '" !== "' + expectedSources[i] + '"');
}
}
t.end();
});