js-platform/idbfs — pull request #6 by humphd (2013-11-08 20:42:40+00:00)
Title: Add fs.readFile, fs.writeFile with tests

This adds `fs.readFile` and `fs.writeFile` modeled after the node.js fs methods of the same name.

In order to get full utf8 support, I've used the spec TextEncoder and TextDecoder, see http://encoding.spec.whatwg.org/#interface-textencoder and http://encoding.spec.whatwg.org/#interface-textdecoder. These are built-into some browsers, and not others (FF has them, Chrome doesn't, and node.js doesn't). I've shimmed them in cases where they aren't available, see `lib/encoding.js` and `lib/encoding-indexes.js`.

I've never worked with `when.js` so let me know if I've done the promises stuff wrong.

I've written round-trip tests, with various different argument patterns. Let me know if you want other tests.

I've also added a `grunt check` task to run jshint. I've cleaned up most of the issues, but there are a few I left, since I wasn't sure your feeling about these particular errors. I'll let you decide and fix/leave them:

```
Linting src/fs.js ...ERROR
[L125:C7] W082: Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.
function check_root_directory_node(error, rootDirectoryNode) {
Linting src/fs.js ...ERROR
[L139:C7] W082: Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.
function read_parent_directory_data(error, parentDirectoryNode) {
Linting src/fs.js ...ERROR
[L142:C58] W018: Confusing use of '!'.
} else if(!_(parentDirectoryNode).has('data') || !parentDirectoryNode.type == MODE_DIRECTORY) {
Linting src/fs.js ...ERROR
[L151:C7] W082: Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.
function get_node_id_from_parent_directory_data(error, parentDirectoryData) {
Linting src/fs.js ...ERROR
[L1372:C11] W082: Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.
function update_descriptor_position(error, stats) {
```