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

@turf/helpers

Package Overview
Dependencies
Maintainers
4
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/helpers - npm Package Compare versions

Comparing version 4.7.3 to 5.0.0-alpha

index.es5.js

87

index.d.ts
/// <reference types='geojson' />
export type Id = string|number
export type Points = GeoJSON.FeatureCollection<GeoJSON.Point>;
export type Point = GeoJSON.Feature<GeoJSON.Point>;
export type MultiPoints = GeoJSON.FeatureCollection<GeoJSON.MultiPoint>;
export type MultiPoint = GeoJSON.Feature<GeoJSON.MultiPoint>;
export type LineStrings = GeoJSON.FeatureCollection<GeoJSON.LineString>;
export type LineString = GeoJSON.Feature<GeoJSON.LineString>;
export type MultiLineStrings = GeoJSON.FeatureCollection<GeoJSON.MultiLineString>;
export type MultiLineString = GeoJSON.Feature<GeoJSON.MultiLineString>;
export type Polygons = GeoJSON.FeatureCollection<GeoJSON.Polygon>;
export type Polygon = GeoJSON.Feature<GeoJSON.Polygon>;
export type MultiPolygons = GeoJSON.FeatureCollection<GeoJSON.MultiPolygon>;
export type MultiPolygon = GeoJSON.Feature<GeoJSON.MultiPolygon>;
// GeoJSON Foreign Members
export type Id = string | number;
export type Properties = {[key: string]: any};
export type BBox = [number, number, number, number];
// TurfJS String Types
export type Units = 'miles' | 'nauticalmiles' | 'degrees' | 'radians' | 'inches' | 'yards' | 'meters' | 'metres' | 'kilometers' | 'kilometres';
export type Geometry = 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon';
export type Grid = 'point' | 'square' | 'hex' | 'triangle';
// GeoJSON Geometry Types
export type Position = GeoJSON.Position;
export type LineStringFeatures = LineString | LineStrings | MultiLineString | MultiLineStrings | GeoJSON.LineString | GeoJSON.MultiLineString
export type PolygonFeatures = Polygon | Polygons | MultiPolygon | MultiPolygons | GeoJSON.Polygon | GeoJSON.MultiPolygon
export type Features<Geom extends GeometryObject> = GeoJSON.FeatureCollection<Geom>;
export type Feature<Geom extends GeometryObject> = GeoJSON.Feature<Geom>;
export type Units = 'miles' | 'nauticalmiles' | 'degrees' | 'radians' | 'inches' | 'yards' | 'meters' | 'metres' | 'kilometers' | 'kilometres';
export type BBox = [number, number, number, number];
export type Point = GeoJSON.Point;
export type MultiPoint = GeoJSON.MultiPoint;
export type MultiLineString = GeoJSON.MultiLineString;
export type LineString = GeoJSON.LineString;
export type Polygon = GeoJSON.Polygon;
export type MultiPolygon = GeoJSON.MultiPolygon;
export type GeometryObject = GeoJSON.GeometryObject;
export type GeometryCollection = GeoJSON.GeometryCollection;
export type Geoms = GeoJSON.Point | GeoJSON.LineString | GeoJSON.Polygon | GeoJSON.MultiPoint | GeoJSON.MultiLineString | GeoJSON.MultiPolygon;
export type GeometryTypes = 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon';
export interface FeatureGeometryCollection extends GeoJSON.Feature<any> {
geometry: GeometryCollection
// GeoJSON Feature Objects
export type FeatureCollection<T extends GeometryObject> = GeoJSON.FeatureCollection<T>;
export type Feature<T extends GeometryObject> = GeoJSON.Feature<T>;
export interface FeatureGeometryCollection extends Feature<any> {
geometry: GeometryCollection;
}
export interface FeatureCollection {
<Geom extends Geoms>(features: Feature<Geom>[], bbox?: BBox, id?: Id): Features<Geom>;
(features: Feature<any>[], bbox?: BBox, id?: Id): Features<any>;
}
export interface Properties {
[key: string]: any
}
/**
* http://turfjs.org/docs/#feature
*/
export function feature<Geom extends GeometryObject>(geometry: Geom, properties?: Properties, bbox?: BBox, id?: Id): Feature<Geom>;
export function feature<T extends GeometryObject>(geometry: T, properties?: Properties, bbox?: BBox, id?: Id): Feature<T>;
/**
* http://turfjs.org/docs/#featurecollection
*/
export function featureCollection<T extends GeometryObject>(features: Feature<T>[], bbox?: BBox, id?: Id): FeatureCollection<T>;
export function featureCollection(features: Feature<any>[], bbox?: BBox, id?: Id): FeatureCollection<any>;
/**
* http://turfjs.org/docs/#geometry
*/
export function geometry(type: GeometryTypes, coordinates: any[], bbox?: BBox): GeometryObject;
export function geometry(type: 'Point', coordinates: Position, bbox?: BBox): Point;
export function geometry(type: 'LineString', coordinates: Position[], bbox?: BBox): LineString;
export function geometry(type: 'Polygon', coordinates: Position[][], bbox?: BBox): Polygon;
export function geometry(type: 'MultiPoint', coordinates: Position[], bbox?: BBox): MultiPoint;
export function geometry(type: 'MultiLineString', coordinates: Position[][], bbox?: BBox): MultiLineString;
export function geometry(type: 'MultiPolygon', coordinates: Position[][][], bbox?: BBox): MultiPolygon;
export function geometry(type: Geometry | string, coordinates: any[], bbox?: BBox): GeometryObject;

@@ -54,3 +56,3 @@ /**

*/
export function point(coordinates: Position, properties?: Properties, bbox?: BBox, id?: Id): Point;
export function point(coordinates: Position, properties?: Properties, bbox?: BBox, id?: Id): Feature<Point>;

@@ -60,3 +62,3 @@ /**

*/
export function polygon(coordinates: Position[][], properties?: Properties, bbox?: BBox, id?: Id): Polygon;
export function polygon(coordinates: Position[][], properties?: Properties, bbox?: BBox, id?: Id): Feature<Polygon>;

@@ -66,13 +68,8 @@ /**

*/
export function lineString(coordinates: Position[], properties?: Properties, bbox?: BBox, id?: Id): LineString;
export function lineString(coordinates: Position[], properties?: Properties, bbox?: BBox, id?: Id): Feature<LineString>;
/**
* http://turfjs.org/docs/#featurecollection
*/
export const featureCollection: FeatureCollection;
/**
* http://turfjs.org/docs/#multilinestring
*/
export function multiLineString(coordinates: Position[][], properties?: Properties, bbox?: BBox, id?: Id): MultiLineString;
export function multiLineString(coordinates: Position[][], properties?: Properties, bbox?: BBox, id?: Id): Feature<MultiLineString>;

@@ -82,3 +79,3 @@ /**

*/
export function multiPoint(coordinates: Position[], properties?: Properties, bbox?: BBox, id?: Id): MultiPoint;
export function multiPoint(coordinates: Position[], properties?: Properties, bbox?: BBox, id?: Id): Feature<MultiPoint>;

@@ -88,3 +85,3 @@ /**

*/
export function multiPolygon(coordinates: Position[][][], properties?: Properties, bbox?: BBox, id?: Id): MultiPolygon;
export function multiPolygon(coordinates: Position[][][], properties?: Properties, bbox?: BBox, id?: Id): Feature<MultiPolygon>;

@@ -91,0 +88,0 @@ /**

@@ -20,3 +20,3 @@ /**

*/
function feature(geometry, properties, bbox, id) {
export function feature(geometry, properties, bbox, id) {
if (geometry === undefined) throw new Error('geometry is required');

@@ -52,3 +52,3 @@ if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');

*/
function geometry(type, coordinates, bbox) {
export function geometry(type, coordinates, bbox) {
// Validation

@@ -88,3 +88,3 @@ if (!type) throw new Error('type is required');

*/
function point(coordinates, properties, bbox, id) {
export function point(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');

@@ -123,3 +123,3 @@ if (coordinates.length === undefined) throw new Error('Coordinates must be an array');

*/
function polygon(coordinates, properties, bbox, id) {
export function polygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');

@@ -176,3 +176,3 @@

*/
function lineString(coordinates, properties, bbox, id) {
export function lineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');

@@ -208,3 +208,3 @@ if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');

*/
function featureCollection(features, bbox, id) {
export function featureCollection(features, bbox, id) {
if (!features) throw new Error('No features passed');

@@ -238,3 +238,3 @@ if (!Array.isArray(features)) throw new Error('features must be an Array');

*/
function multiLineString(coordinates, properties, bbox, id) {
export function multiLineString(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');

@@ -264,3 +264,3 @@

*/
function multiPoint(coordinates, properties, bbox, id) {
export function multiPoint(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');

@@ -291,3 +291,3 @@

*/
function multiPolygon(coordinates, properties, bbox, id) {
export function multiPolygon(coordinates, properties, bbox, id) {
if (!coordinates) throw new Error('No coordinates passed');

@@ -324,3 +324,3 @@

*/
function geometryCollection(geometries, properties, bbox, id) {
export function geometryCollection(geometries, properties, bbox, id) {
if (!geometries) throw new Error('geometries is required');

@@ -378,3 +378,3 @@ if (!Array.isArray(geometries)) throw new Error('geometries must be an Array');

*/
function round(num, precision) {
export function round(num, precision) {
if (num === undefined || num === null || isNaN(num)) throw new Error('num is required');

@@ -395,3 +395,3 @@ if (precision && !(precision >= 0)) throw new Error('precision must be a positive number');

*/
function radiansToDistance(radians, units) {
export function radiansToDistance(radians, units) {
if (radians === undefined || radians === null) throw new Error('radians is required');

@@ -413,3 +413,3 @@

*/
function distanceToRadians(distance, units) {
export function distanceToRadians(distance, units) {
if (distance === undefined || distance === null) throw new Error('distance is required');

@@ -431,3 +431,3 @@

*/
function distanceToDegrees(distance, units) {
export function distanceToDegrees(distance, units) {
return radians2degrees(distanceToRadians(distance, units));

@@ -444,3 +444,3 @@ }

*/
function bearingToAngle(bearing) {
export function bearingToAngle(bearing) {
if (bearing === null || bearing === undefined) throw new Error('bearing is required');

@@ -460,3 +460,3 @@

*/
function radians2degrees(radians) {
export function radians2degrees(radians) {
if (radians === null || radians === undefined) throw new Error('radians is required');

@@ -475,3 +475,3 @@

*/
function degrees2radians(degrees) {
export function degrees2radians(degrees) {
if (degrees === null || degrees === undefined) throw new Error('degrees is required');

@@ -493,3 +493,3 @@

*/
function convertDistance(distance, originalUnit, finalUnit) {
export function convertDistance(distance, originalUnit, finalUnit) {
if (distance === null || distance === undefined) throw new Error('distance is required');

@@ -510,3 +510,3 @@ if (!(distance >= 0)) throw new Error('distance must be a positive number');

*/
function convertArea(area, originalUnit, finalUnit) {
export function convertArea(area, originalUnit, finalUnit) {
if (area === null || area === undefined) throw new Error('area is required');

@@ -535,27 +535,4 @@ if (!(area >= 0)) throw new Error('area must be a positive number');

*/
function isNumber(num) {
export function isNumber(num) {
return !isNaN(num) && num !== null && !Array.isArray(num);
}
module.exports = {
feature: feature,
geometry: geometry,
featureCollection: featureCollection,
geometryCollection: geometryCollection,
point: point,
multiPoint: multiPoint,
lineString: lineString,
multiLineString: multiLineString,
polygon: polygon,
multiPolygon: multiPolygon,
radiansToDistance: radiansToDistance,
distanceToRadians: distanceToRadians,
distanceToDegrees: distanceToDegrees,
radians2degrees: radians2degrees,
degrees2radians: degrees2radians,
bearingToAngle: bearingToAngle,
convertDistance: convertDistance,
convertArea: convertArea,
round: round,
isNumber: isNumber
};
{
"name": "@turf/helpers",
"version": "4.7.3",
"version": "5.0.0-alpha",
"description": "turf helpers module",
"main": "index.js",
"main": "index.es5.js",
"module": "index.js",
"jsnext:main": "index.js",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"index.es5.js"
],
"scripts": {
"test": "node test.js",
"pretest": "rollup -c ../../rollup.config.js",
"test": "node test.es5.js",
"bench": "node bench.js"

@@ -38,5 +42,7 @@ },

"devDependencies": {
"benchmark": "2.1.4",
"tape": "4.8.0"
}
"benchmark": "*",
"rollup": "*",
"tape": "*"
},
"dependencies": {}
}
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