protoblast
Advanced tools
Comparing version 0.7.14 to 0.7.15
@@ -0,1 +1,7 @@ | ||
## 0.7.15 (2022-02-20) | ||
* Fix `Date#secondsToDuration()` using wrong rounded months | ||
* Allow scripts loaded with `Blast.require()` to use top-level await | ||
* Make `Function.series` and `Function.parallel` throw better errors | ||
## 0.7.14 (2021-09-24) | ||
@@ -2,0 +8,0 @@ |
@@ -962,2 +962,3 @@ var rx_duration = /[-+]|(this|next|last|previous)\s+(\w+)|((-?\d*\.?\d+(?:e[-+]?\d+)?)\s*([a-zμ]*))|\w+/ig, | ||
minimize = false, | ||
dec_months, | ||
base_settings, | ||
@@ -970,3 +971,4 @@ context, | ||
days = days % 365; | ||
months = Math.round(days / 30); | ||
dec_months = days / 30; | ||
months = Math.floor(dec_months); | ||
minutes = (~~minutes) % 60; | ||
@@ -1015,4 +1017,12 @@ seconds = Math.round(seconds) % 60; | ||
} else if (months > 1) { | ||
days = days % 30; | ||
// If the string should be minimized, and there are years to show, | ||
// days will be hidden. So in that case the months should be rounded | ||
// correctly (instead of just being rounded down) | ||
if (minimize && years) { | ||
months = Math.round(dec_months); | ||
} | ||
result += numberString(settings.months, months); | ||
days = days % 30; | ||
} | ||
@@ -1019,0 +1029,0 @@ |
@@ -95,3 +95,3 @@ /** | ||
* @since 0.1.2 | ||
* @version 0.7.5 | ||
* @version 0.7.15 | ||
* | ||
@@ -202,2 +202,5 @@ * @param {Boolean} _forceAsync Force asynchronous behaviour [TRUE] | ||
// An error to know where any possible error happened | ||
let origin_error = new Error(''); | ||
handler = function blastSeriesHandler(err, result) { | ||
@@ -235,2 +238,5 @@ | ||
if (i < length && tasks[next]) { | ||
let task = tasks[next]; | ||
scheduler(function nextSerialTask() { | ||
@@ -243,3 +249,10 @@ | ||
if (count == 1) { | ||
err = new Error('Next handler has been called multiple times'); | ||
let message = 'Function.series next handler has been called multiple times'; | ||
if (task && task.name) { | ||
message += ' in "' + task.name + '" task'; | ||
} | ||
err = new Error(message); | ||
err.stack += '\n' + origin_error.stack; | ||
return doRejection(err); | ||
@@ -257,11 +270,11 @@ } else if (count > 1) { | ||
try { | ||
if (typeof tasks[next] == 'function') { | ||
tasks[next](nextHandler, result); | ||
if (typeof task == 'function') { | ||
task(nextHandler, result); | ||
} else { | ||
pledge._addProgressPledge(tasks[next]); | ||
pledge._addProgressPledge(task); | ||
if (typeof tasks[next] != 'object') { | ||
Blast.Classes.Pledge.resolve(tasks[next]).done(nextHandler); | ||
if (typeof task != 'object') { | ||
Blast.Classes.Pledge.resolve(task).done(nextHandler); | ||
} else { | ||
Blast.Classes.Pledge.prototype.handleCallback.call(tasks[next], nextHandler); | ||
Blast.Classes.Pledge.prototype.handleCallback.call(task, nextHandler); | ||
} | ||
@@ -335,3 +348,3 @@ } | ||
* @since 0.1.2 | ||
* @version 0.7.7 | ||
* @version 0.7.15 | ||
*/ | ||
@@ -482,2 +495,5 @@ Blast.defineStatic('Function', function parallel(_forceAsync, _limit, _tasks, _callback) { | ||
// An error to know where any possible error happened | ||
let origin_error = new Error(''); | ||
handler = function blastParallelHandler(i, err, result) { | ||
@@ -510,2 +526,3 @@ | ||
next = started++; | ||
let task = tasks[next]; | ||
@@ -519,3 +536,10 @@ scheduler(function scheduleNextTask() { | ||
if (count == 1) { | ||
err = new Error('Next handler has been called multiple times'); | ||
let message = 'Function.series next handler has been called multiple times'; | ||
if (task && task.name) { | ||
message += ' in "' + task.name + '" task'; | ||
} | ||
err = new Error(message); | ||
err.stack += '\n' + origin_error.stack; | ||
return doRejection(err); | ||
@@ -533,11 +557,11 @@ } else if (count > 1) { | ||
try { | ||
if (typeof tasks[next] == 'function') { | ||
tasks[next](nextHandler); | ||
if (typeof task == 'function') { | ||
task(nextHandler); | ||
} else { | ||
pledge._addProgressPledge(tasks[next]); | ||
pledge._addProgressPledge(task); | ||
if (typeof tasks[next] != 'object') { | ||
Blast.Classes.Pledge.resolve(tasks[next]).done(nextHandler); | ||
if (typeof task != 'object') { | ||
Blast.Classes.Pledge.resolve(task).done(nextHandler); | ||
} else { | ||
Blast.Classes.Pledge.prototype.handleCallback.call(tasks[next], nextHandler); | ||
Blast.Classes.Pledge.prototype.handleCallback.call(task, nextHandler); | ||
} | ||
@@ -544,0 +568,0 @@ } |
@@ -1266,3 +1266,3 @@ module.exports = function BlastInitLoader(modifyPrototype) { | ||
* @author Jelle De Loecker <jelle@develry.be> | ||
* @version 0.6.6 | ||
* @version 0.7.15 | ||
* | ||
@@ -1299,4 +1299,10 @@ * @param {Object} options | ||
head = 'module.exports = function('; | ||
head = 'module.exports = '; | ||
if (options.async) { | ||
head += 'async'; | ||
} | ||
head += ' function('; | ||
if (options.arguments) { | ||
@@ -1303,0 +1309,0 @@ head += Blast.getArgumentConfiguration(options.arguments).names.join(','); |
{ | ||
"name": "protoblast", | ||
"description": "Native object expansion library", | ||
"version": "0.7.14", | ||
"version": "0.7.15", | ||
"author": "Jelle De Loecker <jelle@elevenways.be>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
736245
30520