I'm trying to save a variable containig an array of objects of a class in NodeJS to a file so that I can reuse it from there instead of having to reobtain it like so
const chatAPI = require("some_module");
const client = new chatAPI.Client("Auth-Key");
var channels = client.channels();
//Now channels is something I would like to use later on
//Say
channels.forEach(channel => {channel.send("Hello")});
Is there any way I can save the channels variable to a file so I can load it again into program memory at a later run and use it like I have wothout having to create a new client and fetch the data.
To elaborate it would be the same as if I let this program run for a while with a blocking loop, and later use the variable, in that case I would not have to reparse or reconstruct the data anyhow.
from Is there a way to store a variable from program memory to hardisk retaining functions
No comments:
Post a Comment