mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
refactor: encapsulate Drop passthrough in createScope
This commit is contained in:
@@ -95,7 +95,7 @@ export class Context {
|
||||
return scope
|
||||
}
|
||||
public push (ctx: Scope): Scope {
|
||||
const scope = ctx instanceof Drop ? ctx : createScope(ctx)
|
||||
const scope = createScope(ctx)
|
||||
this.scopes.push(scope)
|
||||
return scope
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface ScopeObject extends Record<string | number | symbol, any> {
|
||||
|
||||
export type Scope = ScopeObject | Drop
|
||||
|
||||
export function createScope (from?: ScopeObject): ScopeObject {
|
||||
export function createScope (from?: Scope): Scope {
|
||||
if (from instanceof Drop) return from
|
||||
return Object.assign(Object.create(null), from)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user