Front end of the Slack clone application.

index.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. 'use strict';
  2. var assign = require('es5-ext/object/assign')
  3. , normalizeOpts = require('es5-ext/object/normalize-options')
  4. , isCallable = require('es5-ext/object/is-callable')
  5. , contains = require('es5-ext/string/#/contains')
  6. , d;
  7. d = module.exports = function (dscr, value/*, options*/) {
  8. var c, e, w, options, desc;
  9. if ((arguments.length < 2) || (typeof dscr !== 'string')) {
  10. options = value;
  11. value = dscr;
  12. dscr = null;
  13. } else {
  14. options = arguments[2];
  15. }
  16. if (dscr == null) {
  17. c = w = true;
  18. e = false;
  19. } else {
  20. c = contains.call(dscr, 'c');
  21. e = contains.call(dscr, 'e');
  22. w = contains.call(dscr, 'w');
  23. }
  24. desc = { value: value, configurable: c, enumerable: e, writable: w };
  25. return !options ? desc : assign(normalizeOpts(options), desc);
  26. };
  27. d.gs = function (dscr, get, set/*, options*/) {
  28. var c, e, options, desc;
  29. if (typeof dscr !== 'string') {
  30. options = set;
  31. set = get;
  32. get = dscr;
  33. dscr = null;
  34. } else {
  35. options = arguments[3];
  36. }
  37. if (get == null) {
  38. get = undefined;
  39. } else if (!isCallable(get)) {
  40. options = get;
  41. get = set = undefined;
  42. } else if (set == null) {
  43. set = undefined;
  44. } else if (!isCallable(set)) {
  45. options = set;
  46. set = undefined;
  47. }
  48. if (dscr == null) {
  49. c = true;
  50. e = false;
  51. } else {
  52. c = contains.call(dscr, 'c');
  53. e = contains.call(dscr, 'e');
  54. }
  55. desc = { get: get, set: set, configurable: c, enumerable: e };
  56. return !options ? desc : assign(normalizeOpts(options), desc);
  57. };