From 3384ab7069ca8a5cd5c65462c335e6664dd40f72 Mon Sep 17 00:00:00 2001 From: sxyuzhenhua Date: Mon, 29 Aug 2022 01:49:06 +0800 Subject: [PATCH] tapble --- lib/db.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/db.js b/lib/db.js index a1fe32c..5f3b4a4 100644 --- a/lib/db.js +++ b/lib/db.js @@ -1,13 +1,29 @@ const Tapable = require('tapable') + +// {'endpoint': [fn, fn]} class DB extends Tapable { - constructor() { - // TODO - } + constructor(options) { + // TODO + super(); + this.options = options || {}; + } - request() { - // TODO - } + request (params = {}) { + // TODO + const options = this.applyPluginsWaterfall('options', this.options); + + return this.applyPluginsBailResult('endpoint', Object.assign(params, options)) + .then(res => { + if(this.applyPluginsBailResult('judge', res)){ + return Promise.reject(res); + } + return Promise.resolve(res); + }) + .catch(err => { + return Promise.reject(err); + }) + } } module.exports = DB \ No newline at end of file