{"_id":"@assanepoi/area-calculator","_rev":"2-06f834c094c01b10a28904c6a74c5e06","name":"@assanepoi/area-calculator","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@assanepoi/area-calculator","version":"1.0.0","keywords":["area"],"author":{"name":"Assanee Saksiritantawan"},"license":"MIT","_id":"@assanepoi/area-calculator@1.0.0","maintainers":[{"name":"assanepoi","email":"assanepoi@hotmail.com"}],"homepage":"https://github.com/assanee/area-calculator#readme","bugs":{"url":"https://github.com/assanee/area-calculator/issues"},"dist":{"shasum":"29dd792ac1e33b7dfc3311056cb80c672c2df945","tarball":"https://registry.npmjs.org/@assanepoi/area-calculator/-/area-calculator-1.0.0.tgz","fileCount":5,"integrity":"sha512-DtFYxWFnqTzik+SzTLh4uBG3TFkBwAxce6HRwRUDZw2mdTRsUIHH3cTnkygknENgpY59mloDWQyVnOmrN1aQnw==","signatures":[{"sig":"MEUCIQDbGvjZQIahdAxNjSronCdQBQcahL5m/xkDFVwAmenkeAIgVdPjuR4rsZ1as7kan9OffYZm2ZrWhd9VN4UgwtKu/UI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5125},"main":"index.js","gitHead":"f674f7efb80c4b47528e1be57781919e897537c7","scripts":{"test":"node test.js"},"_npmUser":{"name":"assanepoi","email":"assanepoi@hotmail.com"},"repository":{"url":"git+https://github.com/assanee/area-calculator.git","type":"git"},"_npmVersion":"10.2.3","description":"A simple module for calculating areas of different shapes","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/area-calculator_1.0.0_1732100886109_0.2617605034049342","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@assanepoi/area-calculator","version":"1.0.1","keywords":["area"],"author":{"name":"Assanee Saksiritantawan"},"license":"MIT","_id":"@assanepoi/area-calculator@1.0.1","maintainers":[{"name":"assanepoi","email":"assanepoi@hotmail.com"}],"homepage":"https://github.com/assanee/area-calculator#readme","bugs":{"url":"https://github.com/assanee/area-calculator/issues"},"dist":{"shasum":"77a07560216e1a2227314fee599e30c623f00fd3","tarball":"https://registry.npmjs.org/@assanepoi/area-calculator/-/area-calculator-1.0.1.tgz","fileCount":5,"integrity":"sha512-IKSXOcgeSfT72A7V6tjqG6EAXSO4vIh1YfwIcLg+9RRwGuxAqHqcwnqPeJpmj6heqgcbNU6R/pYsQb73Y20i9w==","signatures":[{"sig":"MEQCIGSy2BBfGiXC1CFY4t+b9+pnihdZL6uBATs+1vRbHHkmAiBgI90fUIYjPpvC3/yYltBLFiVmJTHYPUxDDzL8J0kftw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7984},"main":"index.js","gitHead":"ec95f1ea5bb57173c432481012fd9e976da6ec34","scripts":{"test":"node test.js"},"_npmUser":{"name":"assanepoi","email":"assanepoi@hotmail.com"},"repository":{"url":"git+https://github.com/assanee/area-calculator.git","type":"git"},"_npmVersion":"10.2.3","description":"A simple module for calculating areas of different shapes","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/area-calculator_1.0.1_1732103218240_0.5595526145312519","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@assanepoi/area-calculator","version":"1.0.2","description":"A simple module for calculating areas of different shapes","main":"index.js","author":{"name":"Assanee Saksiritantawan"},"license":"MIT","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/assanee/area-calculator.git"},"keywords":["area"],"bugs":{"url":"https://github.com/assanee/area-calculator/issues"},"homepage":"https://github.com/assanee/area-calculator#readme","_id":"@assanepoi/area-calculator@1.0.2","gitHead":"ab8e7261a35f158be783f9d599938c79330ee374","_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-XS1qLJ9rtAMAsFOfoykgdlo/FGmD1Neu6FLbXV25j1X44mq1Mh3FsVrSW/CLPMjAf/gO13JjxotsUal5zA3tzQ==","shasum":"035ab6d213bcff22ef694c1889d57736e00d8532","tarball":"https://registry.npmjs.org/@assanepoi/area-calculator/-/area-calculator-1.0.2.tgz","fileCount":5,"unpackedSize":8006,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDL9EFvs8KvzPic9/OrxE4xlNBS/JVtY7CXbfbK0H0RTgIgMBC1kFbBFk26noCPoU0WjXzc4Q1uPbPdYU7ngzLkr1U="}]},"_npmUser":{"name":"assanepoi","email":"assanepoi@hotmail.com"},"directories":{},"maintainers":[{"name":"assanepoi","email":"assanepoi@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/area-calculator_1.0.2_1732166053719_0.10250349972480577"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-20T11:08:06.028Z","modified":"2024-11-21T05:14:14.100Z","1.0.0":"2024-11-20T11:08:06.279Z","1.0.1":"2024-11-20T11:46:58.413Z","1.0.2":"2024-11-21T05:14:13.936Z"},"bugs":{"url":"https://github.com/assanee/area-calculator/issues"},"author":{"name":"Assanee Saksiritantawan"},"license":"MIT","homepage":"https://github.com/assanee/area-calculator#readme","keywords":["area"],"repository":{"type":"git","url":"git+https://github.com/assanee/area-calculator.git"},"description":"A simple module for calculating areas of different shapes","maintainers":[{"name":"assanepoi","email":"assanepoi@hotmail.com"}],"readme":"\n# Area Calculator\n\nA Node.js module for calculating areas of various shapes and geographical regions. This module now supports basic geometric shapes as well as areas derived from latitude and longitude.\n\n## Features\n- Calculate the area of a rectangle.\n- Calculate the area of a circle.\n- Calculate the area of a triangle.\n- Calculate the approximate area between two geographical points (latitude and longitude).\n- Calculate the area of a polygon from an array of geographical coordinates.\n\n## Installation\n\nInstall the module via npm:\n\n```bash\nnpm install @assanepoi/area-calculator\n```\n\n## Usage\n\nImport the module in your Node.js project and start using it:\n\n### Example Code\n\n```javascript\nconst {\n    rectangleArea,\n    circleArea,\n    triangleArea,\n    areaFromLatLon,\n    areaFromLatLonArray\n} = require('@assanepoi/area-calculator');\n\ntry {\n    // Rectangle Area\n    console.log(\"Rectangle Area (5x10):\", rectangleArea(5, 10)); // Output: 50\n\n    // Circle Area\n    console.log(\"Circle Area (radius 7):\", circleArea(7)); // Output: 153.93804002589985\n\n    // Triangle Area\n    console.log(\"Triangle Area (base 6, height 8):\", triangleArea(6, 8)); // Output: 24\n\n    // Area from Latitude and Longitude (two points)\n    console.log(\"Area from Lat/Lon:\", areaFromLatLon(40.748817, -73.985428, 34.052235, -118.243683)); \n\n    // Area from Latitude and Longitude Array (polygon)\n    const coords = [\n        [37.7749, -122.4194],\n        [34.0522, -118.2437],\n        [36.7783, -119.4179]\n    ];\n    console.log(\"Area from Lat/Lon Array:\", areaFromLatLonArray(coords));\n} catch (error) {\n    console.error(\"Error:\", error.message);\n}\n```\n\n### Functions\n\n#### `rectangleArea(width, height)`\nCalculates the area of a rectangle.\n\n- **Parameters**:\n  - `width` (number): The width of the rectangle. Must be greater than 0.\n  - `height` (number): The height of the rectangle. Must be greater than 0.\n- **Returns**: The area of the rectangle.\n\n#### `circleArea(radius)`\nCalculates the area of a circle.\n\n- **Parameters**:\n  - `radius` (number): The radius of the circle. Must be greater than 0.\n- **Returns**: The area of the circle.\n\n#### `triangleArea(base, height)`\nCalculates the area of a triangle.\n\n- **Parameters**:\n  - `base` (number): The base length of the triangle. Must be greater than 0.\n  - `height` (number): The height of the triangle. Must be greater than 0.\n- **Returns**: The area of the triangle.\n\n#### `areaFromLatLon(lat1, lon1, lat2, lon2)`\nCalculates the approximate area between two geographical points using their latitude and longitude.\n\n- **Parameters**:\n  - `lat1`, `lon1` (number): Latitude and longitude of the first point.\n  - `lat2`, `lon2` (number): Latitude and longitude of the second point.\n- **Returns**: The approximate area in square meters.\n\n#### `areaFromLatLonArray(coords)`\nCalculates the area of a polygon from an array of geographical coordinates.\n\n- **Parameters**:\n  - `coords` (array): An array of `[latitude, longitude]` pairs. Must contain at least 3 coordinates.\n- **Returns**: The area in square meters.\n\n## Error Handling\n\nAll functions will throw an error if invalid parameters are provided. Examples:\n- Negative or zero dimensions for geometric shapes.\n- Insufficient coordinates for geographical calculations.\n\n### Example\n```javascript\ntry {\n    console.log(rectangleArea(-5, 10)); // Throws Error\n} catch (error) {\n    console.error(error.message); // Output: Width and height must be greater than 0.\n}\n```\n\n## License\n\nThis project is licensed under the MIT License. See the `LICENSE` file for details.\n\n---\n\nHappy coding! 🚀\n","readmeFilename":"README.md"}