{"_id":"@ajaykrp/math-ops","_rev":"2-f66493470f84e152cc2d7be8ababc10c","name":"@ajaykrp/math-ops","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@ajaykrp/math-ops","version":"1.0.0","keywords":["Math","OPS"],"author":{"name":"Ajay"},"license":"MIT","_id":"@ajaykrp/math-ops@1.0.0","maintainers":[{"name":"ajaykrp","email":"kajay5080@gmail.com"}],"homepage":"https://github.com/AjayKrP/math-ops#readme","bugs":{"url":"https://github.com/AjayKrP/math-ops/issues"},"dist":{"shasum":"c3e8d2558e20159d669a47adf0e08fe06a6b1a58","tarball":"https://registry.npmjs.org/@ajaykrp/math-ops/-/math-ops-1.0.0.tgz","fileCount":3,"integrity":"sha512-nmqHM8xVFgS94U1c8maRa+w8Pq1V3D4IPCaM14ad5UvX9999xD34bvD5fNpeD5OqXeeow8s3qLd3sfAuBzIihw==","signatures":[{"sig":"MEUCIC2QQQw3DraSIdg8058waEbrVvk+ZEAWY8+tQHF8y0k/AiEA9FpY36SYrz/STixQNU/sBAimuCmUgkSYccUtsafR4TA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5643},"main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"ajaykrp","email":"kajay5080@gmail.com"},"repository":{"url":"git+https://github.com/AjayKrP/math-ops.git","type":"git"},"_npmVersion":"10.2.3","description":"Math Operations","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/math-ops_1.0.0_1707805307161_0.08750780041285044","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@ajaykrp/math-ops","version":"1.0.2","keywords":["Math","OPS"],"author":{"name":"Ajay"},"license":"MIT","_id":"@ajaykrp/math-ops@1.0.2","maintainers":[{"name":"ajaykrp","email":"kajay5080@gmail.com"}],"homepage":"https://github.com/AjayKrP/math-ops#readme","bugs":{"url":"https://github.com/AjayKrP/math-ops/issues"},"dist":{"shasum":"7824c122abbdcd069f6bee86a4a36e8ed24f52c8","tarball":"https://registry.npmjs.org/@ajaykrp/math-ops/-/math-ops-1.0.2.tgz","fileCount":3,"integrity":"sha512-MQklC6R2tCE8LzslDebmg+Mw4G2/1bqIjR6pdDHLJuKWa52wjQcuIt3YnENuymNObaoxt1Cqxx9bd/qdSRCOtg==","signatures":[{"sig":"MEUCIQDFpIuziARX320pdB9X4XzzzPNhorwtxGPFNnRP4XKswwIgdoD5WWuDYUnei3nvRQNzGWwk5akfqHdJ5y4Qm/jpM/s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5604},"main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"ajaykrp","email":"kajay5080@gmail.com"},"repository":{"url":"git+https://github.com/AjayKrP/math-ops.git","type":"git"},"_npmVersion":"10.2.3","description":"Math Operations","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/math-ops_1.0.2_1707805635444_0.8520317684448648","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@ajaykrp/math-ops","version":"1.1.0","description":"A versatile TypeScript library designed to handle a wide range of mathematical operations","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"jest","start":"node dist/index.js","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/AjayKrP/math-ops.git"},"keywords":["NodeJS","TypeScript","Math"],"author":{"name":"Ajay"},"license":"MIT","bugs":{"url":"https://github.com/AjayKrP/math-ops/issues"},"homepage":"https://github.com/AjayKrP/math-ops#readme","devDependencies":{"@types/jest":"^29.5.13","jest":"^29.7.0","ts-jest":"^29.2.5","typescript":"^5.6.2"},"_id":"@ajaykrp/math-ops@1.1.0","gitHead":"50d0c151891de9f3a5b9457931d4beac0015f760","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-tIvRZqnF6u9tNpay5KNrs7Ko61xrbzX/nW5uoll9LPwjky6kEWLEDVtLMGPpG0pWdUrvgGs3pFqQEoE3AJNPLg==","shasum":"55267c7b63bd371c10e7a67f9eaecc587330a574","tarball":"https://registry.npmjs.org/@ajaykrp/math-ops/-/math-ops-1.1.0.tgz","fileCount":17,"unpackedSize":17942,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDgTawA078CoXSVNY7szmcS9CA9RtNE1mHoBfTguJP87wIhALMPm6HQaSAn+6o6oKo+DF2Rc9XBEUDQnNb5Ov5iFaOl"}]},"_npmUser":{"name":"ajaykrp","email":"kajay5080@gmail.com"},"directories":{},"maintainers":[{"name":"ajaykrp","email":"kajay5080@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/math-ops_1.1.0_1726400327629_0.2728024956008819"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-13T06:21:47.035Z","modified":"2024-09-15T11:38:48.002Z","1.0.0":"2024-02-13T06:21:47.302Z","1.0.2":"2024-02-13T06:27:15.590Z","1.1.0":"2024-09-15T11:38:47.814Z"},"bugs":{"url":"https://github.com/AjayKrP/math-ops/issues"},"author":{"name":"Ajay"},"license":"MIT","homepage":"https://github.com/AjayKrP/math-ops#readme","keywords":["NodeJS","TypeScript","Math"],"repository":{"type":"git","url":"git+https://github.com/AjayKrP/math-ops.git"},"description":"A versatile TypeScript library designed to handle a wide range of mathematical operations","maintainers":[{"name":"ajaykrp","email":"kajay5080@gmail.com"}],"readme":"# Math Ops Package\n\nThe `@ajaykrp/math-ops` npm package provides functionalities for both basic arithmetic operations and complex arithmetic expression evaluations. It supports addition, subtraction, multiplication, and division, as well as the evaluation of complex expressions with parentheses.\n\n## Installation\n\nYou can install the package via npm:\n\n```bash\nnpm install @ajaykrp/math-ops\n```\n\n## Usag\n\n### Basic Arithmetic Operations\n\nFor basic arithmetic operations (addition, subtraction, multiplication, and division), use the `calculate` function.\n\n```typescript\nimport { calculate } from '@ajaykrp/math-ops';\n\n// Basic arithmetic operations\nconst result1 = calculate('addition', 1, 2, 3); // 6\nconst result2 = calculate('subtraction', 10, 5, 2); // 3\nconst result3 = calculate('multiplication', 2, 3, 4); // 24\nconst result4 = calculate('division', 12, 3, 2); // 2\n\nconsole.log(result1); // 6\nconsole.log(result2); // 3\nconsole.log(result3); // 24\nconsole.log(result4); // 2\n```\n\n### Complex Arithmetic Expression Evaluation\n\nFor evaluating complex arithmetic expressions, use the `ExpressionEvaluator` class.\n\n```typescript\nimport ExpressionEvaluator from '@ajaykrp/math-ops';\n\n// Evaluating complex expressions\nconst result1 = ExpressionEvaluator.evaluate('1 + 2 * 4 / 6'); // 2.3333\nconst result2 = ExpressionEvaluator.evaluate('(1 + 2) * 4 / 6'); // 2\nconst result3 = ExpressionEvaluator.evaluate('1 + (2 * (3 + 4)) / 5'); // 3.4\n\nconsole.log(result1); // 2.3333\nconsole.log(result2); // 2\nconsole.log(result3); // 3.4\n```\n\n## API\n\n### `calculate(operation: string, ...args: number[]): number`\n\nPerforms the specified arithmetic operation.\n\n**Parameters:**\n\n- `operation` (string): The operation to perform. Possible values: 'addition', 'subtraction', 'multiplication', 'division'.\n- `...args` (number[]): The numbers to operate on.\n\n**Returns:**\n\n- `number`: The result of the operation.\n\n### `ExpressionEvaluator.evaluate(expression: string): number`\n\nEvaluates the given arithmetic expression.\n\n**Parameters:**\n\n- `expression` (string): The arithmetic expression to evaluate. Supports operators `+`, `-`, `*`, `/` and parentheses.\n\n**Returns:**\n\n- `number`: The result of the expression.\n\n## Error Handling\n\n- **Basic Arithmetic Operations:** \n  - Throws an error if an invalid argument (non-number) is provided.\n  - Throws an error if division by zero is attempted.\n  - Throws an error if an invalid operation is specified.\n\n- **Complex Arithmetic Expression Evaluation:**\n  - Throws an error if division by zero is attempted.\n  - Throws an error if an invalid character is found in the expression.\n  - Throws an error if the expression is invalid or cannot be parsed correctly.\n\n## Examples\n\n- **Basic Arithmetic:**\n  - Addition: `calculate('addition', 1, 2, 3)`\n  - Subtraction: `calculate('subtraction', 10, 5, 2)`\n  - Multiplication: `calculate('multiplication', 2, 3, 4)`\n  - Division: `calculate('division', 12, 3, 2)`\n\n- **Complex Expressions:**\n  - Simple Expression: `ExpressionEvaluator.evaluate('1 + 2 * 4 / 6')`\n  - With Brackets: `ExpressionEvaluator.evaluate('(1 + 2) * 4 / 6')`\n  - Nested Brackets: `ExpressionEvaluator.evaluate('1 + (2 * (3 + 4)) / 5')`\n  - Division by Zero: `ExpressionEvaluator.evaluate('1 / 0')` (Throws error)\n\n## License\n\nMIT License","readmeFilename":"README.md"}