Skip to content

Instantly share code, notes, and snippets.

@canonic-epicure
Created May 27, 2010 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canonic-epicure/416091 to your computer and use it in GitHub Desktop.
Save canonic-epicure/416091 to your computer and use it in GitHub Desktop.
Class('FileSystem', {
trait : JooseX.CPS,
continued : {
methods : {
save : function (data) {
var CONT = this.CONT
require('fs').saveFile('filename.txt', data, function (err, written) {
if (err) {
CONT.THROW(err)
return
}
CONT.CONTINUE(written)
})
}
}
}
})
var fs = new FileSystem()
fs.save('some data').then(function (written) {
// do smth
}).CATCH(function (exception) {
// do smth
}).FINALLY(function () {
// do smth
}).now()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment