Skip to content

Commit

Permalink
added size
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Giammarchi committed Nov 22, 2018
1 parent ab9ed22 commit 8ed2c0f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
9 changes: 7 additions & 2 deletions cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
try { new Map; }
catch (o_O) {
(function (i, dPs) {'use strict';
var proto = (Map = function Map(iterable) {
var proto = dPs((Map = function Map(iterable) {
dPs(this, {_k: {value: []}, _v: {value: []}});
if (iterable)
iterable.forEach(add, this);
}).prototype;
}).prototype, {size: {
configurable: true,
get: function () {
return this._k.length;
}
}});
proto.clear = function () {
var length = this._k.length;
this._k.splice(0, length);
Expand Down
9 changes: 7 additions & 2 deletions esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
try { new Map; }
catch (o_O) {
(function (i, dPs) {'use strict';
var proto = (Map = function Map(iterable) {
var proto = dPs((Map = function Map(iterable) {
dPs(this, {_k: {value: []}, _v: {value: []}});
if (iterable)
iterable.forEach(add, this);
}).prototype;
}).prototype, {size: {
configurable: true,
get: function () {
return this._k.length;
}
}});
proto.clear = function () {
var length = this._k.length;
this._k.splice(0, length);
Expand Down
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
try { new Map; }
catch (o_O) {
(function (i, dPs) {'use strict';
var proto = (Map = function Map(iterable) {
var proto = dPs((Map = function Map(iterable) {
dPs(this, {_k: {value: []}, _v: {value: []}});
if (iterable)
iterable.forEach(add, this);
}).prototype;
}).prototype, {size: {
configurable: true,
get: function () {
return this._k.length;
}
}});
proto.clear = function () {
var length = this._k.length;
this._k.splice(0, length);
Expand Down
2 changes: 1 addition & 1 deletion min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ function test() {
var ws2 = new Map([[a, b]]);

console.assert(ws1.has(a) === false);
console.assert(ws1.set(a, 123) === ws1);
console.assert(ws1.set(a, 456) === ws1);
console.assert(ws1.set(a, 123) === ws1);
console.assert(ws1.has(a) === true);
console.assert(ws1.size === 1);
ws1.clear();
ws1.set(a, b);
var entries = ws1.entries();
Expand All @@ -57,7 +58,6 @@ function test() {
console.assert(values.length === 1);
console.assert(values[0] === b);
}
console.log(ws1.forEach);
ws1.forEach(function (value, key, map) {
console.assert(value === b);
console.assert(key === a);
Expand Down

0 comments on commit 8ed2c0f

Please sign in to comment.