Permalink
Browse files

updated readme

  • Loading branch information...
1 parent 3404ead commit 20b08b57d634074c6a3857098eaf9a78719ee2db Gabriel Llamas committed Feb 13, 2013
Showing with 14 additions and 0 deletions.
  1. +14 −0 README.md
View
14 README.md
@@ -37,6 +37,7 @@ When you call to `open()` a `Writer` instance is returned. This object inherits
- [bw.open(file[, settings])](#open)
- [Writer#close([callback])](#close)
+- [Writer#flush(callback)](#flush)
- [Writer#line()](#line)
- [Writer#write(data[, offset[, length]])](#write)
- [Writer#writeln(data[, offset[, length]])](#writeln)
@@ -63,6 +64,19 @@ Flushes the current data. After the callback is executed it's safe to read back
This function is typically used when you need to ensure that the data is flushed to the disk at some point before closing the stream.
+```javascript
+var out = bw.open ("file").write ("a");
+//Default buffer size is 16KB so the "a" character is still in memory
+//Let's force and flush it to disk
+out.flush (function (){
+ FS.readFile ("file", function (error, data){
+ if (error) return console.log (error);
+ //data.toString () === "a"
+ out.close ();
+ });
+});
+```
+
<a name="line"></a>
__Writer#line()__
Writes a line, OS dependent, `\r\n` on Windows, `\n` otherwise.

0 comments on commit 20b08b5

Please sign in to comment.