mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-29 15:15:23 -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 {
|
export class BlankDrop extends EmptyDrop {
|
||||||
equals (value: any) {
|
equals (value: any) {
|
||||||
if (value === false) return true
|
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)
|
if (isString(value)) return /^\s*$/.test(value)
|
||||||
return super.equals(value)
|
return super.equals(value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export class EmptyDrop extends Drop implements IDrop, IComparable {
|
|||||||
leq () {
|
leq () {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
value () {
|
valueOf () {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2,9 +2,9 @@ import { Drop } from './drop'
|
|||||||
import { isFunction } from '../util/underscore'
|
import { isFunction } from '../util/underscore'
|
||||||
|
|
||||||
export interface IDrop {
|
export interface IDrop {
|
||||||
value(): any
|
valueOf(): any
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isDrop (value: any): value is IDrop {
|
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 {
|
export class NullDrop extends Drop implements IDrop, IComparable {
|
||||||
equals (value: any) {
|
equals (value: any) {
|
||||||
return isNil(isDrop(value) ? value.value() : value) || value instanceof BlankDrop
|
return isNil(isDrop(value) ? value.valueOf() : value) || value instanceof BlankDrop
|
||||||
}
|
}
|
||||||
gt () {
|
gt () {
|
||||||
return false
|
return false
|
||||||
@@ -20,7 +20,7 @@ export class NullDrop extends Drop implements IDrop, IComparable {
|
|||||||
leq () {
|
leq () {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
value () {
|
valueOf () {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export function parseExp (exp: string, scope: Scope): any {
|
|||||||
|
|
||||||
export function evalExp (str: string, scope: Scope): any {
|
export function evalExp (str: string, scope: Scope): any {
|
||||||
const value = parseExp(str, scope)
|
const value = parseExp(str, scope)
|
||||||
return isDrop(value) ? value.value() : value
|
return isDrop(value) ? value.valueOf() : value
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseValue (str: string, scope: Scope): any {
|
function parseValue (str: string, scope: Scope): any {
|
||||||
@@ -93,7 +93,7 @@ function parseValue (str: string, scope: Scope): any {
|
|||||||
|
|
||||||
export function evalValue (str: string, scope: Scope): any {
|
export function evalValue (str: string, scope: Scope): any {
|
||||||
const value = parseValue(str, scope)
|
const value = parseValue(str, scope)
|
||||||
return isDrop(value) ? value.value() : value
|
return isDrop(value) ? value.valueOf() : value
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isTruthy (val: any): boolean {
|
export function isTruthy (val: any): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user