wkt-parser-helper
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -1,2 +0,3 @@ | ||
import { GeoJSON, GeoJsonProperties, Feature, Geometry, FeatureCollection } from 'geojson'; | ||
import { Geometry, Feature, FeatureCollection, GeoJSON, GeoJsonProperties } from 'geojson'; | ||
/** | ||
@@ -9,3 +10,3 @@ * Converts GeoJSON Geometry to WKT | ||
*/ | ||
export declare function convertGeometryToWK(geojson: Geometry): string; | ||
declare function convertGeometryToWK(geojson: Geometry): string; | ||
/** | ||
@@ -18,3 +19,3 @@ * Converts GeoJSON Feature to WKT | ||
*/ | ||
export declare function convertFeatureToWK(geojson: Feature): string; | ||
declare function convertFeatureToWK(geojson: Feature): string; | ||
/** | ||
@@ -26,3 +27,3 @@ * Converts a GeoJSON FeatureCollection to WKT GeometryCollection | ||
*/ | ||
export declare function convertFeatureCollection(featureCollection: FeatureCollection): string; | ||
declare function convertFeatureCollection(featureCollection: FeatureCollection): string; | ||
/** | ||
@@ -35,3 +36,3 @@ * Shorthand to convert GeoJSON Features, Geometries or FeatureCollections to WKT or WKB | ||
*/ | ||
export declare function convertToWK(geojson: GeoJSON): string; | ||
declare function convertToWK(geojson: GeoJSON): string; | ||
/** | ||
@@ -46,2 +47,4 @@ * Parse a WKT or WKB into a GeoJSON Feature or Geometry | ||
*/ | ||
export declare function parseFromWK(item: string, asFeature?: boolean, properties?: GeoJsonProperties): Feature | Geometry; | ||
declare function parseFromWK(item: string, asFeature?: boolean, properties?: GeoJsonProperties): Feature | Geometry; | ||
export { convertFeatureCollection, convertFeatureToWK, convertGeometryToWK, convertToWK, parseFromWK }; |
@@ -1,2 +0,71 @@ | ||
var e=require("wellknown");function r(r){return e.stringify(r)}function t(e){return r(e.geometry)}function o(e){if("FeatureCollection"!==e.type)throw new Error("GeoJSON is not a FeatureCollection");return"GEOMETRYCOLLECTION("+e.features.map(function(e){return t(e)}).join(",")+")"}exports.convertFeatureCollection=o,exports.convertFeatureToWK=t,exports.convertGeometryToWK=r,exports.convertToWK=function(e){switch(e.type){case"Feature":return t(e);case"FeatureCollection":return o(e);default:return r(e)}},exports.parseFromWK=function(r,t,o){void 0===t&&(t=!1),void 0===o&&(o={});var n=e.parse(r);return t?{type:"Feature",geometry:n,properties:o}:n}; | ||
//# sourceMappingURL=index.js.map | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
convertFeatureCollection: () => convertFeatureCollection, | ||
convertFeatureToWK: () => convertFeatureToWK, | ||
convertGeometryToWK: () => convertGeometryToWK, | ||
convertToWK: () => convertToWK, | ||
parseFromWK: () => parseFromWK | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var import_wellknown = require("wellknown"); | ||
function convertGeometryToWK(geojson) { | ||
return (0, import_wellknown.stringify)(geojson); | ||
} | ||
function convertFeatureToWK(geojson) { | ||
return convertGeometryToWK(geojson.geometry); | ||
} | ||
function convertFeatureCollection(featureCollection) { | ||
if (featureCollection.type !== "FeatureCollection") { | ||
throw new Error("GeoJSON is not a FeatureCollection"); | ||
} | ||
return `GEOMETRYCOLLECTION(${featureCollection.features.map((d) => convertFeatureToWK(d)).join(",")})`; | ||
} | ||
function convertToWK(geojson) { | ||
switch (geojson.type) { | ||
case "Feature": | ||
return convertFeatureToWK(geojson); | ||
case "FeatureCollection": | ||
return convertFeatureCollection(geojson); | ||
default: | ||
return convertGeometryToWK(geojson); | ||
} | ||
} | ||
function parseFromWK(item, asFeature = false, properties = {}) { | ||
const parsed = (0, import_wellknown.parse)(item); | ||
if (asFeature) { | ||
return { | ||
type: "Feature", | ||
geometry: parsed, | ||
properties | ||
}; | ||
} | ||
return parsed; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
convertFeatureCollection, | ||
convertFeatureToWK, | ||
convertGeometryToWK, | ||
convertToWK, | ||
parseFromWK | ||
}); |
{ | ||
"name": "wkt-parser-helper", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"keywords": [ | ||
@@ -12,6 +12,12 @@ "wkt", | ||
"description": "Module to help parse GeoJSONs to WKT and back", | ||
"source": "src/index.ts", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.umd.js", | ||
"typings": "./dist/index.d.ts", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts" | ||
} | ||
}, | ||
"files": [ | ||
@@ -32,6 +38,7 @@ "dist", | ||
"@types/geojson": "^7946.0.7", | ||
"@types/jest": "^27.0.2", | ||
"@types/wellknown": "^0.5.1", | ||
"@typescript-eslint/eslint-plugin": "^4.17.0", | ||
"@typescript-eslint/parser": "^4.17.0", | ||
"c8": "^7.12.0", | ||
"coveralls": "^3.1.1", | ||
"eslint": "^7.22.0", | ||
@@ -42,8 +49,8 @@ "eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.25.1", | ||
"jest": "^27.2.5", | ||
"microbundle": "^0.14.0", | ||
"ts-jest": "^27.0.5", | ||
"tslib": "^2.3.1", | ||
"tsup": "^6.2.1", | ||
"typedoc": "^0.20.30", | ||
"typedoc-plugin-markdown": "^3.6.0" | ||
"typedoc-plugin-markdown": "^3.6.0", | ||
"typescript": "^4.7.4", | ||
"vite": "^3.0.5", | ||
"vitest": "^0.21.1" | ||
}, | ||
@@ -57,8 +64,9 @@ "prettier": { | ||
"scripts": { | ||
"build": "microbundle", | ||
"dev": "microbundle watch", | ||
"test": "jest", | ||
"docs": "typedoc src/index.ts --readme README.md --gitRevision master", | ||
"prepublish": "pnpm run build" | ||
"start": "pnpm run build -- --watch src", | ||
"build": "tsup src/index.ts --format cjs,esm --dts --clean", | ||
"test": "vitest run", | ||
"coverage": "vitest run --coverage", | ||
"lint": "eslint --cache --fix --ignore-path .gitignore --ext .ts,.js src", | ||
"docs": "typedoc src/index.ts --readme README.md --gitRevision master" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
234
0
0
15134
17
7