es6_set_polyfill_rails 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a7709e502df3d854f0eca0d9d3bc4aa449b6f88
4
- data.tar.gz: e5ca4282529631ac437d146e438ed358a60651fc
3
+ metadata.gz: 49f2eaf549f59431d39d4bcdead54d2191df6ac3
4
+ data.tar.gz: 9eebc2ae6e5141fa816a4244970d5943ca9b9c6b
5
5
  SHA512:
6
- metadata.gz: 268f5e107eb70ba0e8240b3d379f6f26f1fa822eec3f5c91f36858ab4ae595b67280524415164c64afbc0d91912c2a486d5c9c6ef8cbb7d54fb109624b2dfa4e
7
- data.tar.gz: 06ba50c2f4661cd1359421b786160c28485bef79da466e42a1e2df0d78573ea0b9badbff31603febf3d1b903fb711d8f95aadff20c9b68a13ed4ebebb49f07dc
6
+ metadata.gz: 4084826d16ada4819023ad76d2812b0d1e28370b01d6d6bec25db1c49b93c16293c7f510ed323ad93ffc0c371c740663fbd651b3f3c055f85b7e34ca129fa1fb
7
+ data.tar.gz: d10f1aa60257b24f24ac747cfd2eed741a3842c0e552db3045e953b192c33b51c37b4dbeb8015318905a3e46708f291a17284bdc9b9350f24bfafde664e11a49
@@ -1,1253 +1,271 @@
1
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.es6Set = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
- 'use strict';
3
-
4
- var copy = require('es5-ext/object/copy')
5
- , map = require('es5-ext/object/map')
6
- , callable = require('es5-ext/object/valid-callable')
7
- , validValue = require('es5-ext/object/valid-value')
8
-
9
- , bind = Function.prototype.bind, defineProperty = Object.defineProperty
10
- , hasOwnProperty = Object.prototype.hasOwnProperty
11
- , define;
12
-
13
- define = function (name, desc, bindTo) {
14
- var value = validValue(desc) && callable(desc.value), dgs;
15
- dgs = copy(desc);
16
- delete dgs.writable;
17
- delete dgs.value;
18
- dgs.get = function () {
19
- if (hasOwnProperty.call(this, name)) return value;
20
- desc.value = bind.call(value, (bindTo == null) ? this : this[bindTo]);
21
- defineProperty(this, name, desc);
22
- return this[name];
23
- };
24
- return dgs;
25
- };
26
-
27
- module.exports = function (props/*, bindTo*/) {
28
- var bindTo = arguments[1];
29
- return map(props, function (desc, name) {
30
- return define(name, desc, bindTo);
31
- });
32
- };
33
-
34
- },{"es5-ext/object/copy":15,"es5-ext/object/map":23,"es5-ext/object/valid-callable":28,"es5-ext/object/valid-value":29}],2:[function(require,module,exports){
35
- 'use strict';
36
-
37
- var assign = require('es5-ext/object/assign')
38
- , normalizeOpts = require('es5-ext/object/normalize-options')
39
- , isCallable = require('es5-ext/object/is-callable')
40
- , contains = require('es5-ext/string/#/contains')
41
-
42
- , d;
43
-
44
- d = module.exports = function (dscr, value/*, options*/) {
45
- var c, e, w, options, desc;
46
- if ((arguments.length < 2) || (typeof dscr !== 'string')) {
47
- options = value;
48
- value = dscr;
49
- dscr = null;
50
- } else {
51
- options = arguments[2];
52
- }
53
- if (dscr == null) {
54
- c = w = true;
55
- e = false;
56
- } else {
57
- c = contains.call(dscr, 'c');
58
- e = contains.call(dscr, 'e');
59
- w = contains.call(dscr, 'w');
60
- }
61
-
62
- desc = { value: value, configurable: c, enumerable: e, writable: w };
63
- return !options ? desc : assign(normalizeOpts(options), desc);
64
- };
65
-
66
- d.gs = function (dscr, get, set/*, options*/) {
67
- var c, e, options, desc;
68
- if (typeof dscr !== 'string') {
69
- options = set;
70
- set = get;
71
- get = dscr;
72
- dscr = null;
73
- } else {
74
- options = arguments[3];
75
- }
76
- if (get == null) {
77
- get = undefined;
78
- } else if (!isCallable(get)) {
79
- options = get;
80
- get = set = undefined;
81
- } else if (set == null) {
82
- set = undefined;
83
- } else if (!isCallable(set)) {
84
- options = set;
85
- set = undefined;
86
- }
87
- if (dscr == null) {
88
- c = true;
89
- e = false;
90
- } else {
91
- c = contains.call(dscr, 'c');
92
- e = contains.call(dscr, 'e');
93
- }
94
-
95
- desc = { get: get, set: set, configurable: c, enumerable: e };
96
- return !options ? desc : assign(normalizeOpts(options), desc);
97
- };
98
-
99
- },{"es5-ext/object/assign":12,"es5-ext/object/is-callable":18,"es5-ext/object/normalize-options":24,"es5-ext/string/#/contains":30}],3:[function(require,module,exports){
100
- // Inspired by Google Closure:
101
- // http://closure-library.googlecode.com/svn/docs/
102
- // closure_goog_array_array.js.html#goog.array.clear
103
-
104
- 'use strict';
105
-
106
- var value = require('../../object/valid-value');
107
-
108
- module.exports = function () {
109
- value(this).length = 0;
110
- return this;
111
- };
112
-
113
- },{"../../object/valid-value":29}],4:[function(require,module,exports){
114
- 'use strict';
115
-
116
- var toPosInt = require('../../number/to-pos-integer')
117
- , value = require('../../object/valid-value')
118
-
119
- , indexOf = Array.prototype.indexOf
120
- , hasOwnProperty = Object.prototype.hasOwnProperty
121
- , abs = Math.abs, floor = Math.floor;
122
-
123
- module.exports = function (searchElement/*, fromIndex*/) {
124
- var i, l, fromIndex, val;
125
- if (searchElement === searchElement) { //jslint: ignore
126
- return indexOf.apply(this, arguments);
127
- }
128
-
129
- l = toPosInt(value(this).length);
130
- fromIndex = arguments[1];
131
- if (isNaN(fromIndex)) fromIndex = 0;
132
- else if (fromIndex >= 0) fromIndex = floor(fromIndex);
133
- else fromIndex = toPosInt(this.length) - floor(abs(fromIndex));
134
-
135
- for (i = fromIndex; i < l; ++i) {
136
- if (hasOwnProperty.call(this, i)) {
137
- val = this[i];
138
- if (val !== val) return i; //jslint: ignore
139
- }
140
- }
141
- return -1;
142
- };
143
-
144
- },{"../../number/to-pos-integer":10,"../../object/valid-value":29}],5:[function(require,module,exports){
145
- 'use strict';
146
-
147
- var toString = Object.prototype.toString
148
-
149
- , id = toString.call((function () { return arguments; }()));
150
-
151
- module.exports = function (x) { return (toString.call(x) === id); };
152
-
153
- },{}],6:[function(require,module,exports){
154
- 'use strict';
155
-
156
- module.exports = require('./is-implemented')()
157
- ? Math.sign
158
- : require('./shim');
159
-
160
- },{"./is-implemented":7,"./shim":8}],7:[function(require,module,exports){
161
- 'use strict';
162
-
163
- module.exports = function () {
164
- var sign = Math.sign;
165
- if (typeof sign !== 'function') return false;
166
- return ((sign(10) === 1) && (sign(-20) === -1));
167
- };
168
-
169
- },{}],8:[function(require,module,exports){
170
- 'use strict';
171
-
172
- module.exports = function (value) {
173
- value = Number(value);
174
- if (isNaN(value) || (value === 0)) return value;
175
- return (value > 0) ? 1 : -1;
176
- };
177
-
178
- },{}],9:[function(require,module,exports){
179
- 'use strict';
180
-
181
- var sign = require('../math/sign')
182
-
183
- , abs = Math.abs, floor = Math.floor;
184
-
185
- module.exports = function (value) {
186
- if (isNaN(value)) return 0;
187
- value = Number(value);
188
- if ((value === 0) || !isFinite(value)) return value;
189
- return sign(value) * floor(abs(value));
190
- };
191
-
192
- },{"../math/sign":6}],10:[function(require,module,exports){
193
- 'use strict';
194
-
195
- var toInteger = require('./to-integer')
196
-
197
- , max = Math.max;
198
-
199
- module.exports = function (value) { return max(0, toInteger(value)); };
200
-
201
- },{"./to-integer":9}],11:[function(require,module,exports){
202
- // Internal method, used by iteration functions.
203
- // Calls a function for each key-value pair found in object
204
- // Optionally takes compareFn to iterate object in specific order
205
-
206
- 'use strict';
207
-
208
- var callable = require('./valid-callable')
209
- , value = require('./valid-value')
210
-
211
- , bind = Function.prototype.bind, call = Function.prototype.call, keys = Object.keys
212
- , propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
1
+ // IE11 has an incomplete implementation of Set which doesn't allow you to iterate the keys
2
+ // so this code assumes you want a full implementation and will redefine Set if the half
3
+ // implementation is present
4
+ if (typeof Set === "undefined" || typeof Set.prototype.keys !== "function") {
5
+ var Set = (function() {
6
+ "use strict";
7
+
8
+ var iterables = {
9
+ "[object Array]": true,
10
+ "[object Arguments]": true,
11
+ "[object HTMLCollection]": true,
12
+ "[object NodeList]": true
13
+ };
213
14
 
214
- module.exports = function (method, defVal) {
215
- return function (obj, cb/*, thisArg, compareFn*/) {
216
- var list, thisArg = arguments[2], compareFn = arguments[3];
217
- obj = Object(value(obj));
218
- callable(cb);
15
+ // shortcuts
16
+ var hasOwn = Object.prototype.hasOwnProperty;
17
+ var toString = Object.prototype.toString;
219
18
 
220
- list = keys(obj);
221
- if (compareFn) {
222
- list.sort((typeof compareFn === 'function') ? bind.call(compareFn, obj) : undefined);
19
+ function hasOwnProp(obj, prop) {
20
+ return hasOwn.call(obj, prop);
223
21
  }
224
- if (typeof method !== 'function') method = list[method];
225
- return call.call(method, list, function (key, index) {
226
- if (!propertyIsEnumerable.call(obj, key)) return defVal;
227
- return call.call(cb, thisArg, obj[key], key, obj, index);
228
- });
229
- };
230
- };
231
-
232
- },{"./valid-callable":28,"./valid-value":29}],12:[function(require,module,exports){
233
- 'use strict';
234
-
235
- module.exports = require('./is-implemented')()
236
- ? Object.assign
237
- : require('./shim');
238
-
239
- },{"./is-implemented":13,"./shim":14}],13:[function(require,module,exports){
240
- 'use strict';
241
-
242
- module.exports = function () {
243
- var assign = Object.assign, obj;
244
- if (typeof assign !== 'function') return false;
245
- obj = { foo: 'raz' };
246
- assign(obj, { bar: 'dwa' }, { trzy: 'trzy' });
247
- return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy';
248
- };
249
-
250
- },{}],14:[function(require,module,exports){
251
- 'use strict';
252
-
253
- var keys = require('../keys')
254
- , value = require('../valid-value')
255
22
 
256
- , max = Math.max;
257
-
258
- module.exports = function (dest, src/*, …srcn*/) {
259
- var error, i, l = max(arguments.length, 2), assign;
260
- dest = Object(value(dest));
261
- assign = function (key) {
262
- try { dest[key] = src[key]; } catch (e) {
263
- if (!error) error = e;
23
+ function isIterable(item) {
24
+ // for purposes of this implementation, an iterable is anything we can iterate with
25
+ // a classic for loop:
26
+ // for (var i = 0; i < item.length; i++)
27
+ // Currently accepts: array, arguments object, HTMLCollection, NodeList
28
+ // and anything that has a .length with a numeric value and, if .length > 0, the first item has a nodeType property
29
+ var name;
30
+ if (typeof item === "object") {
31
+ name = toString.call(item);
32
+ return ((iterables[name] === true) ||
33
+ (typeof item.length === "number" &&
34
+ item.length >= 0 &&
35
+ (item.length === 0 || (typeof item[0] === "object" && item[0].nodeType > 0))
36
+ )
37
+ );
38
+ }
39
+ return false;
264
40
  }
265
- };
266
- for (i = 1; i < l; ++i) {
267
- src = arguments[i];
268
- keys(src).forEach(assign);
269
- }
270
- if (error !== undefined) throw error;
271
- return dest;
272
- };
273
-
274
- },{"../keys":20,"../valid-value":29}],15:[function(require,module,exports){
275
- 'use strict';
276
-
277
- var assign = require('./assign')
278
- , value = require('./valid-value');
279
-
280
- module.exports = function (obj) {
281
- var copy = Object(value(obj));
282
- if (copy !== obj) return copy;
283
- return assign({}, obj);
284
- };
285
-
286
- },{"./assign":12,"./valid-value":29}],16:[function(require,module,exports){
287
- // Workaround for http://code.google.com/p/v8/issues/detail?id=2804
288
-
289
- 'use strict';
290
41
 
291
- var create = Object.create, shim;
292
-
293
- if (!require('./set-prototype-of/is-implemented')()) {
294
- shim = require('./set-prototype-of/shim');
295
- }
296
-
297
- module.exports = (function () {
298
- var nullObject, props, desc;
299
- if (!shim) return create;
300
- if (shim.level !== 1) return create;
301
-
302
- nullObject = {};
303
- props = {};
304
- desc = { configurable: false, enumerable: false, writable: true,
305
- value: undefined };
306
- Object.getOwnPropertyNames(Object.prototype).forEach(function (name) {
307
- if (name === '__proto__') {
308
- props[name] = { configurable: true, enumerable: false, writable: true,
309
- value: undefined };
310
- return;
42
+ // decide if we can use Object.defineProperty
43
+ // include a test for Object.defineProperties (which IE8 does not have) to eliminate
44
+ // using the broken Object.defineProperty in IE8
45
+ var canDefineProperty = Object.defineProperty && Object.defineProperties;
46
+
47
+ function setProperty(obj, propName, value, enumerable, writable) {
48
+ if (canDefineProperty) {
49
+ Object.defineProperty(obj, propName, {
50
+ enumerable: enumerable,
51
+ configurable: false,
52
+ writable: writable,
53
+ value: value
54
+ });
55
+ } else {
56
+ obj[propName] = value;
57
+ }
311
58
  }
312
- props[name] = desc;
313
- });
314
- Object.defineProperties(nullObject, props);
315
-
316
- Object.defineProperty(shim, 'nullPolyfill', { configurable: false,
317
- enumerable: false, writable: false, value: nullObject });
318
-
319
- return function (prototype, props) {
320
- return create((prototype === null) ? nullObject : prototype, props);
321
- };
322
- }());
323
-
324
- },{"./set-prototype-of/is-implemented":26,"./set-prototype-of/shim":27}],17:[function(require,module,exports){
325
- 'use strict';
326
-
327
- module.exports = require('./_iterate')('forEach');
328
-
329
- },{"./_iterate":11}],18:[function(require,module,exports){
330
- // Deprecated
331
-
332
- 'use strict';
333
-
334
- module.exports = function (obj) { return typeof obj === 'function'; };
335
-
336
- },{}],19:[function(require,module,exports){
337
- 'use strict';
338
-
339
- var map = { function: true, object: true };
340
-
341
- module.exports = function (x) {
342
- return ((x != null) && map[typeof x]) || false;
343
- };
344
-
345
- },{}],20:[function(require,module,exports){
346
- 'use strict';
347
-
348
- module.exports = require('./is-implemented')()
349
- ? Object.keys
350
- : require('./shim');
351
-
352
- },{"./is-implemented":21,"./shim":22}],21:[function(require,module,exports){
353
- 'use strict';
354
-
355
- module.exports = function () {
356
- try {
357
- Object.keys('primitive');
358
- return true;
359
- } catch (e) { return false; }
360
- };
361
-
362
- },{}],22:[function(require,module,exports){
363
- 'use strict';
364
-
365
- var keys = Object.keys;
366
-
367
- module.exports = function (object) {
368
- return keys(object == null ? object : Object(object));
369
- };
370
-
371
- },{}],23:[function(require,module,exports){
372
- 'use strict';
373
-
374
- var callable = require('./valid-callable')
375
- , forEach = require('./for-each')
376
-
377
- , call = Function.prototype.call;
378
-
379
- module.exports = function (obj, cb/*, thisArg*/) {
380
- var o = {}, thisArg = arguments[2];
381
- callable(cb);
382
- forEach(obj, function (value, key, obj, index) {
383
- o[key] = call.call(cb, thisArg, value, key, obj, index);
384
- });
385
- return o;
386
- };
387
-
388
- },{"./for-each":17,"./valid-callable":28}],24:[function(require,module,exports){
389
- 'use strict';
390
-
391
- var forEach = Array.prototype.forEach, create = Object.create;
392
-
393
- var process = function (src, obj) {
394
- var key;
395
- for (key in src) obj[key] = src[key];
396
- };
397
59
 
398
- module.exports = function (options/*, …options*/) {
399
- var result = create(null);
400
- forEach.call(arguments, function (options) {
401
- if (options == null) return;
402
- process(Object(options), result);
403
- });
404
- return result;
405
- };
406
-
407
- },{}],25:[function(require,module,exports){
408
- 'use strict';
409
-
410
- module.exports = require('./is-implemented')()
411
- ? Object.setPrototypeOf
412
- : require('./shim');
413
-
414
- },{"./is-implemented":26,"./shim":27}],26:[function(require,module,exports){
415
- 'use strict';
416
-
417
- var create = Object.create, getPrototypeOf = Object.getPrototypeOf
418
- , x = {};
419
-
420
- module.exports = function (/*customCreate*/) {
421
- var setPrototypeOf = Object.setPrototypeOf
422
- , customCreate = arguments[0] || create;
423
- if (typeof setPrototypeOf !== 'function') return false;
424
- return getPrototypeOf(setPrototypeOf(customCreate(null), x)) === x;
425
- };
426
-
427
- },{}],27:[function(require,module,exports){
428
- // Big thanks to @WebReflection for sorting this out
429
- // https://gist.github.com/WebReflection/5593554
430
-
431
- 'use strict';
432
-
433
- var isObject = require('../is-object')
434
- , value = require('../valid-value')
435
-
436
- , isPrototypeOf = Object.prototype.isPrototypeOf
437
- , defineProperty = Object.defineProperty
438
- , nullDesc = { configurable: true, enumerable: false, writable: true,
439
- value: undefined }
440
- , validate;
441
-
442
- validate = function (obj, prototype) {
443
- value(obj);
444
- if ((prototype === null) || isObject(prototype)) return obj;
445
- throw new TypeError('Prototype must be null or an object');
446
- };
447
-
448
- module.exports = (function (status) {
449
- var fn, set;
450
- if (!status) return null;
451
- if (status.level === 2) {
452
- if (status.set) {
453
- set = status.set;
454
- fn = function (obj, prototype) {
455
- set.call(validate(obj, prototype), prototype);
456
- return obj;
457
- };
458
- } else {
459
- fn = function (obj, prototype) {
460
- validate(obj, prototype).__proto__ = prototype;
461
- return obj;
462
- };
60
+ // this private function is used like a private method for setting
61
+ // the .size property. It cannot be called from outside this closure.
62
+ var settable = false;
63
+ function setSize(obj, val) {
64
+ settable = true;
65
+ obj.size = val;
66
+ settable = false;
463
67
  }
464
- } else {
465
- fn = function self(obj, prototype) {
466
- var isNullBase;
467
- validate(obj, prototype);
468
- isNullBase = isPrototypeOf.call(self.nullPolyfill, obj);
469
- if (isNullBase) delete self.nullPolyfill.__proto__;
470
- if (prototype === null) prototype = self.nullPolyfill;
471
- obj.__proto__ = prototype;
472
- if (isNullBase) defineProperty(self.nullPolyfill, '__proto__', nullDesc);
473
- return obj;
474
- };
475
- }
476
- return Object.defineProperty(fn, 'level', { configurable: false,
477
- enumerable: false, writable: false, value: status.level });
478
- }((function () {
479
- var x = Object.create(null), y = {}, set
480
- , desc = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__');
481
-
482
- if (desc) {
483
- try {
484
- set = desc.set; // Opera crashes at this point
485
- set.call(x, y);
486
- } catch (ignore) { }
487
- if (Object.getPrototypeOf(x) === y) return { set: set, level: 2 };
488
- }
489
-
490
- x.__proto__ = y;
491
- if (Object.getPrototypeOf(x) === y) return { level: 2 };
492
-
493
- x = {};
494
- x.__proto__ = y;
495
- if (Object.getPrototypeOf(x) === y) return { level: 1 };
496
-
497
- return false;
498
- }())));
499
-
500
- require('../create');
501
-
502
- },{"../create":16,"../is-object":19,"../valid-value":29}],28:[function(require,module,exports){
503
- 'use strict';
504
-
505
- module.exports = function (fn) {
506
- if (typeof fn !== 'function') throw new TypeError(fn + " is not a function");
507
- return fn;
508
- };
509
-
510
- },{}],29:[function(require,module,exports){
511
- 'use strict';
512
-
513
- module.exports = function (value) {
514
- if (value == null) throw new TypeError("Cannot use null or undefined");
515
- return value;
516
- };
517
-
518
- },{}],30:[function(require,module,exports){
519
- 'use strict';
520
-
521
- module.exports = require('./is-implemented')()
522
- ? String.prototype.contains
523
- : require('./shim');
524
-
525
- },{"./is-implemented":31,"./shim":32}],31:[function(require,module,exports){
526
- 'use strict';
527
-
528
- var str = 'razdwatrzy';
529
-
530
- module.exports = function () {
531
- if (typeof str.contains !== 'function') return false;
532
- return ((str.contains('dwa') === true) && (str.contains('foo') === false));
533
- };
534
68
 
535
- },{}],32:[function(require,module,exports){
536
- 'use strict';
537
-
538
- var indexOf = String.prototype.indexOf;
539
-
540
- module.exports = function (searchString/*, position*/) {
541
- return indexOf.call(this, searchString, arguments[1]) > -1;
542
- };
543
-
544
- },{}],33:[function(require,module,exports){
545
- 'use strict';
546
-
547
- var toString = Object.prototype.toString
548
-
549
- , id = toString.call('');
550
-
551
- module.exports = function (x) {
552
- return (typeof x === 'string') || (x && (typeof x === 'object') &&
553
- ((x instanceof String) || (toString.call(x) === id))) || false;
554
- };
555
-
556
- },{}],34:[function(require,module,exports){
557
- 'use strict';
558
-
559
- var setPrototypeOf = require('es5-ext/object/set-prototype-of')
560
- , contains = require('es5-ext/string/#/contains')
561
- , d = require('d')
562
- , Iterator = require('./')
563
-
564
- , defineProperty = Object.defineProperty
565
- , ArrayIterator;
566
-
567
- ArrayIterator = module.exports = function (arr, kind) {
568
- if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind);
569
- Iterator.call(this, arr);
570
- if (!kind) kind = 'value';
571
- else if (contains.call(kind, 'key+value')) kind = 'key+value';
572
- else if (contains.call(kind, 'key')) kind = 'key';
573
- else kind = 'value';
574
- defineProperty(this, '__kind__', d('', kind));
575
- };
576
- if (setPrototypeOf) setPrototypeOf(ArrayIterator, Iterator);
577
-
578
- ArrayIterator.prototype = Object.create(Iterator.prototype, {
579
- constructor: d(ArrayIterator),
580
- _resolve: d(function (i) {
581
- if (this.__kind__ === 'value') return this.__list__[i];
582
- if (this.__kind__ === 'key+value') return [i, this.__list__[i]];
583
- return i;
584
- }),
585
- toString: d(function () { return '[object Array Iterator]'; })
586
- });
587
-
588
- },{"./":37,"d":2,"es5-ext/object/set-prototype-of":25,"es5-ext/string/#/contains":30}],35:[function(require,module,exports){
589
- 'use strict';
590
-
591
- var isArguments = require('es5-ext/function/is-arguments')
592
- , callable = require('es5-ext/object/valid-callable')
593
- , isString = require('es5-ext/string/is-string')
594
- , get = require('./get')
595
-
596
- , isArray = Array.isArray, call = Function.prototype.call
597
- , some = Array.prototype.some;
598
-
599
- module.exports = function (iterable, cb/*, thisArg*/) {
600
- var mode, thisArg = arguments[2], result, doBreak, broken, i, l, char, code;
601
- if (isArray(iterable) || isArguments(iterable)) mode = 'array';
602
- else if (isString(iterable)) mode = 'string';
603
- else iterable = get(iterable);
604
-
605
- callable(cb);
606
- doBreak = function () { broken = true; };
607
- if (mode === 'array') {
608
- some.call(iterable, function (value) {
609
- call.call(cb, thisArg, value, doBreak);
610
- if (broken) return true;
611
- });
612
- return;
613
- }
614
- if (mode === 'string') {
615
- l = iterable.length;
616
- for (i = 0; i < l; ++i) {
617
- char = iterable[i];
618
- if ((i + 1) < l) {
619
- code = char.charCodeAt(0);
620
- if ((code >= 0xD800) && (code <= 0xDBFF)) char += iterable[++i];
69
+ // this is the constructor function which will be returned
70
+ // from this closure
71
+ function SetConstructor(arg) {
72
+ // private member variable, not used if IE8
73
+ var size = 0;
74
+
75
+ // set properties in cross-browser way
76
+ setProperty(this, "baseType", "Set", false, false); // not enumerable, not writeable
77
+ setProperty(this, "_data", {}, false, true); // not enumerable, writeable
78
+ if (canDefineProperty) {
79
+ Object.defineProperty(this, "size", {
80
+ enumerable: true,
81
+ configurable: false,
82
+ get: function() { return size;},
83
+ set: function(val) {
84
+ if (!settable) {throw new Error("Can't set size property on Set object.")}
85
+ size = val;
86
+ }
87
+ });
88
+ } else {
89
+ // .size is just regular property in IE8
90
+ this.size = 0;
91
+ }
92
+ // now add initial data
93
+ // per spec make sure it isn't undefined or null
94
+ if (arg !== undefined && arg !== null) {
95
+ if (isIterable(arg)) {
96
+ for (var i = 0; i < arg.length; i++) {
97
+ this.add(arg[i]);
98
+ }
99
+ // also check our own custom property in case
100
+ // there is cross window code that won't pass instanceof
101
+ } else if (arg instanceof Set || arg.baseType === "Set") {
102
+ arg.forEach(function(item) {
103
+ this.add(item);
104
+ }, this);
105
+ }
621
106
  }
622
- call.call(cb, thisArg, char, doBreak);
623
- if (broken) break;
624
107
  }
625
- return;
626
- }
627
- result = iterable.next();
628
-
629
- while (!result.done) {
630
- call.call(cb, thisArg, result.value, doBreak);
631
- if (broken) return;
632
- result = iterable.next();
633
- }
634
- };
635
-
636
- },{"./get":36,"es5-ext/function/is-arguments":5,"es5-ext/object/valid-callable":28,"es5-ext/string/is-string":33}],36:[function(require,module,exports){
637
- 'use strict';
638
-
639
- var isArguments = require('es5-ext/function/is-arguments')
640
- , isString = require('es5-ext/string/is-string')
641
- , ArrayIterator = require('./array')
642
- , StringIterator = require('./string')
643
- , iterable = require('./valid-iterable')
644
- , iteratorSymbol = require('es6-symbol').iterator;
645
-
646
- module.exports = function (obj) {
647
- if (typeof iterable(obj)[iteratorSymbol] === 'function') return obj[iteratorSymbol]();
648
- if (isArguments(obj)) return new ArrayIterator(obj);
649
- if (isString(obj)) return new StringIterator(obj);
650
- return new ArrayIterator(obj);
651
- };
652
-
653
- },{"./array":34,"./string":39,"./valid-iterable":40,"es5-ext/function/is-arguments":5,"es5-ext/string/is-string":33,"es6-symbol":46}],37:[function(require,module,exports){
654
- 'use strict';
655
108
 
656
- var clear = require('es5-ext/array/#/clear')
657
- , assign = require('es5-ext/object/assign')
658
- , callable = require('es5-ext/object/valid-callable')
659
- , value = require('es5-ext/object/valid-value')
660
- , d = require('d')
661
- , autoBind = require('d/auto-bind')
662
- , Symbol = require('es6-symbol')
663
-
664
- , defineProperty = Object.defineProperty
665
- , defineProperties = Object.defineProperties
666
- , Iterator;
667
-
668
- module.exports = Iterator = function (list, context) {
669
- if (!(this instanceof Iterator)) return new Iterator(list, context);
670
- defineProperties(this, {
671
- __list__: d('w', value(list)),
672
- __context__: d('w', context),
673
- __nextIndex__: d('w', 0)
674
- });
675
- if (!context) return;
676
- callable(context.on);
677
- context.on('_add', this._onAdd);
678
- context.on('_delete', this._onDelete);
679
- context.on('_clear', this._onClear);
680
- };
109
+ // state variables and shared constants
110
+ var objectCntr = 0;
111
+ var objectCntrBase = "obj_";
112
+ var objectCntrProp = "__objectPolyFillID";
113
+
114
+ // types where we just use the first 3 letters of the type
115
+ // plus underscore + toString() to make the key
116
+ // The first 3 letters of the type makes a namespace for each
117
+ // type so we can have things like 0 and "0" as separate keys
118
+ // "num_0" and "str_0".
119
+ var autoTypes = {
120
+ "string": true,
121
+ "boolean": true,
122
+ "number": true,
123
+ "undefined": true
124
+ };
681
125
 
682
- defineProperties(Iterator.prototype, assign({
683
- constructor: d(Iterator),
684
- _next: d(function () {
685
- var i;
686
- if (!this.__list__) return;
687
- if (this.__redo__) {
688
- i = this.__redo__.shift();
689
- if (i !== undefined) return i;
690
- }
691
- if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++;
692
- this._unBind();
693
- }),
694
- next: d(function () { return this._createResult(this._next()); }),
695
- _createResult: d(function (i) {
696
- if (i === undefined) return { done: true, value: undefined };
697
- return { done: false, value: this._resolve(i) };
698
- }),
699
- _resolve: d(function (i) { return this.__list__[i]; }),
700
- _unBind: d(function () {
701
- this.__list__ = null;
702
- delete this.__redo__;
703
- if (!this.__context__) return;
704
- this.__context__.off('_add', this._onAdd);
705
- this.__context__.off('_delete', this._onDelete);
706
- this.__context__.off('_clear', this._onClear);
707
- this.__context__ = null;
708
- }),
709
- toString: d(function () { return '[object Iterator]'; })
710
- }, autoBind({
711
- _onAdd: d(function (index) {
712
- if (index >= this.__nextIndex__) return;
713
- ++this.__nextIndex__;
714
- if (!this.__redo__) {
715
- defineProperty(this, '__redo__', d('c', [index]));
716
- return;
126
+ function getKey(val, putKeyOnObject) {
127
+ // manufacture a namespaced key
128
+ var type = typeof val, id;
129
+ if (autoTypes[type]) {
130
+ return type.substr(0, 3) + "_" + val;
131
+ } else if (val === null) {
132
+ return "nul_null";
133
+ } else if (type === "object" || type === "function") {
134
+ // coin a unique id for each object and store it on the object
135
+ if (val[objectCntrProp]) {
136
+ return val[objectCntrProp];
137
+ } else if (!putKeyOnObject) {
138
+ // it only returns null if there is no key already on the object
139
+ // and it wasn't requested to create a new key on the object
140
+ return null;
141
+ } else {
142
+ // coin a unique id for the object
143
+ id = objectCntrBase + objectCntr++;
144
+ // include a test for Object.defineProperties to rule out IE8
145
+ // which can't use Object.defineProperty on normal JS objects
146
+ if (toString.call(val) === "[object Object]" && canDefineProperty) {
147
+ Object.defineProperty(val, objectCntrProp, {
148
+ enumerable: false,
149
+ configurable: false,
150
+ writable: false,
151
+ value: id
152
+ });
153
+ } else {
154
+ // no Object.defineProperty() or not plain object, so just assign property directly
155
+ val[objectCntrProp] = id;
156
+ }
157
+ return id;
158
+ }
159
+ } else {
160
+ throw new Error("Unsupported type for Set.add()");
161
+ }
717
162
  }
718
- this.__redo__.forEach(function (redo, i) {
719
- if (redo >= index) this.__redo__[i] = ++redo;
720
- }, this);
721
- this.__redo__.push(index);
722
- }),
723
- _onDelete: d(function (index) {
724
- var i;
725
- if (index >= this.__nextIndex__) return;
726
- --this.__nextIndex__;
727
- if (!this.__redo__) return;
728
- i = this.__redo__.indexOf(index);
729
- if (i !== -1) this.__redo__.splice(i, 1);
730
- this.__redo__.forEach(function (redo, i) {
731
- if (redo > index) this.__redo__[i] = --redo;
732
- }, this);
733
- }),
734
- _onClear: d(function () {
735
- if (this.__redo__) clear.call(this.__redo__);
736
- this.__nextIndex__ = 0;
737
- })
738
- })));
739
-
740
- defineProperty(Iterator.prototype, Symbol.iterator, d(function () {
741
- return this;
742
- }));
743
- defineProperty(Iterator.prototype, Symbol.toStringTag, d('', 'Iterator'));
744
-
745
- },{"d":2,"d/auto-bind":1,"es5-ext/array/#/clear":3,"es5-ext/object/assign":12,"es5-ext/object/valid-callable":28,"es5-ext/object/valid-value":29,"es6-symbol":46}],38:[function(require,module,exports){
746
- 'use strict';
747
-
748
- var isArguments = require('es5-ext/function/is-arguments')
749
- , isString = require('es5-ext/string/is-string')
750
- , iteratorSymbol = require('es6-symbol').iterator
751
-
752
- , isArray = Array.isArray;
753
-
754
- module.exports = function (value) {
755
- if (value == null) return false;
756
- if (isArray(value)) return true;
757
- if (isString(value)) return true;
758
- if (isArguments(value)) return true;
759
- return (typeof value[iteratorSymbol] === 'function');
760
- };
761
-
762
- },{"es5-ext/function/is-arguments":5,"es5-ext/string/is-string":33,"es6-symbol":46}],39:[function(require,module,exports){
763
- // Thanks @mathiasbynens
764
- // http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols
765
-
766
- 'use strict';
767
-
768
- var setPrototypeOf = require('es5-ext/object/set-prototype-of')
769
- , d = require('d')
770
- , Iterator = require('./')
771
-
772
- , defineProperty = Object.defineProperty
773
- , StringIterator;
774
-
775
- StringIterator = module.exports = function (str) {
776
- if (!(this instanceof StringIterator)) return new StringIterator(str);
777
- str = String(str);
778
- Iterator.call(this, str);
779
- defineProperty(this, '__length__', d('', str.length));
780
-
781
- };
782
- if (setPrototypeOf) setPrototypeOf(StringIterator, Iterator);
783
-
784
- StringIterator.prototype = Object.create(Iterator.prototype, {
785
- constructor: d(StringIterator),
786
- _next: d(function () {
787
- if (!this.__list__) return;
788
- if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++;
789
- this._unBind();
790
- }),
791
- _resolve: d(function (i) {
792
- var char = this.__list__[i], code;
793
- if (this.__nextIndex__ === this.__length__) return char;
794
- code = char.charCodeAt(0);
795
- if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++];
796
- return char;
797
- }),
798
- toString: d(function () { return '[object String Iterator]'; })
799
- });
800
-
801
- },{"./":37,"d":2,"es5-ext/object/set-prototype-of":25}],40:[function(require,module,exports){
802
- 'use strict';
803
-
804
- var isIterable = require('./is-iterable');
805
-
806
- module.exports = function (value) {
807
- if (!isIterable(value)) throw new TypeError(value + " is not iterable");
808
- return value;
809
- };
810
-
811
- },{"./is-iterable":38}],41:[function(require,module,exports){
812
- 'use strict';
813
-
814
- module.exports = require('./is-implemented')() ? Set : require('./polyfill');
815
-
816
- },{"./is-implemented":42,"./polyfill":45}],42:[function(require,module,exports){
817
- 'use strict';
818
-
819
- module.exports = function () {
820
- var set, iterator, result;
821
- if (typeof Set !== 'function') return false;
822
- set = new Set(['raz', 'dwa', 'trzy']);
823
- if (String(set) !== '[object Set]') return false;
824
- if (set.size !== 3) return false;
825
- if (typeof set.add !== 'function') return false;
826
- if (typeof set.clear !== 'function') return false;
827
- if (typeof set.delete !== 'function') return false;
828
- if (typeof set.entries !== 'function') return false;
829
- if (typeof set.forEach !== 'function') return false;
830
- if (typeof set.has !== 'function') return false;
831
- if (typeof set.keys !== 'function') return false;
832
- if (typeof set.values !== 'function') return false;
833
-
834
- iterator = set.values();
835
- result = iterator.next();
836
- if (result.done !== false) return false;
837
- if (result.value !== 'raz') return false;
838
-
839
- return true;
840
- };
841
-
842
- },{}],43:[function(require,module,exports){
843
- // Exports true if environment provides native `Set` implementation,
844
- // whatever that is.
845
-
846
- 'use strict';
847
-
848
- module.exports = (function () {
849
- if (typeof Set === 'undefined') return false;
850
- return (Object.prototype.toString.call(Set.prototype) === '[object Set]');
851
- }());
852
-
853
- },{}],44:[function(require,module,exports){
854
- 'use strict';
855
-
856
- var setPrototypeOf = require('es5-ext/object/set-prototype-of')
857
- , contains = require('es5-ext/string/#/contains')
858
- , d = require('d')
859
- , Iterator = require('es6-iterator')
860
- , toStringTagSymbol = require('es6-symbol').toStringTag
861
-
862
- , defineProperty = Object.defineProperty
863
- , SetIterator;
864
-
865
- SetIterator = module.exports = function (set, kind) {
866
- if (!(this instanceof SetIterator)) return new SetIterator(set, kind);
867
- Iterator.call(this, set.__setData__, set);
868
- if (!kind) kind = 'value';
869
- else if (contains.call(kind, 'key+value')) kind = 'key+value';
870
- else kind = 'value';
871
- defineProperty(this, '__kind__', d('', kind));
872
- };
873
- if (setPrototypeOf) setPrototypeOf(SetIterator, Iterator);
874
-
875
- SetIterator.prototype = Object.create(Iterator.prototype, {
876
- constructor: d(SetIterator),
877
- _resolve: d(function (i) {
878
- if (this.__kind__ === 'value') return this.__list__[i];
879
- return [this.__list__[i], this.__list__[i]];
880
- }),
881
- toString: d(function () { return '[object Set Iterator]'; })
882
- });
883
- defineProperty(SetIterator.prototype, toStringTagSymbol, d('c', 'Set Iterator'));
884
-
885
- },{"d":2,"es5-ext/object/set-prototype-of":25,"es5-ext/string/#/contains":30,"es6-iterator":37,"es6-symbol":46}],45:[function(require,module,exports){
886
- 'use strict';
887
163
 
888
- var clear = require('es5-ext/array/#/clear')
889
- , eIndexOf = require('es5-ext/array/#/e-index-of')
890
- , setPrototypeOf = require('es5-ext/object/set-prototype-of')
891
- , callable = require('es5-ext/object/valid-callable')
892
- , d = require('d')
893
- , ee = require('event-emitter')
894
- , Symbol = require('es6-symbol')
895
- , iterator = require('es6-iterator/valid-iterable')
896
- , forOf = require('es6-iterator/for-of')
897
- , Iterator = require('./lib/iterator')
898
- , isNative = require('./is-native-implemented')
899
-
900
- , call = Function.prototype.call
901
- , defineProperty = Object.defineProperty, getPrototypeOf = Object.getPrototypeOf
902
- , SetPoly, getValues, NativeSet;
903
-
904
- if (isNative) NativeSet = Set;
905
-
906
- module.exports = SetPoly = function Set(/*iterable*/) {
907
- var iterable = arguments[0], self;
908
- if (!(this instanceof SetPoly)) throw new TypeError('Constructor requires \'new\'');
909
- if (isNative && setPrototypeOf) self = setPrototypeOf(new NativeSet(), getPrototypeOf(this));
910
- else self = this;
911
- if (iterable != null) iterator(iterable);
912
- defineProperty(self, '__setData__', d('c', []));
913
- if (!iterable) return self;
914
- forOf(iterable, function (value) {
915
- if (eIndexOf.call(this, value) !== -1) return;
916
- this.push(value);
917
- }, self.__setData__);
918
- return self;
919
- };
920
-
921
- if (isNative) {
922
- if (setPrototypeOf) setPrototypeOf(SetPoly, NativeSet);
923
- SetPoly.prototype = Object.create(NativeSet.prototype, { constructor: d(SetPoly) });
924
- }
925
-
926
- ee(Object.defineProperties(SetPoly.prototype, {
927
- add: d(function (value) {
928
- if (this.has(value)) return this;
929
- this.emit('_add', this.__setData__.push(value) - 1, value);
930
- return this;
931
- }),
932
- clear: d(function () {
933
- if (!this.__setData__.length) return;
934
- clear.call(this.__setData__);
935
- this.emit('_clear');
936
- }),
937
- delete: d(function (value) {
938
- var index = eIndexOf.call(this.__setData__, value);
939
- if (index === -1) return false;
940
- this.__setData__.splice(index, 1);
941
- this.emit('_delete', index, value);
942
- return true;
943
- }),
944
- entries: d(function () { return new Iterator(this, 'key+value'); }),
945
- forEach: d(function (cb/*, thisArg*/) {
946
- var thisArg = arguments[1], iterator, result, value;
947
- callable(cb);
948
- iterator = this.values();
949
- result = iterator._next();
950
- while (result !== undefined) {
951
- value = iterator._resolve(result);
952
- call.call(cb, thisArg, value, value, this);
953
- result = iterator._next();
164
+ function SetIterator(keys, data, format) {
165
+ var index = 0, len = keys.length;
166
+ this.next = function() {
167
+ var val, result = {}, key;
168
+ while (true) {
169
+ if (index < len) {
170
+ result.done = false;
171
+ key = keys[index++];
172
+ val = data[key];
173
+ // check to see if key might have been removed
174
+ // undefined is a valid value in the set so we have to check more than that
175
+ // if it is no longer in the set, get the next key
176
+ if (val === undefined && !hasOwnProp(data, key)) {
177
+ continue;
178
+ }
179
+ if (format === "keys") {
180
+ result.value = val;
181
+ } else if (format === "entries") {
182
+ result.value = [val, val];
183
+ }
184
+ } else {
185
+ // clear references to outside data
186
+ keys = null;
187
+ data = null;
188
+ result.done = true;
189
+ }
190
+ return result;
191
+ }
192
+ };
954
193
  }
955
- }),
956
- has: d(function (value) {
957
- return (eIndexOf.call(this.__setData__, value) !== -1);
958
- }),
959
- keys: d(getValues = function () { return this.values(); }),
960
- size: d.gs(function () { return this.__setData__.length; }),
961
- values: d(function () { return new Iterator(this); }),
962
- toString: d(function () { return '[object Set]'; })
963
- }));
964
- defineProperty(SetPoly.prototype, Symbol.iterator, d(getValues));
965
- defineProperty(SetPoly.prototype, Symbol.toStringTag, d('c', 'Set'));
966
-
967
- },{"./is-native-implemented":43,"./lib/iterator":44,"d":2,"es5-ext/array/#/clear":3,"es5-ext/array/#/e-index-of":4,"es5-ext/object/set-prototype-of":25,"es5-ext/object/valid-callable":28,"es6-iterator/for-of":35,"es6-iterator/valid-iterable":40,"es6-symbol":46,"event-emitter":51}],46:[function(require,module,exports){
968
- 'use strict';
969
-
970
- module.exports = require('./is-implemented')() ? Symbol : require('./polyfill');
971
-
972
- },{"./is-implemented":47,"./polyfill":49}],47:[function(require,module,exports){
973
- 'use strict';
974
-
975
- module.exports = function () {
976
- var symbol;
977
- if (typeof Symbol !== 'function') return false;
978
- symbol = Symbol('test symbol');
979
- try { String(symbol); } catch (e) { return false; }
980
- if (typeof Symbol.iterator === 'symbol') return true;
981
-
982
- // Return 'true' for polyfills
983
- if (typeof Symbol.isConcatSpreadable !== 'object') return false;
984
- if (typeof Symbol.iterator !== 'object') return false;
985
- if (typeof Symbol.toPrimitive !== 'object') return false;
986
- if (typeof Symbol.toStringTag !== 'object') return false;
987
- if (typeof Symbol.unscopables !== 'object') return false;
988
-
989
- return true;
990
- };
991
-
992
- },{}],48:[function(require,module,exports){
993
- 'use strict';
994
-
995
- module.exports = function (x) {
996
- return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false;
997
- };
998
-
999
- },{}],49:[function(require,module,exports){
1000
- // ES2015 Symbol polyfill for environments that do not support it (or partially support it_
1001
-
1002
- 'use strict';
1003
-
1004
- var d = require('d')
1005
- , validateSymbol = require('./validate-symbol')
1006
-
1007
- , create = Object.create, defineProperties = Object.defineProperties
1008
- , defineProperty = Object.defineProperty, objPrototype = Object.prototype
1009
- , NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create(null);
1010
-
1011
- if (typeof Symbol === 'function') NativeSymbol = Symbol;
1012
-
1013
- var generateName = (function () {
1014
- var created = create(null);
1015
- return function (desc) {
1016
- var postfix = 0, name, ie11BugWorkaround;
1017
- while (created[desc + (postfix || '')]) ++postfix;
1018
- desc += (postfix || '');
1019
- created[desc] = true;
1020
- name = '@@' + desc;
1021
- defineProperty(objPrototype, name, d.gs(null, function (value) {
1022
- // For IE11 issue see:
1023
- // https://connect.microsoft.com/IE/feedbackdetail/view/1928508/
1024
- // ie11-broken-getters-on-dom-objects
1025
- // https://github.com/medikoo/es6-symbol/issues/12
1026
- if (ie11BugWorkaround) return;
1027
- ie11BugWorkaround = true;
1028
- defineProperty(this, name, d(value));
1029
- ie11BugWorkaround = false;
1030
- }));
1031
- return name;
1032
- };
1033
- }());
1034
-
1035
- // Internal constructor (not one exposed) for creating Symbol instances.
1036
- // This one is used to ensure that `someSymbol instanceof Symbol` always return false
1037
- HiddenSymbol = function Symbol(description) {
1038
- if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor');
1039
- return SymbolPolyfill(description);
1040
- };
1041
-
1042
- // Exposed `Symbol` constructor
1043
- // (returns instances of HiddenSymbol)
1044
- module.exports = SymbolPolyfill = function Symbol(description) {
1045
- var symbol;
1046
- if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor');
1047
- symbol = create(HiddenSymbol.prototype);
1048
- description = (description === undefined ? '' : String(description));
1049
- return defineProperties(symbol, {
1050
- __description__: d('', description),
1051
- __name__: d('', generateName(description))
1052
- });
1053
- };
1054
- defineProperties(SymbolPolyfill, {
1055
- for: d(function (key) {
1056
- if (globalSymbols[key]) return globalSymbols[key];
1057
- return (globalSymbols[key] = SymbolPolyfill(String(key)));
1058
- }),
1059
- keyFor: d(function (s) {
1060
- var key;
1061
- validateSymbol(s);
1062
- for (key in globalSymbols) if (globalSymbols[key] === s) return key;
1063
- }),
1064
-
1065
- // If there's native implementation of given symbol, let's fallback to it
1066
- // to ensure proper interoperability with other native functions e.g. Array.from
1067
- hasInstance: d('', (NativeSymbol && NativeSymbol.hasInstance) || SymbolPolyfill('hasInstance')),
1068
- isConcatSpreadable: d('', (NativeSymbol && NativeSymbol.isConcatSpreadable) ||
1069
- SymbolPolyfill('isConcatSpreadable')),
1070
- iterator: d('', (NativeSymbol && NativeSymbol.iterator) || SymbolPolyfill('iterator')),
1071
- match: d('', (NativeSymbol && NativeSymbol.match) || SymbolPolyfill('match')),
1072
- replace: d('', (NativeSymbol && NativeSymbol.replace) || SymbolPolyfill('replace')),
1073
- search: d('', (NativeSymbol && NativeSymbol.search) || SymbolPolyfill('search')),
1074
- species: d('', (NativeSymbol && NativeSymbol.species) || SymbolPolyfill('species')),
1075
- split: d('', (NativeSymbol && NativeSymbol.split) || SymbolPolyfill('split')),
1076
- toPrimitive: d('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')),
1077
- toStringTag: d('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')),
1078
- unscopables: d('', (NativeSymbol && NativeSymbol.unscopables) || SymbolPolyfill('unscopables'))
1079
- });
1080
-
1081
- // Internal tweaks for real symbol producer
1082
- defineProperties(HiddenSymbol.prototype, {
1083
- constructor: d(SymbolPolyfill),
1084
- toString: d('', function () { return this.__name__; })
1085
- });
1086
-
1087
- // Proper implementation of methods exposed on Symbol.prototype
1088
- // They won't be accessible on produced symbol instances as they derive from HiddenSymbol.prototype
1089
- defineProperties(SymbolPolyfill.prototype, {
1090
- toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }),
1091
- valueOf: d(function () { return validateSymbol(this); })
1092
- });
1093
- defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('',
1094
- function () { return validateSymbol(this); }));
1095
- defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d('c', 'Symbol'));
1096
-
1097
- // Proper implementaton of toPrimitive and toStringTag for returned symbol instances
1098
- defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toStringTag,
1099
- d('c', SymbolPolyfill.prototype[SymbolPolyfill.toStringTag]));
1100
-
1101
- // Note: It's important to define `toPrimitive` as last one, as some implementations
1102
- // implement `toPrimitive` natively without implementing `toStringTag` (or other specified symbols)
1103
- // And that may invoke error in definition flow:
1104
- // See: https://github.com/medikoo/es6-symbol/issues/13#issuecomment-164146149
1105
- defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toPrimitive,
1106
- d('c', SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive]));
1107
-
1108
- },{"./validate-symbol":50,"d":2}],50:[function(require,module,exports){
1109
- 'use strict';
1110
194
 
1111
- var isSymbol = require('./is-symbol');
1112
-
1113
- module.exports = function (value) {
1114
- if (!isSymbol(value)) throw new TypeError(value + " is not a symbol");
1115
- return value;
1116
- };
1117
-
1118
- },{"./is-symbol":48}],51:[function(require,module,exports){
1119
- 'use strict';
1120
-
1121
- var d = require('d')
1122
- , callable = require('es5-ext/object/valid-callable')
1123
-
1124
- , apply = Function.prototype.apply, call = Function.prototype.call
1125
- , create = Object.create, defineProperty = Object.defineProperty
1126
- , defineProperties = Object.defineProperties
1127
- , hasOwnProperty = Object.prototype.hasOwnProperty
1128
- , descriptor = { configurable: true, enumerable: false, writable: true }
1129
-
1130
- , on, once, off, emit, methods, descriptors, base;
1131
-
1132
- on = function (type, listener) {
1133
- var data;
1134
-
1135
- callable(listener);
1136
-
1137
- if (!hasOwnProperty.call(this, '__ee__')) {
1138
- data = descriptor.value = create(null);
1139
- defineProperty(this, '__ee__', descriptor);
1140
- descriptor.value = null;
1141
- } else {
1142
- data = this.__ee__;
1143
- }
1144
- if (!data[type]) data[type] = listener;
1145
- else if (typeof data[type] === 'object') data[type].push(listener);
1146
- else data[type] = [data[type], listener];
1147
-
1148
- return this;
1149
- };
1150
-
1151
- once = function (type, listener) {
1152
- var once, self;
1153
-
1154
- callable(listener);
1155
- self = this;
1156
- on.call(this, type, once = function () {
1157
- off.call(self, type, once);
1158
- apply.call(listener, this, arguments);
1159
- });
1160
-
1161
- once.__eeOnceListener__ = listener;
1162
- return this;
1163
- };
1164
-
1165
- off = function (type, listener) {
1166
- var data, listeners, candidate, i;
1167
-
1168
- callable(listener);
1169
-
1170
- if (!hasOwnProperty.call(this, '__ee__')) return this;
1171
- data = this.__ee__;
1172
- if (!data[type]) return this;
1173
- listeners = data[type];
1174
-
1175
- if (typeof listeners === 'object') {
1176
- for (i = 0; (candidate = listeners[i]); ++i) {
1177
- if ((candidate === listener) ||
1178
- (candidate.__eeOnceListener__ === listener)) {
1179
- if (listeners.length === 2) data[type] = listeners[i ? 0 : 1];
1180
- else listeners.splice(i, 1);
195
+ function getKeys(data) {
196
+ var keys = [];
197
+ for (var prop in data) {
198
+ if (hasOwnProp(data, prop)) {
199
+ keys.push(prop);
200
+ }
1181
201
  }
202
+ return keys;
1182
203
  }
1183
- } else {
1184
- if ((listeners === listener) ||
1185
- (listeners.__eeOnceListener__ === listener)) {
1186
- delete data[type];
1187
- }
1188
- }
1189
-
1190
- return this;
1191
- };
1192
-
1193
- emit = function (type) {
1194
- var i, l, listener, listeners, args;
1195
-
1196
- if (!hasOwnProperty.call(this, '__ee__')) return;
1197
- listeners = this.__ee__[type];
1198
- if (!listeners) return;
1199
-
1200
- if (typeof listeners === 'object') {
1201
- l = arguments.length;
1202
- args = new Array(l - 1);
1203
- for (i = 1; i < l; ++i) args[i - 1] = arguments[i];
1204
204
 
1205
- listeners = listeners.slice();
1206
- for (i = 0; (listener = listeners[i]); ++i) {
1207
- apply.call(listener, this, args);
1208
- }
1209
- } else {
1210
- switch (arguments.length) {
1211
- case 1:
1212
- call.call(listeners, this);
1213
- break;
1214
- case 2:
1215
- call.call(listeners, this, arguments[1]);
1216
- break;
1217
- case 3:
1218
- call.call(listeners, this, arguments[1], arguments[2]);
1219
- break;
1220
- default:
1221
- l = arguments.length;
1222
- args = new Array(l - 1);
1223
- for (i = 1; i < l; ++i) {
1224
- args[i - 1] = arguments[i];
205
+ SetConstructor.prototype = {
206
+ add: function(val) {
207
+ var key = getKey(val, true);
208
+ if (!hasOwnProp(this._data, key)) {
209
+ this._data[key] = val;
210
+ setSize(this, this.size + 1);
211
+ }
212
+ return this;
213
+ },
214
+ clear: function() {
215
+ this._data = {};
216
+ setSize(this, 0);
217
+ },
218
+ // delete has to be in quotes for IE8 - go figure
219
+ "delete": function(val) {
220
+ var key = getKey(val, false);
221
+ if (key !== null && hasOwnProp(this._data, key)) {
222
+ delete this._data[key];
223
+ setSize(this, this.size - 1);
224
+ return true;
225
+ }
226
+ return false;
227
+ },
228
+ // .remove() is non-standard, but here for anyone who wants to use it
229
+ // so that you can use this polyfill all the way down to IE7 and IE8
230
+ // since IE8 can't use a method named .delete()
231
+ remove: function(val) {
232
+ return this["delete"](val);
233
+ },
234
+ forEach: function(fn /*, context */) {
235
+ // by spec, we have to type check the fn argument
236
+ if (typeof fn !== "function") return;
237
+
238
+ // context argument is optional, but .forEach.length is supposed to be 1 by spec
239
+ // so we declare it this way
240
+ var context = arguments[1];
241
+
242
+ // forEach specifies that the iteration set is
243
+ // determined before the first callback so we get all the
244
+ // keys first
245
+ var iter = this.keys(), next, item;
246
+ while ((next = iter.next()) && !next.done) {
247
+ item = next.value;
248
+ fn.call(context, item, item, this);
249
+ }
250
+ },
251
+ has: function(val) {
252
+ var key = getKey(val, false);
253
+ if (key === null) return false;
254
+ return hasOwn.call(this._data, key);
255
+ },
256
+ values: function() {
257
+ return this.keys();
258
+ },
259
+ keys: function() {
260
+ return new SetIterator(getKeys(this._data), this._data, "keys");
261
+ },
262
+ entries: function() {
263
+ return new SetIterator(getKeys(this._data), this._data, "entries");
1225
264
  }
1226
- apply.call(listeners, this, args);
1227
- }
1228
- }
1229
- };
1230
-
1231
- methods = {
1232
- on: on,
1233
- once: once,
1234
- off: off,
1235
- emit: emit
1236
- };
1237
-
1238
- descriptors = {
1239
- on: d(on),
1240
- once: d(once),
1241
- off: d(off),
1242
- emit: d(emit)
1243
- };
1244
-
1245
- base = defineProperties({}, descriptors);
265
+ };
1246
266
 
1247
- module.exports = exports = function (o) {
1248
- return (o == null) ? create(base) : defineProperties(Object(o), descriptors);
1249
- };
1250
- exports.methods = methods;
267
+ SetConstructor.prototype.constructor = SetConstructor;
1251
268
 
1252
- },{"d":2,"es5-ext/object/valid-callable":28}]},{},[41])(41)
1253
- });
269
+ return SetConstructor;
270
+ })();
271
+ }