Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

es6-set

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-set - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

CHANGES

19

package.json
{
"name": "es6-set",
"version": "0.0.0",
"version": "0.1.0",
"description": "ECMAScript6 Set polyfill",

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

},
"scripts": {
"test": "node ./node_modules/tad/bin/tad"
},
"dependencies": {
"d": "git://github.com/medikoo/d.git",
"es5-ext": "git://github.com/medikoo/es5-ext.git",
"es6-iterator": "git://github.com/medikoo/es6-iterator.git",
"event-emitter": "git://github.com/medikoo/event-emitter.git"
"d": "~0.1.1",
"es5-ext": "~0.10.2",
"es6-iterator": "~0.1.1",
"es6-symbol": "0.1.x",
"event-emitter": "~0.3.1"
},
"devDependencies": {
"tad": "~0.1.19"
"tad": "0.2.x"
},
"scripts": {
"test": "node ./node_modules/tad/bin/tad"
},
"license": "MIT"
}
'use strict';
var callable = require('es5-ext/object/valid-callable')
, d = require('d/d')
, ee = require('event-emitter/lib/core')
, getIterator = require('es6-iterator/get')
, forOf = require('es6-iterator/for-of')
, getSetData = require('./_get-set-data')
, Iterator = require('./_iterator')
var clear = require('es5-ext/array/#/clear')
, eIndexOf = require('es5-ext/array/#/e-index-of')
, setPrototypeOf = require('es5-ext/object/set-prototype-of')
, callable = require('es5-ext/object/valid-callable')
, d = require('d')
, ee = require('event-emitter')
, Symbol = require('es6-symbol')
, iterator = require('es6-iterator/valid-iterable')
, forOf = require('es6-iterator/for-of')
, Iterator = require('./lib/iterator')
, isNative = require('./is-native-implemented')
, isArray = Array.isArray
, call = Function.prototype.call, defineProperty = Object.defineProperty
, Set, values;
, SetPoly, getValues;
module.exports = Set = function (/*iterable, comparator*/) {
var iterable = arguments[0], comparator = arguments[1];
if (!(this instanceof Set)) return new Set(iterable, comparator);
module.exports = SetPoly = function (/*iterable*/) {
var iterable = arguments[0];
if (!(this instanceof SetPoly)) return new SetPoly(iterable);
if (this.__setData__ !== undefined) {
throw new TypeError(this + " cannot be reinitialized");
}
if (iterable != null) {
if (!isArray(iterable)) iterable = getIterator(iterable);
}
if (comparator != null) {
if (comparator !== 'is') throw new RangeError("Unknown comparator");
}
defineProperty(this, '__setData__', d('', getSetData(comparator)));
if (iterable != null) iterator(iterable);
defineProperty(this, '__setData__', d('c', []));
if (!iterable) return;
forOf(iterable, function (value) { this.add(value); }, this);
forOf(iterable, function (value) {
if (eIndexOf.call(this, value) !== -1) return;
this.push(value);
}, this.__setData__);
};
ee(Object.defineProperties(Set.prototype, {
constructor: d(Set),
if (isNative) {
if (setPrototypeOf) setPrototypeOf(SetPoly, Set);
SetPoly.prototype = Object.create(Set.prototype, {
constructor: d(SetPoly)
});
}
ee(Object.defineProperties(SetPoly.prototype, {
add: d(function (value) {
if (this.has(value)) return this;
this.emit('_add', this.__setData__.push(value) - 1);
this.emit('_add', this.__setData__.push(value) - 1, value);
return this;
}),
clear: d(function () {
this.__setData__.clear();
if (!this.__setData__.length) return;
clear.call(this.__setData__);
this.emit('_clear');
}),
delete: d(function (value) {
var index = this.__setData__.eIndexOf(value);
var index = eIndexOf.call(this.__setData__, value);
if (index === -1) return false;
this.__setData__.splice(index, 1);
this.emit('_delete', index);
this.emit('_delete', index, value);
return true;

@@ -52,19 +60,21 @@ }),

forEach: d(function (cb/*, thisArg*/) {
var thisArg = arguments[1], iterator, result;
var thisArg = arguments[1], iterator, result, value;
callable(cb);
iterator = this.values();
result = iterator.next();
while (!result.done) {
call.call(cb, thisArg, result.value, result.value, this);
result = iterator.next();
result = iterator._next();
while (result !== undefined) {
value = iterator._resolve(result);
call.call(cb, thisArg, value, value, this);
result = iterator._next();
}
}),
has: d(function (value) {
return (this.__setData__.eIndexOf(value) !== -1);
return (eIndexOf.call(this.__setData__, value) !== -1);
}),
keys: d(values = function () { return new Iterator(this); }),
keys: d(getValues = function () { return this.values(); }),
size: d.gs(function () { return this.__setData__.length; }),
values: d(values),
'@@iterator': d(values),
values: d(function () { return new Iterator(this); }),
toString: d(function () { return '[object Set]'; })
}));
defineProperty(SetPoly.prototype, Symbol.iterator, d(getValues));
defineProperty(SetPoly.prototype, Symbol.toStringTag, d('c', 'Set'));

@@ -24,2 +24,8 @@ # es6-set

### Installation
$ npm install es6-set
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)
#### API

@@ -48,3 +54,2 @@

// FF nightly only:

@@ -66,15 +71,4 @@ for (value of set) {

### Installation
#### NPM
In your project path:
$ npm install es6-set
##### Browser
You can easily bundle _es6-set_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake)
## Tests [![Build Status](https://travis-ci.org/medikoo/es6-set.png)](https://travis-ci.org/medikoo/es6-set)
$ npm test
'use strict';
var aFrom = require('es5-ext/array/from')
, getIterator = require('es6-iterator/get')
, toArray = require('es6-iterator/to-array');
var aFrom = require('es5-ext/array/from')
, toArray = require('es5-ext/array/to-array');

@@ -39,3 +38,3 @@ module.exports = function (T, a) {

a.deep(toArray(set.values()), ['dwa', 'trzy', x, 'cztery'], "Values");
a.deep(toArray(getIterator(set)), ['dwa', 'trzy', x, 'cztery'], "Iterator");
a.deep(toArray(set), ['dwa', 'trzy', x, 'cztery'], "Iterator");

@@ -45,3 +44,3 @@ set.clear();

a(set.has('trzy'), false, "Clear: has");
a.deep(toArray(set.values()), [], "Clear: Values");
a.deep(toArray(set), [], "Clear: Values");
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc