@x-oasis/get-map-key-by-value 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/get-map-key-by-value.cjs.development.js +47 -0
- package/dist/get-map-key-by-value.cjs.development.js.map +1 -0
- package/dist/get-map-key-by-value.cjs.production.min.js +2 -0
- package/dist/get-map-key-by-value.cjs.production.min.js.map +1 -0
- package/dist/get-map-key-by-value.esm.js +43 -0
- package/dist/get-map-key-by-value.esm.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -0
- package/package.json +24 -0
- package/src/index.ts +7 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @x-oasis/get-map-key-by-value
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
$ npm i @x-oasis/get-map-key-by-value
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## How to use
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import getMapKeyByValue from '@x-oasis/get-map-key-by-value'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## How to run test
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ pnpm test
|
|
19
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
6
|
+
if (!o) return;
|
|
7
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
8
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
9
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
10
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
11
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
12
|
+
}
|
|
13
|
+
function _arrayLikeToArray(arr, len) {
|
|
14
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
15
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
16
|
+
return arr2;
|
|
17
|
+
}
|
|
18
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
19
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
20
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
21
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
22
|
+
if (it) o = it;
|
|
23
|
+
var i = 0;
|
|
24
|
+
return function () {
|
|
25
|
+
if (i >= o.length) return {
|
|
26
|
+
done: true
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
done: false,
|
|
30
|
+
value: o[i++]
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getMapKeyByValue(map, searchValue) {
|
|
38
|
+
for (var _iterator = _createForOfIteratorHelperLoose(map.entries()), _step; !(_step = _iterator()).done;) {
|
|
39
|
+
var _step$value = _step.value,
|
|
40
|
+
key = _step$value[0],
|
|
41
|
+
value = _step$value[1];
|
|
42
|
+
if (value === searchValue) return key;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.default = getMapKeyByValue;
|
|
47
|
+
//# sourceMappingURL=get-map-key-by-value.cjs.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-map-key-by-value.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["// https://stackoverflow.com/questions/47135661/how-can-i-get-a-key-in-a-javascript-map-by-its-value\n\nexport default function getMapKeyByValue(map, searchValue) {\n for (const [key, value] of map.entries()) {\n if (value === searchValue) return key;\n }\n}\n"],"names":["getMapKeyByValue","map","searchValue","_iterator","_createForOfIteratorHelperLoose","entries","_step","done","_step$value","value","key"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAEwBA,gBAAgBA,CAACC,GAAG,EAAEC,WAAW;EACvD,SAAAC,SAAA,GAAAC,+BAAA,CAA2BH,GAAG,CAACI,OAAO,EAAE,GAAAC,KAAA,IAAAA,KAAA,GAAAH,SAAA,IAAAI,IAAA,GAAE;IAAA,IAAAC,WAAA,GAAAF,KAAA,CAAAG,KAAA;MAA9BC,GAAG,GAAAF,WAAA;MAAEC,KAAK,GAAAD,WAAA;IACpB,IAAIC,KAAK,KAAKP,WAAW,EAAE,OAAOQ,GAAG;;AAEzC;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";function r(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(t,e){for(var n,o=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return r(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,void 0):void 0}}(t))){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t.entries());!(n=o()).done;){var a=n.value;if(a[1]===e)return a[0]}};
|
|
2
|
+
//# sourceMappingURL=get-map-key-by-value.cjs.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-map-key-by-value.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["// https://stackoverflow.com/questions/47135661/how-can-i-get-a-key-in-a-javascript-map-by-its-value\n\nexport default function getMapKeyByValue(map, searchValue) {\n for (const [key, value] of map.entries()) {\n if (value === searchValue) return key;\n }\n}\n"],"names":["map","searchValue","_step","_iterator","_createForOfIteratorHelperLoose","entries","done","_step$value","value"],"mappings":"uMAEyCA,EAAKC,GAC5C,QAAwCC,EAAxCC,qrBAAAC,CAA2BJ,EAAIK,aAASH,EAAAC,KAAAG,MAAE,CAAA,IAAAC,EAAAL,EAAAM,MACxC,GADoBD,OACNN,EAAa,OADdM"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
2
|
+
if (!o) return;
|
|
3
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
4
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
6
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
7
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
8
|
+
}
|
|
9
|
+
function _arrayLikeToArray(arr, len) {
|
|
10
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
11
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
12
|
+
return arr2;
|
|
13
|
+
}
|
|
14
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
15
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
16
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
17
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
18
|
+
if (it) o = it;
|
|
19
|
+
var i = 0;
|
|
20
|
+
return function () {
|
|
21
|
+
if (i >= o.length) return {
|
|
22
|
+
done: true
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
done: false,
|
|
26
|
+
value: o[i++]
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getMapKeyByValue(map, searchValue) {
|
|
34
|
+
for (var _iterator = _createForOfIteratorHelperLoose(map.entries()), _step; !(_step = _iterator()).done;) {
|
|
35
|
+
var _step$value = _step.value,
|
|
36
|
+
key = _step$value[0],
|
|
37
|
+
value = _step$value[1];
|
|
38
|
+
if (value === searchValue) return key;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default getMapKeyByValue;
|
|
43
|
+
//# sourceMappingURL=get-map-key-by-value.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-map-key-by-value.esm.js","sources":["../src/index.ts"],"sourcesContent":["// https://stackoverflow.com/questions/47135661/how-can-i-get-a-key-in-a-javascript-map-by-its-value\n\nexport default function getMapKeyByValue(map, searchValue) {\n for (const [key, value] of map.entries()) {\n if (value === searchValue) return key;\n }\n}\n"],"names":["getMapKeyByValue","map","searchValue","_iterator","_createForOfIteratorHelperLoose","entries","_step","done","_step$value","value","key"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAEwBA,gBAAgBA,CAACC,GAAG,EAAEC,WAAW;EACvD,SAAAC,SAAA,GAAAC,+BAAA,CAA2BH,GAAG,CAACI,OAAO,EAAE,GAAAC,KAAA,IAAAA,KAAA,GAAAH,SAAA,IAAAI,IAAA,GAAE;IAAA,IAAAC,WAAA,GAAAF,KAAA,CAAAG,KAAA;MAA9BC,GAAG,GAAAF,WAAA;MAAEC,KAAK,GAAAD,WAAA;IACpB,IAAIC,KAAK,KAAKP,WAAW,EAAE,OAAOQ,GAAG;;AAEzC;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getMapKeyByValue(map: any, searchValue: any): any;
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x-oasis/get-map-key-by-value",
|
|
3
|
+
"version": "0.1.34",
|
|
4
|
+
"description": "get-map-key-by-value function",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/get-map-key-by-value.esm.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"index.ts",
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"tsdx": "^0.14.1"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsdx build --tsconfig tsconfig.build.json",
|
|
20
|
+
"clean": "rimraf ./dist",
|
|
21
|
+
"test": "vitest",
|
|
22
|
+
"compile": "tsc -p tsconfig.build.json"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/index.ts
ADDED