A package that combines the ES6 Map data structure with JSON file read/write functionality.
You can install the es6-map-json
package via npm:
npm install es6-map-json
To use the JsonMap
class provided by es6-map-json
, import it into your project and create a new instance:
const JsonMap = require('es6-map-json');
// Create a new instance of JsonMap with a file path
const myMap = new JsonMap('data.json', null, 2, process.cwd());
// Use it like a regular Map
myMap.set('key', 'value');
console.log(myMap.get('key')); // Output: 'value'
// Changes are automatically saved to the JSON file
- Extends the ES6
Map
data structure. - Automatically reads data from a JSON file upon instantiation.
- Automatically saves data to a JSON file after every modification.
Contributions are welcome! Please feel free to submit issues and pull requests.
This package is created and maintained by Liane Cagara.
This project is licensed under the MIT License - see the LICENSE file for details.