Skip to content

Instantly share code, notes, and snippets.

@MadcapJake
Last active August 29, 2015 14:14
Show Gist options
  • Save MadcapJake/9392dc6e19759c2b4a83 to your computer and use it in GitHub Desktop.
Save MadcapJake/9392dc6e19759c2b4a83 to your computer and use it in GitHub Desktop.
shared dynamic Buffer {
}
import io.nodejs.buffer { Buffer }
dynamic FS {
"Asynchronously append data to a file, creating the file if it not yet
exists. data can be a string or a buffer.
JS example:
fs.appendFile('message.txt', 'data to append', function (err) {
if (err) throw err;
console.log('The \"data to append\" was appended to file!');
});
The `options` object can have these three options:
* `encoding` String | Null default = 'utf8'
* `mode` Number default = 438 (aka 0666 in Octal)
* `flag` String default = 'a'"
shared formal void appendFile(String filename, String|Buffer data, Object? options, Callable<Object, [Anything]> callback);
"The synchronous version of [[FS.appendFile]]"
shared formal void appendFileSync(String filename, String|Buffer data, Object? options);
}
FS requireFS() {
dynamic { return require("fs"); }
}
@chochos
Copy link

chochos commented Jan 29, 2015

I would leave options as dynamic instead of Object?. Not sure about the signature of callback.

@MadcapJake
Copy link
Author

Sweet! I'm on the right track then! Thanks for the speedy reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment