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