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

@turf/along

Package Overview
Dependencies
Maintainers
7
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/along - npm Package Compare versions

Comparing version 6.5.0 to 7.0.0-alpha.0

17

dist/es/index.js

@@ -24,9 +24,8 @@ import bearing from "@turf/bearing";

*/
export default function along(line, distance, options) {
if (options === void 0) { options = {}; }
export default function along(line, distance, options = {}) {
// Get Coords
var geom = getGeom(line);
var coords = geom.coordinates;
var travelled = 0;
for (var i = 0; i < coords.length; i++) {
const geom = getGeom(line);
const coords = geom.coordinates;
let travelled = 0;
for (let i = 0; i < coords.length; i++) {
if (distance >= travelled && i === coords.length - 1) {

@@ -36,3 +35,3 @@ break;

else if (travelled >= distance) {
var overshot = distance - travelled;
const overshot = distance - travelled;
if (!overshot) {

@@ -42,4 +41,4 @@ return point(coords[i]);

else {
var direction = bearing(coords[i], coords[i - 1]) - 180;
var interpolated = destination(coords[i], overshot, direction, options);
const direction = bearing(coords[i], coords[i - 1]) - 180;
const interpolated = destination(coords[i], overshot, direction, options);
return interpolated;

@@ -46,0 +45,0 @@ }

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

import { Feature, LineString, Point, Units } from "@turf/helpers";
import { Feature, LineString, Point } from "geojson";
import { Units } from "@turf/helpers";
/**

@@ -3,0 +4,0 @@ * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var bearing_1 = __importDefault(require("@turf/bearing"));
var destination_1 = __importDefault(require("@turf/destination"));
var distance_1 = __importDefault(require("@turf/distance"));
var helpers_1 = require("@turf/helpers");
var invariant_1 = require("@turf/invariant");
const tslib_1 = require("tslib");
const bearing_1 = tslib_1.__importDefault(require("@turf/bearing"));
const destination_1 = tslib_1.__importDefault(require("@turf/destination"));
const distance_1 = tslib_1.__importDefault(require("@turf/distance"));
const helpers_1 = require("@turf/helpers");
const invariant_1 = require("@turf/invariant");
/**

@@ -29,9 +27,8 @@ * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.

*/
function along(line, distance, options) {
if (options === void 0) { options = {}; }
function along(line, distance, options = {}) {
// Get Coords
var geom = invariant_1.getGeom(line);
var coords = geom.coordinates;
var travelled = 0;
for (var i = 0; i < coords.length; i++) {
const geom = invariant_1.getGeom(line);
const coords = geom.coordinates;
let travelled = 0;
for (let i = 0; i < coords.length; i++) {
if (distance >= travelled && i === coords.length - 1) {

@@ -41,3 +38,3 @@ break;

else if (travelled >= distance) {
var overshot = distance - travelled;
const overshot = distance - travelled;
if (!overshot) {

@@ -47,4 +44,4 @@ return helpers_1.point(coords[i]);

else {
var direction = bearing_1.default(coords[i], coords[i - 1]) - 180;
var interpolated = destination_1.default(coords[i], overshot, direction, options);
const direction = bearing_1.default(coords[i], coords[i - 1]) - 180;
const interpolated = destination_1.default(coords[i], overshot, direction, options);
return interpolated;

@@ -51,0 +48,0 @@ }

{
"name": "@turf/along",
"version": "6.5.0",
"version": "7.0.0-alpha.0",
"description": "turf along module",

@@ -60,9 +60,10 @@ "author": "Turf Authors",

"dependencies": {
"@turf/bearing": "^6.5.0",
"@turf/destination": "^6.5.0",
"@turf/distance": "^6.5.0",
"@turf/helpers": "^6.5.0",
"@turf/invariant": "^6.5.0"
"@turf/bearing": "^7.0.0-alpha.0",
"@turf/destination": "^7.0.0-alpha.0",
"@turf/distance": "^7.0.0-alpha.0",
"@turf/helpers": "^7.0.0-alpha.0",
"@turf/invariant": "^7.0.0-alpha.0",
"tslib": "^2.3.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
}

@@ -9,11 +9,12 @@ # @turf/along

**Parameters**
### Parameters
- `line` **[Feature][3]&lt;[LineString][4]>** input line
- `distance` **[number][5]** distance along the line
- `options` **[Object][6]?** Optional parameters
- `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
* `line` **[Feature][3]<[LineString][4]>** input line
* `distance` **[number][5]** distance along the line
* `options` **[Object][6]?** Optional parameters
**Examples**
* `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
### Examples
```javascript

@@ -29,3 +30,3 @@ var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);

Returns **[Feature][3]&lt;[Point][8]>** Point `distance` `units` along the line
Returns **[Feature][3]<[Point][8]>** Point `distance` `units` along the line

@@ -32,0 +33,0 @@ [1]: https://tools.ietf.org/html/rfc7946#section-3.1.4

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