5 次代码提交 34f2d12483 ... 833fdb445b

作者 SHA1 备注 提交日期
  Herby Vojčík 833fdb445b v0.2.0 5 月之前
  Herby Vojčík 0bfed1dfb9 Update author email. 5 月之前
  Herby Vojčík f07a2a3e4d Add resolveBy. 5 月之前
  Herby Vojčík b1bd95e861 Rename. 5 月之前
  Herby Vojčík ebe7f1c83f Change type to module. 5 月之前
共有 3 个文件被更改,包括 6 次插入33 次删除
  1. 0 24
      lib/node.js
  2. 5 9
      package.json
  3. 1 0
      src/deferred.js

+ 0 - 24
lib/node.js

@@ -1,24 +0,0 @@
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
-    value: true
-});
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-/*
- * Deferred pattern built on top of Promise.
- */
-
-var Deferred = function Deferred() {
-    var _this = this;
-
-    _classCallCheck(this, Deferred);
-
-    this.promise = new Promise(function (resolve, reject) {
-        _this.resolve = resolve;
-        _this.reject = reject;
-    });
-};
-
-exports.default = Deferred;

+ 5 - 9
package.json

@@ -1,10 +1,10 @@
 {
   "name": "deferred-lite",
-  "version": "0.1.1",
+  "version": "0.2.0",
   "description": "Deferred pattern on top of Promise",
-  "main": "lib/node.js",
+  "type": "module",
+  "main": "src/deferred.js",
   "scripts": {
-    "build": "babel src --presets es2015 --out-dir lib",
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "repository": {
@@ -14,14 +14,10 @@
   "keywords": [
     "deferred"
   ],
-  "author": "Herbert Vojčík <herby@mailbox.sk>",
+  "author": "Herbert Vojčík <herby@eleison.sk>",
   "license": "MIT",
   "bugs": {
     "url": "https://lolg.it/herby/deferred-lite/issues"
   },
-  "homepage": "https://lolg.it/herby/deferred-lite#readme",
-  "devDependencies": {
-    "babel-cli": "^6.9.0",
-    "babel-preset-es2015": "^6.9.0"
-  }
+  "homepage": "https://lolg.it/herby/deferred-lite#readme"
 }

+ 1 - 0
src/node.js → src/deferred.js

@@ -7,6 +7,7 @@ export default class Deferred {
         this.promise = new Promise((resolve, reject) => {
             this.resolve = resolve;
             this.reject = reject;
+            this.resolveBy = fn => resolve(fn());
         });
     }
 }