mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 04:40:39 -07:00
chore: fix linting
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
"no-var": 2,
|
||||
"prefer-const": 2,
|
||||
"no-unused-vars": "off",
|
||||
"import/export": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
"types": "dist/liquid.d.ts",
|
||||
"browser": "dist/liquid.js",
|
||||
"scripts": {
|
||||
"lint": "eslint . --ext .ts --ext .js",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"unit": "mocha 'test/unit/**/*.ts'",
|
||||
"e2e": "npm run build && mocha 'test/e2e/**/*.ts'",
|
||||
"test": "npm run unit && npm run e2e",
|
||||
@@ -62,7 +62,7 @@
|
||||
"eslint": "^5.12.1",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.15.0",
|
||||
"eslint-plugin-mocha": "^5.2.1",
|
||||
"eslint-plugin-mocha": "^5.3.0",
|
||||
"eslint-plugin-node": "^8.0.1",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import FilterImpl from "src/template/filter/filter-impl";
|
||||
import { FilterImpl } from 'src/template/filter/filter-impl'
|
||||
|
||||
export default {
|
||||
'append': (v: string, arg: string) => v + arg,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
'url_decode': (x: string) => x.split('+').map(decodeURIComponent).join(' '),
|
||||
'url_encode': (x: string) => x.split(' ').map(encodeURIComponent).join('+')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import assert from 'src/util/assert'
|
||||
import { identifier } from 'src/parser/lexical'
|
||||
import { AssignScope } from 'src/scope/scopes'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const re = new RegExp(`(${identifier.source})\\s*=([^]*)`)
|
||||
|
||||
@@ -20,4 +20,4 @@ export default {
|
||||
scope.push(ctx)
|
||||
return Promise.resolve('')
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import BlockMode from 'src/scope/block-mode'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
export default {
|
||||
parse: function (token: TagToken, remainTokens: Token[]) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CaptureScope } from 'src/scope/scopes'
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const re = new RegExp(`(${identifier.source})`)
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { evalExp } from 'src/render/syntax'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
@@ -41,4 +41,4 @@ export default {
|
||||
}
|
||||
return this.liquid.renderer.renderTemplates(this.elseTemplates, scope)
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import TagToken from "src/parser/tag-token";
|
||||
import Token from "src/parser/token";
|
||||
import ITagImplOptions from "src/template/tag/itag-impl-options";
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
@@ -14,4 +14,4 @@ export default {
|
||||
})
|
||||
stream.start()
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import assert from 'src/util/assert'
|
||||
import { value as rValue } from 'src/parser/lexical'
|
||||
import { evalValue } from 'src/render/syntax'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const groupRE = new RegExp(`^(?:(${rValue.source})\\s*:\\s*)?(.*)$`)
|
||||
const candidatesRE = new RegExp(rValue.source, 'g')
|
||||
@@ -40,4 +40,4 @@ export default <ITagImplOptions>{
|
||||
|
||||
return evalValue(candidate, scope)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { identifier } from 'src/parser/lexical'
|
||||
import { CaptureScope, AssignScope, DecrementScope } from 'src/scope/scopes'
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
export default {
|
||||
parse: function (token: TagToken) {
|
||||
@@ -27,4 +27,4 @@ export default {
|
||||
}
|
||||
return --context[this.variable]
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
+17
-17
@@ -3,13 +3,13 @@ import { isString, isObject, isArray } from 'src/util/underscore'
|
||||
import { evalExp } from 'src/render/syntax'
|
||||
import assert from 'src/util/assert'
|
||||
import { identifier, value, hash } from 'src/parser/lexical'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Hash from 'src/template/tag/hash'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
|
||||
`(${value.source})` +
|
||||
@@ -25,10 +25,10 @@ export default <ITagImplOptions>{
|
||||
this.variable = match[1]
|
||||
this.collection = match[2]
|
||||
this.reversed = !!match[3]
|
||||
|
||||
|
||||
this.templates = []
|
||||
this.elseTemplates = []
|
||||
|
||||
|
||||
let p
|
||||
const stream: ParseStream = this.liquid.parser.parseStream(remainTokens)
|
||||
.on('start', () => (p = this.templates))
|
||||
@@ -38,12 +38,12 @@ export default <ITagImplOptions>{
|
||||
.on('end', () => {
|
||||
throw new Error(`tag ${tagToken.raw} not closed`)
|
||||
})
|
||||
|
||||
|
||||
stream.start()
|
||||
},
|
||||
render: async function (scope: Scope, hash: Hash) {
|
||||
let collection = evalExp(this.collection, scope)
|
||||
|
||||
|
||||
if (!isArray(collection)) {
|
||||
if (isString(collection) && collection.length > 0) {
|
||||
collection = [collection] as string[]
|
||||
@@ -54,13 +54,13 @@ export default <ITagImplOptions>{
|
||||
if (!isArray(collection) || !collection.length) {
|
||||
return this.liquid.renderer.renderTemplates(this.elseTemplates, scope)
|
||||
}
|
||||
|
||||
|
||||
const offset = hash.offset || 0
|
||||
const limit = (hash.limit === undefined) ? collection.length : hash.limit
|
||||
|
||||
|
||||
collection = collection.slice(offset, offset + limit)
|
||||
if (this.reversed) collection.reverse()
|
||||
|
||||
|
||||
const contexts = collection.map((item: string, i: number) => {
|
||||
const ctx = {}
|
||||
ctx[this.variable] = item
|
||||
@@ -75,12 +75,12 @@ export default <ITagImplOptions>{
|
||||
}
|
||||
return ctx
|
||||
})
|
||||
|
||||
|
||||
let html = ''
|
||||
let finished = false
|
||||
await mapSeries(contexts, async context => {
|
||||
if (finished) return
|
||||
|
||||
|
||||
scope.push(context)
|
||||
try {
|
||||
html += await this.liquid.renderer.renderTemplates(this.templates, scope)
|
||||
@@ -96,4 +96,4 @@ export default <ITagImplOptions>{
|
||||
})
|
||||
return html
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { evalExp, isTruthy } from 'src/render/syntax'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
|
||||
@@ -2,10 +2,10 @@ import assert from 'src/util/assert'
|
||||
import { value, quotedLine } from 'src/parser/lexical'
|
||||
import { evalValue } from 'src/render/syntax'
|
||||
import BlockMode from 'src/scope/block-mode'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Hash from 'src/template/tag/hash'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const staticFileRE = /[^\s,]+/
|
||||
const withRE = new RegExp(`with\\s+(${value.source})`)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from 'src/util/assert'
|
||||
import { identifier } from 'src/parser/lexical'
|
||||
import { CaptureScope, AssignScope, IncrementScope } from 'src/scope/scopes'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
export default {
|
||||
parse: function (token) {
|
||||
@@ -27,4 +27,4 @@ export default {
|
||||
context[this.variable]++
|
||||
return val
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -2,11 +2,11 @@ import assert from 'src/util/assert'
|
||||
import { value as rValue } from 'src/parser/lexical'
|
||||
import { evalValue } from 'src/render/syntax'
|
||||
import BlockMode from 'src/scope/block-mode'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Hash from 'src/template/tag/hash'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const staticFileRE = /\S+/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import TagToken from "src/parser/tag-token";
|
||||
import Token from "src/parser/token";
|
||||
import ITagImplOptions from "src/template/tag/itag-impl-options";
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
export default <ITagImplOptions>{
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
|
||||
@@ -2,13 +2,13 @@ import { mapSeries } from 'src/util/promise'
|
||||
import assert from 'src/util/assert'
|
||||
import { evalExp } from 'src/render/syntax'
|
||||
import { identifier, value, hash } from 'src/parser/lexical'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Scope from 'src/scope/scope';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Hash from 'src/template/tag/hash'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
|
||||
`(${value.source})` +
|
||||
@@ -72,4 +72,4 @@ export default {
|
||||
}
|
||||
return html
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { evalExp, isFalsy } from 'src/render/syntax'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
@@ -32,4 +31,4 @@ export default {
|
||||
? this.liquid.renderer.renderTemplates(this.templates, scope)
|
||||
: this.liquid.renderer.renderTemplates(this.elseTemplates, scope)
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import { isTruthy, isFalsy, evalExp, evalValue } from './render/syntax'
|
||||
import builtinTags from './builtin/tags'
|
||||
import builtinFilters from './builtin/filters'
|
||||
import { LiquidOptions, NormalizedFullOptions, applyDefault, normalize } from './liquid-options'
|
||||
import FilterImpl from './template/filter/filter-impl';
|
||||
import { FilterImpl } from './template/filter/filter-impl'
|
||||
|
||||
export default class Liquid {
|
||||
public options: NormalizedFullOptions
|
||||
|
||||
@@ -6,7 +6,7 @@ export const quoteBalanced = new RegExp(`(?:${quoted.source}|[^'"])*`)
|
||||
|
||||
// basic types
|
||||
export const integer = /-?\d+/
|
||||
export const number = /-?\d+\.?\d*|\.?\d+/
|
||||
export const number = /[+-]?(?:\d+\.?\d*|\.?\d+)/
|
||||
export const bool = /true|false/
|
||||
|
||||
// property access
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Token from 'src/parser/token'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import TagToken from './tag-token';
|
||||
import TagToken from './tag-token'
|
||||
|
||||
type ParseToken = ((token: Token, remainTokens: Array<Token>) => ITemplate)
|
||||
|
||||
@@ -18,7 +18,7 @@ export default class ParseStream {
|
||||
this.handlers[name] = cb
|
||||
return this
|
||||
}
|
||||
trigger <T extends Token | ITemplate>(event: string, arg?: T) {
|
||||
trigger <T extends Token | ITemplate> (event: string, arg?: T) {
|
||||
const h = this.handlers[event]
|
||||
if (typeof h === 'function') {
|
||||
h(arg)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { RenderBreakError, RenderError } from 'src/util/error'
|
||||
import { RenderError } from 'src/util/error'
|
||||
import assert from 'src/util/assert'
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
|
||||
export default class Render {
|
||||
async renderTemplates (templates: ITemplate[], scope: Scope) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default interface IContext {
|
||||
[key: string]: any;
|
||||
liquid_method_missing?: (key: string) => any;
|
||||
}
|
||||
[key: string]: any;
|
||||
liquid_method_missing?: (key: string) => any; // eslint-disable-line
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import * as lexical from '../parser/lexical'
|
||||
import assert from '../util/assert'
|
||||
import { NormalizedFullOptions, applyDefault } from '../liquid-options'
|
||||
import BlockMode from './block-mode'
|
||||
import IContext from './icontext';
|
||||
import IContext from './icontext'
|
||||
|
||||
export default class Scope {
|
||||
opts: NormalizedFullOptions
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
type FilterImpl = (value: any, ...args: any[]) => any
|
||||
|
||||
export default FilterImpl
|
||||
export type FilterImpl = (value: any, ...args: any[]) => any
|
||||
|
||||
@@ -2,7 +2,7 @@ import assert from 'src/util/assert'
|
||||
import * as lexical from 'src/parser/lexical'
|
||||
import { evalValue } from 'src/render/syntax'
|
||||
import Scope from 'src/scope/scope'
|
||||
import FilterImpl from './filter-impl'
|
||||
import { FilterImpl } from './filter-impl'
|
||||
|
||||
const valueRE = new RegExp(`${lexical.value.source}`, 'g')
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { hashCapture } from 'src/parser/lexical'
|
||||
import { evalValue } from 'src/render/syntax'
|
||||
import Scope from 'src/scope/scope';
|
||||
import Scope from 'src/scope/scope'
|
||||
|
||||
/**
|
||||
* Key-Value Pairs Representing Tag Arguments
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
import * as _ from './underscore'
|
||||
import { __extends } from 'tslib'
|
||||
import Token from 'src/parser/token'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
|
||||
@@ -11,7 +10,7 @@ abstract class LiquidError extends Error {
|
||||
this.originalError = err
|
||||
this.token = token
|
||||
}
|
||||
protected update() {
|
||||
protected update () {
|
||||
const err = this.originalError
|
||||
const context = mkContext(this.token)
|
||||
this.message = mkMessage(err.message, this.token)
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@
|
||||
* The iteratee is invoked with three arguments: (value, index, iterable).
|
||||
*/
|
||||
export function mapSeries<T1, T2> (
|
||||
iterable: T1[],
|
||||
iteratee: (item: T1, idx: number, iterable: T1[]) => Promise<T2> | T2
|
||||
iterable: T1[],
|
||||
iteratee: (item: T1, idx: number, iterable: T1[]) => Promise<T2> | T2
|
||||
): Promise<T2[]> {
|
||||
let ret = Promise.resolve(0)
|
||||
const result: T2[] = []
|
||||
|
||||
@@ -179,6 +179,6 @@ export default function (d: Date, format: string) {
|
||||
// Add the format code
|
||||
const ch = results[0].charAt(1)
|
||||
const func = formatCodes[ch]
|
||||
output += func ? func.call(null, d) : '%' + ch
|
||||
output += func ? func(d) : '%' + ch
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +77,10 @@ export function isError (value: any): boolean {
|
||||
* @param {Function} iteratee The function invoked per iteration.
|
||||
* @return {Object} Returns object.
|
||||
*/
|
||||
export function forOwn <T>(
|
||||
export function forOwn <T> (
|
||||
object: {[key: string]: T} | undefined,
|
||||
iteratee: ((val: T, key: string, obj: {[key: string]: T}) => boolean | void)
|
||||
) {
|
||||
) {
|
||||
object = object || {}
|
||||
for (const k in object) {
|
||||
if (object.hasOwnProperty(k)) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Liquid from 'src/liquid'
|
||||
import { expect, use } from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
import IContext from 'src/scope/icontext';
|
||||
import IContext from 'src/scope/icontext'
|
||||
|
||||
use(chaiAsPromised)
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import { expect } from 'chai'
|
||||
describe('LiquidOptions', function () {
|
||||
describe('#normalize ()', function () {
|
||||
it('should normalize string typed root array', function () {
|
||||
const options = normalize({root: 'foo'})
|
||||
const options = normalize({ root: 'foo' })
|
||||
expect(options.root).to.eql(['foo'])
|
||||
})
|
||||
it('should normalize null typed root as empty array', function () {
|
||||
const options = normalize({root: null} as any)
|
||||
const options = normalize({ root: null } as any)
|
||||
expect(options.root).to.eql([])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as chai from 'chai'
|
||||
import Scope from 'src/scope/scope'
|
||||
import IContext from 'src/scope/icontext';
|
||||
import IContext from 'src/scope/icontext'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
|
||||
Reference in New Issue
Block a user