UNPKG

flavor-js

Version:

FlavorJS the definitive JS natives chainable extensions methods (based on lodash & ES6)

48 lines (46 loc) 1.02 kB
import _ from 'lodash'; /** * @namespace boolean * @description the JS native Boolean class */ export default { native: { /** * isBoolean * @example <caption>eg. usage</caption> * var b = true; * * console.log(Boolean.isBoolean(b)); // true * * console.log(Boolean.isBoolean(2)); // false * * console.log(Boolean.isBoolean(false)); // true * * console.log(Boolean.isBoolean(null)); // false * @memberOf boolean * @method isBoolean * @instance * @return {boolean} */ isBoolean(b) { return Boolean.prototype.isBoolean.call(b); }, /** * randomizes a boolean value * @example <caption>eg. usage</caption> * console.log(Boolean.random()); // it logs true or false * @memberOf boolean * @method random * @instance * @return {boolean} */ random() { return Math.random() >= 0.5; }, }, prototype: { isBoolean() { return _.isBoolean(this); }, }, };