mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
fix: comparison for empty/nil, fixes #321
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { Drop } from './drop'
|
||||
import { Comparable } from './comparable'
|
||||
import { isObject, isString, isArray } from '../util/underscore'
|
||||
import { isObject, isString, isArray, toValue } from '../util/underscore'
|
||||
|
||||
export class EmptyDrop extends Drop implements Comparable {
|
||||
public equals (value: any) {
|
||||
if (value instanceof EmptyDrop) return false
|
||||
value = toValue(value)
|
||||
if (isString(value) || isArray(value)) return value.length === 0
|
||||
if (isObject(value)) return Object.keys(value).length === 0
|
||||
return false
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Drop } from './drop'
|
||||
import { Comparable } from './comparable'
|
||||
import { isNil, toValue } from '../util/underscore'
|
||||
import { BlankDrop } from '../drop/blank-drop'
|
||||
|
||||
export class NullDrop extends Drop implements Comparable {
|
||||
public equals (value: any) {
|
||||
return isNil(toValue(value)) || value instanceof BlankDrop
|
||||
return isNil(toValue(value))
|
||||
}
|
||||
public gt () {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user