Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options: {mutate?: boolean} = {},
): Feature | null {
// Optional parameters
options = options || {};
if (!isObject(options)) { throw new Error("options is invalid"); }
const mutate = options.mutate;
// Validation
if (getType(geojson) !== "FeatureCollection") { throw new Error("geojson must be a FeatureCollection"); }
if (!geojson.features.length) { throw new Error("geojson is empty"); }
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) { geojson = clone(geojson); }
const result: any[] = [];
const lastLine = lineReduce(geojson, (previousLine: any, currentLine: any) => {
// Attempt to merge this LineString with the other LineStrings, updating
// the reference as it is merged with others and grows.
const merged = mergeLineStrings(previousLine, currentLine);
// Accumulate the merged LineString
if (merged) { return merged;
// Put the unmerged LineString back into the list
} else {
result.push(previousLine);
return currentLine;
}
});
// Append the last line
if (lastLine) { result.push(lastLine); }
// Return null if no lines were dissolved
options: {mutate?: boolean} = {},
): Feature | null {
// Optional parameters
options = options || {};
if (!isObject(options)) { throw new Error("options is invalid"); }
const mutate = options.mutate;
// Validation
if (getType(geojson) !== "FeatureCollection") { throw new Error("geojson must be a FeatureCollection"); }
if (!geojson.features.length) { throw new Error("geojson is empty"); }
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) { geojson = clone(geojson); }
const result: any[] = [];
const lastLine = lineReduce(geojson, (previousLine: any, currentLine: any) => {
// Attempt to merge this LineString with the other LineStrings, updating
// the reference as it is merged with others and grows.
const merged = mergeLineStrings(previousLine, currentLine);
// Accumulate the merged LineString
if (merged) { return merged;
// Put the unmerged LineString back into the list
} else {
result.push(previousLine);
return currentLine;
}
});
// Append the last line
if (lastLine) { result.push(lastLine); }
// Return null if no lines were dissolved
throw new Error("options is invalid");
}
var mutate = options.mutate;
// Validation
if (invariant_1.getType(geojson) !== "FeatureCollection") {
throw new Error("geojson must be a FeatureCollection");
}
if (!geojson.features.length) {
throw new Error("geojson is empty");
}
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) {
geojson = clone_1.default(geojson);
}
var result = [];
var lastLine = meta_1.lineReduce(geojson, function (previousLine, currentLine) {
// Attempt to merge this LineString with the other LineStrings, updating
// the reference as it is merged with others and grows.
var merged = mergeLineStrings(previousLine, currentLine);
// Accumulate the merged LineString
if (merged) {
return merged;
// Put the unmerged LineString back into the list
}
else {
result.push(previousLine);
return currentLine;
}
});
// Append the last line
if (lastLine) {
result.push(lastLine);