mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 14:30:38 -07:00
resolved issues raised by hhartle
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
import { Context } from '../context/context'
|
import { Context } from '../context/context'
|
||||||
|
|
||||||
export function isTruthy (val: any, ctx: Context): boolean {
|
export function isTruthy (val: any, ctx: Context): boolean {
|
||||||
if ((val === null) && ctx && ctx.opts && ctx.opts.jsTruthy ) return false;
|
|
||||||
return !isFalsy(val, ctx)
|
return !isFalsy(val, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFalsy (val: any, ctx: Context): boolean {
|
export function isFalsy (val: any, ctx: Context): boolean {
|
||||||
if(ctx && ctx.opts && ctx.opts.jsTruthy) {
|
if(ctx.opts.jsTruthy) {
|
||||||
return val == false
|
return !val
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return val === false || undefined === val || val === null
|
return val === false || undefined === val || val === null
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ describe('boolean jsTruthy', async function () {
|
|||||||
expect(isTruthy(false, ctx)).to.be.false
|
expect(isTruthy(false, ctx)).to.be.false
|
||||||
})
|
})
|
||||||
it('null is always falsy', function () {
|
it('null is always falsy', function () {
|
||||||
expect(isTruthy(null, ctx)).to.be.false
|
expect(isTruthy(null, ctx)).to.be.true
|
||||||
})
|
})
|
||||||
it('null is always falsy', function () {
|
it('null is always falsy', function () {
|
||||||
expect(isTruthy(null, ctx)).to.be.false
|
expect(isTruthy(null, ctx)).to.be.false
|
||||||
|
|||||||
Reference in New Issue
Block a user