resolved issues raised by hhartle

This commit is contained in:
Amit Gupta
2020-10-08 12:43:37 +08:00
committed by Jun Yang
parent 02bfed1c57
commit f807383f2a
2 changed files with 3 additions and 4 deletions
+2 -3
View File
@@ -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
+1 -1
View File
@@ -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