How to use the es6-set/polyfill.prototype function in es6-set

To help you get started, we’ve selected a few es6-set 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 / plain-set.js View on Github external
'use strict';

var d              = require('d')
  , aFrom          = require('es5-ext/array/from')
  , setPrototypeOf = require('es5-ext/object/set-prototype-of')
  , Set            = require('es6-set/polyfill')

  , PlainSet;

module.exports = PlainSet = function (/*iterable*/) {
	return setPrototypeOf(new Set(arguments[0]), PlainSet.prototype);
};
setPrototypeOf(PlainSet, Set);

PlainSet.prototype = Object.create(Set.prototype, {
	first: d.gs(require('es6-set/ext/get-first')),
	last: d.gs(require('es6-set/ext/get-last')),
	copy: d(require('es6-set/ext/copy')),
	every: d(require('es6-set/ext/every')),
	some: d(require('es6-set/ext/some')),
	toArray: d(function () { return aFrom(this); })
});
github medikoo / dbjs / _setup / 1.property / reverse-set.js View on Github external
, defineProperties = Object.defineProperties
  , ReverseSet;

ReverseSet = module.exports = function (key, sKey, descriptor) {
	return defineProperties(setPrototypeOf(new Set(), ReverseSet.prototype), {
		__key__: d('', key),
		__sKey__: d('', sKey),
		__descriptor__: d('', descriptor),
		__isObjectKey__: d('', sKey[0] === '7'),
		__lastModifiedMap__: d('', create(null)),
		__lastEventMap__: d('', create(null))
	});
};
setPrototypeOf(ReverseSet, Set);

ReverseSet.prototype = Object.create(Set.prototype, {
	constructor: d(ReverseSet),
	add: d(function (obj) {
		var desc, sKey, rDesc;
		this._assertReverse_();
		desc = this.__descriptor__;
		desc.object.constructor.validate(obj);
		sKey = desc._sKey_;
		rDesc = obj._getDescriptor_(sKey);
		if (rDesc.multiple) {
			obj._multipleAdd_(sKey, obj._validateMultipleAdd_(sKey, this.__key__), this.__sKey__);
			return this;
		}
		obj._set_(sKey, obj._validateSet_(sKey, this.__key__));
		return this;
	}),
	clear: d(function () {
github medikoo / dbjs / _setup / 2.multiple-item / multiple.js View on Github external
var item = this[sKey];
	if (!item.hasOwnProperty('_value_')) return false;
	return item._value_;
};

module.exports = Multiple = function (obj, pSKey) {
	return defineProperties(setPrototypeOf(new Set(), Multiple.prototype), {
		object: d('', obj),
		dbId: d('', obj.__id__ + '/' + pSKey),
		__pSKey__: d('', pSKey),
		__setData__: d('', obj._getMultipleItems_(pSKey))
	});
};
setPrototypeOf(Multiple, Set);

Multiple.prototype = create(Set.prototype, assign({
	constructor: d(Multiple),
	dbKind: d('multiple'),
	_serialize: d(serialize),
	add: d(function (key) {
		var obj = this.object;
		key = obj._validateMultipleAdd_(this.__pSKey__, key);
		obj._multipleAdd_(this.__pSKey__, key, serialize(key));
		return this;
	}),
	clear: d(function () {
		this.object.database._postponed += 1;
		this._validateClear_().forEach(function (sKey) {
			var item = this.__setData__[sKey];
			if (!item.hasOwnProperty('_value_')) return;
			new Event(item, undefined); //jslint: ignore
		}, this);

es6-set

ECMAScript6 Set polyfill

ISC
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis