normalize-options.js 955 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. var create = Object.create, defineProperty = Object.defineProperty;
  3. module.exports = function (t, a) {
  4. var x = { foo: "raz", bar: "dwa" }, y;
  5. y = t(x);
  6. a.not(y, x, "Returns copy");
  7. a.deep(y, x, "Plain");
  8. x = { raz: "one", dwa: "two" };
  9. defineProperty(x, "get", {
  10. configurable: true,
  11. enumerable: true,
  12. get: function () { return this.dwa; }
  13. });
  14. x = create(x);
  15. x.trzy = "three";
  16. x.cztery = "four";
  17. x = create(x);
  18. x.dwa = "two!";
  19. x.trzy = "three!";
  20. x.piec = "five";
  21. x.szesc = "six";
  22. a.deep(
  23. t(x),
  24. {
  25. raz: "one",
  26. dwa: "two!",
  27. trzy: "three!",
  28. cztery: "four",
  29. piec: "five",
  30. szesc: "six",
  31. get: "two!"
  32. },
  33. "Deep object"
  34. );
  35. a.deep(
  36. t({ marko: "raz", raz: "foo" }, x, { szesc: "elo", siedem: "bibg" }),
  37. {
  38. marko: "raz",
  39. raz: "one",
  40. dwa: "two!",
  41. trzy: "three!",
  42. cztery: "four",
  43. piec: "five",
  44. szesc: "elo",
  45. siedem: "bibg",
  46. get: "two!"
  47. },
  48. "Multiple options"
  49. );
  50. };