🔑 Get the same key for the same sequence of values!
APACHE-2.0 License
$ npm i keyalesce
import keyalesce from 'keyalesce'
const hangouts = new Set()
const createHangoutKey = (person1, person2) =>
keyalesce([person1, person2].sort())
const hangOut = (person1, person2) =>
hangouts.add(createHangoutKey(person1, person2))
const didTheyHangOut = (person1, person2) =>
hangouts.has(createHangoutKey(person1, person2))
hangOut(`Tomer`, `Samuel`)
hangOut(`Tomer`, `Amanda`)
console.log(didTheyHangOut(`Tomer`, `Samuel`))
console.log(didTheyHangOut(`Samuel`, `Tomer`))
//=> true
//=> true
console.log(didTheyHangOut(`Tomer`, `Amanda`))
console.log(didTheyHangOut(`Amanda`, `Tomer`))
//=> true
//=> true
console.log(didTheyHangOut(`Samuel`, `Amanda`))
console.log(didTheyHangOut(`Amanda`, `Samuel`))
//=> false
//=> false
Stars are always welcome!
For bugs and feature requests, please create an issue.
For pull requests, please read the contributing guidelines.
This is not an official Google product.