Comparing version 1.1.2 to 1.3.0
@@ -5,17 +5,1 @@ /** | ||
**/ | ||
const _PROMISE_THEN = Promise.prototype.then; | ||
const _PROMISE_CATCH = Promise.prototype.catch; | ||
const _PROMISE_FINALLY = Promise.prototype.finally; | ||
Promise.prototype.then = function(...args){ | ||
const next_promise = _PROMISE_THEN.call(this, ...args); | ||
return Object.assign(next_promise, this); | ||
}; | ||
Promise.prototype.catch = function(...args){ | ||
const next_promise = _PROMISE_CATCH.call(this, ...args); | ||
return Object.assign(next_promise, this); | ||
}; | ||
Promise.prototype.finally = function(...args){ | ||
const next_promise = _PROMISE_FINALLY.call(this, ...args); | ||
return Object.assign(next_promise, this); | ||
}; |
@@ -12,3 +12,5 @@ /** | ||
}; | ||
HTMLElement.prototype.getData = function(key) { | ||
return this.dataset[key]; | ||
}; | ||
HTMLElement.prototype.removeData = function(...data_names) { | ||
@@ -15,0 +17,0 @@ for( const name of data_names ) { |
{ | ||
"name": "extes", | ||
"version": "1.1.2", | ||
"version": "1.3.0", | ||
"description": "A tiny library that extends native js with some handy tools", | ||
@@ -5,0 +5,0 @@ "main": "index.mjs", |
@@ -5,2 +5,31 @@ /** | ||
**/ | ||
const _PROMISE_THEN = Promise.prototype.then; | ||
const _PROMISE_CATCH = Promise.prototype.catch; | ||
const _PROMISE_FINALLY = Promise.prototype.finally; | ||
Promise.prototype.then = function(...args) { | ||
const next_promise = _PROMISE_THEN.call(this, ...args); | ||
Object.assign(next_promise, this); | ||
delete this._prev; | ||
Object.defineProperty(next_promise, '_prev', {value:this}); | ||
return next_promise; | ||
}; | ||
Promise.prototype.catch = function(...args) { | ||
const next_promise = _PROMISE_CATCH.call(this, ...args); | ||
Object.assign(next_promise, this); | ||
delete this._prev; | ||
Object.defineProperty(next_promise, '_prev', {value:this}); | ||
return next_promise; | ||
}; | ||
Promise.prototype.finally = function(...args) { | ||
const next_promise = _PROMISE_FINALLY.call(this, ...args); | ||
Object.assign(next_promise, this); | ||
delete this._prev; | ||
Object.defineProperty(next_promise, '_prev', {value:this}); | ||
return next_promise; | ||
}; | ||
Promise.wait = PromiseWaitAll; | ||
@@ -11,2 +40,5 @@ Promise.create = FlattenedPromise; | ||
function PromiseWaitAll(promise_queue=[]) { | ||
@@ -13,0 +45,0 @@ if ( !Array.isArray(promise_queue) ){ |
20858
683