geojson-stream
Advanced tools
Comparing version 0.0.0 to 0.0.1
{ | ||
"name": "geojson-stream", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "stream features into and out of geojson", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha -R spec" | ||
"test": "tap test/*.js" | ||
}, | ||
@@ -26,10 +26,9 @@ "repository": { | ||
"dependencies": { | ||
"JSONStream": "~0.7.1", | ||
"through": "~2.3.4" | ||
"JSONStream": "^1.0.0", | ||
"through": "^2.3.4" | ||
}, | ||
"devDependencies": { | ||
"expect.js": "~0.2.0", | ||
"mocha": "~1.13.0", | ||
"concat-stream": "~1.0.1" | ||
"concat-stream": "~1.0.1", | ||
"tap": "~0.4.9" | ||
} | ||
} |
# geojson-stream | ||
[![build status](https://secure.travis-ci.org/mapbox/geojson-stream.png)](http://travis-ci.org/mapbox/geojson-stream) | ||
Stream features into and out of [GeoJSON](http://geojson.org/) objects | ||
and Feature Collections. Little more than [JSONStream](https://github.com/dominictarr/JSONStream) | ||
with pre-filled settings. | ||
## usage | ||
npm install --save geojson-stream | ||
## api | ||
### `geojsonStream.stringify()` | ||
Returns a transform stream that accepts GeoJSON Feature objects and emits | ||
a stringified FeatureCollection | ||
### `geojsonStream.parse()` | ||
Returns a transform stream that accepts a GeoJSON FeatureCollection as a stream | ||
and emits Feature objects |
@@ -1,2 +0,2 @@ | ||
var expect = require('expect.js'), | ||
var test = require('tap').test, | ||
fs = require('fs'), | ||
@@ -6,39 +6,33 @@ concat = require('concat-stream'), | ||
describe('geojson-stream', function() { | ||
describe('read', function() { | ||
it('accepts a stream', function(done) { | ||
var s = geojsonStream.parse(); | ||
fs.createReadStream('test/data/featurecollection.geojson') | ||
.pipe(s).pipe(concat(function(d) { | ||
expect(d).to.eql(JSON.parse(fs.readFileSync('test/data/featurecollection.result'))); | ||
done(); | ||
})); | ||
}); | ||
}); | ||
test('geojson-stream: read', function(t) { | ||
var s = geojsonStream.parse(); | ||
fs.createReadStream(__dirname + '/data/featurecollection.geojson') | ||
.pipe(s).pipe(concat(function(d) { | ||
t.deepEqual(d, JSON.parse(fs.readFileSync(__dirname + '/data/featurecollection.result'))); | ||
t.end(); | ||
})); | ||
}); | ||
describe('write', function() { | ||
it('writes a geojson document', function(done) { | ||
var pt = { | ||
type: 'Feature', | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [0, 0] | ||
}, | ||
properties: {} | ||
}; | ||
test('geojson-stream: write', function(t) { | ||
var pt = { | ||
type: 'Feature', | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [0, 0] | ||
}, | ||
properties: {} | ||
}; | ||
var s = geojsonStream.stringify(); | ||
s.pipe(concat(finish)); | ||
s.write(pt); | ||
s.end(); | ||
var s = geojsonStream.stringify(); | ||
s.pipe(concat(finish)); | ||
s.write(pt); | ||
s.end(); | ||
function finish(str) { | ||
expect(JSON.parse(str)).to.eql({ | ||
type: 'FeatureCollection', | ||
features: [pt] | ||
}); | ||
done(); | ||
} | ||
function finish(str) { | ||
t.deepEqual(JSON.parse(str), { | ||
type: 'FeatureCollection', | ||
features: [pt] | ||
}); | ||
}); | ||
t.end(); | ||
} | ||
}); |
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
4153
2
7
24
44
+ AddedJSONStream@1.3.5(transitive)
+ Addedjsonparse@1.3.1(transitive)
- RemovedJSONStream@0.7.4(transitive)
- Removedjsonparse@0.0.5(transitive)
UpdatedJSONStream@^1.0.0
Updatedthrough@^2.3.4