Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nazar-pc/array-map-set
Just like regular Map and Set, but treats different ArrayBufferView's with the same values as equal
https://github.com/nazar-pc/array-map-set
arraymap arrayset map set
Last synced: about 1 month ago
JSON representation
Just like regular Map and Set, but treats different ArrayBufferView's with the same values as equal
- Host: GitHub
- URL: https://github.com/nazar-pc/array-map-set
- Owner: nazar-pc
- Created: 2018-05-06T03:03:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-16T01:05:17.000Z (over 6 years ago)
- Last Synced: 2024-10-14T14:39:48.118Z (about 1 month ago)
- Topics: arraymap, arrayset, map, set
- Language: LiveScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# ArrayMap and ArraySet [![Travis CI](https://img.shields.io/travis/nazar-pc/array-map-set/master.svg?label=Travis%20CI)](https://travis-ci.org/nazar-pc/array-map-set)
Just like regular Map and Set, but treats different `ArrayBufferView`s with the same values as equal.When dealing with `Uint8Array` or other `ArrayBufferView` instance, you might receive them from different sources (like from the network, binary files, etc).
If you use these `Uint8Array`s as keys in `Map` or `Set`, different instances will be treated as completely different keys.
This package provides `ArrayMap` and `ArraySet` implementations, that work exactly the same way as plain versions, but treat such `Uint8Array`s as the same as long as they have the same contents.
You will also get consistently the same instance of `Uint8Array` as you iterate over keys or values and all of the `ArrayMap` or `ArraySet` will share the same instance of `Uint8Array`.Internal implementation uses `WeakMap` and is optimized for high memory efficiency and performance.
## How to install
```
npm install array-map-set
```## How to use
Node.js:
```javascript
var array_map_set = require('array-map-set')// Do stuff
```
Browser:
```javascript
requirejs(['array-map-set'], function (array_map_set) {
// Do stuff
})
```## API
### array_map_set.ArrayMap(array : Array) : Map
Similar to plain `Map` (only accepts arrays as argument though), returns `Map` object.### array_map_set.ArraySet(array : Array) : Set
Similar to plain `Set` (only accepts arrays as argument though), returns `Set` object.## Contribution
Feel free to create issues and send pull requests (for big changes create an issue first and link it from the PR), they are highly appreciated!When reading LiveScript code make sure to configure 1 tab to be 4 spaces (GitHub uses 8 by default), otherwise code might be hard to read.
## License
Free Public License 1.0.0 / Zero Clause BSD Licensehttps://opensource.org/licenses/FPL-1.0.0
https://tldrlegal.com/license/bsd-0-clause-license