Skip to content

Commit

Permalink
refactoring es6 classes
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Aug 27, 2019
1 parent a513233 commit d7eb7fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
32 changes: 14 additions & 18 deletions lib/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,24 @@
*
* @see {@tutorial client}
*
* @returns {PromiseAdapter}
*/
function PromiseAdapter(create, resolve, reject) {
class PromiseAdapter {
constructor(create, resolve, reject) {
this.create = create;
this.resolve = resolve;
this.reject = reject;

if (!(this instanceof PromiseAdapter)) {
return new PromiseAdapter(create, resolve, reject);
}

this.create = create;
this.resolve = resolve;
this.reject = reject;
if (typeof create !== 'function') {
throw new TypeError('Adapter requires a function to create a promise.');
}

if (typeof create !== 'function') {
throw new TypeError('Adapter requires a function to create a promise.');
}

if (typeof resolve !== 'function') {
throw new TypeError('Adapter requires a function to resolve a promise.');
}
if (typeof resolve !== 'function') {
throw new TypeError('Adapter requires a function to resolve a promise.');
}

if (typeof reject !== 'function') {
throw new TypeError('Adapter requires a function to reject a promise.');
if (typeof reject !== 'function') {
throw new TypeError('Adapter requires a function to reject a promise.');
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/////////////////////////////////////

function isError(e, name) {
var confirmed = e instanceof Error &&
let confirmed = e instanceof Error &&
typeof e === 'object' &&
typeof e.message === 'string' &&
typeof e.stack === 'string';
Expand Down

0 comments on commit d7eb7fa

Please sign in to comment.