UNPKG

@modernpoacher/rules-runner

Version:
27 lines (19 loc) 620 B
import debug from 'debug' import { toBoolean } from '#rules-runner/common' const log = debug('@modernpoacher/rules-runner/comparators/boolean') log('`@modernpoacher/rules-runner` is awake') export default function boolean (expected, actual) { log('boolean') let b try { b = toBoolean(expected) } catch (e) { throw new Error(`"${expected}" is not a boolean or does not transform to a boolean`) } try { const value = toBoolean(actual) return b === value } catch (e) { throw new Error(`Unexpected value for "boolean": "${actual}" must be a boolean or transform to a boolean`) } }