Socket
Book a DemoInstallSign in
Socket

json-manager

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-manager

Json manager read update set get from file

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

JSON Manager

Install

	npm i -S json-manager

Options

Defaults

	{ "dir":""
	, "target":""
	, "watch":false
	, "autoSave":true
	}

Example


	var JSONMGR = require('json-manager')
	var json = new JSONMGR({dir:"./",target:"package.json",watch:true})

	json.init().then(console.log.bind(console))
	json.on("changed",function(j){console.log(j.toJSON())})

Functions

  • init()
    • returns promise calls read()
    • Should call this on start
    • needed for watch to auto start
  • read()
    • returns promise gives JSON (object)
    • pull data from file
    • if no data will save empty object to file with autoSave on
  • toJSON()
    • returns (object) that is stored in memory
  • toString()
    • returns (string) Stringify of json stored in memory
  • set(key,value)
    • the key is a deepbody string "key1.key2.1"
    • sets the key
    • returns promise save to file if autoSave on
  • unset(key)
    • the key is a deepbody string "key1.key2.1"
    • deletes the key from obj
    • returns promise save to file if autoSave on
  • get(key)
    • the key is a deepbody string "key1.key2.1"
    • returns data
  • update(json)
    • json is (object) to replace the whole object
    • returns promise save to file if autoSave on
  • save()
    • force save of json in memory
    • returns promise save to file
  • copy(dir,target)
    • save of json in memory in new location
    • returns promise save to file
  • move(dir,target)
    • save of json in memory in new location
    • object now points to new file and removes old file
    • returns promise save to file
  • delete()
    • returns promise delete file
  • startWatch()
  • stopWatch()

Keywords

json

FAQs

Package last updated on 02 Apr 2015

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.