Source: util/isType.js

  1. /**
  2. * @module isType
  3. */
  4. /**
  5. * @function
  6. * @name isObject
  7. * @description Checks if the input is an object excluding null
  8. * @param {*} input Input Argument
  9. * @returns true if input is an object excluding null, false otherwise
  10. */
  11. function isObject(input) {
  12. return input !== null && typeof input === 'object';
  13. }
  14. /**
  15. * @function
  16. * @name isNull
  17. * @description Checks if the input is null
  18. * @param {*} input Input Argument
  19. * @returns true if input is null, false otherwise
  20. */
  21. function isNull(input) {
  22. return input === null;
  23. }
  24. /**
  25. * @function
  26. * @name isString
  27. * @description Checks if the input is a string
  28. * @param {*} input Input Argument
  29. * @returns true if input is a string, false otherwise
  30. */
  31. function isString(input) {
  32. return typeof input === 'string';
  33. }
  34. /**
  35. * @function
  36. * @name isNumber
  37. * @description Checks if the input is a number
  38. * @param {*} input Input Argument
  39. * @returns true if input is a number, false otherwise
  40. */
  41. function isNumber(input) {
  42. return typeof input === 'number';
  43. }
  44. module.exports = {
  45. isObject,
  46. isNull,
  47. isString,
  48. isNumber
  49. };