12345678910111213141516171819202122232425 |
- /** @format */
- // ---------MAP-----------
- interface Map<K, V> {
- findKeyByValue(value: any): any
- keysArr(): any[]
- valuesArr(): any[]
- }
- Map.prototype.findKeyByValue = function (value: any) {
- const keys = this.keysArr()
- const values = this.valuesArr()
- let returnKeys = []
- for (let i = 0; i < values.length; i++) {
- if (values[i] == value) {
- returnKeys.push(keys[i])
- }
- }
- return returnKeys
- }
- Map.prototype.keysArr = function () {
- return Array.from(this.keys())
- }
- Map.prototype.valuesArr = function () {
- return Array.from(this.values())
- }
|