https://github.com/igorskyflyer/npm-jmap
๐ถ๏ธ Reads a JSON file into a Map. ๐ป
https://github.com/igorskyflyer/npm-jmap
back-end es6 file file-system igorskyflyer javascript js json map npm read typescript utility
Last synced: 5 months ago
JSON representation
๐ถ๏ธ Reads a JSON file into a Map. ๐ป
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-jmap
- Owner: igorskyflyer
- License: mit
- Created: 2024-06-25T20:38:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-27T19:58:15.000Z (10 months ago)
- Last Synced: 2025-09-28T20:48:34.956Z (9 months ago)
- Topics: back-end, es6, file, file-system, igorskyflyer, javascript, js, json, map, npm, read, typescript, utility
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@igorskyflyer/jmap
- Size: 143 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
jMap
๐ถ๏ธ Reads a JSON file into a Map. ๐ป
## ๐ Table of Contents
- [Features](#-features)
- [Usage](#-usage)
- [API](#-api)
- [Changelog](#-changelog)
- [Support](#-support)
- [License](#-license)
- [Related](#-related)
- [Author](#-author)
## ๐ค 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:
```bash
pnpm add @igorskyflyer/jmap
```
```bash
yarn add @igorskyflyer/jmap
```
```bash
npm i @igorskyflyer/jmap
```
## ๐คน๐ผ API
```jMap(path: string): Map```
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`
```ts
import { jMap } from '@igorskyflyer/jmap'
const sample: Map = jMap('./test/data/sample.json')
console.log(sample.get('glossary').title) // 'example glossary'
```
> The used sample JSON file is located here, [JSON sample](https://github.com/igorskyflyer/npm-jmap/blob/main/test/data/sample.json).
## ๐ Changelog
๐ The changelog is available here, [CHANGELOG.md](https://github.com/igorskyflyer/npm-jmap/blob/main/CHANGELOG.md).
## ๐ชช License
Licensed under the MIT license which is available here, [MIT license](https://github.com/igorskyflyer/npm-jmap/blob/main/LICENSE.txt).
## ๐ Support
I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. โ
Thank you for supporting my efforts! ๐๐
## ๐งฌ Related
[@igorskyflyer/zep](https://www.npmjs.com/package/@igorskyflyer/zep)
> _๐ง Zep is a zero-dependency, efficient debounce module. โฐ_
[@igorskyflyer/pathexists](https://www.npmjs.com/package/@igorskyflyer/pathexists)
> _๐งฒ 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](https://www.npmjs.com/package/@igorskyflyer/adblock-filter-counter)
> _๐ฒ A dead simple npm module that counts Adblock filter rules.๐ฆ_
[@igorskyflyer/mp3size](https://www.npmjs.com/package/@igorskyflyer/mp3size)
> _๐งฎ Calculates an estimated file size of Mp3 files. ๐ถ_
[@igorskyflyer/odin](https://www.npmjs.com/package/@igorskyflyer/odin)
> _๐ฑ Odin is an Object wrapper that allows you to create objects and set their attributes - all at once! ๐บ_
## ๐จ๐ปโ๐ป Author
Created by **Igor Dimitrijeviฤ** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).