Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created September 21, 2009 14:10
Show Gist options
  • Select an option

  • Save brandon-beacher/190255 to your computer and use it in GitHub Desktop.

Select an option

Save brandon-beacher/190255 to your computer and use it in GitHub Desktop.
// Serialize the data to the disk
function save_data() {
- var file = new node.fs.File();
- file.open("tasks.db", "w");
- file.write(JSON.stringify(tasks));
- file.close();
+ var fd = node.fs.open("tasks.db", node.O_WRONLY, 0666).wait();
+ node.fs.write(fd, JSON.stringify(tasks)).wait();
+ node.fs.close(fd).wait();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment