steveukx / properties

Properties reader for Node.js
MIT License
77 stars 33 forks source link

initialize from JSON string #32

Open informvisu opened 4 years ago

informvisu commented 4 years ago

May be an enhancement. Initialize from JSON string to facilitate the properties sharing in Node.js worker threads.

const propsReader = require('properties-reader');
//Now
global.env = propsReader(path/to/file/name);
//Future
global.env = propsReader(path/to/file/name, JSON string, writeToFile); //Write to file, if true

For architectural reasons, don't allow threads to read the properties from file. You might know that worker_threads doesn't allow object sharing