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

@turf/truncate

Package Overview
Dependencies
Maintainers
4
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/truncate - npm Package Compare versions

Comparing version 5.1.5 to 6.0.0

index.ts

36

index.js

@@ -1,4 +0,4 @@

import { coordEach } from '@turf/meta';
import { isObject } from '@turf/helpers';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var meta_1 = require("@turf/meta");
/**

@@ -28,25 +28,23 @@ * Takes a GeoJSON Feature or FeatureCollection and truncates the precision of the geometry.

function truncate(geojson, options) {
if (options === void 0) { options = {}; }
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var precision = options.precision;
var coordinates = options.coordinates;
var mutate = options.mutate;
// default params
precision = (precision === undefined || precision === null || isNaN(precision)) ? 6 : precision;
coordinates = (coordinates === undefined || coordinates === null || isNaN(coordinates)) ? 3 : coordinates;
// validation
if (!geojson) throw new Error('<geojson> is required');
if (typeof precision !== 'number') throw new Error('<precision> must be a number');
if (typeof coordinates !== 'number') throw new Error('<coordinates> must be a number');
if (!geojson)
throw new Error('<geojson> is required');
if (typeof precision !== 'number')
throw new Error('<precision> must be a number');
if (typeof coordinates !== 'number')
throw new Error('<coordinates> must be a number');
// prevent input mutation
if (mutate === false || mutate === undefined) geojson = JSON.parse(JSON.stringify(geojson));
if (mutate === false || mutate === undefined)
geojson = JSON.parse(JSON.stringify(geojson));
var factor = Math.pow(10, precision);
// Truncate Coordinates
coordEach(geojson, function (coords) {
meta_1.coordEach(geojson, function (coords) {
truncateCoords(coords, factor, coordinates);

@@ -56,3 +54,2 @@ });

}
/**

@@ -69,4 +66,4 @@ * Truncate Coordinates - Mutates coordinates in place

// Remove extra coordinates (usually elevation coordinates and more)
if (coords.length > coordinates) coords.splice(coordinates, coords.length);
if (coords.length > coordinates)
coords.splice(coordinates, coords.length);
// Truncate coordinate decimals

@@ -78,3 +75,2 @@ for (var i = 0; i < coords.length; i++) {

}
export default truncate;
exports.default = truncate;

@@ -0,19 +1,15 @@

{
"name": "@turf/truncate",
"version": "5.1.5",
"version": "6.0.0",
"description": "turf truncate module",
"main": "main.js",
"module": "main.es.js",
"types": "index.d.ts",
"main": "index",
"files": [
"index.js",
"index.d.ts",
"main.js",
"main.es.js"
"index.ts"
],
"scripts": {
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js",
"bench": "node -r @std/esm bench.js",
"pretest": "tsc",
"test": "node test.js",
"bench": "node bench.js",
"docs": "node ../../scripts/generate-readmes"

@@ -41,6 +37,5 @@ },

"devDependencies": {
"@std/esm": "*",
"benchmark": "*",
"load-json-file": "*",
"rollup": "*",
"typescript": "*",
"tape": "*",

@@ -50,9 +45,5 @@ "write-json-file": "*"

"dependencies": {
"@turf/helpers": "^5.1.5",
"@turf/meta": "^5.1.5"
},
"@std/esm": {
"esm": "js",
"cjs": true
"@turf/helpers": "6.x",
"@turf/meta": "6.x"
}
}
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