@turf/geojson-rbush 7.1.0 → 7.2.0

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.
@@ -6,8 +6,7 @@ var _bbox = require('@turf/bbox');
6
6
  function geojsonRbush(maxEntries) {
7
7
  var tree = new (0, _rbush2.default)(maxEntries);
8
8
  tree.insert = function(feature) {
9
- if (feature.type !== "Feature")
10
- throw new Error("invalid feature");
9
+ if (feature.type !== "Feature") throw new Error("invalid feature");
11
10
  feature.bbox = feature.bbox ? feature.bbox : _bbox.bbox.call(void 0, feature);
12
11
  return _rbush2.default.prototype.insert.call(this, feature);
13
12
  };
@@ -15,15 +14,13 @@ function geojsonRbush(maxEntries) {
15
14
  var load = [];
16
15
  if (Array.isArray(features)) {
17
16
  features.forEach(function(feature) {
18
- if (feature.type !== "Feature")
19
- throw new Error("invalid features");
17
+ if (feature.type !== "Feature") throw new Error("invalid features");
20
18
  feature.bbox = feature.bbox ? feature.bbox : _bbox.bbox.call(void 0, feature);
21
19
  load.push(feature);
22
20
  });
23
21
  } else {
24
22
  _meta.featureEach.call(void 0, features, function(feature) {
25
- if (feature.type !== "Feature")
26
- throw new Error("invalid features");
23
+ if (feature.type !== "Feature") throw new Error("invalid features");
27
24
  feature.bbox = feature.bbox ? feature.bbox : _bbox.bbox.call(void 0, feature);
28
25
  load.push(feature);
29
26
  });
@@ -31,8 +28,7 @@ function geojsonRbush(maxEntries) {
31
28
  return _rbush2.default.prototype.load.call(this, load);
32
29
  };
33
30
  tree.remove = function(feature, equals) {
34
- if (feature.type !== "Feature")
35
- throw new Error("invalid feature");
31
+ if (feature.type !== "Feature") throw new Error("invalid feature");
36
32
  feature.bbox = feature.bbox ? feature.bbox : _bbox.bbox.call(void 0, feature);
37
33
  return _rbush2.default.prototype.remove.call(this, feature, equals);
38
34
  };
@@ -58,18 +54,13 @@ function geojsonRbush(maxEntries) {
58
54
  };
59
55
  tree.toBBox = function(geojson) {
60
56
  var bbox;
61
- if (geojson.bbox)
62
- bbox = geojson.bbox;
63
- else if (Array.isArray(geojson) && geojson.length === 4)
64
- bbox = geojson;
57
+ if (geojson.bbox) bbox = geojson.bbox;
58
+ else if (Array.isArray(geojson) && geojson.length === 4) bbox = geojson;
65
59
  else if (Array.isArray(geojson) && geojson.length === 6)
66
60
  bbox = [geojson[0], geojson[1], geojson[3], geojson[4]];
67
- else if (geojson.type === "Feature")
68
- bbox = _bbox.bbox.call(void 0, geojson);
69
- else if (geojson.type === "FeatureCollection")
70
- bbox = _bbox.bbox.call(void 0, geojson);
71
- else
72
- throw new Error("invalid geojson");
61
+ else if (geojson.type === "Feature") bbox = _bbox.bbox.call(void 0, geojson);
62
+ else if (geojson.type === "FeatureCollection") bbox = _bbox.bbox.call(void 0, geojson);
63
+ else throw new Error("invalid geojson");
73
64
  return {
74
65
  minX: bbox[0],
75
66
  minY: bbox[1],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.js"],"names":[],"mappings":";AAAA,OAAO,WAAW;AAClB,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,gBAAgB;AAiBjC,SAAS,aAAa,YAAY;AAChC,MAAI,OAAO,IAAI,MAAM,UAAU;AAY/B,OAAK,SAAS,SAAU,SAAS;AAC/B,QAAI,QAAQ,SAAS;AAAW,YAAM,IAAI,MAAM,iBAAiB;AACjE,YAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO;AAC7D,WAAO,MAAM,UAAU,OAAO,KAAK,MAAM,OAAO;AAAA,EAClD;AAeA,OAAK,OAAO,SAAU,UAAU;AAC9B,QAAI,OAAO,CAAC;AAEZ,QAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,eAAS,QAAQ,SAAU,SAAS;AAClC,YAAI,QAAQ,SAAS;AAAW,gBAAM,IAAI,MAAM,kBAAkB;AAClE,gBAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO;AAC7D,aAAK,KAAK,O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,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW;AAAG,aAAO;AAAA,aACvD,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW;AACpD,aAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC;AAAA,aAC/C,QAAQ,SAAS;AAAW,aAAO,SAAS,OAAO;AAAA,aACnD,QAAQ,SAAS;AAAqB,aAAO,SAAS,OAAO;AAAA;AACjE,YAAM,IAAI,MAAM,iBAAiB;AAEtC,WAAO;AAAA,MACL,MAAM,KAAK,CAAC;AAAA,MACZ,MAAM,KAAK,CAAC;AAAA,MACZ,MAAM,KAAK,CAAC;AAAA,MACZ,MAAM,KAAK,CAAC;AAAA,IACd;AAAA,EACF;AACA,SAAO;AACT;AAGA,IAAO,6BAAQ","sourcesContent":["import rbush from \"rbush\";\nimport { featureCollection } from \"@turf/helpers\";\nimport { featureEach } from \"@turf/meta\";\nimport { bbox as turfBBox } from \"@turf/bbox\";\n\n/**\n * @module rbush\n */\n\n/**\n * GeoJSON implementation of [RBush](https://github.com/mourner/rbush#rbush) spatial index.\n *\n * @name rbush\n * @param {number} [maxEntries=9] defines the maximum number of entries in a tree node. 9 (used by default) is a\n * reasonable choice for most applications. Higher value means faster insertion and slower search, and vice versa.\n * @returns {RBush} GeoJSON RBush\n * @example\n * var geojsonRbush = require('geojson-rbush').default;\n * var tree = geojsonRbush();\n */\nfunction geojsonRbush(maxEntries) {\n var tree = new rbush(maxEntries);\n\n /**\n * [insert](https://github.com/mourner/rbush#data-format)\n *\n * @memberof rbush\n * @param {Feature} feature insert single GeoJSON Feature\n * @returns {RBush} GeoJSON RBush\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n * tree.insert(poly)\n */\n tree.insert = function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid feature\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n return rbush.prototype.insert.call(this, feature);\n };\n\n /**\n * [load](https://github.com/mourner/rbush#bulk-inserting-data)\n *\n * @memberof rbush\n * @param {FeatureCollection|Array<Feature>} features load entire GeoJSON FeatureCollection\n * @returns {RBush} GeoJSON RBush\n * @example\n * var polys = turf.polygons([\n * [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]],\n * [[[-93, 32], [-83, 32], [-83, 39], [-93, 39], [-93, 32]]]\n * ]);\n * tree.load(polys);\n */\n tree.load = function (features) {\n var load = [];\n // Load an Array of Features\n if (Array.isArray(features)) {\n features.forEach(function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid features\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n load.push(feature);\n });\n } else {\n // Load a FeatureCollection\n featureEach(features, function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid features\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n load.push(feature);\n });\n }\n return rbush.prototype.load.call(this, load);\n };\n\n /**\n * [remove](https://github.com/mourner/rbush#removing-data)\n *\n * @memberof rbush\n * @param {Feature} feature remove single GeoJSON Feature\n * @param {Function} equals Pass a custom equals function to compare by value for removal.\n * @returns {RBush} GeoJSON RBush\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.remove(poly);\n */\n tree.remove = function (feature, equals) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid feature\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n return rbush.prototype.remove.call(this, feature, equals);\n };\n\n /**\n * [clear](https://github.com/mourner/rbush#removing-data)\n *\n * @memberof rbush\n * @returns {RBush} GeoJSON Rbush\n * @example\n * tree.clear()\n */\n tree.clear = function () {\n return rbush.prototype.clear.call(this);\n };\n\n /**\n * [search](https://github.com/mourner/rbush#search)\n *\n * @memberof rbush\n * @param {BBox|FeatureCollection|Feature} geojson search with GeoJSON\n * @returns {FeatureCollection} all features that intersects with the given GeoJSON.\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.search(poly);\n */\n tree.search = function (geojson) {\n var features = rbush.prototype.search.call(this, this.toBBox(geojson));\n return featureCollection(features);\n };\n\n /**\n * [collides](https://github.com/mourner/rbush#collisions)\n *\n * @memberof rbush\n * @param {BBox|FeatureCollection|Feature} geojson collides with GeoJSON\n * @returns {boolean} true if there are any items intersecting the given GeoJSON, otherwise false.\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.collides(poly);\n */\n tree.collides = function (geojson) {\n return rbush.prototype.collides.call(this, this.toBBox(geojson));\n };\n\n /**\n * [all](https://github.com/mourner/rbush#search)\n *\n * @memberof rbush\n * @returns {FeatureCollection} all the features in RBush\n * @example\n * tree.all()\n */\n tree.all = function () {\n var features = rbush.prototype.all.call(this);\n return featureCollection(features);\n };\n\n /**\n * [toJSON](https://github.com/mourner/rbush#export-and-import)\n *\n * @memberof rbush\n * @returns {any} export data as JSON object\n * @example\n * var exported = tree.toJSON()\n */\n tree.toJSON = function () {\n return rbush.prototype.toJSON.call(this);\n };\n\n /**\n * [fromJSON](https://github.com/mourner/rbush#export-and-import)\n *\n * @memberof rbush\n * @param {any} json import previously exported data\n * @returns {RBush} GeoJSON RBush\n * @example\n * var exported = {\n * \"children\": [\n * {\n * \"type\": \"Feature\",\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 50]\n * },\n * \"properties\": {},\n * \"bbox\": [110, 50, 110, 50]\n * }\n * ],\n * \"height\": 1,\n * \"leaf\": true,\n * \"minX\": 110,\n * \"minY\": 50,\n * \"maxX\": 110,\n * \"maxY\": 50\n * }\n * tree.fromJSON(exported)\n */\n tree.fromJSON = function (json) {\n return rbush.prototype.fromJSON.call(this, json);\n };\n\n /**\n * Converts GeoJSON to {minX, minY, maxX, maxY} schema\n *\n * @memberof rbush\n * @private\n * @param {BBox|FeatureCollection|Feature} geojson feature(s) to retrieve BBox from\n * @returns {Object} converted to {minX, minY, maxX, maxY}\n */\n tree.toBBox = function (geojson) {\n var bbox;\n if (geojson.bbox) bbox = geojson.bbox;\n else if (Array.isArray(geojson) && geojson.length === 4) bbox = geojson;\n else if (Array.isArray(geojson) && geojson.length === 6)\n bbox = [geojson[0], geojson[1], geojson[3], geojson[4]];\n else if (geojson.type === \"Feature\") bbox = turfBBox(geojson);\n else if (geojson.type === \"FeatureCollection\") bbox = turfBBox(geojson);\n else throw new Error(\"invalid geojson\");\n\n return {\n minX: bbox[0],\n minY: bbox[1],\n maxX: bbox[2],\n maxY: bbox[3],\n };\n };\n return tree;\n}\n\nexport { geojsonRbush };\nexport default geojsonRbush;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-geojson-rbush/dist/cjs/index.cjs","../../index.js"],"names":[],"mappings":"AAAA;ACAA,4EAAkB;AAClB,wCAAkC;AAClC,kCAA4B;AAC5B,kCAAiC;AAiBjC,SAAS,YAAA,CAAa,UAAA,EAAY;AAChC,EAAA,IAAI,KAAA,EAAO,IAAI,oBAAA,CAAM,UAAU,CAAA;AAY/B,EAAA,IAAA,CAAK,OAAA,EAAS,QAAA,CAAU,OAAA,EAAS;AAC/B,IAAA,GAAA,CAAI,OAAA,CAAQ,KAAA,IAAS,SAAA,EAAW,MAAM,IAAI,KAAA,CAAM,iBAAiB,CAAA;AACjE,IAAA,OAAA,CAAQ,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,wBAAA,OAAgB,CAAA;AAC7D,IAAA,OAAO,eAAA,CAAM,SAAA,CAAU,MAAA,CAAO,IAAA,CAAK,IAAA,EAAM,OAAO,CAAA;AAAA,EAClD,CAAA;AAeA,EAAA,IAAA,CAAK,KAAA,EAAO,QAAA,CAAU,QAAA,EAAU;AAC9B,IAAA,IAAI,KAAA,EAAO,CAAC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QAAA,CAAU,OAAA,EAAS;AAC/B,IAAA,IAAI,IAAA;AACJ,IAAA,GAAA,CAAI,OAAA,CAAQ,IAAA,EAAM,KAAA,EAAO,OAAA,CAAQ,IAAA;AAAA,IAAA,KAAA,GAAA,CACxB,KAAA,CAAM,OAAA,CAAQ,OAAO,EAAA,GAAK,OAAA,CAAQ,OAAA,IAAW,CAAA,EAAG,KAAA,EAAO,OAAA;AAAA,IAAA,KAAA,GAAA,CACvD,KAAA,CAAM,OAAA,CAAQ,OAAO,EAAA,GAAK,OAAA,CAAQ,OAAA,IAAW,CAAA;AACpD,MAAA,KAAA,EAAO,CAAC,OAAA,CAAQ,CAAC,CAAA,EAAG,OAAA,CAAQ,CAAC,CAAA,EAAG,OAAA,CAAQ,CAAC,CAAA,EAAG,OAAA,CAAQ,CAAC,CAAC,CAAA;AAAA,IAAA,KAAA,GAAA,CAC/C,OAAA,CAAQ,KAAA,IAAS,SAAA,EAAW,KAAA,EAAO,wBAAA,OAAgB,CAAA;AAAA,IAAA,KAAA,GAAA,CACnD,OAAA,CAAQ,KAAA,IAAS,mBAAA,EAAqB,KAAA,EAAO,wBAAA,OAAgB,CAAA;AAAA,IAAA,KACjE,MAAM,IAAI,KAAA,CAAM,iBAAiB,CAAA;AAEtC,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,IAAA,CAAK,CAAC,CAAA;AAAA,MACZ,IAAA,EAAM,IAAA,CAAK,CAAC,CAAA;AAAA,MACZ,IAAA,EAAM,IAAA,CAAK,CAAC,CAAA;AAAA,MACZ,IAAA,EAAM,IAAA,CAAK,CAAC;AAAA,IACd,CAAA;AAAA,EACF,CAAA;AACA,EAAA,OAAO,IAAA;AACT;AAGA,IAAO,2BAAA,EAAQ,YAAA;ADlJf;AACE;AACA;AACF,kFAAC","file":"/home/runner/work/turf/turf/packages/turf-geojson-rbush/dist/cjs/index.cjs","sourcesContent":[null,"import rbush from \"rbush\";\nimport { featureCollection } from \"@turf/helpers\";\nimport { featureEach } from \"@turf/meta\";\nimport { bbox as turfBBox } from \"@turf/bbox\";\n\n/**\n * @module rbush\n */\n\n/**\n * GeoJSON implementation of [RBush](https://github.com/mourner/rbush#rbush) spatial index.\n *\n * @function rbush\n * @param {number} [maxEntries=9] defines the maximum number of entries in a tree node. 9 (used by default) is a\n * reasonable choice for most applications. Higher value means faster insertion and slower search, and vice versa.\n * @returns {RBush} GeoJSON RBush\n * @example\n * var geojsonRbush = require('geojson-rbush').default;\n * var tree = geojsonRbush();\n */\nfunction geojsonRbush(maxEntries) {\n var tree = new rbush(maxEntries);\n\n /**\n * [insert](https://github.com/mourner/rbush#data-format)\n *\n * @memberof rbush\n * @param {Feature} feature insert single GeoJSON Feature\n * @returns {RBush} GeoJSON RBush\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n * tree.insert(poly)\n */\n tree.insert = function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid feature\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n return rbush.prototype.insert.call(this, feature);\n };\n\n /**\n * [load](https://github.com/mourner/rbush#bulk-inserting-data)\n *\n * @memberof rbush\n * @param {FeatureCollection|Array<Feature>} features load entire GeoJSON FeatureCollection\n * @returns {RBush} GeoJSON RBush\n * @example\n * var polys = turf.polygons([\n * [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]],\n * [[[-93, 32], [-83, 32], [-83, 39], [-93, 39], [-93, 32]]]\n * ]);\n * tree.load(polys);\n */\n tree.load = function (features) {\n var load = [];\n // Load an Array of Features\n if (Array.isArray(features)) {\n features.forEach(function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid features\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n load.push(feature);\n });\n } else {\n // Load a FeatureCollection\n featureEach(features, function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid features\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n load.push(feature);\n });\n }\n return rbush.prototype.load.call(this, load);\n };\n\n /**\n * [remove](https://github.com/mourner/rbush#removing-data)\n *\n * @memberof rbush\n * @param {Feature} feature remove single GeoJSON Feature\n * @param {Function} equals Pass a custom equals function to compare by value for removal.\n * @returns {RBush} GeoJSON RBush\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.remove(poly);\n */\n tree.remove = function (feature, equals) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid feature\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n return rbush.prototype.remove.call(this, feature, equals);\n };\n\n /**\n * [clear](https://github.com/mourner/rbush#removing-data)\n *\n * @memberof rbush\n * @returns {RBush} GeoJSON Rbush\n * @example\n * tree.clear()\n */\n tree.clear = function () {\n return rbush.prototype.clear.call(this);\n };\n\n /**\n * [search](https://github.com/mourner/rbush#search)\n *\n * @memberof rbush\n * @param {BBox|FeatureCollection|Feature} geojson search with GeoJSON\n * @returns {FeatureCollection} all features that intersects with the given GeoJSON.\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.search(poly);\n */\n tree.search = function (geojson) {\n var features = rbush.prototype.search.call(this, this.toBBox(geojson));\n return featureCollection(features);\n };\n\n /**\n * [collides](https://github.com/mourner/rbush#collisions)\n *\n * @memberof rbush\n * @param {BBox|FeatureCollection|Feature} geojson collides with GeoJSON\n * @returns {boolean} true if there are any items intersecting the given GeoJSON, otherwise false.\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.collides(poly);\n */\n tree.collides = function (geojson) {\n return rbush.prototype.collides.call(this, this.toBBox(geojson));\n };\n\n /**\n * [all](https://github.com/mourner/rbush#search)\n *\n * @memberof rbush\n * @returns {FeatureCollection} all the features in RBush\n * @example\n * tree.all()\n */\n tree.all = function () {\n var features = rbush.prototype.all.call(this);\n return featureCollection(features);\n };\n\n /**\n * [toJSON](https://github.com/mourner/rbush#export-and-import)\n *\n * @memberof rbush\n * @returns {any} export data as JSON object\n * @example\n * var exported = tree.toJSON()\n */\n tree.toJSON = function () {\n return rbush.prototype.toJSON.call(this);\n };\n\n /**\n * [fromJSON](https://github.com/mourner/rbush#export-and-import)\n *\n * @memberof rbush\n * @param {any} json import previously exported data\n * @returns {RBush} GeoJSON RBush\n * @example\n * var exported = {\n * \"children\": [\n * {\n * \"type\": \"Feature\",\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 50]\n * },\n * \"properties\": {},\n * \"bbox\": [110, 50, 110, 50]\n * }\n * ],\n * \"height\": 1,\n * \"leaf\": true,\n * \"minX\": 110,\n * \"minY\": 50,\n * \"maxX\": 110,\n * \"maxY\": 50\n * }\n * tree.fromJSON(exported)\n */\n tree.fromJSON = function (json) {\n return rbush.prototype.fromJSON.call(this, json);\n };\n\n /**\n * Converts GeoJSON to {minX, minY, maxX, maxY} schema\n *\n * @memberof rbush\n * @private\n * @param {BBox|FeatureCollection|Feature} geojson feature(s) to retrieve BBox from\n * @returns {Object} converted to {minX, minY, maxX, maxY}\n */\n tree.toBBox = function (geojson) {\n var bbox;\n if (geojson.bbox) bbox = geojson.bbox;\n else if (Array.isArray(geojson) && geojson.length === 4) bbox = geojson;\n else if (Array.isArray(geojson) && geojson.length === 6)\n bbox = [geojson[0], geojson[1], geojson[3], geojson[4]];\n else if (geojson.type === \"Feature\") bbox = turfBBox(geojson);\n else if (geojson.type === \"FeatureCollection\") bbox = turfBBox(geojson);\n else throw new Error(\"invalid geojson\");\n\n return {\n minX: bbox[0],\n minY: bbox[1],\n maxX: bbox[2],\n maxY: bbox[3],\n };\n };\n return tree;\n}\n\nexport { geojsonRbush };\nexport default geojsonRbush;\n"]}
package/dist/esm/index.js CHANGED
@@ -6,8 +6,7 @@ import { bbox as turfBBox } from "@turf/bbox";
6
6
  function geojsonRbush(maxEntries) {
7
7
  var tree = new rbush(maxEntries);
8
8
  tree.insert = function(feature) {
9
- if (feature.type !== "Feature")
10
- throw new Error("invalid feature");
9
+ if (feature.type !== "Feature") throw new Error("invalid feature");
11
10
  feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
12
11
  return rbush.prototype.insert.call(this, feature);
13
12
  };
@@ -15,15 +14,13 @@ function geojsonRbush(maxEntries) {
15
14
  var load = [];
16
15
  if (Array.isArray(features)) {
17
16
  features.forEach(function(feature) {
18
- if (feature.type !== "Feature")
19
- throw new Error("invalid features");
17
+ if (feature.type !== "Feature") throw new Error("invalid features");
20
18
  feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
21
19
  load.push(feature);
22
20
  });
23
21
  } else {
24
22
  featureEach(features, function(feature) {
25
- if (feature.type !== "Feature")
26
- throw new Error("invalid features");
23
+ if (feature.type !== "Feature") throw new Error("invalid features");
27
24
  feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
28
25
  load.push(feature);
29
26
  });
@@ -31,8 +28,7 @@ function geojsonRbush(maxEntries) {
31
28
  return rbush.prototype.load.call(this, load);
32
29
  };
33
30
  tree.remove = function(feature, equals) {
34
- if (feature.type !== "Feature")
35
- throw new Error("invalid feature");
31
+ if (feature.type !== "Feature") throw new Error("invalid feature");
36
32
  feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
37
33
  return rbush.prototype.remove.call(this, feature, equals);
38
34
  };
@@ -58,18 +54,13 @@ function geojsonRbush(maxEntries) {
58
54
  };
59
55
  tree.toBBox = function(geojson) {
60
56
  var bbox;
61
- if (geojson.bbox)
62
- bbox = geojson.bbox;
63
- else if (Array.isArray(geojson) && geojson.length === 4)
64
- bbox = geojson;
57
+ if (geojson.bbox) bbox = geojson.bbox;
58
+ else if (Array.isArray(geojson) && geojson.length === 4) bbox = geojson;
65
59
  else if (Array.isArray(geojson) && geojson.length === 6)
66
60
  bbox = [geojson[0], geojson[1], geojson[3], geojson[4]];
67
- else if (geojson.type === "Feature")
68
- bbox = turfBBox(geojson);
69
- else if (geojson.type === "FeatureCollection")
70
- bbox = turfBBox(geojson);
71
- else
72
- throw new Error("invalid geojson");
61
+ else if (geojson.type === "Feature") bbox = turfBBox(geojson);
62
+ else if (geojson.type === "FeatureCollection") bbox = turfBBox(geojson);
63
+ else throw new Error("invalid geojson");
73
64
  return {
74
65
  minX: bbox[0],
75
66
  minY: bbox[1],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.js"],"sourcesContent":["import rbush from \"rbush\";\nimport { featureCollection } from \"@turf/helpers\";\nimport { featureEach } from \"@turf/meta\";\nimport { bbox as turfBBox } from \"@turf/bbox\";\n\n/**\n * @module rbush\n */\n\n/**\n * GeoJSON implementation of [RBush](https://github.com/mourner/rbush#rbush) spatial index.\n *\n * @name rbush\n * @param {number} [maxEntries=9] defines the maximum number of entries in a tree node. 9 (used by default) is a\n * reasonable choice for most applications. Higher value means faster insertion and slower search, and vice versa.\n * @returns {RBush} GeoJSON RBush\n * @example\n * var geojsonRbush = require('geojson-rbush').default;\n * var tree = geojsonRbush();\n */\nfunction geojsonRbush(maxEntries) {\n var tree = new rbush(maxEntries);\n\n /**\n * [insert](https://github.com/mourner/rbush#data-format)\n *\n * @memberof rbush\n * @param {Feature} feature insert single GeoJSON Feature\n * @returns {RBush} GeoJSON RBush\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n * tree.insert(poly)\n */\n tree.insert = function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid feature\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n return rbush.prototype.insert.call(this, feature);\n };\n\n /**\n * [load](https://github.com/mourner/rbush#bulk-inserting-data)\n *\n * @memberof rbush\n * @param {FeatureCollection|Array<Feature>} features load entire GeoJSON FeatureCollection\n * @returns {RBush} GeoJSON RBush\n * @example\n * var polys = turf.polygons([\n * [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]],\n * [[[-93, 32], [-83, 32], [-83, 39], [-93, 39], [-93, 32]]]\n * ]);\n * tree.load(polys);\n */\n tree.load = function (features) {\n var load = [];\n // Load an Array of Features\n if (Array.isArray(features)) {\n features.forEach(function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid features\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n load.push(feature);\n });\n } else {\n // Load a FeatureCollection\n featureEach(features, function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid features\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n load.push(feature);\n });\n }\n return rbush.prototype.load.call(this, load);\n };\n\n /**\n * [remove](https://github.com/mourner/rbush#removing-data)\n *\n * @memberof rbush\n * @param {Feature} feature remove single GeoJSON Feature\n * @param {Function} equals Pass a custom equals function to compare by value for removal.\n * @returns {RBush} GeoJSON RBush\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.remove(poly);\n */\n tree.remove = function (feature, equals) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid feature\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n return rbush.prototype.remove.call(this, feature, equals);\n };\n\n /**\n * [clear](https://github.com/mourner/rbush#removing-data)\n *\n * @memberof rbush\n * @returns {RBush} GeoJSON Rbush\n * @example\n * tree.clear()\n */\n tree.clear = function () {\n return rbush.prototype.clear.call(this);\n };\n\n /**\n * [search](https://github.com/mourner/rbush#search)\n *\n * @memberof rbush\n * @param {BBox|FeatureCollection|Feature} geojson search with GeoJSON\n * @returns {FeatureCollection} all features that intersects with the given GeoJSON.\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.search(poly);\n */\n tree.search = function (geojson) {\n var features = rbush.prototype.search.call(this, this.toBBox(geojson));\n return featureCollection(features);\n };\n\n /**\n * [collides](https://github.com/mourner/rbush#collisions)\n *\n * @memberof rbush\n * @param {BBox|FeatureCollection|Feature} geojson collides with GeoJSON\n * @returns {boolean} true if there are any items intersecting the given GeoJSON, otherwise false.\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.collides(poly);\n */\n tree.collides = function (geojson) {\n return rbush.prototype.collides.call(this, this.toBBox(geojson));\n };\n\n /**\n * [all](https://github.com/mourner/rbush#search)\n *\n * @memberof rbush\n * @returns {FeatureCollection} all the features in RBush\n * @example\n * tree.all()\n */\n tree.all = function () {\n var features = rbush.prototype.all.call(this);\n return featureCollection(features);\n };\n\n /**\n * [toJSON](https://github.com/mourner/rbush#export-and-import)\n *\n * @memberof rbush\n * @returns {any} export data as JSON object\n * @example\n * var exported = tree.toJSON()\n */\n tree.toJSON = function () {\n return rbush.prototype.toJSON.call(this);\n };\n\n /**\n * [fromJSON](https://github.com/mourner/rbush#export-and-import)\n *\n * @memberof rbush\n * @param {any} json import previously exported data\n * @returns {RBush} GeoJSON RBush\n * @example\n * var exported = {\n * \"children\": [\n * {\n * \"type\": \"Feature\",\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 50]\n * },\n * \"properties\": {},\n * \"bbox\": [110, 50, 110, 50]\n * }\n * ],\n * \"height\": 1,\n * \"leaf\": true,\n * \"minX\": 110,\n * \"minY\": 50,\n * \"maxX\": 110,\n * \"maxY\": 50\n * }\n * tree.fromJSON(exported)\n */\n tree.fromJSON = function (json) {\n return rbush.prototype.fromJSON.call(this, json);\n };\n\n /**\n * Converts GeoJSON to {minX, minY, maxX, maxY} schema\n *\n * @memberof rbush\n * @private\n * @param {BBox|FeatureCollection|Feature} geojson feature(s) to retrieve BBox from\n * @returns {Object} converted to {minX, minY, maxX, maxY}\n */\n tree.toBBox = function (geojson) {\n var bbox;\n if (geojson.bbox) bbox = geojson.bbox;\n else if (Array.isArray(geojson) && geojson.length === 4) bbox = geojson;\n else if (Array.isArray(geojson) && geojson.length === 6)\n bbox = [geojson[0], geojson[1], geojson[3], geojson[4]];\n else if (geojson.type === \"Feature\") bbox = turfBBox(geojson);\n else if (geojson.type === \"FeatureCollection\") bbox = turfBBox(geojson);\n else throw new Error(\"invalid geojson\");\n\n return {\n minX: bbox[0],\n minY: bbox[1],\n maxX: bbox[2],\n maxY: bbox[3],\n };\n };\n return tree;\n}\n\nexport { geojsonRbush };\nexport default geojsonRbush;\n"],"mappings":";AAAA,OAAO,WAAW;AAClB,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,gBAAgB;AAiBjC,SAAS,aAAa,YAAY;AAChC,MAAI,OAAO,IAAI,MAAM,UAAU;AAY/B,OAAK,SAAS,SAAU,SAAS;AAC/B,QAAI,QAAQ,SAAS;AAAW,YAAM,IAAI,MAAM,iBAAiB;AACjE,YAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO;AAC7D,WAAO,MAAM,UAAU,OAAO,KAAK,MAAM,OAAO;AAAA,EAClD;AAeA,OAAK,OAAO,SAAU,UAAU;AAC9B,QAAI,OAAO,CAAC;AAEZ,QAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,eAAS,QAAQ,SAAU,SAAS;AAClC,YAAI,QAAQ,SAAS;AAAW,gBAAM,IAAI,MAAM,kBAAkB;AAClE,gBAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO;AAC7D,aAAK,KAAK,OAAO;AAAA,MACnB,CAAC;AAAA,IACH,OAAO;AAEL,kBAAY,UAAU,SAAU,SAAS;AACvC,YAAI,QAAQ,SAAS;AAAW,gBAAM,IAAI,MAAM,kBAAkB;AAClE,gBAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO;AAC7D,aAAK,KAAK,OAAO;AAAA,MACnB,CAAC;AAAA,IACH;AACA,WAAO,MAAM,UAAU,KAAK,KAAK,MAAM,IAAI;AAAA,EAC7C;AAcA,OAAK,SAAS,SAAU,SAAS,QAA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AAEtC,WAAO;AAAA,MACL,MAAM,KAAK,CAAC;AAAA,MACZ,MAAM,KAAK,CAAC;AAAA,MACZ,MAAM,KAAK,CAAC;AAAA,MACZ,MAAM,KAAK,CAAC;AAAA,IACd;AAAA,EACF;AACA,SAAO;AACT;AAGA,IAAO,6BAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.js"],"sourcesContent":["import rbush from \"rbush\";\nimport { featureCollection } from \"@turf/helpers\";\nimport { featureEach } from \"@turf/meta\";\nimport { bbox as turfBBox } from \"@turf/bbox\";\n\n/**\n * @module rbush\n */\n\n/**\n * GeoJSON implementation of [RBush](https://github.com/mourner/rbush#rbush) spatial index.\n *\n * @function rbush\n * @param {number} [maxEntries=9] defines the maximum number of entries in a tree node. 9 (used by default) is a\n * reasonable choice for most applications. Higher value means faster insertion and slower search, and vice versa.\n * @returns {RBush} GeoJSON RBush\n * @example\n * var geojsonRbush = require('geojson-rbush').default;\n * var tree = geojsonRbush();\n */\nfunction geojsonRbush(maxEntries) {\n var tree = new rbush(maxEntries);\n\n /**\n * [insert](https://github.com/mourner/rbush#data-format)\n *\n * @memberof rbush\n * @param {Feature} feature insert single GeoJSON Feature\n * @returns {RBush} GeoJSON RBush\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n * tree.insert(poly)\n */\n tree.insert = function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid feature\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n return rbush.prototype.insert.call(this, feature);\n };\n\n /**\n * [load](https://github.com/mourner/rbush#bulk-inserting-data)\n *\n * @memberof rbush\n * @param {FeatureCollection|Array<Feature>} features load entire GeoJSON FeatureCollection\n * @returns {RBush} GeoJSON RBush\n * @example\n * var polys = turf.polygons([\n * [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]],\n * [[[-93, 32], [-83, 32], [-83, 39], [-93, 39], [-93, 32]]]\n * ]);\n * tree.load(polys);\n */\n tree.load = function (features) {\n var load = [];\n // Load an Array of Features\n if (Array.isArray(features)) {\n features.forEach(function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid features\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n load.push(feature);\n });\n } else {\n // Load a FeatureCollection\n featureEach(features, function (feature) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid features\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n load.push(feature);\n });\n }\n return rbush.prototype.load.call(this, load);\n };\n\n /**\n * [remove](https://github.com/mourner/rbush#removing-data)\n *\n * @memberof rbush\n * @param {Feature} feature remove single GeoJSON Feature\n * @param {Function} equals Pass a custom equals function to compare by value for removal.\n * @returns {RBush} GeoJSON RBush\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.remove(poly);\n */\n tree.remove = function (feature, equals) {\n if (feature.type !== \"Feature\") throw new Error(\"invalid feature\");\n feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);\n return rbush.prototype.remove.call(this, feature, equals);\n };\n\n /**\n * [clear](https://github.com/mourner/rbush#removing-data)\n *\n * @memberof rbush\n * @returns {RBush} GeoJSON Rbush\n * @example\n * tree.clear()\n */\n tree.clear = function () {\n return rbush.prototype.clear.call(this);\n };\n\n /**\n * [search](https://github.com/mourner/rbush#search)\n *\n * @memberof rbush\n * @param {BBox|FeatureCollection|Feature} geojson search with GeoJSON\n * @returns {FeatureCollection} all features that intersects with the given GeoJSON.\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.search(poly);\n */\n tree.search = function (geojson) {\n var features = rbush.prototype.search.call(this, this.toBBox(geojson));\n return featureCollection(features);\n };\n\n /**\n * [collides](https://github.com/mourner/rbush#collisions)\n *\n * @memberof rbush\n * @param {BBox|FeatureCollection|Feature} geojson collides with GeoJSON\n * @returns {boolean} true if there are any items intersecting the given GeoJSON, otherwise false.\n * @example\n * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);\n *\n * tree.collides(poly);\n */\n tree.collides = function (geojson) {\n return rbush.prototype.collides.call(this, this.toBBox(geojson));\n };\n\n /**\n * [all](https://github.com/mourner/rbush#search)\n *\n * @memberof rbush\n * @returns {FeatureCollection} all the features in RBush\n * @example\n * tree.all()\n */\n tree.all = function () {\n var features = rbush.prototype.all.call(this);\n return featureCollection(features);\n };\n\n /**\n * [toJSON](https://github.com/mourner/rbush#export-and-import)\n *\n * @memberof rbush\n * @returns {any} export data as JSON object\n * @example\n * var exported = tree.toJSON()\n */\n tree.toJSON = function () {\n return rbush.prototype.toJSON.call(this);\n };\n\n /**\n * [fromJSON](https://github.com/mourner/rbush#export-and-import)\n *\n * @memberof rbush\n * @param {any} json import previously exported data\n * @returns {RBush} GeoJSON RBush\n * @example\n * var exported = {\n * \"children\": [\n * {\n * \"type\": \"Feature\",\n * \"geometry\": {\n * \"type\": \"Point\",\n * \"coordinates\": [110, 50]\n * },\n * \"properties\": {},\n * \"bbox\": [110, 50, 110, 50]\n * }\n * ],\n * \"height\": 1,\n * \"leaf\": true,\n * \"minX\": 110,\n * \"minY\": 50,\n * \"maxX\": 110,\n * \"maxY\": 50\n * }\n * tree.fromJSON(exported)\n */\n tree.fromJSON = function (json) {\n return rbush.prototype.fromJSON.call(this, json);\n };\n\n /**\n * Converts GeoJSON to {minX, minY, maxX, maxY} schema\n *\n * @memberof rbush\n * @private\n * @param {BBox|FeatureCollection|Feature} geojson feature(s) to retrieve BBox from\n * @returns {Object} converted to {minX, minY, maxX, maxY}\n */\n tree.toBBox = function (geojson) {\n var bbox;\n if (geojson.bbox) bbox = geojson.bbox;\n else if (Array.isArray(geojson) && geojson.length === 4) bbox = geojson;\n else if (Array.isArray(geojson) && geojson.length === 6)\n bbox = [geojson[0], geojson[1], geojson[3], geojson[4]];\n else if (geojson.type === \"Feature\") bbox = turfBBox(geojson);\n else if (geojson.type === \"FeatureCollection\") bbox = turfBBox(geojson);\n else throw new Error(\"invalid geojson\");\n\n return {\n minX: bbox[0],\n minY: bbox[1],\n maxX: bbox[2],\n maxY: bbox[3],\n };\n };\n return tree;\n}\n\nexport { geojsonRbush };\nexport default geojsonRbush;\n"],"mappings":";AAAA,OAAO,WAAW;AAClB,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,gBAAgB;AAiBjC,SAAS,aAAa,YAAY;AAChC,MAAI,OAAO,IAAI,MAAM,UAAU;AAY/B,OAAK,SAAS,SAAU,SAAS;AAC/B,QAAI,QAAQ,SAAS,UAAW,OAAM,IAAI,MAAM,iBAAiB;AACjE,YAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO;AAC7D,WAAO,MAAM,UAAU,OAAO,KAAK,MAAM,OAAO;AAAA,EAClD;AAeA,OAAK,OAAO,SAAU,UAAU;AAC9B,QAAI,OAAO,CAAC;AAEZ,QAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,eAAS,QAAQ,SAAU,SAAS;AAClC,YAAI,QAAQ,SAAS,UAAW,OAAM,IAAI,MAAM,kBAAkB;AAClE,gBAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO;AAC7D,aAAK,KAAK,OAAO;AAAA,MACnB,CAAC;AAAA,IACH,OAAO;AAEL,kBAAY,UAAU,SAAU,SAAS;AACvC,YAAI,QAAQ,SAAS,UAAW,OAAM,IAAI,MAAM,kBAAkB;AAClE,gBAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO;AAC7D,aAAK,KAAK,OAAO;AAAA,MACnB,CAAC;AAAA,IACH;AACA,WAAO,MAAM,UAAU,KAAK,KAAK,MAAM,IAAI;AAAA,EAC7C;AAcA,OAAK,SAAS,SAAU,SAAS,QAAQ;AACvC,QAAI,QAAQ,SAAS,UAAW,OAAM,IAAI,MAAM,iBAAiB;AACjE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,CAAC;AAAA,MACZ,MAAM,KAAK,CAAC;AAAA,MACZ,MAAM,KAAK,CAAC;AAAA,IACd;AAAA,EACF;AACA,SAAO;AACT;AAGA,IAAO,6BAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/geojson-rbush",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "GeoJSON implementation of RBush",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -58,25 +58,25 @@
58
58
  "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
59
59
  },
60
60
  "devDependencies": {
61
- "@turf/bbox-polygon": "^7.1.0",
62
- "@turf/random": "^7.1.0",
61
+ "@turf/bbox-polygon": "^7.2.0",
62
+ "@turf/random": "^7.2.0",
63
63
  "@types/benchmark": "^2.1.5",
64
- "@types/tape": "^4.2.32",
64
+ "@types/tape": "^4.13.4",
65
65
  "benchmark": "^2.1.4",
66
66
  "load-json-file": "^7.0.1",
67
67
  "npm-run-all": "^4.1.5",
68
- "tape": "^5.7.2",
69
- "tsup": "^8.0.1",
70
- "tsx": "^4.6.2",
68
+ "tape": "^5.9.0",
69
+ "tsup": "^8.3.5",
70
+ "tsx": "^4.19.2",
71
71
  "typescript": "^5.2.2",
72
72
  "write-json-file": "^5.0.0"
73
73
  },
74
74
  "dependencies": {
75
- "@turf/bbox": "^7.1.0",
76
- "@turf/helpers": "^7.1.0",
77
- "@turf/meta": "^7.1.0",
75
+ "@turf/bbox": "^7.2.0",
76
+ "@turf/helpers": "^7.2.0",
77
+ "@turf/meta": "^7.2.0",
78
78
  "@types/geojson": "^7946.0.10",
79
79
  "rbush": "^3.0.1"
80
80
  },
81
- "gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
81
+ "gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
82
82
  }