Socket
Socket
Sign inDemoInstall

leaflet-polylinedecorator

Package Overview
Dependencies
1
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 1.4.1

2

bower.json
{
"name": "leaflet-polylinedecorator",
"main": "leaflet.polylineDecorator.js",
"version": "1.4.0",
"version": "1.4.1",
"authors": [

@@ -6,0 +6,0 @@ "Benjamin Becquet"

@@ -51,26 +51,27 @@ (function (global, factory) {

var pointsEqual = function pointsEqual(a, b) {
return a.x === b.x && a.y === b.y;
};
function pointsToSegments(pts) {
var segments = [];
var a = void 0,
b = void 0,
distA = 0,
distAB = void 0;
for (var i = 1, l = pts.length; i < l; i++) {
a = pts[i - 1];
b = pts[i];
distAB = pointDistance(a, b);
segments.push({
a: a,
b: b,
distA: distA, // distances from the start of the polyline
distB: distA + distAB,
heading: computeSegmentHeading(a, b)
});
distA += distAB;
}
return segments;
return pts.reduce(function (segments, b, idx, points) {
// this test skips same adjacent points
if (idx > 0 && !pointsEqual(b, points[idx - 1])) {
var a = points[idx - 1];
var distA = segments.length > 0 ? segments[segments.length - 1].distB : 0;
var distAB = pointDistance(a, b);
segments.push({
a: a,
b: b,
distA: distA,
distB: distA + distAB,
heading: computeSegmentHeading(a, b)
});
}
return segments;
}, []);
}
function projectPatternOnPointPath(pts, pattern) {
// 1. split the path as segment infos
// 1. split the path into segment infos
var segments = pointsToSegments(pts);

@@ -83,5 +84,2 @@ var nbSegments = segments.length;

var totalPathLength = segments[nbSegments - 1].distB;
if (totalPathLength === 0) {
return [];
}

@@ -88,0 +86,0 @@ var offset = asRatioToPathLength(pattern.offset, totalPathLength);

{
"name": "leaflet-polylinedecorator",
"version": "1.4.0",
"version": "1.4.1",
"repository": "bbecquet/Leaflet.PolylineDecorator",

@@ -5,0 +5,0 @@ "main": "./dist/leaflet.polylineDecorator.js",

@@ -39,23 +39,25 @@

const pointsEqual = (a, b) => a.x === b.x && a.y === b.y;
function pointsToSegments(pts) {
const segments = [];
let a, b, distA = 0, distAB;
for (let i = 1, l = pts.length; i < l; i++) {
a = pts[i - 1];
b = pts[i];
distAB = pointDistance(a, b);
segments.push({
a,
b,
distA, // distances from the start of the polyline
distB: distA + distAB,
heading: computeSegmentHeading(a, b),
});
distA += distAB;
}
return segments;
return pts.reduce((segments, b, idx, points) => {
// this test skips same adjacent points
if (idx > 0 && !pointsEqual(b, points[idx - 1])) {
const a = points[idx - 1];
const distA = segments.length > 0 ? segments[segments.length - 1].distB : 0;
const distAB = pointDistance(a, b);
segments.push({
a,
b,
distA,
distB: distA + distAB,
heading: computeSegmentHeading(a, b),
});
}
return segments;
}, []);
}
function projectPatternOnPointPath(pts, pattern) {
// 1. split the path as segment infos
// 1. split the path into segment infos
const segments = pointsToSegments(pts);

@@ -66,3 +68,2 @@ const nbSegments = segments.length;

const totalPathLength = segments[nbSegments - 1].distB;
if (totalPathLength === 0) { return []; }

@@ -69,0 +70,0 @@ const offset = asRatioToPathLength(pattern.offset, totalPathLength);

@@ -86,1 +86,16 @@ import test from 'ava';

});
test('ignores empty segments', t => {
t.deepEqual(
projectPatternOnPointPath([A, A, B, B, B, C, D, D, D], patternStart),
projectPatternOnPointPath([A, B, C, D], patternStart)
);
t.deepEqual(
projectPatternOnPointPath([A, A, B, B, B, C, D, D, D], patternQuarter),
projectPatternOnPointPath([A, B, C, D], patternQuarter)
);
t.deepEqual(
projectPatternOnPointPath([A, A, B, B, B, C, D, D, D], pattern3Repeat),
projectPatternOnPointPath([A, B, C, D], pattern3Repeat)
);
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc