How to use the es6-set/primitive.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 / test / _setup / utils / define-set-observable.js View on Github external
module.exports = function (t, a) {
	var proto = create(Set.prototype), initialized, set, event;

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

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

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

	set.add('raz');
	set._emitAdd_('raz');
	a.deep(event, { type: 'add', value: 'raz', target: set }, "Event");
github medikoo / dbjs / _setup / objects-set.js View on Github external
, setGetLast       = require('es6-set/ext/get-last')
  , setCopy          = require('es6-set/ext/copy')
  , setEvery         = require('es6-set/ext/every')
  , setSome          = require('es6-set/ext/some')
  , createReadOnly   = require('observable-set/create-read-only')
  , createObservable = require('observable-set/create-complete')
  , serializeObject  = require('./serialize/object')
  , defFilterByKey   = require('./utils/define-filter-by-key')

  , propertyIsEnumerable = Object.prototype.propertyIsEnumerable, keys = Object.keys
  , ObjectsSet;

ObjectsSet = function () { return setPrototypeOf(new PrimitiveSet(), ObjectsSet.prototype); };
setPrototypeOf(ObjectsSet, PrimitiveSet);

ObjectsSet.prototype = Object.create(PrimitiveSet.prototype, {
	constructor: d(ObjectsSet),
	_serialize: d(serializeObject),
	getById: d(function (id) { return this.__setData__[id] || null; }),
	_plainForEach_: d(function (cb/*, thisArg*/) {
		var thisArg = arguments[1];
		keys(this.__setData__).forEach(function (key) {
			if (!propertyIsEnumerable.call(this, key)) return;
			cb.call(thisArg, this[key]);
		}, this.__setData__);
	})
});

defFilterByKey(ObjectsSet.prototype);

module.exports = createReadOnly(createObservable(ObjectsSet));
Object.defineProperties(module.exports.prototype, {

es6-set

ECMAScript6 Set polyfill

ISC
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis