(C, NAME, methods, commonMethods, isMap, isWeak)
| 1478 | , tmp = {}; |
| 1479 | |
| 1480 | function getCollection(C, NAME, methods, commonMethods, isMap, isWeak){ |
| 1481 | var ADDER = isMap ? 'set' : 'add' |
| 1482 | , proto = C && C[PROTOTYPE] |
| 1483 | , O = {}; |
| 1484 | function initFromIterable(that, iterable){ |
| 1485 | if(iterable != undefined)forOf(iterable, isMap, that[ADDER], that); |
| 1486 | return that; |
| 1487 | } |
| 1488 | function fixSVZ(key, chain){ |
| 1489 | var method = proto[key]; |
| 1490 | if(framework)proto[key] = function(a, b){ |
| 1491 | var result = method.call(this, a === 0 ? 0 : a, b); |
| 1492 | return chain ? this : result; |
| 1493 | }; |
| 1494 | } |
| 1495 | if(!isNative(C) || !(isWeak || (!BUGGY_ITERATORS && has(proto, FOR_EACH) && has(proto, 'entries')))){ |
| 1496 | // create collection constructor |
| 1497 | C = isWeak |
| 1498 | ? function(iterable){ |
| 1499 | assertInstance(this, C, NAME); |
| 1500 | set(this, UID, uid++); |
| 1501 | initFromIterable(this, iterable); |
| 1502 | } |
| 1503 | : function(iterable){ |
| 1504 | var that = this; |
| 1505 | assertInstance(that, C, NAME); |
| 1506 | set(that, O1, create(null)); |
| 1507 | set(that, SIZE, 0); |
| 1508 | set(that, LAST, undefined); |
| 1509 | set(that, FIRST, undefined); |
| 1510 | initFromIterable(that, iterable); |
| 1511 | }; |
| 1512 | assignHidden(assignHidden(C[PROTOTYPE], methods), commonMethods); |
| 1513 | isWeak || !DESC || defineProperty(C[PROTOTYPE], 'size', {get: function(){ |
| 1514 | return assertDefined(this[SIZE]); |
| 1515 | }}); |
| 1516 | } else { |
| 1517 | var Native = C |
| 1518 | , inst = new C |
| 1519 | , chain = inst[ADDER](isWeak ? {} : -0, 1) |
| 1520 | , buggyZero; |
| 1521 | // wrap to init collections from iterable |
| 1522 | if(checkDangerIterClosing(function(O){ new C(O) })){ |
| 1523 | C = function(iterable){ |
| 1524 | assertInstance(this, C, NAME); |
| 1525 | return initFromIterable(new Native, iterable); |
| 1526 | }; |
| 1527 | C[PROTOTYPE] = proto; |
| 1528 | if(framework)proto[CONSTRUCTOR] = C; |
| 1529 | } |
| 1530 | isWeak || inst[FOR_EACH](function(val, key){ |
| 1531 | buggyZero = 1 / key === -Infinity; |
| 1532 | }); |
| 1533 | // fix converting -0 key to +0 |
| 1534 | if(buggyZero){ |
| 1535 | fixSVZ('delete'); |
| 1536 | fixSVZ('has'); |
| 1537 | isMap && fixSVZ('get'); |
no test coverage detected