@turf/sample 7.2.0 → 7.3.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.
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +8 -8
package/dist/cjs/index.cjs
CHANGED
|
@@ -17,9 +17,9 @@ function getRandomSubarray(arr, size) {
|
|
|
17
17
|
}
|
|
18
18
|
return shuffled.slice(min);
|
|
19
19
|
}
|
|
20
|
-
var
|
|
20
|
+
var index_default = sample;
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
exports.default =
|
|
24
|
+
exports.default = index_default; exports.sample = sample;
|
|
25
25
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-sample/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACEA,wCAAkC;AAqBlC,SAAS,MAAA,CACP,EAAA,EACA,GAAA,EACsB;AACtB,EAAA,GAAA,CAAI,CAAC,EAAA,EAAI,MAAM,IAAI,KAAA,CAAM,gBAAgB,CAAA;AACzC,EAAA,GAAA,CAAI,IAAA,IAAQ,KAAA,GAAQ,IAAA,IAAQ,KAAA,CAAA,EAAW,MAAM,IAAI,KAAA,CAAM,iBAAiB,CAAA;AACxE,EAAA,GAAA,CAAI,OAAO,IAAA,IAAQ,QAAA,EAAU,MAAM,IAAI,KAAA,CAAM,sBAAsB,CAAA;AACnE,EAAA,IAAI,MAAA,EAAQ,wCAAA,iBAAkB,CAAkB,EAAA,CAAG,QAAA,EAAU,GAAG,CAAC,CAAA;AACjE,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,iBAAA,CACP,GAAA,EACA,IAAA,EACA;AACA,EAAA,IAAI,SAAA,EAAW,GAAA,CAAI,KAAA,C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AAA,EAAI,GAAA,CAAI,MAAA,EACR,IAAA,EAAM,EAAA,EAAI,IAAA,EACV,IAAA,EACA,KAAA;AACF,EAAA,MAAA,CAAO,CAAA,GAAA,EAAM,GAAA,EAAK;AAChB,IAAA,MAAA,EAAQ,IAAA,CAAK,KAAA,CAAA,CAAO,EAAA,EAAI,CAAA,EAAA,EAAK,IAAA,CAAK,MAAA,CAAO,CAAC,CAAA;AAC1C,IAAA,KAAA,EAAO,QAAA,CAAS,KAAK,CAAA;AACrB,IAAA,QAAA,CAAS,KAAK,EAAA,EAAI,QAAA,CAAS,CAAC,CAAA;AAC5B,IAAA,QAAA,CAAS,CAAC,EAAA,EAAI,IAAA;AAAA,EAChB;AACA,EAAA,OAAO,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA;AAC3B;AAGA,IAAO,cAAA,EAAQ,MAAA;ADjCf;AACE;AACA;AACF,yDAAC","file":"/home/runner/work/turf/turf/packages/turf-sample/dist/cjs/index.cjs","sourcesContent":[null,"// http://stackoverflow.com/questions/11935175/sampling-a-random-subset-from-an-array\nimport { Feature, FeatureCollection, Geometry, GeometryObject } from \"geojson\";\nimport { featureCollection } from \"@turf/helpers\";\n\n/**\n * Takes a {@link FeatureCollection} and returns a FeatureCollection with given number of {@link Feature|features} at random.\n *\n * @function\n * @param {FeatureCollection} featurecollection set of input features\n * @param {number} num number of features to select\n * @returns {FeatureCollection} a FeatureCollection with `n` features\n * @example\n * var points = turf.randomPoint(100, {bbox: [-80, 30, -60, 60]});\n *\n * var sample = turf.sample(points, 5);\n *\n * //addToMap\n * var addToMap = [points, sample]\n * turf.featureEach(sample, function (currentFeature) {\n * currentFeature.properties['marker-size'] = 'large';\n * currentFeature.properties['marker-color'] = '#000';\n * });\n */\nfunction sample<T extends GeometryObject>(\n fc: FeatureCollection<T>,\n num: number\n): FeatureCollection<T> {\n if (!fc) throw new Error(\"fc is required\");\n if (num === null || num === undefined) throw new Error(\"num is required\");\n if (typeof num !== \"number\") throw new Error(\"num must be a number\");\n var outFC = featureCollection(getRandomSubarray(fc.features, num));\n return outFC;\n}\n\nfunction getRandomSubarray<T extends Geometry>(\n arr: Feature<T>[],\n size: number\n) {\n var shuffled = arr.slice(0),\n i = arr.length,\n min = i - size,\n temp,\n index;\n while (i-- > min) {\n index = Math.floor((i + 1) * Math.random());\n temp = shuffled[index];\n shuffled[index] = shuffled[i];\n shuffled[i] = temp;\n }\n return shuffled.slice(min);\n}\n\nexport { sample };\nexport default sample;\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -17,9 +17,9 @@ function getRandomSubarray(arr, size) {
|
|
|
17
17
|
}
|
|
18
18
|
return shuffled.slice(min);
|
|
19
19
|
}
|
|
20
|
-
var
|
|
20
|
+
var index_default = sample;
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
index_default as default,
|
|
23
23
|
sample
|
|
24
24
|
};
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["// http://stackoverflow.com/questions/11935175/sampling-a-random-subset-from-an-array\nimport { Feature, FeatureCollection, Geometry, GeometryObject } from \"geojson\";\nimport { featureCollection } from \"@turf/helpers\";\n\n/**\n * Takes a {@link FeatureCollection} and returns a FeatureCollection with given number of {@link Feature|features} at random.\n *\n * @function\n * @param {FeatureCollection} featurecollection set of input features\n * @param {number} num number of features to select\n * @returns {FeatureCollection} a FeatureCollection with `n` features\n * @example\n * var points = turf.randomPoint(100, {bbox: [-80, 30, -60, 60]});\n *\n * var sample = turf.sample(points, 5);\n *\n * //addToMap\n * var addToMap = [points, sample]\n * turf.featureEach(sample, function (currentFeature) {\n * currentFeature.properties['marker-size'] = 'large';\n * currentFeature.properties['marker-color'] = '#000';\n * });\n */\nfunction sample<T extends GeometryObject>(\n fc: FeatureCollection<T>,\n num: number\n): FeatureCollection<T> {\n if (!fc) throw new Error(\"fc is required\");\n if (num === null || num === undefined) throw new Error(\"num is required\");\n if (typeof num !== \"number\") throw new Error(\"num must be a number\");\n var outFC = featureCollection(getRandomSubarray(fc.features, num));\n return outFC;\n}\n\nfunction getRandomSubarray<T extends Geometry>(\n arr: Feature<T>[],\n size: number\n) {\n var shuffled = arr.slice(0),\n i = arr.length,\n min = i - size,\n temp,\n index;\n while (i-- > min) {\n index = Math.floor((i + 1) * Math.random());\n temp = shuffled[index];\n shuffled[index] = shuffled[i];\n shuffled[i] = temp;\n }\n return shuffled.slice(min);\n}\n\nexport { sample };\nexport default sample;\n"],"mappings":";AAEA,SAAS,yBAAyB;AAqBlC,SAAS,OACP,IACA,KACsB;AACtB,MAAI,CAAC,GAAI,OAAM,IAAI,MAAM,gBAAgB;AACzC,MAAI,QAAQ,QAAQ,QAAQ,OAAW,OAAM,IAAI,MAAM,iBAAiB;AACxE,MAAI,OAAO,QAAQ,SAAU,OAAM,IAAI,MAAM,sBAAsB;AACnE,MAAI,QAAQ,kBAAkB,kBAAkB,GAAG,UAAU,GAAG,CAAC;AACjE,SAAO;AACT;AAEA,SAAS,kBACP,KACA,MACA;AACA,MAAI,WAAW,IAAI,MAAM,CAAC,GACxB,IAAI,IAAI,QACR,MAAM,IAAI,MACV,MACA;AACF,SAAO,MAAM,KAAK;AAChB,YAAQ,KAAK,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC;AAC1C,WAAO,SAAS,KAAK;AACrB,aAAS,KAAK,IAAI,SAAS,CAAC;AAC5B,aAAS,CAAC,IAAI;AAAA,EAChB;AACA,SAAO,SAAS,MAAM,GAAG;AAC3B;AAGA,IAAO,
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["// http://stackoverflow.com/questions/11935175/sampling-a-random-subset-from-an-array\nimport { Feature, FeatureCollection, Geometry, GeometryObject } from \"geojson\";\nimport { featureCollection } from \"@turf/helpers\";\n\n/**\n * Takes a {@link FeatureCollection} and returns a FeatureCollection with given number of {@link Feature|features} at random.\n *\n * @function\n * @param {FeatureCollection} featurecollection set of input features\n * @param {number} num number of features to select\n * @returns {FeatureCollection} a FeatureCollection with `n` features\n * @example\n * var points = turf.randomPoint(100, {bbox: [-80, 30, -60, 60]});\n *\n * var sample = turf.sample(points, 5);\n *\n * //addToMap\n * var addToMap = [points, sample]\n * turf.featureEach(sample, function (currentFeature) {\n * currentFeature.properties['marker-size'] = 'large';\n * currentFeature.properties['marker-color'] = '#000';\n * });\n */\nfunction sample<T extends GeometryObject>(\n fc: FeatureCollection<T>,\n num: number\n): FeatureCollection<T> {\n if (!fc) throw new Error(\"fc is required\");\n if (num === null || num === undefined) throw new Error(\"num is required\");\n if (typeof num !== \"number\") throw new Error(\"num must be a number\");\n var outFC = featureCollection(getRandomSubarray(fc.features, num));\n return outFC;\n}\n\nfunction getRandomSubarray<T extends Geometry>(\n arr: Feature<T>[],\n size: number\n) {\n var shuffled = arr.slice(0),\n i = arr.length,\n min = i - size,\n temp,\n index;\n while (i-- > min) {\n index = Math.floor((i + 1) * Math.random());\n temp = shuffled[index];\n shuffled[index] = shuffled[i];\n shuffled[i] = temp;\n }\n return shuffled.slice(min);\n}\n\nexport { sample };\nexport default sample;\n"],"mappings":";AAEA,SAAS,yBAAyB;AAqBlC,SAAS,OACP,IACA,KACsB;AACtB,MAAI,CAAC,GAAI,OAAM,IAAI,MAAM,gBAAgB;AACzC,MAAI,QAAQ,QAAQ,QAAQ,OAAW,OAAM,IAAI,MAAM,iBAAiB;AACxE,MAAI,OAAO,QAAQ,SAAU,OAAM,IAAI,MAAM,sBAAsB;AACnE,MAAI,QAAQ,kBAAkB,kBAAkB,GAAG,UAAU,GAAG,CAAC;AACjE,SAAO;AACT;AAEA,SAAS,kBACP,KACA,MACA;AACA,MAAI,WAAW,IAAI,MAAM,CAAC,GACxB,IAAI,IAAI,QACR,MAAM,IAAI,MACV,MACA;AACF,SAAO,MAAM,KAAK;AAChB,YAAQ,KAAK,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC;AAC1C,WAAO,SAAS,KAAK;AACrB,aAAS,KAAK,IAAI,SAAS,CAAC;AAC5B,aAAS,CAAC,IAAI;AAAA,EAChB;AACA,SAAO,SAAS,MAAM,GAAG;AAC3B;AAGA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/sample",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.3.0",
|
|
4
|
+
"description": "Takes a FeatureCollection and returns a FeatureCollection with given number of features at random.",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bugs": {
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/benchmark": "^2.1.5",
|
|
55
|
-
"@types/tape": "^
|
|
55
|
+
"@types/tape": "^5.8.1",
|
|
56
56
|
"benchmark": "^2.1.4",
|
|
57
57
|
"npm-run-all": "^4.1.5",
|
|
58
58
|
"tape": "^5.9.0",
|
|
59
|
-
"tsup": "^8.
|
|
60
|
-
"tsx": "^4.19.
|
|
61
|
-
"typescript": "^5.
|
|
59
|
+
"tsup": "^8.4.0",
|
|
60
|
+
"tsx": "^4.19.4",
|
|
61
|
+
"typescript": "^5.8.3"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@turf/helpers": "
|
|
64
|
+
"@turf/helpers": "7.3.0",
|
|
65
65
|
"@types/geojson": "^7946.0.10",
|
|
66
66
|
"tslib": "^2.8.1"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "9f58a103e8f9a587ab640307ed03ba5233913ddd"
|
|
69
69
|
}
|