Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use arrow functions when calling Array.prototype.filter #8557

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions core/events/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,8 @@ function fireNow() {
const queue = filter(FIRE_QUEUE, true);
FIRE_QUEUE.length = 0;
for (const event of queue) {
if (!event.workspaceId) {
continue;
}
const eventWorkspace = common.getWorkspaceById(event.workspaceId);
if (eventWorkspace) {
eventWorkspace.fireChangeListener(event);
}
if (!event.workspaceId) continue;
common.getWorkspaceById(event.workspaceId)?.fireChangeListener(event);
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/utils/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ function hasCategoriesInternal(toolboxJson: ToolboxInfo | null): boolean {
return toolboxKind === CATEGORY_TOOLBOX_KIND;
}

const categories = toolboxJson['contents'].filter(function (item) {
return item['kind'].toUpperCase() === 'CATEGORY';
});
const categories = toolboxJson['contents'].filter(
(item) => item['kind'].toUpperCase() === 'CATEGORY',
);
return !!categories.length;
}

Expand Down
10 changes: 2 additions & 8 deletions core/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ export class Workspace implements IASTNodeLocation {
blocks.sort(this.sortObjects_.bind(this));
}

return blocks.filter(function (block: Block) {
return !block.isInsertionMarker();
});
return blocks.filter((block) => !block.isInsertionMarker());
}

/**
Expand Down Expand Up @@ -341,11 +339,7 @@ export class Workspace implements IASTNodeLocation {

// Insertion markers exist on the workspace for rendering reasons, but
// aren't "real" blocks from a developer perspective.
const filtered = blocks.filter(function (block) {
return !block.isInsertionMarker();
});

return filtered;
return blocks.filter((block) => !block.isInsertionMarker());
}

/** Dispose of all blocks and comments in workspace. */
Expand Down
4 changes: 1 addition & 3 deletions core/workspace_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {

// Update all blocks in workspace that have a style name.
this.updateBlockStyles_(
this.getAllBlocks(false).filter(function (block) {
return !!block.getStyleName();
}),
this.getAllBlocks(false).filter((block) => !!block.getStyleName()),
);

// Update current toolbox selection.
Expand Down
6 changes: 3 additions & 3 deletions tests/mocha/event_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1745,9 +1745,9 @@ suite('Events', function () {
// Fire all events
this.clock.runAll();

const disabledEvents = this.workspace.getUndoStack().filter(function (e) {
return e.element === 'disabled';
});
const disabledEvents = this.workspace
.getUndoStack()
.filter((e) => e.element === 'disabled');
assert.isEmpty(
disabledEvents,
'Undo stack should not contain any disabled events',
Expand Down
Loading