10 examples of 'object keys map' in JavaScript

Every line of 'object keys map' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
42function mapKeys(obj, iteratee = (value) => value) {
43 const newObj = {};
44
45 Object.keys(obj).each((key) => {
46 newObj[key] = iteratee(obj[key], key, obj);
47 });
48
49 return newObj;
50}
151static keys( map: {[key: string]: any} ): string[] { return Object.keys( map ); }
82function keys(map: Map) {
83 const keys: T[] = []
84 map.forEach((v, k) => keys.push(k))
85 return keys
86}
21export function objToMap(obj) {
22 return Object.keys(obj || {}).reduce((out, key) => out.set(key, obj[key]), new Map());
23}
57function _mapKey(keyMapping, keyName, toMap){
58 var currentMapping = keyMapping[keyName];
59 //if no states are mapped to this key yet then map the toMap to the key
60 if (undefined === currentMapping){
61 keyMapping[keyName] = toMap;
62 //otherwise if there is a toMap mapped then turn the mapping into an array
63 // including the already mapped toMap and the new toMap
64 }else if (typeof currentMapping === "string"){
65 keyMapping[keyName] = [currentMapping, toMap];
66 //otherwise we have multiple states mapped already, just add another one onto the array
67 }else{
68 keyMapping[keyName][currentMapping.length] = toMap;
69 }
70}
60function fillKeys(map, keys, value) {
61 var i = keys.length;
62 while (i--) {
63 map[keys[i]] = value;
64 }
65 return map;
66}
19export function objectKeys(obj: T) {
20 return Object.keys(obj) as Array>;
21}
6export function keys(obj: T): Array {
7 return Object.keys(obj) as Array;
8}
16export default function mapObject(obj: Record, iteratee: Iteratee) {
17 const keys = Object.keys(obj);
18 const mappedObject = {};
19
20 keys.forEach(key => {
21 mappedObject[key] = iteratee(obj[key], key);
22 });
23
24 return mappedObject;
25}
147function keys(obj) {
148 return Object.keys(obj)
149}

Related snippets