@ohuoy/easymap 1.0.24 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/lib/mapbox-gl-draw/src/lib/common_selectors.js +4 -0
  2. package/lib/mapbox-gl-draw/src/lib/geojson-area.js +92 -0
  3. package/lib/mapbox-gl-draw/src/lib/mouse_event_point.js +1 -1
  4. package/lib/mapbox-gl-draw/src/lib/point-geometry.js +314 -0
  5. package/lib/mapbox-gl-draw/src/lib/sort_features.js +1 -1
  6. package/package.json +1 -1
  7. package/src/components/control/DrawBar.js +3 -3
  8. package/src/components/control/constants.js +0 -101
  9. package/src/components/control/lib/common_selectors.js +0 -68
  10. package/src/components/control/lib/constrain_feature_movement.js +0 -83
  11. package/src/components/control/lib/create_midpoint.js +0 -35
  12. package/src/components/control/lib/create_supplementary_points.js +0 -83
  13. package/src/components/control/lib/create_vertex.js +0 -29
  14. package/src/components/control/lib/double_click_zoom.js +0 -18
  15. package/src/components/control/lib/euclidean_distance.js +0 -5
  16. package/src/components/control/lib/features_at.js +0 -48
  17. package/src/components/control/lib/get_features_and_set_cursor.js +0 -22
  18. package/src/components/control/lib/id.js +0 -7
  19. package/src/components/control/lib/index.js +0 -43
  20. package/src/components/control/lib/is_click.js +0 -18
  21. package/src/components/control/lib/is_event_at_coordinates.js +0 -6
  22. package/src/components/control/lib/is_tap.js +0 -15
  23. package/src/components/control/lib/map_event_to_bounding_box.js +0 -14
  24. package/src/components/control/lib/mode_handler.js +0 -116
  25. package/src/components/control/lib/mouse_event_point.js +0 -19
  26. package/src/components/control/lib/move_features.js +0 -33
  27. package/src/components/control/lib/sort_features.js +0 -38
  28. package/src/components/control/lib/string_set.js +0 -55
  29. package/src/components/control/lib/string_sets_are_equal.js +0 -4
  30. package/src/components/control/lib/theme.js +0 -153
  31. package/src/components/control/lib/to_dense_array.js +0 -11
  32. /package/{src/components/control → lib/mapbox-gl-draw/src}/extendMode/direct_select_rect.js +0 -0
  33. /package/{src/components/control → lib/mapbox-gl-draw/src}/extendMode/rectmode.js +0 -0
  34. /package/{src/components/control → lib/mapbox-gl-draw/src}/extendMode/simple_select_rect.js +0 -0
@@ -1,35 +0,0 @@
1
- import * as Constants from '../constants.js';
2
-
3
- export default function(parent, startVertex, endVertex) {
4
- const startCoord = startVertex.geometry.coordinates;
5
- const endCoord = endVertex.geometry.coordinates;
6
-
7
- // If a coordinate exceeds the projection, we can't calculate a midpoint,
8
- // so run away
9
- if (startCoord[1] > Constants.LAT_RENDERED_MAX ||
10
- startCoord[1] < Constants.LAT_RENDERED_MIN ||
11
- endCoord[1] > Constants.LAT_RENDERED_MAX ||
12
- endCoord[1] < Constants.LAT_RENDERED_MIN) {
13
- return null;
14
- }
15
-
16
- const mid = {
17
- lng: (startCoord[0] + endCoord[0]) / 2,
18
- lat: (startCoord[1] + endCoord[1]) / 2
19
- };
20
-
21
- return {
22
- type: Constants.geojsonTypes.FEATURE,
23
- properties: {
24
- meta: Constants.meta.MIDPOINT,
25
- parent,
26
- lng: mid.lng,
27
- lat: mid.lat,
28
- coord_path: endVertex.properties.coord_path
29
- },
30
- geometry: {
31
- type: Constants.geojsonTypes.POINT,
32
- coordinates: [mid.lng, mid.lat]
33
- }
34
- };
35
- }
@@ -1,83 +0,0 @@
1
- import createVertex from './create_vertex.js';
2
- import createMidpoint from './create_midpoint.js';
3
- import * as Constants from '../constants.js';
4
-
5
- function createSupplementaryPoints(geojson, options = {}, basePath = null) {
6
- const { type, coordinates } = geojson.geometry;
7
- const featureId = geojson.properties && geojson.properties.id;
8
-
9
- let supplementaryPoints = [];
10
-
11
- if (type === Constants.geojsonTypes.POINT) {
12
- // For points, just create a vertex
13
- supplementaryPoints.push(createVertex(featureId, coordinates, basePath, isSelectedPath(basePath)));
14
- } else if (type === Constants.geojsonTypes.POLYGON) {
15
- // Cycle through a Polygon's rings and
16
- // process each line
17
- coordinates.forEach((line, lineIndex) => {
18
- processLine(line, (basePath !== null) ? `${basePath}.${lineIndex}` : String(lineIndex));
19
- });
20
- } else if (type === Constants.geojsonTypes.LINE_STRING) {
21
- processLine(coordinates, basePath);
22
- } else if (type.indexOf(Constants.geojsonTypes.MULTI_PREFIX) === 0) {
23
- processMultiGeometry();
24
- }
25
-
26
- function processLine(line, lineBasePath) {
27
- let firstPointString = '';
28
- let lastVertex = null;
29
- line.forEach((point, pointIndex) => {
30
- const pointPath = (lineBasePath !== undefined && lineBasePath !== null) ? `${lineBasePath}.${pointIndex}` : String(pointIndex);
31
- const vertex = createVertex(featureId, point, pointPath, isSelectedPath(pointPath));
32
-
33
- // If we're creating midpoints, check if there was a
34
- // vertex before this one. If so, add a midpoint
35
- // between that vertex and this one.
36
- if (options.midpoints && lastVertex) {
37
- const midpoint = createMidpoint(featureId, lastVertex, vertex);
38
- if (midpoint) {
39
- supplementaryPoints.push(midpoint);
40
- }
41
- }
42
- lastVertex = vertex;
43
-
44
- // A Polygon line's last point is the same as the first point. If we're on the last
45
- // point, we want to draw a midpoint before it but not another vertex on it
46
- // (since we already a vertex there, from the first point).
47
- const stringifiedPoint = JSON.stringify(point);
48
- if (firstPointString !== stringifiedPoint) {
49
- supplementaryPoints.push(vertex);
50
- }
51
- if (pointIndex === 0) {
52
- firstPointString = stringifiedPoint;
53
- }
54
- });
55
- }
56
-
57
- function isSelectedPath(path) {
58
- if (!options.selectedPaths) return false;
59
- return options.selectedPaths.indexOf(path) !== -1;
60
- }
61
-
62
- // Split a multi-geometry into constituent
63
- // geometries, and accumulate the supplementary points
64
- // for each of those constituents
65
- function processMultiGeometry() {
66
- const subType = type.replace(Constants.geojsonTypes.MULTI_PREFIX, '');
67
- coordinates.forEach((subCoordinates, index) => {
68
- const subFeature = {
69
- type: Constants.geojsonTypes.FEATURE,
70
- properties: geojson.properties,
71
- geometry: {
72
- type: subType,
73
- coordinates: subCoordinates
74
- }
75
- };
76
- supplementaryPoints = supplementaryPoints.concat(createSupplementaryPoints(subFeature, options, index));
77
- });
78
- }
79
-
80
- return supplementaryPoints;
81
- }
82
-
83
- export default createSupplementaryPoints;
@@ -1,29 +0,0 @@
1
- import * as Constants from '../constants.js';
2
-
3
- /**
4
- * Returns GeoJSON for a Point representing the
5
- * vertex of another feature.
6
- *
7
- * @param {string} parentId
8
- * @param {Array<number>} coordinates
9
- * @param {string} path - Dot-separated numbers indicating exactly
10
- * where the point exists within its parent feature's coordinates.
11
- * @param {boolean} selected
12
- * @return {GeoJSON} Point
13
- */
14
-
15
- export default function(parentId, coordinates, path, selected) {
16
- return {
17
- type: Constants.geojsonTypes.FEATURE,
18
- properties: {
19
- meta: Constants.meta.VERTEX,
20
- parent: parentId,
21
- coord_path: path,
22
- active: (selected) ? Constants.activeStates.ACTIVE : Constants.activeStates.INACTIVE
23
- },
24
- geometry: {
25
- type: Constants.geojsonTypes.POINT,
26
- coordinates
27
- }
28
- };
29
- }
@@ -1,18 +0,0 @@
1
- export default {
2
- enable(ctx) {
3
- setTimeout(() => {
4
- // First check we've got a map and some context.
5
- if (!ctx.map || !ctx.map.doubleClickZoom || !ctx._ctx || !ctx._ctx.store || !ctx._ctx.store.getInitialConfigValue) return;
6
- // Now check initial state wasn't false (we leave it disabled if so)
7
- if (!ctx._ctx.store.getInitialConfigValue('doubleClickZoom')) return;
8
- ctx.map.doubleClickZoom.enable();
9
- }, 0);
10
- },
11
- disable(ctx) {
12
- setTimeout(() => {
13
- if (!ctx.map || !ctx.map.doubleClickZoom) return;
14
- // Always disable here, as it's necessary in some cases.
15
- ctx.map.doubleClickZoom.disable();
16
- }, 0);
17
- }
18
- };
@@ -1,5 +0,0 @@
1
- export default function(a, b) {
2
- const x = a.x - b.x;
3
- const y = a.y - b.y;
4
- return Math.sqrt((x * x) + (y * y));
5
- }
@@ -1,48 +0,0 @@
1
- import sortFeatures from './sort_features.js';
2
- import mapEventToBoundingBox from './map_event_to_bounding_box.js';
3
- import * as Constants from '../constants.js';
4
- import StringSet from './string_set.js';
5
-
6
- const META_TYPES = [
7
- Constants.meta.FEATURE,
8
- Constants.meta.MIDPOINT,
9
- Constants.meta.VERTEX
10
- ];
11
-
12
- // Requires either event or bbox
13
- export default {
14
- click: featuresAtClick,
15
- touch: featuresAtTouch
16
- };
17
-
18
- function featuresAtClick(event, bbox, ctx) {
19
- return featuresAt(event, bbox, ctx, ctx.options.clickBuffer);
20
- }
21
-
22
- function featuresAtTouch(event, bbox, ctx) {
23
- return featuresAt(event, bbox, ctx, ctx.options.touchBuffer);
24
- }
25
-
26
- function featuresAt(event, bbox, ctx, buffer) {
27
- if (ctx.map === null) return [];
28
-
29
- const box = (event) ? mapEventToBoundingBox(event, buffer) : bbox;
30
-
31
- const queryParams = {};
32
-
33
- if (ctx.options.styles) queryParams.layers = ctx.options.styles.map(s => s.id).filter(id => ctx.map.getLayer(id) != null);
34
-
35
- const features = ctx.map.queryRenderedFeatures(box, queryParams)
36
- .filter(feature => META_TYPES.indexOf(feature.properties.meta) !== -1);
37
-
38
- const featureIds = new StringSet();
39
- const uniqueFeatures = [];
40
- features.forEach((feature) => {
41
- const featureId = feature.properties.id;
42
- if (featureIds.has(featureId)) return;
43
- featureIds.add(featureId);
44
- uniqueFeatures.push(feature);
45
- });
46
-
47
- return sortFeatures(uniqueFeatures);
48
- }
@@ -1,22 +0,0 @@
1
- import featuresAt from './features_at.js';
2
- import * as Constants from '../constants.js';
3
-
4
- export default function getFeatureAtAndSetCursors(event, ctx) {
5
- const features = featuresAt.click(event, null, ctx);
6
- const classes = { mouse: Constants.cursors.NONE };
7
-
8
- if (features[0]) {
9
- classes.mouse = (features[0].properties.active === Constants.activeStates.ACTIVE) ?
10
- Constants.cursors.MOVE : Constants.cursors.POINTER;
11
- classes.feature = features[0].properties.meta;
12
- }
13
-
14
- if (ctx.events.currentModeName().indexOf('draw') !== -1) {
15
- classes.mouse = Constants.cursors.ADD;
16
- }
17
-
18
- ctx.ui.queueMapClasses(classes);
19
- ctx.ui.updateMapClasses();
20
-
21
- return features[0];
22
- }
@@ -1,7 +0,0 @@
1
- import {customAlphabet} from 'nanoid/non-secure';
2
-
3
- const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 32);
4
-
5
- export function generateID() {
6
- return nanoid();
7
- }
@@ -1,43 +0,0 @@
1
- import * as CommonSelectors from "./common_selectors.js";
2
- import constrainFeatureMovement from "./constrain_feature_movement.js";
3
- import createMidPoint from "./create_midpoint.js";
4
- import createSupplementaryPoints from "./create_supplementary_points.js";
5
- import createVertex from "./create_vertex.js";
6
- import doubleClickZoom from "./double_click_zoom.js";
7
- import euclideanDistance from "./euclidean_distance.js";
8
- import featuresAt from "./features_at.js";
9
- import getFeatureAtAndSetCursors from "./get_features_and_set_cursor.js";
10
- import isClick from "./is_click.js";
11
- import isEventAtCoordinates from "./is_event_at_coordinates.js";
12
- import isTap from "./is_tap.js";
13
- import mapEventToBoundingBox from "./map_event_to_bounding_box.js";
14
- import ModeHandler from "./mode_handler.js";
15
- import moveFeatures from "./move_features.js";
16
- import sortFeatures from "./sort_features.js";
17
- import StringSet from "./string_set.js";
18
- import stringSetsAreEqual from "./string_sets_are_equal.js";
19
- import theme from "./theme.js";
20
- import toDenseArray from "./to_dense_array.js";
21
-
22
- export {
23
- CommonSelectors,
24
- constrainFeatureMovement,
25
- createMidPoint,
26
- createSupplementaryPoints,
27
- createVertex,
28
- doubleClickZoom,
29
- euclideanDistance,
30
- featuresAt,
31
- getFeatureAtAndSetCursors,
32
- isClick,
33
- isEventAtCoordinates,
34
- isTap,
35
- mapEventToBoundingBox,
36
- ModeHandler,
37
- moveFeatures,
38
- sortFeatures,
39
- stringSetsAreEqual,
40
- StringSet,
41
- theme,
42
- toDenseArray,
43
- };
@@ -1,18 +0,0 @@
1
- import euclideanDistance from './euclidean_distance.js';
2
-
3
- const FINE_TOLERANCE = 4;
4
- const GROSS_TOLERANCE = 12;
5
- const INTERVAL = 500;
6
-
7
- export default function isClick(start, end, options = {}) {
8
- const fineTolerance = (options.fineTolerance != null) ? options.fineTolerance : FINE_TOLERANCE;
9
- const grossTolerance = (options.grossTolerance != null) ? options.grossTolerance : GROSS_TOLERANCE;
10
- const interval = (options.interval != null) ? options.interval : INTERVAL;
11
-
12
- start.point = start.point || end.point;
13
- start.time = start.time || end.time;
14
- const moveDistance = euclideanDistance(start.point, end.point);
15
-
16
- return moveDistance < fineTolerance ||
17
- (moveDistance < grossTolerance && (end.time - start.time) < interval);
18
- }
@@ -1,6 +0,0 @@
1
- function isEventAtCoordinates(event, coordinates) {
2
- if (!event.lngLat) return false;
3
- return event.lngLat.lng === coordinates[0] && event.lngLat.lat === coordinates[1];
4
- }
5
-
6
- export default isEventAtCoordinates;
@@ -1,15 +0,0 @@
1
- import euclideanDistance from './euclidean_distance.js';
2
-
3
- export const TAP_TOLERANCE = 25;
4
- export const TAP_INTERVAL = 250;
5
-
6
- export default function isTap(start, end, options = {}) {
7
- const tolerance = (options.tolerance != null) ? options.tolerance : TAP_TOLERANCE;
8
- const interval = (options.interval != null) ? options.interval : TAP_INTERVAL;
9
-
10
- start.point = start.point || end.point;
11
- start.time = start.time || end.time;
12
- const moveDistance = euclideanDistance(start.point, end.point);
13
-
14
- return moveDistance < tolerance && (end.time - start.time) < interval;
15
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Returns a bounding box representing the event's location.
3
- *
4
- * @param {Event} mapEvent - Mapbox GL JS map event, with a point properties.
5
- * @return {Array<Array<number>>} Bounding box.
6
- */
7
- function mapEventToBoundingBox(mapEvent, buffer = 0) {
8
- return [
9
- [mapEvent.point.x - buffer, mapEvent.point.y - buffer],
10
- [mapEvent.point.x + buffer, mapEvent.point.y + buffer]
11
- ];
12
- }
13
-
14
- export default mapEventToBoundingBox;
@@ -1,116 +0,0 @@
1
-
2
- const ModeHandler = function(mode, DrawContext) {
3
-
4
- const handlers = {
5
- drag: [],
6
- click: [],
7
- mousemove: [],
8
- mousedown: [],
9
- mouseup: [],
10
- mouseout: [],
11
- keydown: [],
12
- keyup: [],
13
- touchstart: [],
14
- touchmove: [],
15
- touchend: [],
16
- tap: []
17
- };
18
-
19
- const ctx = {
20
- on(event, selector, fn) {
21
- if (handlers[event] === undefined) {
22
- throw new Error(`Invalid event type: ${event}`);
23
- }
24
- handlers[event].push({
25
- selector,
26
- fn
27
- });
28
- },
29
- render(id) {
30
- DrawContext.store.featureChanged(id);
31
- }
32
- };
33
-
34
- const delegate = function (eventName, event) {
35
- const handles = handlers[eventName];
36
- let iHandle = handles.length;
37
- while (iHandle--) {
38
- const handle = handles[iHandle];
39
- if (handle.selector(event)) {
40
- const skipRender = handle.fn.call(ctx, event);
41
- if (!skipRender) {
42
- DrawContext.store.render();
43
- }
44
- DrawContext.ui.updateMapClasses();
45
-
46
- // ensure an event is only handled once
47
- // we do this to let modes have multiple overlapping selectors
48
- // and relay on order of oppertations to filter
49
- break;
50
- }
51
- }
52
- };
53
-
54
- mode.start.call(ctx);
55
-
56
- return {
57
- render: mode.render,
58
- stop() {
59
- if (mode.stop) mode.stop();
60
- },
61
- trash() {
62
- if (mode.trash) {
63
- mode.trash();
64
- DrawContext.store.render();
65
- }
66
- },
67
- combineFeatures() {
68
- if (mode.combineFeatures) {
69
- mode.combineFeatures();
70
- }
71
- },
72
- uncombineFeatures() {
73
- if (mode.uncombineFeatures) {
74
- mode.uncombineFeatures();
75
- }
76
- },
77
- drag(event) {
78
- delegate('drag', event);
79
- },
80
- click(event) {
81
- delegate('click', event);
82
- },
83
- mousemove(event) {
84
- delegate('mousemove', event);
85
- },
86
- mousedown(event) {
87
- delegate('mousedown', event);
88
- },
89
- mouseup(event) {
90
- delegate('mouseup', event);
91
- },
92
- mouseout(event) {
93
- delegate('mouseout', event);
94
- },
95
- keydown(event) {
96
- delegate('keydown', event);
97
- },
98
- keyup(event) {
99
- delegate('keyup', event);
100
- },
101
- touchstart(event) {
102
- delegate('touchstart', event);
103
- },
104
- touchmove(event) {
105
- delegate('touchmove', event);
106
- },
107
- touchend(event) {
108
- delegate('touchend', event);
109
- },
110
- tap(event) {
111
- delegate('tap', event);
112
- }
113
- };
114
- };
115
-
116
- export default ModeHandler;
@@ -1,19 +0,0 @@
1
- import Point from '../../../../lib/point-geometry';
2
-
3
- /**
4
- * Returns a Point representing a mouse event's position
5
- * relative to a containing element.
6
- *
7
- * @param {MouseEvent} mouseEvent
8
- * @param {Node} container
9
- * @returns {Point}
10
- */
11
- function mouseEventPoint(mouseEvent, container) {
12
- const rect = container.getBoundingClientRect();
13
- return new Point(
14
- mouseEvent.clientX - rect.left - (container.clientLeft || 0),
15
- mouseEvent.clientY - rect.top - (container.clientTop || 0)
16
- );
17
- }
18
-
19
- export default mouseEventPoint;
@@ -1,33 +0,0 @@
1
- import constrainFeatureMovement from './constrain_feature_movement.js';
2
- import * as Constants from '../constants.js';
3
-
4
- export default function(features, delta) {
5
- const constrainedDelta = constrainFeatureMovement(features.map(feature => feature.toGeoJSON()), delta);
6
-
7
- features.forEach((feature) => {
8
- const currentCoordinates = feature.getCoordinates();
9
-
10
- const moveCoordinate = (coord) => {
11
- const point = {
12
- lng: coord[0] + constrainedDelta.lng,
13
- lat: coord[1] + constrainedDelta.lat
14
- };
15
- return [point.lng, point.lat];
16
- };
17
- const moveRing = ring => ring.map(coord => moveCoordinate(coord));
18
- const moveMultiPolygon = multi => multi.map(ring => moveRing(ring));
19
-
20
- let nextCoordinates;
21
- if (feature.type === Constants.geojsonTypes.POINT) {
22
- nextCoordinates = moveCoordinate(currentCoordinates);
23
- } else if (feature.type === Constants.geojsonTypes.LINE_STRING || feature.type === Constants.geojsonTypes.MULTI_POINT) {
24
- nextCoordinates = currentCoordinates.map(moveCoordinate);
25
- } else if (feature.type === Constants.geojsonTypes.POLYGON || feature.type === Constants.geojsonTypes.MULTI_LINE_STRING) {
26
- nextCoordinates = currentCoordinates.map(moveRing);
27
- } else if (feature.type === Constants.geojsonTypes.MULTI_POLYGON) {
28
- nextCoordinates = currentCoordinates.map(moveMultiPolygon);
29
- }
30
-
31
- feature.incomingCoords(nextCoordinates);
32
- });
33
- }
@@ -1,38 +0,0 @@
1
- import area from '../../../../lib/geojson-area';
2
- import * as Constants from '../constants.js';
3
-
4
- const FEATURE_SORT_RANKS = {
5
- Point: 0,
6
- LineString: 1,
7
- MultiLineString: 1,
8
- Polygon: 2
9
- };
10
-
11
- function comparator(a, b) {
12
- const score = FEATURE_SORT_RANKS[a.geometry.type] - FEATURE_SORT_RANKS[b.geometry.type];
13
-
14
- if (score === 0 && a.geometry.type === Constants.geojsonTypes.POLYGON) {
15
- return a.area - b.area;
16
- }
17
-
18
- return score;
19
- }
20
-
21
- // Sort in the order above, then sort polygons by area ascending.
22
- function sortFeatures(features) {
23
- return features.map((feature) => {
24
- if (feature.geometry.type === Constants.geojsonTypes.POLYGON) {
25
- feature.area = area.geometry({
26
- type: Constants.geojsonTypes.FEATURE,
27
- property: {},
28
- geometry: feature.geometry
29
- });
30
- }
31
- return feature;
32
- }).sort(comparator).map((feature) => {
33
- delete feature.area;
34
- return feature;
35
- });
36
- }
37
-
38
- export default sortFeatures;
@@ -1,55 +0,0 @@
1
- function StringSet(items) {
2
- this._items = {};
3
- this._nums = {};
4
- this._length = items ? items.length : 0;
5
- if (!items) return;
6
- for (let i = 0, l = items.length; i < l; i++) {
7
- this.add(items[i]);
8
- if (items[i] === undefined) continue;
9
- if (typeof items[i] === 'string') this._items[items[i]] = i;
10
- else this._nums[items[i]] = i;
11
-
12
- }
13
- }
14
-
15
- StringSet.prototype.add = function(x) {
16
- if (this.has(x)) return this;
17
- this._length++;
18
- if (typeof x === 'string') this._items[x] = this._length;
19
- else this._nums[x] = this._length;
20
- return this;
21
- };
22
-
23
- StringSet.prototype.delete = function(x) {
24
- if (this.has(x) === false) return this;
25
- this._length--;
26
- delete this._items[x];
27
- delete this._nums[x];
28
- return this;
29
- };
30
-
31
- StringSet.prototype.has = function(x) {
32
- if (typeof x !== 'string' && typeof x !== 'number') return false;
33
- return this._items[x] !== undefined || this._nums[x] !== undefined;
34
- };
35
-
36
- StringSet.prototype.values = function() {
37
- const values = [];
38
- Object.keys(this._items).forEach((k) => {
39
- values.push({ k, v: this._items[k] });
40
- });
41
- Object.keys(this._nums).forEach((k) => {
42
- values.push({ k: JSON.parse(k), v: this._nums[k] });
43
- });
44
-
45
- return values.sort((a, b) => a.v - b.v).map(a => a.k);
46
- };
47
-
48
- StringSet.prototype.clear = function() {
49
- this._length = 0;
50
- this._items = {};
51
- this._nums = {};
52
- return this;
53
- };
54
-
55
- export default StringSet;
@@ -1,4 +0,0 @@
1
- export default function(a, b) {
2
- if (a.length !== b.length) return false;
3
- return JSON.stringify(a.map(id => id).sort()) === JSON.stringify(b.map(id => id).sort());
4
- }