{"_id":"simplesets","_rev":"33-a0c5ed1d16272378c2c4bcd56514d7bb","name":"simplesets","description":"Simple set data type, with API similar to Python's sets module.","dist-tags":{"latest":"1.2.0"},"versions":{"0.9.0":{"name":"simplesets","version":"0.9.0","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets","_id":"simplesets@0.9.0","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/simplesets/-/simplesets-0.9.0.tgz","shasum":"f26c981309b697445f4d0e0f7aaece16b2302353","integrity":"sha512-i7nGw+MZqTH8UeHjQxuBzLkxZJRQ3db3pCEHH6FodChzJ6Qu/005wiyRDbmthuTM86saPQeZsQfn1p1+5Zypwg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFAGwFOPkxqa1OlvMY/Kq6nCdnaSDlcTMhi5MSEgUiBLAiAS71WkYN22KokdFGf6FHNMZWXSHaO3PICdFe+d5aU99w=="}]},"directories":{}},"1.0.0":{"name":"simplesets","version":"1.0.0","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets","repository":{"type":"git","url":"http://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_id":"simplesets@1.0.0","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.0.0.tgz","shasum":"2c15bd85fc54dddd9acc4959d1daf51b4770fbac","integrity":"sha512-GGsV8Hf8j9R092yDHYqqkrG29sQmacITuHTdDG21zHebNUo17sdrELJwFy1tPE2NZgJ69FGNnBRvTMZJH6PqEA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDibmKQ8Fgpvem6PiF9DWJemr34RR83dT1F4D1rMtbFNAiEAgJbW0RLFMb/kpg+neIYzunCgRxMfTC1eWi4A6aqlJbM="}]},"directories":{}},"1.1.0":{"name":"simplesets","version":"1.1.0","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets","repository":{"type":"git","url":"http://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_id":"simplesets@1.1.0","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.1.0.tgz","shasum":"670d1b577fe83081cd81f235b28ed32bbb6ff53c","integrity":"sha512-VrQzGjdn8Hsl9Wmo7Zoy5H4UD2eu1w51p0+j4mTaw7z53L7UfzFI+j+nDoI8X04Pl3pYuqvjAmwAr5QGZMMHiw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICbRFkUc7b9TXRRieAikTrb1fjDgKA2LHoqqN84Fq/5HAiAOFHW3QdS2pff2pNNIJlRNYelipZF5fF6burAlwnD+sQ=="}]},"directories":{}},"1.1.1":{"name":"simplesets","version":"1.1.1","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets","repository":{"type":"git","url":"http://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_id":"simplesets@1.1.1","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.1.1.tgz","shasum":"d0edd0430dc1f7c7be495bed1a11cafb02c782e3","integrity":"sha512-mbrHcOY0xrcJ80cFqRLG4rCFijATEY4E6ulRZU9YeSa8FYjWHM5oqEG1jnLvjulrQZ5iZi+4t+BnVIgKSgca2w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC31cAdILcXBgeZ4u0GGWO2u9LxtpzGdyyXMWGnqIffXgIgcNj/MapQ2IEQ//etNXaA9KwBdHl5lNtwZZkvAEDO+hc="}]},"directories":{}},"1.1.2":{"name":"simplesets","version":"1.1.2","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets","repository":{"type":"git","url":"http://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_id":"simplesets@1.1.2","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.1.2.tgz","shasum":"cd2097f9fa14c2f01fcee6f5a6968dd115f1315f","integrity":"sha512-SJ/P7xbC8eoeoMbFdQX13adWuR7Z4EmdzKeU8kbzsMAWBL6hzgT2TX2KI5ehZUkWr1B7KHbSbuC1cQ2y6mUNsA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAz930fs44xO1pgTnHumhrC/RXvVCg+3hxldYiE9R640AiEAqiKn3wPhAL/sqm2K4eh8gYxHRH4Ha4+PJOms8xR06ok="}]},"directories":{}},"1.1.3":{"name":"simplesets","version":"1.1.3","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets","repository":{"type":"git","url":"http://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_id":"simplesets@1.1.3","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.1.3.tgz","shasum":"06965c54943a7c2b781e446f8b7b67a4dc3bd2c7","integrity":"sha512-xmYmf5dDne4PKYXUJNcaLZZ0ThxM8FGauM3LJi1DkR7/Qn5NwiDqvlR7te5VI3VG0gAYPS40nczJEvcnVlu9gA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGNAiJ3xBt9SrIPLdGvqkhT6y4tvy29KJAfT6ebwRLohAiEAutWR4Q+D6O7CtNMzO7FJPcfY11j6N5w/IC8xizDGhVI="}]},"directories":{}},"1.1.4":{"name":"simplesets","version":"1.1.4","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets","repository":{"type":"git","url":"http://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_id":"simplesets@1.1.4","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.1.4.tgz","shasum":"cb157a983e6935b7934a0530292d120b77da071a","integrity":"sha512-QdRpyLVXWZ92OGWni0zLlZAGkDKAZOMydsHR61bDIuWbu+4ZJBqjNCdJ0OBzY2ecVmTD8Ks4vQ4qye4g0EC23g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCx91wKkS433v+zTIIL60CWl0ap+8KoSra6EnIBl3vHgwIhAMXKDU600iAREa52zaw6IT45rDoK3hvOmx8+PeLBx+XB"}]},"directories":{}},"1.1.5":{"name":"simplesets","version":"1.1.5","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets","repository":{"type":"git","url":"http://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_id":"simplesets@1.1.5","engines":{"node":"*"},"_nodeSupported":true,"_npmVersion":"0.2.7-2","_nodeVersion":"v0.3.1-pre","dist":{"tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.1.5.tgz","shasum":"be9745f28b8ed16e964e7057892cf0d381612864","integrity":"sha512-V7buId50u095LPw/FohiprSUtNfsmg62z9pU3CsG32XRDvqnZmi7SR5ZpjWYcpfZDrhb1Gil/tCzc0536hNMQw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDQjOMCkSsQvBizqaukIyA3WVg2xiyWuM1vSh7sBgJFeAiEAyeq+pESuKQGKGQrKRDkX6tvalfd6ZVjKxvbBlgmjOzc="}]},"directories":{}},"1.1.6":{"name":"simplesets","version":"1.1.6","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets.js","repository":{"type":"git","url":"git://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_id":"simplesets@1.1.6","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.0","_nodeVersion":"v0.5.0-pre","directories":{"lib":"./lib"},"_defaultsLoaded":true,"dist":{"shasum":"f56c4b81ab278425ef33c664079c0eba7e401a9f","tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.1.6.tgz","integrity":"sha512-URp9qmv6NzE71VsxmuSMKmgPoOO3ERX8jXNONxxYSRfKhf1H25Zl24WkleabPmx2o9D4elGkIVaawgV1axOrLA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAskC5nUnA4M1XXGSUPdkVdzcC4s2qgiI+I+tcjYzzZlAiEAv236PnLSnu24H+BiMxoTmYNAyVEG3+pocxfO/mmP9gA="}]}},"1.2.0":{"name":"simplesets","version":"1.2.0","description":"Simple set data type, with API similar to Python's sets module.","author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"main":"./lib/simplesets.js","repository":{"type":"git","url":"git://github.com/PeterScott/simplesets-nodejs.git"},"homepage":"http://github.com/PeterScott/simplesets-nodejs","scripts":{"test":"node test/testsets.js"},"_npmUser":{"name":"PeterScott","email":"pjscott@iastate.edu"},"_id":"simplesets@1.2.0","dependencies":{},"devDependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.0-3","_nodeVersion":"v0.6.9","_defaultsLoaded":true,"dist":{"shasum":"814b371da577f59788b284b6e7fc7652bf7f4b19","tarball":"https://registry.npmjs.org/simplesets/-/simplesets-1.2.0.tgz","integrity":"sha512-dMvnx/ITjxvdPJiCo2ZtISG6bNuQ8+Hk7/NYGPcEcA4q2sO2WrMSkNHMKkL6dhRYPHjr5oGWDWnHVogkOPHdgg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF9Y5MyE6qUkpgmj1EKyDuAyzguODrTaW3q7cnHSOV5oAiEA4DPV4+IEfBvuxDPqeRDc4YyaJ6bslsw6XoeNqJcnLjg="}]},"readme":"Simple set datatype for JavaScript\n==========\n\nThis provides a set data type, with an API very close to that of [Python's sets module](http://docs.python.org/library/sets.html).\n\nInstallation\n----------\n\nIf you have the node package manager, this is easy:\n\n    npm install simplesets\n\nYou could also clone the git repository, and install it manually.\n\nUsage\n----------\n\nHere's an example of how you use it:\n\n```js\nvar sets = require('simplesets');\n\nvar s1 = new sets.Set(['hello', 'world', 'how', 'are', 'you', 'today']);\nvar s2 = new sets.Set(['say', 'hello', 'to', 'the', 'world']);\n\n// Print out both of the sets, as arrays of their elements.\nconsole.log('s1 =', s1.array());\nconsole.log('s2 =', s2.array());\n\n// Do some set operations.\nconsole.log('Intersection:', s1.intersection(s2).array());\nconsole.log('s1 - s2:', s1.difference(s2).array());\nconsole.log('s2 - s1:', s2.difference(s1).array());\nconsole.log('Union:', s1.union(s2).array());\n\n// Make a set with numbers and strings.\nvar s3 = new sets.Set([1, 2, 3, 'a', 'b', 'c']);\nconsole.log('Mixing data types:', s3.array());\n// Add in some more data types.\nvar my_dict = {foo: 42, bar: 'bazaar'};\ns3.add(my_dict);\t\t// This will add to the set...\ns3.add(my_dict);\t\t// ...but now this will do nothing.\ns3.remove(3);\ns3.remove('c');\nconsole.log('New s3 =', s3.array());\n\n// You can make shallow copies of sets.\nvar s4 = new sets.Set([1, 2, 3]);\nvar s5 = s4.copy();\ns4.add(42);\ns5.remove(2);\nconsole.log('s4 =', s4.array());\nconsole.log('s5 =', s5.array());\n```\n    \nThe set data type has the simplest, stupidest implementation possible: an unordered array. This is because of how JavaScript's data types work. If it were possible to compute a hash value from any data type, or get its memory address, then we could do something more elaborate. If `<` and `>` operations were defined for all data types, we could use some kind of balanced tree representation, or sorted arrays. If JavaScript objects supported arbitrary data types as indices, this would all be too easy. But none of those things is true, so we're stuck relying only on the `===` operation, and unsorted arrays. For small sets, this is not a problem. For larger sets, if performance of set operations turns out to be problematic, you may want to use a specialized set data type. For example, if your set members are all strings, you could represent sets as objects with set members as keys, and it would be fast. For this, use the `StringSet` class, described below.\n\nSet API\n----------\n\nThe `Set` class has the following methods:\n\n* `new Set(items)`: Creates a new set. If an array `items` is given, its contents will be added to the set.\n\n* `has(x)`: Does this set contain an element `x`? Returns `true` or `false`.\n\n* `add(x)`: Add an element `x` to this set, and return this set.\n\n* `remove(x)`: Remove an element `x` from this set, if it is part of the set. If it is not part of the set, do nothing. Returns this set.\n\n* `union(other)`: Return a new set containing the items found in either this set, the other set, or both.\n\n* `intersection(other)`: Return a new set containing the items found in both this set and the other set.\n\n* `difference(other)`: Return a new set containing the items in this set that are not in the other set.\n\n* `symmetric_difference(other)`: Return a new set containing the items in either this set or the other set, but not both.\n\n* `issubset(other)`: Return `true` if every element of this set is in the other set.\n\n* `issuperset(other)`: Return `true` if every element of the other is in this set.\n\n* `equals(other)`: Return `true` if this set equals another set, i.e. if every element in each set is equal to an element in the other set.\n\n* `array()`: Return a copy of the items in the set, as an array.\n\n* `size()`: Return the size of the set.\n\n* `copy()`: Return a shallow copy of the set.\n\n* `pop()`: Remove and return a random element of the set, or null if the set is empty.\n\n* `pick()`: Return a random element of the set, or null if the set is empty. Unlike `pop`, does not remove the element from the set.\n\n* `each(callback)`: Call a callback function on each element of the set. If the set is changed by the callback, the results are undefined. The callback takes a single argument: the set element that it's being called on. Callback takes the same parameters as the forEach method of arrays:  value, index, set. Takes an optional parameter that sets what this is bound to.\n\nThe condition for determining whether two values are equal is the `===` operator. Therefore sets can support any mix of data types, as long as the data types can be compared for equality in some meaningful sense with `===`.\n\nSpecialized sets\n----------\n\nIf all of your set members have unique string representations, then you can create a set using object properties to keep track of the members. This takes advantage of the fast built-in object type in JavaScript, and is generally better than using general-purpose sets if there will not be collisions, e.g. a set containing both the number 42 and the string \"42\".\n\nThe `StringSet` class behaves just like the `Set` class, but it uses this object-based encoding and requires that all set members have unique string representations. Instantiate it with `new StringSet(items)`, and the API is the same as described above.\n\nNote that `Set` will generally be faster and more memory-efficient than `StringSet` for sets with fewer than around 110 elements. `StringSet` is good for large sets, though.\n","maintainers":[{"name":"PeterScott","email":"pjscott@iastate.edu"}]}},"maintainers":[{"name":"PeterScott","email":"pjscott@iastate.edu"}],"author":{"name":"Peter Scott","email":"pjscott@iastate.edu"},"repository":{"type":"git","url":"git://github.com/PeterScott/simplesets-nodejs.git"},"time":{"modified":"2022-06-26T20:05:20.345Z","created":"2011-03-17T14:54:37.080Z","0.9.0":"2011-03-17T14:54:37.080Z","1.0.0":"2011-03-17T14:54:37.080Z","1.1.0":"2011-03-17T14:54:37.080Z","1.1.1":"2011-03-17T14:54:37.080Z","1.1.2":"2011-03-17T14:54:37.080Z","1.1.3":"2011-03-17T14:54:37.080Z","1.1.4":"2011-03-17T14:54:37.080Z","1.1.5":"2011-03-17T14:54:37.080Z","1.1.6":"2011-03-17T14:54:38.508Z","1.2.0":"2012-02-03T22:12:10.705Z"},"users":{"havvy":true,"jabclab":true}}