stream-json
Advanced tools
Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "stream-json", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "stream-json is a SAX-inspired stream components with a minimal memory footprint to parse huge JSON files. Includes utilities to stream Django-like JSON database dumps.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/uhop/stream-json", |
@@ -41,11 +41,8 @@ # stream-json | ||
var makeSource = require("stream-json"); | ||
var source = makeSource(); | ||
var fs = require("fs"); | ||
var source = makeSource(); | ||
var objectCounter = 0; | ||
source.on("startObject", function(){ ++objectCounter; }); | ||
source.on("end", function(){ | ||
@@ -376,3 +373,3 @@ console.log("Found ", objectCounter, " objects."); | ||
* If `current` is an object, a primitive value will be added directly to it using a current value of `key`. | ||
* After use `key` is assigned `null` to prevent memory leaks. | ||
* After use `key` is assigned `null` to prevent memory leaks. | ||
* If `current` is an array, a primitive value will be added directly to it by `push()`. | ||
@@ -406,8 +403,5 @@ * `stack` — an array of parent objects. | ||
```js | ||
var makeSource = require("stream-json"); | ||
var StreamArray = require("stream-json/utils/StreamArray"); | ||
var stream = StreamArray.make(); | ||
var source = makeSource(options), | ||
stream = StreamArray.make(); | ||
// Example of use: | ||
@@ -435,2 +429,26 @@ | ||
### utils/StreamObject | ||
Similar to `StreamArray`, except that instead of breaking an array into its elements it breaks an object into key/value pairs. Each pair has two properties: `key` and `value`. | ||
Like `StreamArray`, `StreamObject` is both a constructor and has a static `make()` function for common use cases. | ||
```js | ||
var StreamObject = require("stream-json/utils/StreamObject"); | ||
var stream = StreamObject.make(); | ||
// Example of use: | ||
stream.output.on("data", function(object){ | ||
console.log(object.key, object.value); | ||
}); | ||
stream.output.on("end", function(){ | ||
console.log("done"); | ||
}); | ||
fs.createReadStream(fname).pipe(stream.input); | ||
``` | ||
See the `StreamArray` documentation for more information. | ||
### utils/StreamFilteredArray | ||
@@ -451,3 +469,2 @@ | ||
```js | ||
var makeSource = require("stream-json"); | ||
var StreamFilteredArray = require("stream-json/utils/StreamFilteredArray"); | ||
@@ -467,4 +484,3 @@ | ||
var source = makeSource(options), | ||
stream = StreamFilteredArray.make({objectFilter: f}); | ||
var stream = StreamFilteredArray.make({objectFilter: f}); | ||
@@ -519,3 +535,2 @@ // Example of use: | ||
```js | ||
var makeSource = require("stream-json"); | ||
var StreamArray = require("stream-json/utils/StreamArray"); | ||
@@ -535,4 +550,3 @@ var FilterObjects = require("stream-json/utils/FilterObjects"); | ||
var source = makeSource(options), | ||
stream = StreamArray.make(), | ||
var stream = StreamArray.make(), | ||
filter = new FilterObjects({itemFilter: f}); | ||
@@ -542,6 +556,6 @@ | ||
stream.output.on("data", function(object){ | ||
filter.on("data", function(object){ | ||
console.log(object.index, object.value); | ||
}); | ||
stream.output.on("end", function(){ | ||
filter.on("end", function(){ | ||
console.log("done"); | ||
@@ -569,3 +583,3 @@ }); | ||
The whole library is organized as set of small components, which can be combined to produce the most effective pipeline. All components are based on node.js [streams](http://nodejs.org/api/stream.html), and [events](http://nodejs.org/api/events.html). They implement all require standard APIs. It is easy to add your own components to solve your unique tasks. | ||
The whole library is organized as set of small components, which can be combined to produce the most effective pipeline. All components are based on node.js [streams](http://nodejs.org/api/stream.html), and [events](http://nodejs.org/api/events.html). They implement all required standard APIs. It is easy to add your own components to solve your unique tasks. | ||
@@ -624,2 +638,3 @@ The code of all components are compact and simple. Please take a look at their source code to see how things are implemented, so you can produce your own components in no time. | ||
- 0.4.1 *added `StreamObject` by [Sam Noedel](https://github.com/delta62)* | ||
- 0.4.0 *new high-performant Combo component, switched to the previous parser.* | ||
@@ -626,0 +641,0 @@ - 0.3.0 *new even faster parser, bug fixes.* |
@@ -22,4 +22,5 @@ "use strict"; | ||
require("./test_combo"); | ||
require("./test_object"); | ||
unit.run(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
207178
55
3668
649
239