Socket
Book a DemoInstallSign in
Socket

@haxtra/live-object

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@haxtra/live-object

Standard javascript object with built-in JSON serialization to file

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

live-object

Standard javascript object with built-in JSON serialization to file. Dreams do come true sometimes.

Install

npm i @haxtra/live-object

Usage

const liveObject = require('live-object')

const obj = liveObject('/path/to/file')
obj.foo = 'bar'
obj.save()
$ cat /path/to/file
> {"foo":"bar"}

API

obj = liveObject(filePath, default?, opts?)

// filePath   - (str) json file path, to load and save (required)
// default    - (obj) used when file at path is not found
// opts.reset - (bool) ignore file even if it exists, force default

obj.save(filePath?, pretty?)

// filePath   - (str) alternative file to save to, used for this save only
//                    does not change/update path given at creation time
// pretty     - (bool) save formatted json, with proper indentation

Rules

  • read/write uses sync api
  • save key is reserved
  • JSON.stringify rules apply, see docs

License

MIT

Keywords

node

FAQs

Package last updated on 07 Apr 2023

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.