Current collected state Current
Observed since 20 Oct, 19:14 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Alternate and slightly faster implementation of [map2](https://www.npmjs.com/package/map2) and [set2](https://www.npmjs.com/package/set2) allowing you to use more than one key as the key
Alternate and slightly faster implementation of map2 and set2 allowing you to use more than one key as the key
✅ Performance guarantee. Found a faster implementation? Make an issue on our github!
Map2 & Set2Set and Map.swap() and .pop()import '2keys'
const map = new Map()
map.set([1, 2], 3)
map.get([1, 2])
// => undefined
// ES6 map is by reference, not value
const map = new Map2()
map.set(1, 2, 3)
map.get(1, 2)
// => 3
const x = {}, y = []
map.set(x, y, {a: 1})
map.get(x, y)
// => {a: 1}
map.has(x, y)
// true
map.delete(x, y)
map.get(x, y)
// => undefined
const map = new Map2([
[1, 2, 3],
[1, 5, 6],
[2, 10, 12],
])
map.set(3, 4, 7).set(9, 9, 9)
map.size
// => 5
for(const [k1, k2, v] of map){
console.log(k1, k2, v)
}
// 1 2 3
// 1 5 6
// 2 10 12
// 3 4 7
// 9 9 9
console.log([...map.values()])
// => [3, 6, 12, 7, 9]
console.log([...map.keys()])
// => [[1, 2], [1, 5], [2, 10], [3, 4], [9, 9]]
console.log(map.submap(1))
// => Map(2) { 2 => 3, 5 => 6 }
console.log(map)
// Map2(4) { (1, 2) => 3, (1, 5) => 6, (2, 10) => 12, (3, 4) => 7, (9, 9) => 9 }
map.clear()
const set = new Set2()
// Chaining works on both set and map
set.add(1, 2).add(3, 4)
set.swap(5, 5)
// => false
set
// Set2(3) { (1, 2), (3, 4), (5, 5) }
set.swap(5, 5)
// => true (entry was present, set unchanged)
for(const [a, b] of set){
console.log(a, b)
}
// 1 2
// 3 4
// 5 5
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 19:14 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:09530e8b228d4d590d8eb9d34037ecd074a7b2f8bf1bae3a4b3cae5bd4711b83