An open API service indexing awesome lists of open source software.

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. ๐ŸŒป

Awesome Lists containing this project

README

          


Icon of jMap

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. โ˜•




Donate to igorskyflyer




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/)).