feat: make ordered argument optional for workspace functions (#7424)

This commit is contained in:
randrei12
2023-08-22 20:28:10 +03:00
committed by GitHub
parent 9909868435
commit 93106777b0

View File

@@ -206,7 +206,7 @@ export class Workspace implements IASTNodeLocation {
* @param ordered Sort the list if true.
* @returns The top-level block objects.
*/
getTopBlocks(ordered: boolean): Block[] {
getTopBlocks(ordered = false): Block[] {
// Copy the topBlocks list.
const blocks = new Array<Block>().concat(this.topBlocks);
if (ordered && blocks.length > 1) {
@@ -247,7 +247,7 @@ export class Workspace implements IASTNodeLocation {
* @param ordered Sort the list if true.
* @returns The blocks of the given type.
*/
getBlocksByType(type: string, ordered: boolean): Block[] {
getBlocksByType(type: string, ordered = false): Block[] {
if (!this.typedBlocksDB.has(type)) {
return [];
}
@@ -307,7 +307,7 @@ export class Workspace implements IASTNodeLocation {
* @returns The top-level comment objects.
* @internal
*/
getTopComments(ordered: boolean): WorkspaceComment[] {
getTopComments(ordered = false): WorkspaceComment[] {
// Copy the topComments list.
const comments = new Array<WorkspaceComment>().concat(this.topComments);
if (ordered && comments.length > 1) {
@@ -323,7 +323,7 @@ export class Workspace implements IASTNodeLocation {
* @param ordered Sort the list if true.
* @returns Array of blocks.
*/
getAllBlocks(ordered: boolean): Block[] {
getAllBlocks(ordered = false): Block[] {
let blocks: Block[];
if (ordered) {
// Slow, but ordered.