Helpers

objectToMap.mjs

@mr_ozio/scraper-utils · v2.5.0 · Generated April 21, 2026

Target Style

Target Style

1 exports

const

mapFrom

Target Style
export const mapFrom = (obj) => new Map(Object.entries(obj))

Converts an object into a map with a shorter, more natural name.

Target style API. Preferred for new code.

Parameters

  • objRecord<string, T>

Returns

Map<string, T>

Legacy Style

Legacy Style

1 exports

const

objectToMap

Legacy Style
export const objectToMap = (obj) => mapFrom(obj)

Converts an object into a map of its enumerable entries.

Legacy API. Kept for older code and not the preferred choice for new code.

Parameters

  • objRecord<string, T>

Returns

Map<string, T>

Example

const map = mapFrom({ foo: 1, bar: 2 })