Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

package.json deps, more comprehensive (and now failing) tests

  • Loading branch information...
commit 041153e5e31afb161b43643e24662f82f268ab02 1 parent d3b0e13
@DTrejo authored
Showing with 35 additions and 3 deletions.
  1. +7 −3 package.json
  2. +13 −0 readme.md
  3. +15 −0 test/test.js
View
10 package.json
@@ -15,7 +15,11 @@
"scripts": {
"test": "nodeunit test/test.js"
},
- "engines": {
- "node": "*"
- }
+ "dependencies": {
+ "traverse": ">=0.2.6"
+ },
+ "devDependencies" : {
+ "nodeunit": ">=0.5.1"
+ },
+ "engines": { "node": ">=0.4.1" }
}
View
13 readme.md
@@ -2,6 +2,8 @@
A streaming version of `JSON.stringify`.
+ npm install
+
## Methods
### `streamify(object, function)`
@@ -37,3 +39,14 @@ Most of this was written by [James Halliday](http://substack.net), with a few sm
### TODOs
- allow a stream to be passed into `streamify(object, stream)`?
+- escapes strings correctly
+- package.json has deps
+- throw binary data at it and make sure JSON.parse() doesn't error when you read it back
+ try using this string:
+
+ var s = ''; for (var i = 0; i < 255; i++) { s += String.fromCharCode(i) }
+
+ and maybe this to fix it, along with something else.
+
+ .replace(/\\/gi, '\\\\')
+- fix the tests which fail on the above few todos
View
15 test/test.js
@@ -48,4 +48,19 @@ module.exports = testCase({
assert.done();
});
}
+ , test_encode_object: function(assert) {
+ var s = '';
+ for (var i = 0; i < 255; i++) { s += String.fromCharCode(i); }
+ var obj = { "a tricky string": s };
+ var str = ''
+ streamify(obj, function(data) { str += data; });
+
+ assert.equals(JSON.stringify(obj), str
+ , 'Properly escapes strings');
+
+ assert.equals(JSON.parse(JSON.stringify(obj)), JSON.parse(str)
+ , 'Properly parses strings');
+ assert.done();
+ }
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.