Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geojsonhint

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojsonhint - npm Package Compare versions

Comparing version 0.1.2 to 0.1.4

test/data/bad/badfeature.geojson

43

geojsonhint.js

@@ -7,3 +7,3 @@ (function(e){if("function"==typeof bootstrap)bootstrap("geojsonhint",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeGeojsonhint=e}else"undefined"!=typeof window?window.geojsonhint=e():global.geojsonhint=e()})(function(){var define,ses,bootstrap,module,exports;

var errors = [];
var errors = [], gj;

@@ -26,2 +26,6 @@ function root(_) {

function everyIs(_, type) {
return _.every(function(x) { return typeof x === 'number'; });
}
function requiredProperty(_, name, type) {

@@ -52,2 +56,3 @@ if (typeof _[name] == 'undefined') {

// http://geojson.org/geojson-spec.html#feature-collection-objects
function FeatureCollection(_) {

@@ -76,5 +81,3 @@ crs(_);

}
if (_.some(function(p) {
return (typeof p !== 'number');
})) {
if (!everyIs(_, 'number')) {
return errors.push({

@@ -111,4 +114,12 @@ message: 'each element in a position must be a number',

if (typeof _.crs === 'object') {
requiredProperty(_.crs, 'type', 'string');
requiredProperty(_.crs, 'properties', 'object');
var strErr = requiredProperty(_.crs, 'type', 'string'),
propErr = requiredProperty(_.crs, 'properties', 'object');
if (!strErr && !propErr) {
// http://geojson.org/geojson-spec.html#named-crs
if (_.crs.type == 'name') {
requiredProperty(_.crs.properties, 'name', 'string');
} else if (_.crs.type == 'link') {
requiredProperty(_.crs.properties, 'href', 'string');
}
}
}

@@ -120,5 +131,3 @@ }

if (Array.isArray(_.bbox)) {
if (_.bbox.some(function(p) {
return (typeof p !== 'number');
})) {
if (!everyIs(_.bbox, 'number')) {
return errors.push({

@@ -146,2 +155,3 @@ message: 'each element in a bbox property must be a number',

// http://geojson.org/geojson-spec.html#polygon
function Polygon(_) {

@@ -155,2 +165,3 @@ crs(_);

// http://geojson.org/geojson-spec.html#multipolygon
function MultiPolygon(_) {

@@ -164,2 +175,3 @@ crs(_);

// http://geojson.org/geojson-spec.html#linestring
function LineString(_) {

@@ -173,2 +185,3 @@ crs(_);

// http://geojson.org/geojson-spec.html#multilinestring
function MultiLineString(_) {

@@ -209,4 +222,5 @@ crs(_);

requiredProperty(_, 'properties', 'object');
requiredProperty(_, 'geometry', 'object');
root(_.geometry);
if (!requiredProperty(_, 'geometry', 'object')) {
root(_.geometry);
}
}

@@ -226,2 +240,9 @@

if (typeof str !== 'string') {
return [{
message: 'Expected string input',
line: 0
}];
}
try {

@@ -228,0 +249,0 @@ gj = jsonlint.parse(str);

@@ -24,3 +24,3 @@ var jsonlint = require('jsonlint-lines');

function everyIs(_, type) {
return _.every(function(x) { return typeof x === 'number'; });
return _.every(function(x) { return typeof x === type; });
}

@@ -58,2 +58,8 @@

if (!requiredProperty(_, 'features', 'array')) {
if (!_.features.every(function(_) { return _; })) {
return errors.push({
message: 'Every feature must be an object',
line: _.__line__
});
}
_.features.forEach(Feature);

@@ -212,4 +218,5 @@ }

requiredProperty(_, 'properties', 'object');
requiredProperty(_, 'geometry', 'object');
root(_.geometry);
if (!requiredProperty(_, 'geometry', 'object')) {
root(_.geometry);
}
}

@@ -229,2 +236,9 @@

if (typeof str !== 'string') {
return [{
message: 'Expected string input',
line: 0
}];
}
try {

@@ -231,0 +245,0 @@ gj = jsonlint.parse(str);

{
"name": "geojsonhint",
"version": "0.1.2",
"version": "0.1.4",
"description": "validate and sanity-check geojson files",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,2 +23,14 @@ var expect = require('expect.js'),

});
it('requires an input', function() {
expect(geojsonhint.hint(undefined)).to.eql([{
message: 'Expected string input',
line: 0
}]);
});
it('requires a root type', function() {
expect(geojsonhint.hint('{}')).to.eql([{
message: 'The type property is required and was not found',
line: 1
}]);
});
describe('validates incorrect files', function() {

@@ -25,0 +37,0 @@ glob.sync('test/data/bad/*.geojson').forEach(function(f) {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc