Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Hall committed Mar 16, 2020
2 parents ee3af9e + 6e7e36c commit 919f102
Show file tree
Hide file tree
Showing 8 changed files with 2,263 additions and 2,481 deletions.
195 changes: 1 addition & 194 deletions .eslintrc.yml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .nycrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
all: true
reporter:
- "lcov"
exclude:
- "database/build.js"
- "lib/routemap.js"
- "coverage/**"
- "test/**"
- "app.js"
4 changes: 4 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tabWidth: 4
bracketSpacing: false
printWidth: 80
arrowParens: avoid
12 changes: 6 additions & 6 deletions dist/promisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ exports.promisify = promisify;
var customArgumentsToken = "__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";
/**
* promisify()
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into
* an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)
* and rejects when `error` is truthy.
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) --
* into an ES6-compatible Promise. Promisify provides a default callback of the
* form (error, result) and rejects when `error` is truthy.
*
* @param {function} original - The function to promisify
* @return {function} A promisified version of `original`
Expand All @@ -24,8 +24,8 @@ function promisify(original) {
} // If the user has asked us to decode argument names for them, honour that


var argumentNames = original[customArgumentsToken]; // If the user has supplied a custom Promise implementation, use it. Otherwise
// fall back to whatever we can find on the global object.
var argumentNames = original[customArgumentsToken]; // If the user has supplied a custom Promise implementation, use it.
// Otherwise fall back to whatever we can find on the global object.

var ES6Promise = promisify.Promise || Promise; // If we can find no Promise implemention, then fail now.

Expand Down Expand Up @@ -66,7 +66,7 @@ function promisify(original) {
resolve(o);
}); // Call the function.

original.call.apply(original, [_this].concat(args));
original.apply(_this, args);
});
};
} // Attach this symbol to the exported function, so users can use it
Expand Down
3 changes: 0 additions & 3 deletions lib/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
parserOptions:
sourceType: module

env:
commonjs: false
19 changes: 9 additions & 10 deletions lib/promisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ const customArgumentsToken = "__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";

/**
* promisify()
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into
* an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)
* and rejects when `error` is truthy.
* Transforms callback-based function -- func(arg1, arg2 .. argN, callback) --
* into an ES6-compatible Promise. Promisify provides a default callback of the
* form (error, result) and rejects when `error` is truthy.
*
* @param {function} original - The function to promisify
* @return {function} A promisified version of `original`
*/
function promisify(original) {

// Ensure the argument is a function
if (typeof original !== "function") {
throw new TypeError("Argument to promisify must be a function");
Expand All @@ -21,21 +20,21 @@ function promisify(original) {
// If the user has asked us to decode argument names for them, honour that
const argumentNames = original[customArgumentsToken];

// If the user has supplied a custom Promise implementation, use it. Otherwise
// fall back to whatever we can find on the global object.
// If the user has supplied a custom Promise implementation, use it.
// Otherwise fall back to whatever we can find on the global object.
const ES6Promise = promisify.Promise || Promise;

// If we can find no Promise implemention, then fail now.
if (typeof ES6Promise !== "function") {
throw new Error("No Promise implementation found; do you need a polyfill?");
throw new Error(
"No Promise implementation found; do you need a polyfill?"
);
}

return function (...args) {
return function(...args) {
return new ES6Promise((resolve, reject) => {

// Append the callback bound to the context
args.push(function callback(err, ...values) {

if (err) {
return reject(err);
}
Expand Down
Loading

0 comments on commit 919f102

Please sign in to comment.