mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: upgrade to TypeScript 3.0.1 (#3024)
This commit is contained in:
committed by
Andrey Lushnikov
parent
25632133e2
commit
2e0007669d
@@ -13,12 +13,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template V
|
||||
*/
|
||||
class Multimap {
|
||||
constructor() {
|
||||
this._map = new Map();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {T} key
|
||||
* @param {V} value
|
||||
*/
|
||||
set(key, value) {
|
||||
let set = this._map.get(key);
|
||||
if (!set) {
|
||||
@@ -28,6 +35,10 @@ class Multimap {
|
||||
set.add(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {T} key
|
||||
* @return {!Set<V>}
|
||||
*/
|
||||
get(key) {
|
||||
let result = this._map.get(key);
|
||||
if (!result)
|
||||
@@ -35,10 +46,19 @@ class Multimap {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {T} key
|
||||
* @return {boolean}
|
||||
*/
|
||||
has(key) {
|
||||
return this._map.has(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {T} key
|
||||
* @param {V} value
|
||||
* @return {boolean}
|
||||
*/
|
||||
hasValue(key, value) {
|
||||
const set = this._map.get(key);
|
||||
if (!set)
|
||||
@@ -53,6 +73,11 @@ class Multimap {
|
||||
return this._map.size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {T} key
|
||||
* @param {V} value
|
||||
* @return {boolean}
|
||||
*/
|
||||
delete(key, value) {
|
||||
const values = this.get(key);
|
||||
const result = values.delete(value);
|
||||
@@ -61,10 +86,17 @@ class Multimap {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {T} key
|
||||
*/
|
||||
deleteAll(key) {
|
||||
this._map.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {T} key
|
||||
* @return {V}
|
||||
*/
|
||||
firstValue(key) {
|
||||
const set = this._map.get(key);
|
||||
if (!set)
|
||||
@@ -72,10 +104,16 @@ class Multimap {
|
||||
return set.values().next().value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {T}
|
||||
*/
|
||||
firstKey() {
|
||||
return this._map.keys().next().value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {!Array<V>}
|
||||
*/
|
||||
valuesArray() {
|
||||
const result = [];
|
||||
for (const key of this._map.keys())
|
||||
@@ -83,6 +121,9 @@ class Multimap {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {!Array<T>}
|
||||
*/
|
||||
keysArray() {
|
||||
return Array.from(this._map.keys());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user