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

geojson-numeric

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-numeric - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

15

index.js

@@ -1,2 +0,2 @@

function numeric( geojson ) {
function numeric( geojson, recursive ) {

@@ -15,7 +15,12 @@ function isNumeric(n) {

function toNumeric(obj) {
for (var key in obj) {
if (isNumeric(obj[key]))
obj[key] = parseFloat(obj[key]);
else if (recursive && typeof obj[key] === "object")
toNumeric(obj[key]);
}
}
features.forEach(function mapFeature(f) {
for (var key in f.properties) {
if (isNumeric(f.properties[key]))
f.properties[key] = parseFloat(f.properties[key]);
}
toNumeric(f.properties);
});

@@ -22,0 +27,0 @@

{
"name": "geojson-numeric",
"version": "0.1.1",
"version": "0.2.0",
"description": "Makes properties of geojson features numeric.",

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

@@ -63,1 +63,31 @@ var numerify = require("../");

test('recursive', function (t) {
var geojson = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0,0]
},
"properties": {
"tags": {
"asd": "fasd",
"num": "123",
},
"array": [
"str",
"1.23"
]
}
}]
};
var result = numerify(geojson,true);
t.equal(geojson.features[0].properties.tags.asd, "fasd");
t.equal(geojson.features[0].properties.tags.num, 123);
t.equal(geojson.features[0].properties.array.length, 2);
t.equal(geojson.features[0].properties.array[0], "str");
t.equal(geojson.features[0].properties.array[1], 1.23);
t.end();
});

Sorry, the diff of this file is not supported yet

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