{"_id":"y-ary","_rev":"3-dfb0a84939e51666a1e822e57a9b7267","name":"y-ary","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.2":{"name":"y-ary","version":"0.0.2","keywords":["typescript","mathematics","formula-parser","formula-interpreter","array-generation","random","validation","experimental","matrix","math-library","dynamic-evaluation"],"author":{"name":"AmaiDonatsu"},"license":"MIT","_id":"y-ary@0.0.2","maintainers":[{"name":"nissunay","email":"nissunay@gmail.com"}],"homepage":"https://github.com/AmaiDonatsu/Y-ary#readme","bugs":{"url":"https://github.com/AmaiDonatsu/Y-ary/issues"},"dist":{"shasum":"773ae77c6992dc0fba71de3a3d997d43afeaa81e","tarball":"https://registry.npmjs.org/y-ary/-/y-ary-0.0.2.tgz","fileCount":9,"integrity":"sha512-XTlA9Zxf7ABc9bjPJczgmB6efmJBzH9WtyqWrgGKZv8osfBexE5MhKZETpvjLSJ9Xs9YxuipNBiDpAa3E0MBRA==","signatures":[{"sig":"MEQCIFTcqxi+rlKWvxYoDOkGLFHLmOWqb4O+aBbo6SiH3vIHAiBt8Rx99rPh+fszfchoKg7s/gynCcDMZ0VCoSzM5YaNpA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":99365},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"6bf998d1eba555e5defcc187f7ababa255e37d1f","scripts":{"dev":"tsup --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsup","prepublishOnly":"pnpm run build"},"_npmUser":{"name":"nissunay","email":"nissunay@gmail.com"},"repository":{"url":"git+https://github.com/AmaiDonatsu/Y-ary.git","type":"git"},"_npmVersion":"11.6.0","description":"Experimental TypeScript math library: Formula interpreter + smart array generation with 30+ validation rules","directories":{},"_nodeVersion":"24.9.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.15.1","devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/y-ary_0.0.2_1768650343729_0.5180750253430704","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"y-ary","version":"0.0.4","keywords":["typescript","mathematics","formula-parser","formula-interpreter","array-generation","random","validation","experimental","matrix","math-library","dynamic-evaluation"],"author":{"name":"AmaiDonatsu"},"license":"MIT","_id":"y-ary@0.0.4","maintainers":[{"name":"nissunay","email":"nissunay@gmail.com"}],"homepage":"https://github.com/AmaiDonatsu/Y-ary#readme","bugs":{"url":"https://github.com/AmaiDonatsu/Y-ary/issues"},"dist":{"shasum":"eb89e34c463eed42d2bf2881963fbb17008dce1c","tarball":"https://registry.npmjs.org/y-ary/-/y-ary-0.0.4.tgz","fileCount":9,"integrity":"sha512-u++8xDzvxWd6F4q1iZlOw8i713WIlKpklzBHrgFBkJZ3Guq+wa3rbXVZW61ZDHGzWjoB1GVqckA0GLHHOOss1g==","signatures":[{"sig":"MEUCIQDCFqmXz0XgIJnsQPAPIeZut8/nSxl6jp6avEPMNKaf1wIgR6eUagjMDbBovUHZ8CSUViCns5OYqqykNmZlwf0Pwnc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":99722},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"2fc08c44f5522590b1c312a6ca843d868a8dbdfd","scripts":{"dev":"tsup --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsup","release":"pnpm run release:patch","release:major":"npm version major && git push origin main --tags && npm publish","release:minor":"npm version minor && git push origin main --tags && npm publish","release:patch":"npm version patch && git push origin main --tags && npm publish","prepublishOnly":"pnpm run build"},"_npmUser":{"name":"nissunay","email":"nissunay@gmail.com"},"repository":{"url":"git+https://github.com/AmaiDonatsu/Y-ary.git","type":"git"},"_npmVersion":"11.6.0","description":"Experimental TypeScript math library: Formula interpreter + smart array generation with 30+ validation rules","directories":{},"_nodeVersion":"24.9.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.15.1","devDependencies":{"tsup":"^8.5.1","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/y-ary_0.0.4_1768660176311_0.28070742979582475","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"y-ary","version":"0.0.5","description":"Experimental TypeScript math library: Formula interpreter + smart array generation with 30+ validation rules","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"build":"tsup","dev":"tsup --watch","prepublishOnly":"pnpm run build","test":"echo \"Error: no test specified\" && exit 1","release:patch":"npm version patch && git push origin main --tags && npm publish","release:minor":"npm version minor && git push origin main --tags && npm publish","release:major":"npm version major && git push origin main --tags && npm publish","release":"pnpm run release:patch"},"keywords":["typescript","mathematics","formula-parser","formula-interpreter","array-generation","random","validation","experimental","matrix","math-library","dynamic-evaluation"],"author":{"name":"AmaiDonatsu"},"repository":{"type":"git","url":"git+https://github.com/AmaiDonatsu/Y-ary.git"},"homepage":"https://github.com/AmaiDonatsu/Y-ary#readme","bugs":{"url":"https://github.com/AmaiDonatsu/Y-ary/issues"},"license":"MIT","devDependencies":{"tsup":"^8.5.1","typescript":"^5.9.3"},"packageManager":"pnpm@10.15.1","_id":"y-ary@0.0.5","gitHead":"0bab425934e292fa044e425ea56d35bb08453e03","_nodeVersion":"24.9.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-5q3X9j5jV+cZlmnowNhmhg5oKtFtLKY6ktBR5xuSZkT7Pc5XicG/42SqCM4urleIfGTcIbRlj93xYMWR/uJzcA==","shasum":"9b1f1ad1e075df2e138e4711e3061f26bccffa5b","tarball":"https://registry.npmjs.org/y-ary/-/y-ary-0.0.5.tgz","fileCount":9,"unpackedSize":124169,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDwAUVUpG7MEC7Wn4wnMLcqAPUNhIahtRPKtURvUX3Q4QIgVauI+rSckYbtUdy/N+sLa2chQ20V+arEvehMVQJnyyo="}]},"_npmUser":{"name":"nissunay","email":"nissunay@gmail.com"},"directories":{},"maintainers":[{"name":"nissunay","email":"nissunay@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/y-ary_0.0.5_1768697870143_0.9288126805172261"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-17T11:45:43.728Z","modified":"2026-01-18T00:57:50.414Z","0.0.2":"2026-01-17T11:45:43.897Z","0.0.4":"2026-01-17T14:29:36.458Z","0.0.5":"2026-01-18T00:57:50.307Z"},"bugs":{"url":"https://github.com/AmaiDonatsu/Y-ary/issues"},"author":{"name":"AmaiDonatsu"},"license":"MIT","homepage":"https://github.com/AmaiDonatsu/Y-ary#readme","keywords":["typescript","mathematics","formula-parser","formula-interpreter","array-generation","random","validation","experimental","matrix","math-library","dynamic-evaluation"],"repository":{"type":"git","url":"git+https://github.com/AmaiDonatsu/Y-ary.git"},"description":"Experimental TypeScript math library: Formula interpreter + smart array generation with 30+ validation rules","maintainers":[{"name":"nissunay","email":"nissunay@gmail.com"}],"readme":"# Y-ary\r\n\r\n<img src=\"./res/banner.webp\" width=\"50%\" alt=\"Y-ary Banner\">\r\n\r\nY-ary is an experimental TypeScript library for mathematical operations and data generation. \r\nIt provides tools to evaluate mathematical formulas from strings with dynamic variables, \r\nand generate controlled random arrays/matrices with sophisticated validation rules.\r\n\r\nPerfect for: games, testing, simulations, educational tools, and mathematical experimentation.\r\n\r\n## Features\r\n\r\n### 🧮 Formula Interpreter\r\n- **Dynamic Evaluation**: Interpret mathematical formulas as strings at runtime.\r\n- **Variable Injection**: Easily map variable names to numeric values using the `where` object.\r\n- **Full JavaScript Math Support**: Use standard operators (`+`, `-`, `*`, `/`, `**`, etc.) and all `Math` functions (e.g., `Math.sqrt`, `Math.pow`).\r\n- **Safety Focused**: Uses the `Function` constructor for evaluation, providing a more controlled environment than `eval`.\r\n- **Word-Boundary Precision**: Replaces variables only when they match as whole words, avoiding accidental partial replacements.\r\n\r\n### 🎲 Smart Array Generation\r\n- **Random Array Generation**: Create 1D arrays or 2D matrices with controlled randomization.\r\n- **Occurrence Limits**: Define how many times each number can appear using a bank system.\r\n- **30+ Validation Rules**: Pre-built rules for common patterns (parity, ranges, sequences, etc.).\r\n- **Custom Rules**: Create your own validation functions for specific requirements.\r\n- **Rule Combinators**: Combine rules with AND, OR, and NOT logic.\r\n\r\n\r\n## Installation\r\n\r\n### From npm registry\r\n\r\n```bash\r\npnpm add y-ary\r\n```\r\n\r\n### From GitHub repository\r\n\r\nUsing **pnpm**:\r\n```bash\r\npnpm add https://github.com/AmaiDonatsu/Y-ary.git\r\n```\r\n\r\nUsing **npm**:\r\n```bash\r\nnpm install https://github.com/AmaiDonatsu/Y-ary.git\r\n```\r\n\r\n## Usage\r\n\r\n### Formula Interpreter\r\n\r\nThe `formulaInterpreter` function evaluates mathematical formulas with dynamic variables.\r\n\r\n```typescript\r\nimport { formulaInterpreter } from 'y-ary';\r\n\r\n// Basic usage\r\nconst result = formulaInterpreter('x / 1 + y', { x: 4, y: 6 });\r\nconsole.log(result); // Output: 10\r\n\r\n// Complex formulas with Math functions\r\nconst complexResult = formulaInterpreter('Math.sqrt(a) + Math.pow(b, 2) - c', {\r\n  a: 16,\r\n  b: 3,\r\n  c: 5\r\n});\r\nconsole.log(complexResult); // Output: 8 (4 + 9 - 5)\r\n```\r\n\r\n### Array Generation\r\n\r\nGenerate random arrays or matrices with controlled distribution and validation rules.\r\n\r\n#### Basic 1D Array\r\n```typescript\r\nimport { arrayWithBankNums } from 'y-ary';\r\n\r\n// Generate array of length 5\r\n// Each number (1-10) can appear up to 3 times\r\nconst array = arrayWithBankNums(\r\n  { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3, 7: 3, 8: 3, 9: 3, 10: 3 },\r\n  [5]\r\n);\r\n// Possible result: [3, 7, 1, 9, 2]\r\n```\r\n\r\n#### 2D Matrix\r\n```typescript\r\n// Generate 3x4 matrix (3 rows, 4 columns)\r\nconst matrix = arrayWithBankNums(\r\n  { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3 },\r\n  [3, 4]\r\n);\r\n// Possible result:\r\n// [\r\n//   [1, 3, 2, 5],\r\n//   [4, 1, 6, 3],\r\n//   [2, 5, 4, 6]\r\n// ]\r\n```\r\n\r\n#### Using Validation Rules\r\n```typescript\r\nimport { arrayWithBankNums, onlyEven, inRange, and, noConsecutiveRepeats } from 'y-ary';\r\n\r\n// Only even numbers\r\nconst evenArray = arrayWithBankNums(\r\n  { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3 },\r\n  [5],\r\n  onlyEven\r\n);\r\n// Possible result: [2, 4, 6, 2, 4]\r\n\r\n// Combine multiple rules: even AND in range 2-8\r\nconst filtered = arrayWithBankNums(\r\n  { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3, 7: 3, 8: 3, 9: 3, 10: 3 },\r\n  [5],\r\n  and([onlyEven, inRange(2, 8)])\r\n);\r\n// Possible result: [2, 4, 6, 8, 2]\r\n\r\n// No consecutive repeats\r\nconst noRepeats = arrayWithBankNums(\r\n  { 1: 5, 2: 5, 3: 5 },\r\n  [10],\r\n  noConsecutiveRepeats\r\n);\r\n// Possible result: [1, 2, 3, 1, 2, 3, 2, 1, 3, 2]\r\n```\r\n\r\n#### Custom Validation Rules\r\n```typescript\r\n// Create your own rule\r\nconst customRule = (num: number, arr: number[]) => {\r\n  // Only allow numbers greater than the last element\r\n  if (arr.length === 0) return true;\r\n  return num > arr[arr.length - 1];\r\n};\r\n\r\nconst ascending = arrayWithBankNums(\r\n  { 1: 2, 2: 2, 3: 2, 4: 2, 5: 2 },\r\n  [5],\r\n  customRule\r\n);\r\n// Possible result: [1, 2, 3, 4, 5]\r\n```\r\n\r\n### Available Validation Rules\r\n\r\nY-ary includes 30+ pre-built validation rules:\r\n\r\n**Parity**: `onlyEven`, `onlyOdd`  \r\n**Range**: `inRange(min, max)`, `notInRange(min, max)`  \r\n**Repetition**: `noConsecutiveRepeats`, `noDuplicates`, `maxOccurrences(n)`, `noRepeatInLast(n)`  \r\n**Sum/Average**: `sumLessThan(max)`, `averageInRange(min, max)`  \r\n**Sequence**: `ascending`, `descending`, `alternateEvenOdd`  \r\n**Divisibility**: `divisibleBy(n)`, `notDivisibleBy(n)`  \r\n**Advanced**: `onlyPrimes`, `onlySquares`, `maxDifference(n)`, `balanceEvenOdd(n)`  \r\n**Combinators**: `and([rules])`, `or([rules])`, `not(rule)`  \r\n\r\nSee [docs/array-docs.md](./docs/array-docs.md) for complete documentation.\r\n\r\n\r\n## Security Note\r\n\r\n⚠️ **Formula Interpreter**: This library uses dynamic code evaluation. Only use it with trusted or validated formulas. Avoid evaluating formulas directly from untrusted user input without proper sanitization.\r\n\r\n⚠️ **Array Generation**: Custom validation rules execute user-provided functions. Ensure that custom rules are from trusted sources and don't perform expensive operations that could impact performance.\r\n\r\n\r\n## Development\r\n\r\n```bash\r\n# Install dependencies\r\npnpm install\r\n\r\n# Build the package\r\npnpm build\r\n\r\n# Watch mode during development\r\npnpm dev\r\n```\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.md"}