Skip to content

Commit

Permalink
webpack 4 babel
Browse files Browse the repository at this point in the history
  • Loading branch information
Keillion committed Apr 21, 2022
1 parent 379d995 commit 77d072b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mutable-promise",
"version": "1.1.10",
"version": "1.1.13",
"description": "Wrapper for Promise. Resolvable, rejectable, redirectable.",
"files": [
"/dist",
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type Executor<T> = (resolve: Resolve<T>, reject: Reject) => void;

const isPromiseLike = (value:any) => (value && "object" === typeof value && "function" === typeof value.then);

class MutablePromise<T>{ //extends Promise<T>{
class MutablePromise<T> extends Promise<T>{

private _s: string;
get status(){ return this._s; }
Expand Down Expand Up @@ -55,11 +55,13 @@ class MutablePromise<T>{ //extends Promise<T>{
let rs: Resolve<T>;
let rj: Reject;
const fn = (_rs: Resolve<T>, _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<T>)=>{
if(this.isPending){
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "esnext",
"target": "es2017",
"module": "esnext",
//"lib": ["DOM","ES2015"],
//"strict": true,
Expand Down

0 comments on commit 77d072b

Please sign in to comment.