UNPKG

next-sql

Version:

Next-gen SQL connector, easy way to query SQL and create relationship linked object.

25 lines (24 loc) 964 B
module.exports = { defined: val => typeof val !== 'undefined' && val !== null, bool: val => typeof val === 'boolean', number: val => typeof val === 'number' && !Number.isNaN(val), nan: val => typeof val === 'number' && Number.isNaN(val), string: val => typeof val === 'string', fn: val => typeof val === 'function', async: val => typeof val === 'function' && !!val.constructor && val.constructor.name === 'AsyncFunction', promise: val => val instanceof Promise, buffer: val => val instanceof Buffer, array: val => Array.isArray(val), object: val => typeof val === 'object', plainObject: val => Object.prototype.toString.call(val) === '[object Object]', empty(val) { if (!val) return true if (this.array(val)) return val.length === 0 if (this.plainObject(val)) return Object.keys(val).length === 0 if (this.buffer(val)) return val.byteLength === 0 return false }, notEmpty(val) { return !this.empty(val) }, }