Update checked-in dependencies
This commit is contained in:
parent
4fad06f438
commit
40a500c743
4168 changed files with 298222 additions and 374905 deletions
58
node_modules/eslint-plugin-github/lib/utils/object-map.js
generated
vendored
Normal file
58
node_modules/eslint-plugin-github/lib/utils/object-map.js
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// @ts-check
|
||||
const {isDeepStrictEqual} = require('util')
|
||||
|
||||
/**
|
||||
* ObjectMap extends Map, but determines key equality using Node.js’ `util.isDeepStrictEqual` rather than using [SameValueZero](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#key_equality). This makes using objects as keys a bit simpler.
|
||||
*/
|
||||
module.exports = class ObjectMap extends Map {
|
||||
#data
|
||||
|
||||
constructor(iterable = []) {
|
||||
super()
|
||||
this.#data = iterable
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.#data = []
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
if (!this.has(key)) {
|
||||
return false
|
||||
}
|
||||
this.#data = this.#data.filter(([existingKey]) => !isDeepStrictEqual(existingKey, key))
|
||||
return true
|
||||
}
|
||||
|
||||
entries() {
|
||||
return this.#data[Symbol.iterator]()
|
||||
}
|
||||
|
||||
forEach(cb) {
|
||||
for (const [key, value] of this.#data) {
|
||||
cb(value, key, this.#data)
|
||||
}
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return this.#data.find(([existingKey]) => isDeepStrictEqual(existingKey, key))?.[1]
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return this.#data.findIndex(([existingKey]) => isDeepStrictEqual(existingKey, key)) !== -1
|
||||
}
|
||||
|
||||
keys() {
|
||||
return this.#data.map(([key]) => key)[Symbol.iterator]()
|
||||
}
|
||||
|
||||
set(key, value) {
|
||||
this.delete(key)
|
||||
this.#data.push([key, value])
|
||||
return this
|
||||
}
|
||||
|
||||
values() {
|
||||
return this.#data.map(([, value]) => value)[Symbol.iterator]()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue