Socket
Socket
Sign inDemoInstall

geojson-stream

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0 to 0.0.1

.travis.yml

13

package.json
{
"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();
}
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc