lib with functions for utils

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-07-23 08:49:52 -03:00
parent 3896c7778a
commit 8469e04a98
2 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,9 @@
const {
isString,
isObject,
isDefined
} = require("../../utils/fun.js");
function JSONParser() { function JSONParser() {
} }
@ -9,9 +15,6 @@ const nullOrIndefinedPayload =
new Error("null or undefined payload"); new Error("null or undefined payload");
// Functions // Functions
const isString = (v) => (typeof v) === "string";
const isObject = (v) => (typeof v) === "object";
const isDefined = (v) => v && (typeof v) != "undefined";
const isDefinedOrThrow = (v) => const isDefinedOrThrow = (v) =>
(isDefined(v) (isDefined(v)
? () => true ? () => true

10
lib/utils/fun.js Normal file
View File

@ -0,0 +1,10 @@
// Functional approach
const isString = (v) => (typeof v) === "string";
const isObject = (v) => (typeof v) === "object";
const isDefined = (v) => v && (typeof v) != "undefined";
module.exports = {
isString : isString,
isObject : isObject,
isDefined : isDefined
};