1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- const {assert} = require('./assert');
- class PromiseAdapter {
- constructor(api) {
- if (!api || typeof api !== 'object') {
- throw new TypeError('Adapter requires an api configuration object.');
- }
- api = assert(api, ['create', 'resolve', 'reject', 'all']);
- this.create = api.create;
- this.resolve = api.resolve;
- this.reject = api.reject;
- this.all = api.all;
- if (typeof this.create !== 'function') {
- throw new TypeError('Function \'create\' must be specified.');
- }
- if (typeof this.resolve !== 'function') {
- throw new TypeError('Function \'resolve\' must be specified.');
- }
- if (typeof this.reject !== 'function') {
- throw new TypeError('Function \'reject\' must be specified.');
- }
- if (typeof this.all !== 'function') {
- throw new TypeError('Function \'all\' must be specified.');
- }
- }
- }
- module.exports = {PromiseAdapter};
|