All Projects → blond → Hash Set

blond / Hash Set

Licence: mit
#️⃣ Set with custom equality comparisons

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Hash Set

Collection
A PHP library for representing and manipulating collections.
Stars: ✭ 488 (+8033.33%)
Mutual labels:  hash, set
invokable
Objects are functions! Treat any Object or Class as a Proc (like Enumerable but for Procs).
Stars: ✭ 40 (+566.67%)
Mutual labels:  set, hash
Search That Hash
🔎Searches Hash APIs to crack your hash quickly🔎 If hash is not found, automatically pipes into HashCat⚡
Stars: ✭ 466 (+7666.67%)
Mutual labels:  hash
Jquery.localscroll
Animated anchor navigation made easy with jQuery
Stars: ✭ 624 (+10300%)
Mutual labels:  hash
Ethereumjs Util
Project is in active development and has been moved to the EthereumJS monorepo.
Stars: ✭ 534 (+8800%)
Mutual labels:  hash
Zet
Set() as it should be.
Stars: ✭ 475 (+7816.67%)
Mutual labels:  set
Name That Hash
🔗 Don't know what type of hash it is? Name That Hash will name that hash type! 🤖 Identify MD5, SHA256 and 3000+ other hashes ☄ Comes with a neat web app 🔥
Stars: ✭ 540 (+8900%)
Mutual labels:  hash
Php Enum
Simple and fast implementation of enumerations with native PHP
Stars: ✭ 446 (+7333.33%)
Mutual labels:  set
Go Set
Type-safe, zero-allocation sets for Go
Stars: ✭ 751 (+12416.67%)
Mutual labels:  set
John
John the Ripper jumbo - advanced offline password cracker, which supports hundreds of hash and cipher types, and runs on many operating systems, CPUs, GPUs, and even some FPGAs
Stars: ✭ 5,656 (+94166.67%)
Mutual labels:  hash
Learningmasteringalgorithms C
Mastering Algorithms with C 《算法精解:C语言描述》源码及Xcode工程、Linux工程
Stars: ✭ 615 (+10150%)
Mutual labels:  set
Pg pathman
Partitioning tool for PostgreSQL
Stars: ✭ 509 (+8383.33%)
Mutual labels:  hash
Seqbox
A single file container/archive that can be reconstructed even after total loss of file system structures
Stars: ✭ 480 (+7900%)
Mutual labels:  hash
Xxhash
Extremely fast non-cryptographic hash algorithm
Stars: ✭ 5,783 (+96283.33%)
Mutual labels:  hash
Hashids
A small PHP library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user.
Stars: ✭ 4,596 (+76500%)
Mutual labels:  hash
Robin Hood Hashing
Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
Stars: ✭ 658 (+10866.67%)
Mutual labels:  hash
Bitcracker
BitCracker is the first open source password cracking tool for memory units encrypted with BitLocker
Stars: ✭ 463 (+7616.67%)
Mutual labels:  hash
Specs
Content-addressed, authenticated, immutable data structures
Stars: ✭ 539 (+8883.33%)
Mutual labels:  hash
Algorithm
Algorithm is a library of tools that is used to create intelligent applications.
Stars: ✭ 787 (+13016.67%)
Mutual labels:  set
Free Style
Make CSS easier and more maintainable by using JavaScript
Stars: ✭ 693 (+11450%)
Mutual labels:  hash

hash-set

NPM Status Travis Status Coverage Status

The original Set uses Same-value-zero equality.

Use this package if you need custom comparison behavior.

Install

$ npm install --save hash-set

Usage

import hashSet from 'hash-set';

// Create Set class which compares objects with JSON.stringify
const JSONSet = hashSet(JSON.stringify);
// Create instance of JSONSet
const mySet = new JSONSet();

mySet.add({ a: 1 });
mySet.add({ b: 2 });

mySet.has({ a: 1 }); // true
mySet.has({ b: 2 }); // true
mySet.has({ c: 3 }); // false, `{ c: 3 }` has not been added to the set

mySet.size; // 2

mySet.delete({ a: 1 }); // removes `{ a: 1 }` from the set
mySet.has({ a: 1 });    // false, `{ a: 1 }` has been removed

mySet.size; // 1

API

hashSet(hashFn)

Returns Set class with custom equality comparisons.

hashFn

Type: function

The function to determine the unique of value.

HashSet executes a provided function every time you call add(value), has(value), delete(value).

The result of hashFn(value) will be used for comparison with the values of HashSet. For comparison will be used Same-value-zero.

Example

const mySet = new Set();

mySet.add(1);   // value has been added to the set
mySet.add('1'); // value has been added to the set
                // because `Object.is(1, '1')` is `false`

console.log(mySet); // Set { 1, '1' }
import hashSet from 'hash-set';

function hashFn(value) {
    return value.toString();
}

const StringSet = hashSet(hashFn);
const mySet = new StringSet();

mySet.add(1);   // value has been added to the set
mySet.add('1'); // value has not been added to the set
                // because `Object.is(hashFn(1), hashFn('1'))` is `true`

console.log(mySet); // Set { 1 }

License

MIT © Andrew Abramov

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].