perf: use polymophism instead duck test

This commit is contained in:
harttle
2019-03-25 20:11:23 +08:00
parent 64dd057552
commit 82d7673554
18 changed files with 120 additions and 98 deletions
+15 -2
View File
@@ -1,8 +1,21 @@
import DelimitedToken from './delimited-token'
import Token from './token'
import { NormalizedFullOptions } from '../liquid-options'
export default class OutputToken extends DelimitedToken {
constructor (raw: string, value: string, input: string, line: number, pos: number, file?: string) {
super(raw, value, input, line, pos, file)
constructor (
raw: string,
value: string,
input: string,
line: number,
pos: number,
options: NormalizedFullOptions,
file?: string
) {
super(raw, value, input, line, pos, options.trimOutputLeft, options.trimOutputRight, file)
this.type = 'output'
}
static is (token: Token): token is OutputToken {
return token.type === 'output'
}
}