From 4ea1350685f883ff6dfd0946b1f47a36aee84fb3 Mon Sep 17 00:00:00 2001 From: Benjamin Becquet Date: Sun, 28 Jan 2018 12:43:58 +0100 Subject: [PATCH] Move functions not depending on state out of the class --- dist/leaflet.polylineDecorator.js | 18 +++++++++--------- src/L.PolylineDecorator.js | 17 +++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/dist/leaflet.polylineDecorator.js b/dist/leaflet.polylineDecorator.js index 2da132e..cb2fdee 100644 --- a/dist/leaflet.polylineDecorator.js +++ b/dist/leaflet.polylineDecorator.js @@ -284,6 +284,14 @@ L$1.Symbol.marker = function (options) { return new L$1.Symbol.Marker(options); }; +var isCoord = function isCoord(c) { + return c instanceof L$1.LatLng || Array.isArray(c) && c.length === 2 && typeof c[0] === 'number'; +}; + +var isCoordArray = function isCoordArray(ll) { + return Array.isArray(ll) && isCoord(ll[0]); +}; + L$1.PolylineDecorator = L$1.FeatureGroup.extend({ options: { patterns: [] @@ -306,7 +314,7 @@ L$1.PolylineDecorator = L$1.FeatureGroup.extend({ _initPaths: function _initPaths(input, isPolygon) { var _this = this; - if (this._isCoordArray(input)) { + if (isCoordArray(input)) { // Leaflet Polygons don't need the first point to be repeated, but we do var coords = isPolygon ? input.concat([input[0]]) : input; return [coords]; @@ -324,14 +332,6 @@ L$1.PolylineDecorator = L$1.FeatureGroup.extend({ return []; }, - _isCoordArray: function _isCoordArray(ll) { - return Array.isArray(ll) && this._isCoord(ll[0]); - }, - - _isCoord: function _isCoord(c) { - return c instanceof L$1.LatLng || Array.isArray(c) && c.length === 2 && typeof c[0] === 'number'; - }, - // parse pattern definitions and precompute some values _initPatterns: function _initPatterns(patternDefs) { return patternDefs.map(this._parsePatternDef); diff --git a/src/L.PolylineDecorator.js b/src/L.PolylineDecorator.js index 647cb1d..307cef7 100644 --- a/src/L.PolylineDecorator.js +++ b/src/L.PolylineDecorator.js @@ -5,6 +5,12 @@ import { } from './patternUtils.js'; import './L.Symbol.js'; +const isCoord = c => + (c instanceof L.LatLng) || + (Array.isArray(c) && c.length === 2 && typeof c[0] === 'number'); + +const isCoordArray = ll => Array.isArray(ll) && isCoord(ll[0]); + L.PolylineDecorator = L.FeatureGroup.extend({ options: { patterns: [] @@ -25,7 +31,7 @@ L.PolylineDecorator = L.FeatureGroup.extend({ * array of one of the previous. */ _initPaths: function(input, isPolygon) { - if (this._isCoordArray(input)) { + if (isCoordArray(input)) { // Leaflet Polygons don't need the first point to be repeated, but we do const coords = isPolygon ? input.concat([input[0]]) : input; return [coords]; @@ -43,15 +49,6 @@ L.PolylineDecorator = L.FeatureGroup.extend({ return []; }, - _isCoordArray: function(ll) { - return Array.isArray(ll) && this._isCoord(ll[0]); - }, - - _isCoord: function(c) { - return c instanceof L.LatLng - || (Array.isArray(c) && c.length === 2 && typeof c[0] === 'number'); - }, - // parse pattern definitions and precompute some values _initPatterns: function(patternDefs) { return patternDefs.map(this._parsePatternDef);