UNPKG

action-u

Version:

Redux Action Generator (promoting action creators and types)

35 lines (33 loc) 844 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = verify; /** * A convenience assertion utility, typically used to validate * pre-conditions of a routine. * * **Advanced**: verify.prefix(msgPrefix) returns a higher-order * verify() function where all messages are prefixed. * * @param {truthy} condition - a "truthy" condition which * must be satisfied. * * @param {string} msg - a message clarifying the condition being * checked. * * @throws {Error} an Error is thrown when the supplied condition is * NOT met. * * @private */ function verify(condition, msg) { if (!condition) { throw new Error(msg); } } verify.prefix = function (msgPrefix) { return function (condition, msg) { return verify(condition, msgPrefix + msg); }; };