@igorskyflyer/jmap
v1.0.1
Published
🕶️ Reads a JSON file into a Map. 🌻
Maintainers
Readme
📃 Table of Contents
🤖 Features
- 📂 Load any valid JSON file into memory instantly
- 🗺️ Get all properties as a ready‑to‑use Map
- 🎯 Access values quickly by key lookup
- 🧩 Works with any JSON structure, flat or nested
- 🚫 Clear errors if file is missing or invalid
- ⚡ Fast, synchronous execution for small to medium files
- 🔍 Retains exact JSON keys and values with no transformation
🕵🏼 Usage
Install it by executing any of the following, depending on your preferred package manager:
pnpm add @igorskyflyer/jmapyarn add @igorskyflyer/jmapnpm i @igorskyflyer/jmap🤹🏼 API
jMap(path: string): Map<string, unknown>
Reads a JSON file into a Map.
path: string - path to the JSON file, required.
Throws an exception if the file cannot be read or there is an error while parsing the JSON file.
Returns Map with all JSON properties and values.
demo.ts
import { jMap } from '@igorskyflyer/jmap'
const sample: Map<string, unknown> = jMap('./test/data/sample.json')
console.log(sample.get('glossary').title) // 'example glossary'
The used sample JSON file is located here, JSON sample.
📝 Changelog
📑 The changelog is available here, CHANGELOG.md.
🪪 License
Licensed under the MIT license which is available here, MIT license.
💖 Support
🧬 Related
🧠 Zep is a zero-dependency, efficient debounce module. ⏰
🧲 Provides ways of properly checking if a path exists inside a given array of files/directories both on Windows and UNIX-like operating systems. 🗺
@igorskyflyer/adblock-filter-counter
🐲 A dead simple npm module that counts Adblock filter rules.🦘
🧮 Calculates an estimated file size of Mp3 files. 🎶
🔱 Odin is an Object wrapper that allows you to create objects and set their attributes - all at once! 🔺
👨🏻💻 Author
Created by Igor Dimitrijević (@igorskyflyer).
