Sha256: ff78f1539a69437cda0e6c1fd41367c7a0bde1e401ac6eb0f78800b78e040345
Contents?: true
Size: 1.19 KB
Versions: 8
Compression:
Stored size: 1.19 KB
Contents
function isNil(value) { return (value === undefined) || (value === null); } function isBlank(value) { if (isNil(value)) { return true; } switch (typeof value) { case 'string': return value.trim().length === 0; case 'number': return value !== 0 && !value; case 'object': if (Array.isArray(value)) { return value.length === 0; } else { return Object.getOwnPropertyNames(value).length === 0 } default: return !value; } } beforeEach(function () { jasmine.addMatchers({ toBeNil: function () { return { compare: function (actual, _expected) { return { pass: isNil(actual) }; } }; }, toBeFunction: function () { return { compare: function (actual, _expected) { return { pass: typeof actual === 'function' }; } }; }, toBeBlank: function () { return { compare: function (actual, _expected) { return { pass: isBlank(actual) }; } }; }, toBePresent: function () { return { compare: function (actual, _expected) { return { pass: !isBlank(actual) }; } }; } }); });
Version data entries
8 entries across 8 versions & 1 rubygems