1
0

index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. 'use strict';
  2. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  3. module.exports = function (t, a) {
  4. var o, c, cg, cs, ce, ceg, ces, cew, cw, e, eg, es, ew, v, vg, vs, w, df, dfg
  5. , dfs;
  6. o = Object.create(Object.prototype, {
  7. c: t('c', c = {}),
  8. cgs: t.gs('c', cg = function () {}, cs = function () {}),
  9. ce: t('ce', ce = {}),
  10. cegs: t.gs('ce', ceg = function () {}, ces = function () {}),
  11. cew: t('cew', cew = {}),
  12. cw: t('cw', cw = {}),
  13. e: t('e', e = {}),
  14. egs: t.gs('e', eg = function () {}, es = function () {}),
  15. ew: t('ew', ew = {}),
  16. v: t('', v = {}),
  17. vgs: t.gs('', vg = function () {}, vs = function () {}),
  18. w: t('w', w = {}),
  19. df: t(df = {}),
  20. dfgs: t.gs(dfg = function () {}, dfs = function () {})
  21. });
  22. return {
  23. c: function (a) {
  24. var d = getOwnPropertyDescriptor(o, 'c');
  25. a(d.value, c, "Value");
  26. a(d.get, undefined, "Get");
  27. a(d.set, undefined, "Set");
  28. a(d.configurable, true, "Configurable");
  29. a(d.enumerable, false, "Enumerable");
  30. a(d.writable, false, "Writable");
  31. d = getOwnPropertyDescriptor(o, 'cgs');
  32. a(d.value, undefined, "GS Value");
  33. a(d.get, cg, "GS Get");
  34. a(d.set, cs, "GS Set");
  35. a(d.configurable, true, "GS Configurable");
  36. a(d.enumerable, false, "GS Enumerable");
  37. a(d.writable, undefined, "GS Writable");
  38. },
  39. ce: function (a) {
  40. var d = getOwnPropertyDescriptor(o, 'ce');
  41. a(d.value, ce, "Value");
  42. a(d.get, undefined, "Get");
  43. a(d.set, undefined, "Set");
  44. a(d.configurable, true, "Configurable");
  45. a(d.enumerable, true, "Enumerable");
  46. a(d.writable, false, "Writable");
  47. d = getOwnPropertyDescriptor(o, 'cegs');
  48. a(d.value, undefined, "GS Value");
  49. a(d.get, ceg, "GS Get");
  50. a(d.set, ces, "GS Set");
  51. a(d.configurable, true, "GS Configurable");
  52. a(d.enumerable, true, "GS Enumerable");
  53. a(d.writable, undefined, "GS Writable");
  54. },
  55. cew: function (a) {
  56. var d = getOwnPropertyDescriptor(o, 'cew');
  57. a(d.value, cew, "Value");
  58. a(d.get, undefined, "Get");
  59. a(d.set, undefined, "Set");
  60. a(d.configurable, true, "Configurable");
  61. a(d.enumerable, true, "Enumerable");
  62. a(d.writable, true, "Writable");
  63. },
  64. cw: function (a) {
  65. var d = getOwnPropertyDescriptor(o, 'cw');
  66. a(d.value, cw, "Value");
  67. a(d.get, undefined, "Get");
  68. a(d.set, undefined, "Set");
  69. a(d.configurable, true, "Configurable");
  70. a(d.enumerable, false, "Enumerable");
  71. a(d.writable, true, "Writable");
  72. },
  73. e: function (a) {
  74. var d = getOwnPropertyDescriptor(o, 'e');
  75. a(d.value, e, "Value");
  76. a(d.get, undefined, "Get");
  77. a(d.set, undefined, "Set");
  78. a(d.configurable, false, "Configurable");
  79. a(d.enumerable, true, "Enumerable");
  80. a(d.writable, false, "Writable");
  81. d = getOwnPropertyDescriptor(o, 'egs');
  82. a(d.value, undefined, "GS Value");
  83. a(d.get, eg, "GS Get");
  84. a(d.set, es, "GS Set");
  85. a(d.configurable, false, "GS Configurable");
  86. a(d.enumerable, true, "GS Enumerable");
  87. a(d.writable, undefined, "GS Writable");
  88. },
  89. ew: function (a) {
  90. var d = getOwnPropertyDescriptor(o, 'ew');
  91. a(d.value, ew, "Value");
  92. a(d.get, undefined, "Get");
  93. a(d.set, undefined, "Set");
  94. a(d.configurable, false, "Configurable");
  95. a(d.enumerable, true, "Enumerable");
  96. a(d.writable, true, "Writable");
  97. },
  98. v: function (a) {
  99. var d = getOwnPropertyDescriptor(o, 'v');
  100. a(d.value, v, "Value");
  101. a(d.get, undefined, "Get");
  102. a(d.set, undefined, "Set");
  103. a(d.configurable, false, "Configurable");
  104. a(d.enumerable, false, "Enumerable");
  105. a(d.writable, false, "Writable");
  106. d = getOwnPropertyDescriptor(o, 'vgs');
  107. a(d.value, undefined, "GS Value");
  108. a(d.get, vg, "GS Get");
  109. a(d.set, vs, "GS Set");
  110. a(d.configurable, false, "GS Configurable");
  111. a(d.enumerable, false, "GS Enumerable");
  112. a(d.writable, undefined, "GS Writable");
  113. },
  114. w: function (a) {
  115. var d = getOwnPropertyDescriptor(o, 'w');
  116. a(d.value, w, "Value");
  117. a(d.get, undefined, "Get");
  118. a(d.set, undefined, "Set");
  119. a(d.configurable, false, "Configurable");
  120. a(d.enumerable, false, "Enumerable");
  121. a(d.writable, true, "Writable");
  122. },
  123. d: function (a) {
  124. var d = getOwnPropertyDescriptor(o, 'df');
  125. a(d.value, df, "Value");
  126. a(d.get, undefined, "Get");
  127. a(d.set, undefined, "Set");
  128. a(d.configurable, true, "Configurable");
  129. a(d.enumerable, false, "Enumerable");
  130. a(d.writable, true, "Writable");
  131. d = getOwnPropertyDescriptor(o, 'dfgs');
  132. a(d.value, undefined, "GS Value");
  133. a(d.get, dfg, "GS Get");
  134. a(d.set, dfs, "GS Set");
  135. a(d.configurable, true, "GS Configurable");
  136. a(d.enumerable, false, "GS Enumerable");
  137. a(d.writable, undefined, "GS Writable");
  138. },
  139. Options: {
  140. v: function (a) {
  141. var x = {}, d = t(x, { foo: true });
  142. a.deep(d, { configurable: true, enumerable: false, writable: true,
  143. value: x, foo: true }, "No descriptor");
  144. d = t('c', 'foo', { marko: 'elo' });
  145. a.deep(d, { configurable: true, enumerable: false, writable: false,
  146. value: 'foo', marko: 'elo' }, "Descriptor");
  147. },
  148. gs: function (a) {
  149. var gFn = function () {}, sFn = function () {}, d;
  150. d = t.gs(gFn, sFn, { foo: true });
  151. a.deep(d, { configurable: true, enumerable: false, get: gFn, set: sFn,
  152. foo: true }, "No descriptor");
  153. d = t.gs(null, sFn, { foo: true });
  154. a.deep(d, { configurable: true, enumerable: false, get: undefined,
  155. set: sFn, foo: true }, "No descriptor: Just set");
  156. d = t.gs(gFn, { foo: true });
  157. a.deep(d, { configurable: true, enumerable: false, get: gFn,
  158. set: undefined, foo: true }, "No descriptor: Just get");
  159. d = t.gs('e', gFn, sFn, { bar: true });
  160. a.deep(d, { configurable: false, enumerable: true, get: gFn, set: sFn,
  161. bar: true }, "Descriptor");
  162. d = t.gs('e', null, sFn, { bar: true });
  163. a.deep(d, { configurable: false, enumerable: true, get: undefined,
  164. set: sFn, bar: true }, "Descriptor: Just set");
  165. d = t.gs('e', gFn, { bar: true });
  166. a.deep(d, { configurable: false, enumerable: true, get: gFn,
  167. set: undefined, bar: true }, "Descriptor: Just get");
  168. }
  169. }
  170. };
  171. };