horae-configure

0.0.7 • Public • Published

Introduction

"horae" is a lightweight JavaScript library that provides methods to easily read JSON files and manipulate data using the set, get, has, and save functions.

Features

  • Read JSON files effortlessly.
  • Modify JSON data using set and get methods.
  • Check if a specific property exists using has.
  • Save the updated JSON data back to the file.

Installation

You can install "horae" via npm:

npm install horae-configure

You can install "horae" via yarn:

yarn add horae-configure

How to use?

You need to first prepare a JSON file in the outermost layer of the project

{
  "position": {
    "x": 1,
    "y": 2
  }
}

and then initialize horae variable

const horae = new Horae<{
  position: {
    x: number;
    y: number;
  };
}>('config');

get method

horae.get('position.x'); // 1
horae.get('position.y'); // 2

has method

horae.has('position.x'); // true
horae.has('position.y'); // true
horae.has('position.z'); // false

set method

horae.set('position.x', 100);
horae.get('position.x'); // 100

save method

horae.set('position.', 100);
horae.save();

Go back and view the JSON file

{
  "position": {
    "x": 1000,
    "y": 2
  }
}

Package Sidebar

Install

npm i horae-configure

Weekly Downloads

38

Version

0.0.7

License

MIT

Unpacked Size

7.55 kB

Total Files

4

Last publish

Collaborators

  • jiaweihong