mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
perf: use polymophism instead duck test
This commit is contained in:
@@ -45,7 +45,7 @@ export default class Context {
|
||||
}
|
||||
return this.scopes.splice(i, 1)[0]
|
||||
}
|
||||
findScope (key: string) {
|
||||
private findScope (key: string) {
|
||||
for (let i = this.scopes.length - 1; i >= 0; i--) {
|
||||
const candidate = this.scopes[i]
|
||||
if (key in candidate) {
|
||||
@@ -73,7 +73,7 @@ export default class Context {
|
||||
* accessSeq("foo['b]r']") // ['foo', 'b]r']
|
||||
* accessSeq("foo[bar.coo]") // ['foo', 'bar'], for bar.coo == 'bar'
|
||||
*/
|
||||
async parseProp (str: string) {
|
||||
private async parseProp (str: string) {
|
||||
str = String(str)
|
||||
const seq: string[] = []
|
||||
let name = ''
|
||||
@@ -107,8 +107,7 @@ export default class Context {
|
||||
i++
|
||||
break
|
||||
default:// foo.bar
|
||||
name += str[i]
|
||||
i++
|
||||
name += str[i++]
|
||||
}
|
||||
}
|
||||
push()
|
||||
|
||||
Reference in New Issue
Block a user