Index: node_modules/rw/test/cat-async
===================================================================
--- node_modules/rw/test/cat-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/cat-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,10 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.readFile(process.argv[2] || "-", "utf8", function(error, contents) {
+  if (error) throw error;
+  rw.writeFile("-", contents, "utf8", function(error) {
+    if (error) throw error;
+  });
+});
Index: node_modules/rw/test/cat-sync
===================================================================
--- node_modules/rw/test/cat-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/cat-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,5 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.writeFileSync("-", rw.readFileSync(process.argv[2] || "-", "utf8"), "utf8");
Index: node_modules/rw/test/encode-object-async
===================================================================
--- node_modules/rw/test/encode-object-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/encode-object-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.writeFile(process.argv[2] || "-", "gréén\n", {encoding: process.argv[3]}, function(error) {
+  if (error) throw error;
+});
Index: node_modules/rw/test/encode-object-sync
===================================================================
--- node_modules/rw/test/encode-object-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/encode-object-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,5 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.writeFileSync(process.argv[2] || "-", "gréén\n", {encoding: process.argv[3]});
Index: node_modules/rw/test/encode-string-async
===================================================================
--- node_modules/rw/test/encode-string-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/encode-string-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.writeFile(process.argv[2] || "-", "gréén\n", process.argv[3], function(error) {
+  if (error) throw error;
+});
Index: node_modules/rw/test/encode-string-sync
===================================================================
--- node_modules/rw/test/encode-string-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/encode-string-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,5 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.writeFileSync(process.argv[2] || "-", "gréén\n", process.argv[3]);
Index: node_modules/rw/test/encoding-async
===================================================================
--- node_modules/rw/test/encoding-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/encoding-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,42 @@
+#!/usr/bin/env node
+
+var fs = require("fs"),
+    queue = require("d3-queue").queue,
+    rw = require("../");
+
+var code = 0;
+
+queue(1)
+    .defer(testRead, "utf8", "gréén\n")
+    .defer(testRead, {encoding: "utf8"}, "gréén\n")
+    .defer(testRead, "ascii", "grC)C)n\n")
+    .defer(testRead, {encoding: "ascii"}, "grC)C)n\n")
+    .defer(testWrite, "utf8", "gréén\n")
+    .defer(testWrite, {encoding: "utf8"}, "gréén\n")
+    .defer(testWrite, "ascii", "gr��n\n")
+    .defer(testWrite, {encoding: "ascii"}, "gr��n\n")
+    .await(done);
+
+function testRead(options, expected, callback) {
+  rw.readFile("test/utf8.txt", options, function(error, actual) {
+    if (error) return void callback(error);
+    if (actual !== expected) console.warn(actual + " !== " + expected), code = 1;
+    callback(null);
+  });
+}
+
+function testWrite(options, expected, callback) {
+  rw.writeFile("test/encoding-async.out", "gréén\n", options, function(error) {
+    if (error) return void callback(error);
+    fs.readFile("test/encoding-async.out", "utf8", function(error, actual) {
+      if (error) return void callback(error);
+      if (actual !== expected) console.warn(actual + " !== " + expected), code = 1;
+      callback(null);
+    });
+  });
+}
+
+function done(error) {
+  if (error) throw error;
+  process.exit(code);
+}
Index: node_modules/rw/test/encoding-sync
===================================================================
--- node_modules/rw/test/encoding-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/encoding-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+var fs = require("fs"),
+    rw = require("../");
+
+var code = 0,
+    actual,
+    expected;
+
+if ((actual = rw.readFileSync("test/utf8.txt", "utf8")) !== (expected = "gréén\n")) code = 1, console.warn(actual + " !== " + expected);
+if ((actual = rw.readFileSync("test/utf8.txt", {encoding: "utf8"})) !== (expected = "gréén\n")) code = 1, console.warn(actual + " !== " + expected);
+if ((actual = rw.readFileSync("test/utf8.txt", "ascii")) !== (expected = "grC)C)n\n")) code = 1, console.warn(actual + " !== " + expected);
+if ((actual = rw.readFileSync("test/utf8.txt", {encoding: "ascii"})) !== (expected = "grC)C)n\n")) code = 1, console.warn(actual + " !== " + expected);
+
+rw.writeFileSync("test/encoding-sync.out", "gréén\n", "utf8"); if ((actual = fs.readFileSync("test/encoding-sync.out", "utf8")) !== (expected = "gréén\n")) code = 1, console.warn(actual + " !== " + expected);
+rw.writeFileSync("test/encoding-sync.out", "gréén\n", {encoding: "utf8"}); if ((actual = fs.readFileSync("test/encoding-sync.out", "utf8")) !== (expected = "gréén\n")) code = 1, console.warn(actual + " !== " + expected);
+rw.writeFileSync("test/encoding-sync.out", "gréén\n", "ascii"); if ((actual = fs.readFileSync("test/encoding-sync.out", "utf8")) !== (expected = "gr��n\n")) code = 1, console.warn(actual + " !== " + expected);
+rw.writeFileSync("test/encoding-sync.out", "gréén\n", {encoding: "ascii"}); if ((actual = fs.readFileSync("test/encoding-sync.out", "utf8")) !== (expected = "gr��n\n")) code = 1, console.warn(actual + " !== " + expected);
+
+process.exit(code);
Index: node_modules/rw/test/run-tests
===================================================================
--- node_modules/rw/test/run-tests	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/run-tests	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+FILE=test/input.txt
+
+rm -f -- $FILE
+for i in {1..10000}; do printf '%09X\n' $RANDOM >> $FILE; done
+
+function test()
+{
+   if [[ $1 -eq 0 ]]
+   then
+      echo -e "\x1B[1;32m✓ $2\x1B[0m"
+   else
+      echo -e "\x1B[1;31m✗ $2\x1B[0m"
+   fi
+}
+
+test/encoding-sync; test $? "encoding-sync applies the specified encodings"
+test/encoding-async; test $? "encoding-async applies the specified encodings"
+[ "$(test/wc-async $FILE)" = "100000" ]; test $? "wc-async reads an entire file"
+[ "$(test/wc-sync $FILE)" = "100000" ]; test $? "wc-sync reads an entire file"
+[ "$(test/wc-async < $FILE)" = "100000" ]; test $? "wc-async reads an entire file from stdin"
+[ "$(test/wc-sync < $FILE)" = "100000" ]; test $? "wc-sync reads an entire file from stdin"
+[ "$(cat $FILE | test/wc-async)" = "100000" ]; test $? "wc-async reads an entire file from a pipe"
+[ "$(cat $FILE | test/wc-sync)" = "100000" ]; test $? "wc-sync reads an entire file from a pipe"
+[ "$(test/cat-async $FILE | wc -c | tr -d ' ')" = "100000" ]; test $? "cat-async reads an entire file and writes it to a pipe"
+[ "$(test/cat-sync $FILE | wc -c | tr -d ' ')" = "100000" ]; test $? "cat-sync reads an entire file and writes it to a pipe"
+[ "$(test/cat-async $FILE | test/wc-async)" = "100000" ]; test $? "cat-async reads an entire file and writes it to a pipe to wc-async "
+[ "$(test/cat-async $FILE | test/wc-sync)" = "100000" ]; test $? "cat-async reads an entire file and writes it to a pipe to wc-sync "
+[ "$(test/cat-sync $FILE | test/wc-async)" = "100000" ]; test $? "cat-sync reads an entire file and writes it to a pipe to wc-async "
+[ "$(test/cat-sync $FILE | test/wc-sync)" = "100000" ]; test $? "cat-sync reads an entire file and writes it to a pipe to wc-sync "
+[ "$(test/cat-async < $FILE | wc -c | tr -d ' ')" = "100000" ]; test $? "cat-async reads an entire file from stdin and writes it to a pipe"
+[ "$(test/cat-sync < $FILE | wc -c | tr -d ' ')" = "100000" ]; test $? "cat-sync reads an entire file from stdin and writes it to a pipe"
+[ "$(test/cat-async < $FILE | test/wc-async)" = "100000" ]; test $? "cat-async reads an entire file from stdin and writes it to a pipe to wc-async"
+[ "$(test/cat-async < $FILE | test/wc-sync)" = "100000" ]; test $? "cat-async reads an entire file from stdin and writes it to a pipe to wc-sync"
+[ "$(test/cat-sync < $FILE | test/wc-async)" = "100000" ]; test $? "cat-sync reads an entire file from stdin and writes it to a pipe to wc-async"
+[ "$(test/cat-sync < $FILE | test/wc-sync)" = "100000" ]; test $? "cat-sync reads an entire file from stdin and writes it to a pipe to wc-sync"
+[ "$(cat $FILE | test/cat-async | test/wc-async)" = "100000" ]; test $? "cat-async reads an entire file from a pipe and writes it to a pipe to wc-async"
+[ "$(cat $FILE | test/cat-async | test/wc-sync)" = "100000" ]; test $? "cat-async reads an entire file from a pipe and writes it to a pipe to wc-sync"
+[ "$(cat $FILE | test/cat-sync | test/wc-async)" = "100000" ]; test $? "cat-sync reads an entire file from a pipe and writes it to a pipe to wc-async"
+[ "$(cat $FILE | test/cat-sync | test/wc-sync)" = "100000" ]; test $? "cat-sync reads an entire file from a pipe and writes it to a pipe to wc-sync"
+[ "$(cat $FILE | test/cat-async | head -n 100 | test/wc-async)" = "1000" ]; test $? "cat-async reads an entire file from a pipe and writes it to a pipe to head to wc-async"
+[ "$(cat $FILE | test/cat-async | head -n 100 | test/wc-sync)" = "1000" ]; test $? "cat-async reads an entire file from a pipe and writes it to a pipe to head to wc-sync"
+[ "$(cat $FILE | test/cat-sync | head -n 100 | test/wc-async)" = "1000" ]; test $? "cat-sync reads an entire file from a pipe and writes it to a pipe to head to wc-async"
+[ "$(cat $FILE | test/cat-sync | head -n 100 | test/wc-sync)" = "1000" ]; test $? "cat-sync reads an entire file from a pipe and writes it to a pipe to head to wc-sync"
+[ "$(cat $FILE 2> /dev/null | head -n 100 | test/cat-async | test/wc-async)" = "1000" ]; test $? "cat-async reads the head of a file from a pipe and writes it to wc-async"
+[ "$(cat $FILE 2> /dev/null | head -n 100 | test/cat-async | test/wc-sync)" = "1000" ]; test $? "cat-async reads the head of a file from a pipe and writes it to wc-sync"
+[ "$(cat $FILE 2> /dev/null | head -n 100 | test/cat-sync | test/wc-async)" = "1000" ]; test $? "cat-sync reads the head of a file from a pipe and writes it to wc-async"
+[ "$(cat $FILE 2> /dev/null | head -n 100 | test/cat-sync | test/wc-sync)" = "1000" ]; test $? "cat-sync reads the head of a file from a pipe and writes it to wc-sync"
+[ "$(test/write-async test/write.out && cat test/write.out)" = "Hello, world!" ]; test $? "write-async writes an entire file"
+[ "$(test/write-sync test/write.out && cat test/write.out)" = "Hello, world!" ]; test $? "write-sync writes an entire file"
+
+rm -f -- $FILE test/write.out test/encoding-sync.out test/encoding-async.out
Index: node_modules/rw/test/utf8.txt
===================================================================
--- node_modules/rw/test/utf8.txt	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/utf8.txt	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,1 @@
+gréén
Index: node_modules/rw/test/wc-async
===================================================================
--- node_modules/rw/test/wc-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/wc-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,8 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.readFile(process.argv[2] || "-", function(error, contents) {
+  if (error) throw error;
+  console.log(contents.length);
+});
Index: node_modules/rw/test/wc-sync
===================================================================
--- node_modules/rw/test/wc-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/wc-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,5 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+console.log(rw.readFileSync(process.argv[2] || "-", "utf8").length);
Index: node_modules/rw/test/write-async
===================================================================
--- node_modules/rw/test/write-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/write-async	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.writeFile(process.argv[2] || "-", "Hello, world!", "utf8", function(error) {
+  if (error) throw error;
+});
Index: node_modules/rw/test/write-sync
===================================================================
--- node_modules/rw/test/write-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
+++ node_modules/rw/test/write-sync	(revision e4c61dd6cd86e06265bc2bd91adba84a0f04044a)
@@ -0,0 +1,5 @@
+#!/usr/bin/env node
+
+var rw = require("../").dash;
+
+rw.writeFileSync(process.argv[2] || "-", "Hello, world!", "utf8");
