Socket
Socket
Sign inDemoInstall

es6-map

Package Overview
Dependencies
10
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

LICENSE

2

is-implemented.js

@@ -6,2 +6,3 @@ 'use strict';

if (typeof Map !== 'function') return false;
if (String(Map.prototype) !== '[object Map]') return false;
try {

@@ -30,3 +31,4 @@ // WebKit doesn't support arguments and crashes

if (result.value[1] !== 'one') return false;
return true;
};

2

is-map.js

@@ -10,4 +10,4 @@ 'use strict';

module.exports = function (x) {
return (x && ((Global && (x instanceof Global)) ||
return (x && ((Global && ((x instanceof Global) || (x === Global.prototype))) ||
(toString.call(x) === id) || (x[toStringTagSymbol] === 'Map'))) || false;
};

@@ -8,3 +8,3 @@ // Exports true if environment provides native `Map` implementation,

if (typeof Map === 'undefined') return false;
return (Object.prototype.toString.call(Map.prototype) === '[object Map]');
return (Object.prototype.toString.call(new Map()) === '[object Map]');
}());
{
"name": "es6-map",
"version": "0.1.1",
"version": "0.1.2",
"description": "ECMAScript6 Map polyfill",

@@ -15,2 +15,3 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",

"polyfill",
"ponyfill",
"ecmascript"

@@ -24,12 +25,12 @@ ],

"d": "~0.1.1",
"es5-ext": "~0.10.4",
"es6-iterator": "~0.1.1",
"es6-set": "~0.1.1",
"es6-symbol": "~0.1.1",
"event-emitter": "~0.3.1"
"es5-ext": "~0.10.8",
"es6-iterator": "2",
"es6-set": "~0.1.2",
"es6-symbol": "3",
"event-emitter": "~0.3.4"
},
"devDependencies": {
"tad": "0.2.x",
"xlint": "~0.2.1",
"xlint-jslint-medikoo": "~0.1.2"
"tad": "~0.2.3",
"xlint": "~0.2.2",
"xlint-jslint-medikoo": "~0.1.4"
},

@@ -36,0 +37,0 @@ "scripts": {

@@ -16,17 +16,20 @@ 'use strict';

, call = Function.prototype.call, defineProperties = Object.defineProperties
, call = Function.prototype.call
, defineProperties = Object.defineProperties, getPrototypeOf = Object.getPrototypeOf
, MapPoly;
module.exports = MapPoly = function (/*iterable*/) {
var iterable = arguments[0], keys, values;
if (!(this instanceof MapPoly)) return new MapPoly(iterable);
if (this.__mapKeysData__ !== undefined) {
throw new TypeError(this + " cannot be reinitialized");
var iterable = arguments[0], keys, values, self;
if (!(this instanceof MapPoly)) throw new TypeError('Constructor requires \'new\'');
if (isNative && setPrototypeOf && (Map !== MapPoly)) {
self = setPrototypeOf(new Map(), getPrototypeOf(this));
} else {
self = this;
}
if (iterable != null) iterator(iterable);
defineProperties(this, {
defineProperties(self, {
__mapKeysData__: d('c', keys = []),
__mapValuesData__: d('c', values = [])
});
if (!iterable) return;
if (!iterable) return self;
forOf(iterable, function (value) {

@@ -38,3 +41,4 @@ var key = validValue(value)[0];

values.push(value);
}, this);
}, self);
return self;
};

@@ -41,0 +45,0 @@

@@ -10,8 +10,9 @@ 'use strict';

, forOf = require('es6-iterator/for-of')
, Map = require('../polyfill')
, isNative = require('../is-native-implemented')
, MapPolyfill = require('../polyfill')
, Iterator = require('../lib/primitive-iterator')
, call = Function.prototype.call
, defineProperty = Object.defineProperty
, create = Object.create, defineProperties = Object.defineProperties
, create = Object.create, defineProperty = Object.defineProperty
, defineProperties = Object.defineProperties, getPrototypeOf = Object.getPrototypeOf
, hasOwnProperty = Object.prototype.hasOwnProperty

@@ -21,15 +22,15 @@ , PrimitiveMap;

module.exports = PrimitiveMap = function (/*iterable, serialize*/) {
var iterable = arguments[0], serialize = arguments[1];
if (!(this instanceof PrimitiveMap)) {
return new PrimitiveMap(iterable, serialize);
var iterable = arguments[0], serialize = arguments[1], self;
if (!(this instanceof PrimitiveMap)) throw new TypeError('Constructor requires \'new\'');
if (isNative && setPrototypeOf && (Map !== MapPolyfill)) {
self = setPrototypeOf(new Map(), getPrototypeOf(this));
} else {
self = this;
}
if (this.__mapData__ !== undefined) {
throw new TypeError(this + " cannot be reinitialized");
}
if (iterable != null) iterator(iterable);
if (serialize !== undefined) {
callable(serialize);
defineProperty(this, '_serialize', d('', serialize));
defineProperty(self, '_serialize', d('', serialize));
}
defineProperties(this, {
defineProperties(self, {
__mapKeysData__: d('c', create(null)),

@@ -39,19 +40,20 @@ __mapValuesData__: d('c', create(null)),

});
if (!iterable) return;
if (!iterable) return self;
forOf(iterable, function (value) {
var key = validValue(value)[0], sKey = this._serialize(key);
var key = validValue(value)[0], sKey = self._serialize(key);
if (sKey == null) throw new TypeError(key + " cannot be serialized");
value = value[1];
if (hasOwnProperty.call(this.__mapKeysData__, sKey)) {
if (this.__mapValuesData__[sKey] === value) return;
if (hasOwnProperty.call(self.__mapKeysData__, sKey)) {
if (self.__mapValuesData__[sKey] === value) return;
} else {
++this.__size__;
++self.__size__;
}
this.__mapKeysData__[sKey] = key;
this.__mapValuesData__[sKey] = value;
}, this);
self.__mapKeysData__[sKey] = key;
self.__mapValuesData__[sKey] = value;
});
return self;
};
if (setPrototypeOf) setPrototypeOf(PrimitiveMap, Map);
if (setPrototypeOf) setPrototypeOf(PrimitiveMap, MapPolyfill);
PrimitiveMap.prototype = create(Map.prototype, {
PrimitiveMap.prototype = create(MapPolyfill.prototype, {
constructor: d(PrimitiveMap),

@@ -58,0 +60,0 @@ _serialize: d(function (value) {

@@ -6,15 +6,15 @@ # es6-map

If you want to make sure your environment implements `Map`, do:
It’s safest to use *es6-map* as a [ponyfill](http://kikobeats.com/polyfill-ponyfill-and-prollyfill/) – a polyfill which doesn’t touch global objects:
```javascript
require('es6-map/implement');
var Map = require('es6-map');
```
If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `Map` on global scope, do:
If you want to make sure your environment implements `Map` globally, do:
```javascript
var Map = require('es6-map');
require('es6-map/implement');
```
If you strictly want to use polyfill even if native `Map` exists, do:
If you strictly want to use the polyfill even if the native `Map` exists, do:

@@ -21,0 +21,0 @@ ```javascript

@@ -54,2 +54,8 @@ 'use strict';

a.deep(toArray(map), [], "Clear: Values");
a.h1("Empty initialization");
map = new T();
map.set('foo', 'bar');
a(map.size, 1);
a(map.get('foo'), 'bar');
};

@@ -53,2 +53,8 @@ 'use strict';

a.deep(toArray(map.values()), [], "Clear: Values");
a.h1("Empty initialization");
map = new T();
map.set('foo', 'bar');
a(map.size, 1);
a(map.get('foo'), 'bar');
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc