diff --git a/package.json b/package.json index 5c2a7ea..f6063ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mutable-promise", - "version": "1.1.10", + "version": "1.1.13", "description": "Wrapper for Promise. Resolvable, rejectable, redirectable.", "files": [ "/dist", diff --git a/src/index.ts b/src/index.ts index db34102..9368230 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ type Executor = (resolve: Resolve, reject: Reject) => void; const isPromiseLike = (value:any) => (value && "object" === typeof value && "function" === typeof value.then); -class MutablePromise{ //extends Promise{ +class MutablePromise extends Promise{ private _s: string; get status(){ return this._s; } @@ -55,11 +55,13 @@ class MutablePromise{ //extends Promise{ let rs: Resolve; let rj: Reject; const fn = (_rs: Resolve, _rj: Reject)=>{ rs = _rs; rj = _rj; }; - // super(fn); + super(fn); // walkaround babel which can not extend builtin class - this.then = (new Promise(fn).then); - + // let _this = this; + // let then = new Promise(fn).then; + // this.then = function(){ then.apply(_this, arguments) } as any; + this._s = "pending"; this.resolve = (value: ResolveValue)=>{ if(this.isPending){ diff --git a/tsconfig.json b/tsconfig.json index 9085ee9..5d8c1c7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "esnext", + "target": "es2017", "module": "esnext", //"lib": ["DOM","ES2015"], //"strict": true,