mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Modernize & fix bad var assignment
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
* `email@2.1.1`
|
||||
- Updated `nodemailer` to v6.6.3
|
||||
|
||||
* `callback-hook@1.3.1`
|
||||
- Modernized the code
|
||||
- Fixed a variable assignment bug in `dontBindEnvironment` function
|
||||
|
||||
## v2.3.2, 2021-07-13
|
||||
|
||||
#### Meteor Version Release
|
||||
|
||||
@@ -60,7 +60,7 @@ export class Hook {
|
||||
}
|
||||
|
||||
register(callback) {
|
||||
var exceptionHandler = this.exceptionHandler || function (exception) {
|
||||
const exceptionHandler = this.exceptionHandler || function (exception) {
|
||||
// Note: this relies on the undocumented fact that if bindEnvironment's
|
||||
// onException throws, and you are invoking the callback either in the
|
||||
// browser or from within a Fiber in Node, the exception is propagated.
|
||||
@@ -73,7 +73,7 @@ export class Hook {
|
||||
callback = dontBindEnvironment(callback, exceptionHandler);
|
||||
}
|
||||
|
||||
var id = this.nextCallbackId++;
|
||||
const id = this.nextCallbackId++;
|
||||
this.callbacks[id] = callback;
|
||||
|
||||
return {
|
||||
@@ -100,12 +100,12 @@ export class Hook {
|
||||
// propagated), so we need to be in a Fiber.
|
||||
Meteor._nodeCodeMustBeInFiber();
|
||||
|
||||
var ids = Object.keys(this.callbacks);
|
||||
for (var i = 0; i < ids.length; ++i) {
|
||||
var id = ids[i];
|
||||
const ids = Object.keys(this.callbacks);
|
||||
for (let i = 0; i < ids.length; ++i) {
|
||||
const id = ids[i];
|
||||
// check to see if the callback was removed during iteration
|
||||
if (hasOwn.call(this.callbacks, id)) {
|
||||
var callback = this.callbacks[id];
|
||||
const callback = this.callbacks[id];
|
||||
if (! iterator(callback)) {
|
||||
break;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ export class Hook {
|
||||
// Copied from Meteor.bindEnvironment and removed all the env stuff.
|
||||
function dontBindEnvironment(func, onException, _this) {
|
||||
if (!onException || typeof(onException) === 'string') {
|
||||
var description = onException || "callback of async function";
|
||||
const description = onException || "callback of async function";
|
||||
onException = function (error) {
|
||||
Meteor._debug(
|
||||
"Exception in " + description,
|
||||
@@ -127,8 +127,9 @@ function dontBindEnvironment(func, onException, _this) {
|
||||
}
|
||||
|
||||
return function (...args) {
|
||||
let ret;
|
||||
try {
|
||||
var ret = func.apply(_this, args);
|
||||
ret = func.apply(_this, args);
|
||||
} catch (e) {
|
||||
onException(e);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Tinytest.add("callback-hook - binds to registrar's env by default", function (test) {
|
||||
var hook = new Hook();
|
||||
var envVar = new Meteor.EnvironmentVariable;
|
||||
const hook = new Hook();
|
||||
const envVar = new Meteor.EnvironmentVariable;
|
||||
envVar.withValue("registrar's value", function() {
|
||||
hook.register(function() {
|
||||
test.equal(envVar.get(), "registrar's value");
|
||||
@@ -14,8 +14,8 @@ Tinytest.add("callback-hook - binds to registrar's env by default", function (te
|
||||
});
|
||||
|
||||
Tinytest.add("callback-hook - uses invoker's env with {bindEnvironment: false}", function (test) {
|
||||
var hook = new Hook({ bindEnvironment: false });
|
||||
var envVar = new Meteor.EnvironmentVariable;
|
||||
const hook = new Hook({ bindEnvironment: false });
|
||||
const envVar = new Meteor.EnvironmentVariable;
|
||||
envVar.withValue("registrar's value", function() {
|
||||
hook.register(function() {
|
||||
test.equal(envVar.get(), "invoker's value");
|
||||
@@ -29,7 +29,7 @@ Tinytest.add("callback-hook - uses invoker's env with {bindEnvironment: false}",
|
||||
});
|
||||
|
||||
Tinytest.add("callback-hook - exceptions unhandled with {bindEnvironment: false}", function (test) {
|
||||
var hook = new Hook({ bindEnvironment: false });
|
||||
const hook = new Hook({ bindEnvironment: false });
|
||||
hook.register(function() {
|
||||
throw new Error("Test error");
|
||||
});
|
||||
@@ -39,9 +39,9 @@ Tinytest.add("callback-hook - exceptions unhandled with {bindEnvironment: false}
|
||||
});
|
||||
|
||||
Tinytest.add("callback-hook - exceptionHandler used with {bindEnvironment: false}", function (test) {
|
||||
var exToThrow = new Error("Test error");
|
||||
var thrownEx = null;
|
||||
var hook = new Hook({
|
||||
const exToThrow = new Error("Test error");
|
||||
let thrownEx = null;
|
||||
const hook = new Hook({
|
||||
bindEnvironment: false,
|
||||
exceptionHandler: function (ex) { thrownEx = ex; }
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Package.describe({
|
||||
summary: "Register callbacks on a hook",
|
||||
version: '1.3.0'
|
||||
version: '1.3.1'
|
||||
});
|
||||
|
||||
Package.onUse(function (api) {
|
||||
|
||||
Reference in New Issue
Block a user