![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
self-reload-json
Advanced tools
Simple node.js module which will auto reload specified JSON file. The instance created with this module will act as the parsed JSON object itself once loaded, you can read and write JSON content directly with the instance, also it will update automatically when the source JSON file is changed. Optional there is a save function that allows you write the modified data back into the JSON file.
With NPM:
$ npm install self-reload-json
Then in script file:
var SelfReloadJSON = require('self-reload-json');
To load a JSON file:
var config = new SelfReloadJSON(___dirname + '/config.json');
Then all loaded JSON content will be the part of the instance, just change it freely, then you can use the save function to save the changes back to the JSON file.
The SelfReloadJSON
class itself inherits EventEmitter
.
new SelfReloadJSON(options | fileName)
Construct the instance of self reload JSON file.
'utf8'
.true
if you want to keep the removed properties in the instance. Default is false
.'native'
or 'polling'
, default is 'native'
, defines what method to determine the changes of JSON file. 'native'
mode will use system API to detect, and 'polling'
mode will poll the modefied time of the JSON file. In the most case 'native' is more efficient, but some of the operating system does not support this, in this case 'polling'
should be used as fallback.5000
milliseconds.null
.save
(see below). Default is null
.stop()
Stop watching the changes of the JSON file. You can use resume
to continue watching the changes.
resume()
Start to watch the changes of the JSON file. In default, this is automatically called after instance construction.
forceUpdate()
Force update the JSON file.
save(options)
Write the changes back to the JSON file.
JSON.stringify
. Default is null
.As this class is also inherits from EventHandler
class of Node.JS, it will expose 2 event types with event handler.
on('updated', function(json) { ... })
This event will be emitted after the JSON content refreshed. The json
parameter is the raw parsed JSON object (not the SelfReloadJSON instance itself).
on('error', function(err) { ... })
This event will be emitted while error occured when loading the updated JSON file. The err
parameter will be the error thrown by the updater.
If a property name conflicts with the function names described above, they will be ignored. To get those values you should use updated
event listener instead.
FAQs
Self reloading JSON handler
We found that self-reload-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.