mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 22:10:41 -07:00
refactor: Drop.prototype.value => valueOf
This commit is contained in:
@@ -5,7 +5,7 @@ import { EmptyDrop } from '../drop/empty-drop'
|
||||
export class BlankDrop extends EmptyDrop {
|
||||
equals (value: any) {
|
||||
if (value === false) return true
|
||||
if (isNil(isDrop(value) ? value.value() : value)) return true
|
||||
if (isNil(isDrop(value) ? value.valueOf() : value)) return true
|
||||
if (isString(value)) return /^\s*$/.test(value)
|
||||
return super.equals(value)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class EmptyDrop extends Drop implements IDrop, IComparable {
|
||||
leq () {
|
||||
return false
|
||||
}
|
||||
value () {
|
||||
valueOf () {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ import { Drop } from './drop'
|
||||
import { isFunction } from '../util/underscore'
|
||||
|
||||
export interface IDrop {
|
||||
value(): any
|
||||
valueOf(): any
|
||||
}
|
||||
|
||||
export function isDrop (value: any): value is IDrop {
|
||||
return value instanceof Drop && isFunction((value as any).value)
|
||||
return value instanceof Drop && isFunction((value as any).valueOf)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { BlankDrop } from '../drop/blank-drop'
|
||||
|
||||
export class NullDrop extends Drop implements IDrop, IComparable {
|
||||
equals (value: any) {
|
||||
return isNil(isDrop(value) ? value.value() : value) || value instanceof BlankDrop
|
||||
return isNil(isDrop(value) ? value.valueOf() : value) || value instanceof BlankDrop
|
||||
}
|
||||
gt () {
|
||||
return false
|
||||
@@ -20,7 +20,7 @@ export class NullDrop extends Drop implements IDrop, IComparable {
|
||||
leq () {
|
||||
return false
|
||||
}
|
||||
value () {
|
||||
valueOf () {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user