Front end of the Slack clone application.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. /**
  3. * Module dependencies
  4. */
  5. exports.extend = require('extend-shallow');
  6. exports.SourceMap = require('source-map');
  7. exports.sourceMapResolve = require('source-map-resolve');
  8. /**
  9. * Convert backslash in the given string to forward slashes
  10. */
  11. exports.unixify = function(fp) {
  12. return fp.split(/\\+/).join('/');
  13. };
  14. /**
  15. * Return true if `val` is a non-empty string
  16. *
  17. * @param {String} `str`
  18. * @return {Boolean}
  19. */
  20. exports.isString = function(str) {
  21. return str && typeof str === 'string';
  22. };
  23. /**
  24. * Cast `val` to an array
  25. * @return {Array}
  26. */
  27. exports.arrayify = function(val) {
  28. if (typeof val === 'string') return [val];
  29. return val ? (Array.isArray(val) ? val : [val]) : [];
  30. };
  31. /**
  32. * Get the last `n` element from the given `array`
  33. * @param {Array} `array`
  34. * @return {*}
  35. */
  36. exports.last = function(arr, n) {
  37. return arr[arr.length - (n || 1)];
  38. };