⬅️ Back to Table of Contents
📄 objectIterators.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
3 |
📊 Variables & Constants |
2 |
📚 Table of Contents
🛠️ File Location:
📂 packages/eslint-plugin/src/util/objectIterators.ts
Variables & Constants
Name |
Type |
Kind |
Value |
Exported |
values |
Return[] |
const |
[] |
✗ |
accumulator |
Accumulator |
let/var |
initial |
✗ |
Functions
objectForEachKey(obj: T, callback: (key: keyof T) => void): void
Code
export function objectForEachKey<T extends Record<string, unknown>>(
obj: T,
callback: (key: keyof T) => void,
): void {
const keys = Object.keys(obj);
for (const key of keys) {
callback(key);
}
}
- Parameters:
obj: T
callback: (key: keyof T) => void
- Return Type:
void
- Calls:
Object.keys
callback
objectMapKey(obj: T, callback: (key: keyof T) => Return): Return[]
Code
export function objectMapKey<T extends Record<string, unknown>, Return>(
obj: T,
callback: (key: keyof T) => Return,
): Return[] {
const values: Return[] = [];
objectForEachKey(obj, key => {
values.push(callback(key));
});
return values;
}
- Parameters:
obj: T
callback: (key: keyof T) => Return
- Return Type:
Return[]
- Calls:
objectForEachKey
values.push
callback
objectReduceKey(obj: T, callback: (acc: Accumulator, key: keyof T) => Accumulator, initial: Accumulator): Accumulator
Code
export function objectReduceKey<T extends Record<string, unknown>, Accumulator>(
obj: T,
callback: (acc: Accumulator, key: keyof T) => Accumulator,
initial: Accumulator,
): Accumulator {
let accumulator = initial;
objectForEachKey(obj, key => {
accumulator = callback(accumulator, key);
});
return accumulator;
}
- Parameters:
obj: T
callback: (acc: Accumulator, key: keyof T) => Accumulator
initial: Accumulator
- Return Type:
Accumulator
- Calls:
objectForEachKey
callback