Function to validate types

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-10-31 17:51:16 -03:00
parent 1905266d1f
commit 0b9bf5a548
1 changed files with 10 additions and 0 deletions

View File

@ -3,6 +3,11 @@ const isString = (v) => (typeof v) === "string";
const isObject = (v) => (typeof v) === "object";
const isDefined = (v) => v && (typeof v) != "undefined";
const isBoolean = (v) => (typeof v) === "boolean";
const isInteger = (v) => Number.isInteger(v);
const isDate = (v) => (v instanceof Date);
const isBinary = (v) => (v instanceof ArrayBuffer);
const isStringOrThrow = (v, t) =>
(isString(v)
? true
@ -47,6 +52,11 @@ module.exports = {
isObject,
isDefined,
isBoolean,
isInteger,
isDate,
isBinary,
isDefinedOrThrow,
isStringOrObjectOrThrow,