Skip to content

Commit

Permalink
use nullish coalescing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuspoehls committed Jan 27, 2024
1 parent b02d30d commit 9079d37
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/view/src/drivers/handlebars/helpers/append.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export default function append (stackName: string, context: any): void {
throw new Error('Provide a name when using the "append" handlebars helper.')
}

context.data.root = context.data.root || {}
const stacks = context.data.root.stacks || {}
const stack = stacks[stackName] || []
context.data.root = context.data.root ?? {}
const stacks = context.data.root.stacks ?? {}
const stack = stacks[stackName] ?? []

// @ts-expect-error
stack.push({ mode: 'append', data: context.fn(this) })
Expand Down
6 changes: 3 additions & 3 deletions packages/view/src/drivers/handlebars/helpers/prepend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export default function prepend (stackName: string, context: any): void {
throw new Error('Provide a name when using the "prepend" handlebars helper.')
}

context.data.root = context.data.root || {}
const stacks = context.data.root.stacks || {}
const stack = stacks[stackName] || []
context.data.root = context.data.root ?? {}
const stacks = context.data.root.stacks ?? {}
const stack = stacks[stackName] ?? []

// @ts-expect-error
stack.unshift({ mode: 'prepend', data: context.fn(this) })
Expand Down
6 changes: 3 additions & 3 deletions packages/view/src/drivers/handlebars/helpers/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export default function stack (name: string, context: any): string {
throw new Error('Provide a name when using the "stack" handlebars helper.')
}

const data = context.data.root || {}
const stacks = data.stacks || {}
const stack = stacks[name] || []
const data = context.data.root ?? {}
const stacks = data.stacks ?? {}
const stack = stacks[name] ?? []

const content = stack
.reduce((carry: string[], { mode, data }: { mode: string, data: string }) => {
Expand Down

0 comments on commit 9079d37

Please sign in to comment.