Commit 5270e051 authored by Dan Allen's avatar Dan Allen
Browse files

merge !114

resolves #123 add support for varargs to {{and}} and {{or}} helpers
parents b8c46a1a 622cc391
'use strict'
module.exports = (a, b) => a && b
module.exports = (...args) => {
const numArgs = args.length
if (numArgs === 3) return args[0] && args[1]
if (numArgs < 3) throw new Error('{{and}} helper expects at least 2 arguments')
args.pop()
return args.every((it) => it)
}
'use strict'
module.exports = (a, b) => a || b
module.exports = (...args) => {
const numArgs = args.length
if (numArgs === 3) return args[0] || args[1]
if (numArgs < 3) throw new Error('{{or}} helper expects at least 2 arguments')
args.pop()
return args.some((it) => it)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment