normalize-options.js 893 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 () {
  13. return this.dwa;
  14. }
  15. });
  16. x = create(x);
  17. x.trzy = "three";
  18. x.cztery = "four";
  19. x = create(x);
  20. x.dwa = "two!";
  21. x.trzy = "three!";
  22. x.piec = "five";
  23. x.szesc = "six";
  24. a.deep(t(x), { raz: "one",
  25. dwa: "two!",
  26. trzy: "three!",
  27. cztery: "four",
  28. piec: "five",
  29. szesc: "six",
  30. get: "two!" }, "Deep object");
  31. a.deep(t({ marko: "raz", raz: "foo" }, x, { szesc: "elo", siedem: "bibg" }),
  32. { marko: "raz",
  33. raz: "one",
  34. dwa: "two!",
  35. trzy: "three!",
  36. cztery: "four",
  37. piec: "five",
  38. szesc: "elo",
  39. siedem: "bibg",
  40. get: "two!" }, "Multiple options");
  41. };