How to use the es6-map/primitive.prototype function in es6-map

To help you get started, we’ve selected a few es6-map examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github medikoo / dbjs / _setup / index.js View on Github external
if (getPrototypeOf(obj) !== proto) {
			// It appears that some browsers (as Safari OSX v9.0.3) need extra slap(!) here
			console.error("This browser doesn't mind its business as it should. " +
				"Fixed prototype chain error for " + stringify(id));
			setPrototypeOf(obj, proto);
			if (getPrototypeOf(obj) !== proto) {
				throw new Error("Unrecoverable piece of shit"); // Luckily haven't happend so far
			}
		}
		objects._add(obj);
		proto._descendants_._add(obj);
		return obj;
	};

	objects._add(object = createProto(Map.prototype, 'Base#', 'object'));
	objects._add(descriptor = createProto(Map.prototype, '$', 'descriptor', object));
	objects._add(item = createProto(Object.prototype, '*', 'item', object));
	objects._add(descriptorDescriptor = createProto(Object.prototype, '/', 'sub-descriptor',
		object));

	setupProp(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupMultiple(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupDescProp(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupType(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupDescMeta(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);

	defineProperties(objects, {
github medikoo / dbjs / _setup / index.js View on Github external
obj = new Constructor(id, valueId, object, master);
		if (getPrototypeOf(obj) !== proto) {
			// It appears that some browsers (as Safari OSX v9.0.3) need extra slap(!) here
			console.error("This browser doesn't mind its business as it should. " +
				"Fixed prototype chain error for " + stringify(id));
			setPrototypeOf(obj, proto);
			if (getPrototypeOf(obj) !== proto) {
				throw new Error("Unrecoverable piece of shit"); // Luckily haven't happend so far
			}
		}
		objects._add(obj);
		proto._descendants_._add(obj);
		return obj;
	};

	objects._add(object = createProto(Map.prototype, 'Base#', 'object'));
	objects._add(descriptor = createProto(Map.prototype, '$', 'descriptor', object));
	objects._add(item = createProto(Object.prototype, '*', 'item', object));
	objects._add(descriptorDescriptor = createProto(Object.prototype, '/', 'sub-descriptor',
		object));

	setupProp(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupMultiple(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupDescProp(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupType(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupDescMeta(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
github medikoo / dbjs / test / _setup / utils / define-map-observable.js View on Github external
module.exports = function (t, a) {
	var proto = create(Map.prototype), initialized, map, event;

	t(proto, function () { initialized = true; });

	map = create(proto);
	map = proto.constructor.call(map);

	map.set('foo', 'bar');
	a(initialized, undefined, "Not observable");
	map.on('foo', function () {});
	a(initialized, undefined, "Not 'change' listener");
	map.on('change', function (e) { event = e; });
	a(initialized, true, "'change' listener");

	map.set('raz', 'dwa');
	map._emitSet_('raz', 'dwa');
	a.deep(event, { type: 'set', key: 'raz', value: 'dwa', target: map }, "Event");
github medikoo / dbjs / _setup / 1.property / reverse-map.js View on Github external
, defineProperty = Object.defineProperty
  , ReverseMap;

ReverseMap = module.exports = function (obj, sKey) {
	var desc, self = setPrototypeOf(new Map(), ReverseMap.prototype);
	defineProperty(self, '__descriptor__', d('',
		desc = obj._getOwnDescriptor_(sKey)));
	desc = desc.__descriptors__.reverse;
	if (desc && (desc._value_ !== undefined)) obj._serialize_(desc._value_);
	self._includeObjBranch_(obj, sKey, null, true);
	return self;
};
setPrototypeOf(ReverseMap, Map);

ReverseMap.prototype = Object.create(Map.prototype, {
	constructor: d(ReverseMap),
	_serialize: d(serialize),
	_includeObjBranch_: d(function (object, sKey, postponed, init) {
		postponed = this._includeObj_(object, sKey, postponed, init);
		if (!object.hasOwnProperty('__descendants__')) return postponed;
		object.__descendants__._plainForEach_(function self(object) {
			postponed = this._includeObjBranch_(object, sKey, postponed, init);
		}, this);
		return postponed;
	}),
	_includeObj_: d(function (object, sKey, postponed, init) {
		var desc = object._getDescriptor_(sKey), value, data, iKey, item;
		if (!desc._reverse_ && !desc.nested && desc.multiple) {
			value = desc._resolveValueValue_();
			if (isGetter(value)) return postponed;
			data = object.__multiples__[sKey];

es6-map

ECMAScript6 Map polyfill

MIT
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis

Popular es6-map functions