_label(option) { if (!option) { return option; } if (isString(option)) { return option; } return option.label; }
export function length(rawValue) { if (rawValue instanceof StyleLength && !rawValue.isRelative) return rawValue; if (!isNumber(rawValue) && !isString(rawValue)) return undefined; let value = Number(rawValue); if (!isFinite(value)) return undefined; return new StyleLength(value); }
export function weight(rawValue) { if (!isNumber(rawValue) && !isString(rawValue)) return undefined; let value = Number(rawValue); if (!isFinite(value)) return undefined; return new StyleWeight(value); }
string(value, schema) { const emptyError = checkEmpty(value, schema.required); if (!isNil(emptyError)) return emptyError; const err = []; if (!isString(value)) err.push('This is not a text!'); return err; }
it('should implement a generator', () => { s.def('::ingredient2', s.cat(':quantity', isInteger, ':unit', isString)); expect(s.exercise('::ingredient2', 7)).to.have.length(7) .to.satisfy(sample => every(sample, ([[v1, v2]]) => isInteger(v1) || isString(v2))); });
extractName(command) { if (isObject(command) === false || isString(command.constructor.name) === false ) { throw new InvalidCommandException('Invalid Command Name.'); } return command.constructor.name; }
// eslint-disable-next-line require-jsdoc constructor(fields) { this._fields = {}; this._highlight = { fields: this._fields }; // Does this smell? if (isNil(fields)) return; if (isString(fields)) this.field(fields); else this.fields(fields); }
function writeWrap(writeFunc) { return function (chunk, enc, next) { if (!isString(chunk)) { // chunk is a buffer, convert it to string writeFunc(chunk.toString()); } else { writeFunc(chunk); } return next(); }; }
hasDeclaredEvent(name) { if (!isString(name)) throw new Error(`Failed to execute 'hasDeclaredEvent': Parameter 1 is not of type 'string'.`); return this.listeners.has(name); }
const allBlanks = o => { if(isString(o) === false) { return false; } return emptyString(o) ? false : every(blankString, o.split('')) }
static extractMessageId (body) { if (!body || !isString(body.message_id)) { return null; } return body.message_id; }
/** * Check if string is HEX, requires a 0x in front * * @public * @static * @method isHexStrict * @param {String} hex to be checked * @returns {Boolean} */ const isHexStrict = hex => (isString(hex) || isNumber(hex)) && /^(-)?0x[0-9a-f]*$/i.test(hex)
export function character(rawValue) { if (!isString(rawValue) || rawValue.length !== 1) return undefined; return rawValue; }
export function number(rawValue) { if (!isNumber(rawValue) && !isString(rawValue)) return undefined; let value = Number(rawValue); if (!isFinite(value)) return undefined; return value; }
_label(option) { if (!option) { return option; } if (isString(option)) { return option; } return option.label; }