Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/browserify-sign-4.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 authored Sep 10, 2024
2 parents aa40cb2 + 764ae1a commit da541ec
Show file tree
Hide file tree
Showing 21 changed files with 3,477 additions and 3,695 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:

strategy:
matrix:
node-version: [12, 14, 16]
node-version: [16]

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.20.2
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ URL may be a regular expression, e.g. `/\\/post\\//\\d+`
If the response is a `Function`, it will be passed any capture groups from the regular expression along with the XMLHttpRequest object:

```js
server.respondWith(/\/todo-items\/(\d+)/, function(xhr, id) {
server.respondWith(/\/todo-items\/(\d+)/, function (xhr, id) {
xhr.respond(
200,
{ "Content-Type": "application/json" },
'[{ "id": ' + id + " }]"
'[{ "id": ' + id + " }]",
);
});
```
Expand Down
4 changes: 2 additions & 2 deletions lib/configure-logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function configureLogger(config) {
// Function which prints errors.
if (!config.hasOwnProperty("logger")) {
// eslint-disable-next-line no-empty-function
config.logger = function() {};
config.logger = function () {};
}
// When set to true, any errors logged will be thrown immediately;
// If set to false, the errors will be thrown in separate execution frame.
Expand All @@ -28,7 +28,7 @@ function configureLogger(config) {
var err = {
name: e.name || label,
message: e.message || e.toString(),
stack: e.stack
stack: e.stack,
};

function throwLoggedError() {

Check warning on line 34 in lib/configure-logger/index.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc comment
Expand Down
62 changes: 31 additions & 31 deletions lib/configure-logger/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ var sinon = require("sinon");

var configureLogError = require("./index");

describe("configureLogger", function() {
beforeEach(function() {
describe("configureLogger", function () {
beforeEach(function () {
this.sandbox = sinon.createSandbox();
this.timeOutStub = this.sandbox.stub();
});

afterEach(function() {
afterEach(function () {
this.sandbox.restore();
});

it("is a function", function() {
it("is a function", function () {
var instance = configureLogError();
assert.isFunction(instance);
});

it("calls config.logger function with a String", function() {
it("calls config.logger function with a String", function () {
var spy = this.sandbox.spy();
var logError = configureLogError({
logger: spy,
setTimeout: this.timeOutStub,
useImmediateExceptions: false
useImmediateExceptions: false,
});
var name = "Quisque consequat, elit id suscipit.";
var message =
Expand All @@ -43,12 +43,12 @@ describe("configureLogger", function() {
assert(spy.calledWithMatch(message));
});

it("calls config.logger function with a stack", function() {
it("calls config.logger function with a stack", function () {
var spy = this.sandbox.spy();
var logError = configureLogError({
logger: spy,
setTimeout: this.timeOutStub,
useImmediateExceptions: false
useImmediateExceptions: false,
});
var stack =
"Integer rutrum dictum elit, posuere accumsan nisi pretium vel. Phasellus adipiscing.";
Expand All @@ -62,10 +62,10 @@ describe("configureLogger", function() {
assert(spy.calledWithMatch(stack));
});

it("should call config.setTimeout", function() {
it("should call config.setTimeout", function () {
var logError = configureLogError({
setTimeout: this.timeOutStub,
useImmediateExceptions: false
useImmediateExceptions: false,
});
var error = new Error();

Expand All @@ -74,10 +74,10 @@ describe("configureLogger", function() {
assert(this.timeOutStub.calledOnce);
});

it("should pass a throwing function to config.setTimeout", function() {
it("should pass a throwing function to config.setTimeout", function () {
var logError = configureLogError({
setTimeout: this.timeOutStub,
useImmediateExceptions: false
useImmediateExceptions: false,
});
var error = new Error();

Expand All @@ -87,72 +87,72 @@ describe("configureLogger", function() {
assert.exception(func);
});

describe("config.useImmediateExceptions", function() {
beforeEach(function() {
describe("config.useImmediateExceptions", function () {
beforeEach(function () {
this.sandbox = sinon.createSandbox();
this.timeOutStub = this.sandbox.stub();
});

afterEach(function() {
afterEach(function () {
this.sandbox.restore();
});

it("throws the logged error immediately, does not call logError.setTimeout when flag is true", function() {
it("throws the logged error immediately, does not call logError.setTimeout when flag is true", function () {
var error = new Error();
var logError = configureLogError({
setTimeout: this.timeOutStub,
useImmediateExceptions: true
useImmediateExceptions: true,
});

assert.exception(function() {
assert.exception(function () {
logError("an error", error);
});
assert(this.timeOutStub.notCalled);
});

it("does not throw logged error immediately and calls logError.setTimeout when flag is false", function() {
it("does not throw logged error immediately and calls logError.setTimeout when flag is false", function () {
var error = new Error();
var logError = configureLogError({
setTimeout: this.timeOutStub,
useImmediateExceptions: false
useImmediateExceptions: false,
});

refute.exception(function() {
refute.exception(function () {
logError("an error", error);
});
assert(this.timeOutStub.called);
});
});

describe("#835", function() {
it("logError() throws an exception if the passed err is read-only", function() {
describe("#835", function () {
it("logError() throws an exception if the passed err is read-only", function () {
var logError = configureLogError({ useImmediateExceptions: true });

// passes
var err = {
name: "TestError",
message: "this is a proper exception"
message: "this is a proper exception",
};
assert.exception(
function() {
function () {
logError("#835 test", err);
},
{
name: err.name
}
name: err.name,
},
);

// fails until this issue is fixed
assert.exception(
function() {
function () {
logError(
"#835 test",
"this literal string is not a proper exception"
"this literal string is not a proper exception",
);
},
{
name: "#835 test"
}
name: "#835 test",
},
);
});
});
Expand Down
24 changes: 12 additions & 12 deletions lib/event/event-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ function flattenOptions(options) {
return {
capture: Boolean(options),
once: false,
passive: false
passive: false,
};
}
return {
capture: Boolean(options.capture),
once: Boolean(options.once),
passive: Boolean(options.passive)
passive: Boolean(options.passive),
};
}
function not(fn) {

Check warning on line 17 in lib/event/event-target.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc comment
return function() {
return function () {
return !fn.apply(this, arguments);
};
}
function hasListenerFilter(listener, capture) {

Check warning on line 22 in lib/event/event-target.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc comment
return function(listenerSpec) {
return function (listenerSpec) {
return (
listenerSpec.capture === capture &&
listenerSpec.listener === listener
Expand All @@ -33,7 +33,7 @@ var EventTarget = {
addEventListener: function addEventListener(
event,
listener,
providedOptions
providedOptions,
) {
// 3. Let capture, passive, and once be the result of flattening more options.
// Flatten property before executing step 2,
Expand All @@ -59,13 +59,13 @@ var EventTarget = {
// callback, capture is capture, passive is passive, and once is once.
if (
!this.eventListeners[event].some(
hasListenerFilter(listener, options.capture)
hasListenerFilter(listener, options.capture),
)
) {
this.eventListeners[event].push({
listener: listener,
capture: options.capture,
once: options.once
once: options.once,
});
}
},
Expand All @@ -74,7 +74,7 @@ var EventTarget = {
removeEventListener: function removeEventListener(
event,
listener,
providedOptions
providedOptions,
) {
if (!this.eventListeners || !this.eventListeners[event]) {
return;
Expand All @@ -88,7 +88,7 @@ var EventTarget = {
// and capture is capture, then set that event listener’s
// removed to true and remove it from the associated list of event listeners.
this.eventListeners[event] = this.eventListeners[event].filter(
not(hasListenerFilter(listener, options.capture))
not(hasListenerFilter(listener, options.capture)),
);
},

Expand All @@ -103,10 +103,10 @@ var EventTarget = {

// Remove listeners, that should be dispatched once
// before running dispatch loop to avoid nested dispatch issues
self.eventListeners[type] = listeners.filter(function(listenerSpec) {
self.eventListeners[type] = listeners.filter(function (listenerSpec) {
return !listenerSpec.once;
});
listeners.forEach(function(listenerSpec) {
listeners.forEach(function (listenerSpec) {
var listener = listenerSpec.listener;
if (typeof listener === "function") {
listener.call(self, event);
Expand All @@ -116,7 +116,7 @@ var EventTarget = {
});

return Boolean(event.defaultPrevented);
}
},
};

module.exports = EventTarget;
8 changes: 4 additions & 4 deletions lib/event/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Event(type, bubbles, cancelable, target) {
}

Event.prototype = {
initEvent: function(type, bubbles, cancelable, target) {
initEvent: function (type, bubbles, cancelable, target) {
this.type = type;
this.bubbles = bubbles;
this.cancelable = cancelable;
Expand All @@ -14,11 +14,11 @@ Event.prototype = {
},

// eslint-disable-next-line no-empty-function
stopPropagation: function() {},
stopPropagation: function () {},

preventDefault: function() {
preventDefault: function () {
this.defaultPrevented = true;
}
},
};

module.exports = Event;
2 changes: 1 addition & 1 deletion lib/event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = {
Event: require("./event"),
ProgressEvent: require("./progress-event"),
CustomEvent: require("./custom-event"),
EventTarget: require("./event-target")
EventTarget: require("./event-target"),
};
Loading

0 comments on commit da541ec

Please sign in to comment.