New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

json-interface

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-interface

To load JSON configuration files with permision of read or write, returns an API that allows access to parsed JSON object. If write specified, two methods are attached, save and revert. Implements a cache so the same instance of parsed JSON objects can be

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

README

Adds an API layer on top of JSON config files.

Purpose

  • Simplify loading and saving of json files across a nodejs project
  • Utilises a cache to ensure integrity or data object across multiple node modules.
    • Will return the same object instance of the data to operate upon, unless noCache = true
  • Emulates permissions of read/write upon a JSON file
    • if read: {data : jsonObj}
    • if write: {data:jsonObj, save:fnc, revert:fnc}
  • Version - 0.0.2

Operation

  • jsonConfigInterface = require('json-config-interface')
  • Config files can be loaded with or without .json extension specified
  • Config files can be loaded from:
    • relative dir path jsonConfigInterface.get('./my-config')
    • absolute dir path jsonConfigInterface.get('/path/to/configs/my-config')
    • explicitly defined config directory jsonConfigInterface.setDir('/path/to/configs/'); jsonConfigInterface.get('my-config')
  • Get with methods to save and revert jsonConfigInterface.get('/my-config', 'write')
  • Get a fresh load of config file not from shared cahce jsonConfigInterface.get('/my-config', 'write', true)
  • Purge cache of config file jsonConfigInterface.purge('/my-config')
  • Purge entire cache jsonConfigInterface.purge()

TODO

*json schema validation support

  • sandbox object returns made where write is not specified, as currently a load in read mode can still make edits. (is this possible? some form of JSON parse clone could be used, but it would need to be updated if anywhere else makes a legit edit, how would we watch for that?)

Keywords

JSON

FAQs

Package last updated on 31 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts