{"_id":"@aamirtech/utils","_rev":"33-18d2a9848aab2f23c7c650ee8ac3fb1e","name":"@aamirtech/utils","dist-tags":{"latest":"0.1.7"},"versions":{"0.1.5":{"name":"@aamirtech/utils","version":"0.1.5","_id":"@aamirtech/utils@0.1.5","maintainers":[{"name":"aamirkhan","email":"aamirmakofficial@gmail.com"}],"dist":{"shasum":"322e83aabd379fb3f0debd78a3c3a47731947a85","tarball":"https://registry.npmjs.org/@aamirtech/utils/-/utils-0.1.5.tgz","fileCount":18,"integrity":"sha512-oBYq7hq1uTmhgn4Fgp1cyY0UArfZzKerNV+iClO98xW1XENFZ8/V5Gp/weEdcH5nycxfzTcCOSdjRm5JoQNZ9Q==","signatures":[{"sig":"MEYCIQD3lbJfyJpL0rkpQzBIRXjG1MW+6dZVSvKYXZBy+0MStwIhAJlkWMqiX06VaKgZdlKMTPLD89wJREiVhHyA5EBMaZjX","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16666},"_npmUser":{"name":"aamirkhan","email":"aamirmakofficial@gmail.com"},"_integrity":"sha512-oBYq7hq1uTmhgn4Fgp1cyY0UArfZzKerNV+iClO98xW1XENFZ8/V5Gp/weEdcH5nycxfzTcCOSdjRm5JoQNZ9Q==","_npmVersion":"10.8.3","directories":{},"_nodeVersion":"22.6.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/utils_0.1.5_1729058147865_0.14587710870630755","host":"s3://npm-registry-packages"}},"0.1.6":{"name":"@aamirtech/utils","version":"0.1.6","keywords":["utils","id","generator","snowflake","otp"],"author":"Aamir Khan <aamirmakofficial@gmail.com>","license":"MIT","_id":"@aamirtech/utils@0.1.6","maintainers":[{"name":"aamirkhan","email":"aamirmakofficial@gmail.com"}],"homepage":"https://aamir.tech/utils","bugs":{"url":"https://github.com/aamirtech/utils/issues"},"dist":{"shasum":"cd5ddc1d3f28d824f2f939d94da59fd594af586f","tarball":"https://registry.npmjs.org/@aamirtech/utils/-/utils-0.1.6.tgz","fileCount":18,"integrity":"sha512-of1nQBWUcJZjpN9g1KPTj3HlEF6dtei6xLbwoI5Nve8n5Np19kIqCE8PuwMXip5dTDl2ur82nw21mLEZXHA/5g==","signatures":[{"sig":"MEUCIFHMHKIpDcVitXoNpRupwSKJZsd3BnVIPAZMJtar8lK0AiEA2PXpJXtFDhqjufmdyfI3XRhbAUbNFl8NWoWfZf3Dttk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18397},"main":"dist/index.js","shasum":"cd5ddc1d3f28d824f2f939d94da59fd594af586f","scripts":{"test":"bun test","build":"bun compile && bun build:map","compile":"rm -rf node_modules && bun run tsc","build:map":"tsc -d --declarationDir ./dist ","test:coverage":"bun test --coverage"},"_npmUser":{"name":"aamirkhan","email":"aamirmakofficial@gmail.com"},"_integrity":"sha512-of1nQBWUcJZjpN9g1KPTj3HlEF6dtei6xLbwoI5Nve8n5Np19kIqCE8PuwMXip5dTDl2ur82nw21mLEZXHA/5g==","repository":{"url":"git+https://github.com/aamirtech/utils.git","type":"git"},"_npmVersion":"10.8.3","description":"Library packed with your basic code utils.","directories":{},"_nodeVersion":"22.6.0","organization":"aamir tech","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"^1.1.14"},"_npmOperationalInternal":{"tmp":"tmp/utils_0.1.6_1733254230324_0.187436435113981","host":"s3://npm-registry-packages"}},"0.1.7":{"name":"@aamirtech/utils","description":"Library packed with your basic code utils.","license":"MIT","organization":"aamir tech","version":"0.1.7","author":{"name":"Aamir Khan","email":"aamirmakofficial@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/aamirtech/utils.git"},"main":"dist/index.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"build":"bun run clean && bunx rollup -c","build:legacy":"bun run clean && bunx tsc","build:dev":"bun run clean && bunx rollup -c --environment NODE_ENV:development","clean":"rm -rf dist","build:analyze":"bun run build && du -sh dist/* && echo 'Total:' && du -sh dist","size":"bun run build && find dist -name '*.js' -exec wc -c {} + | sort -n","prepublishOnly":"bun run build && bun test","test":"bun test","test:coverage":"bun test --coverage"},"publishConfig":{"access":"public"},"bugs":{"url":"https://github.com/aamirtech/utils/issues"},"devDependencies":{"@rollup/plugin-commonjs":"^28.0.6","@rollup/plugin-node-resolve":"^16.0.2","@rollup/plugin-typescript":"^12.1.4","@types/bun":"^1.2.23","@types/node":"^24.7.0","rollup":"^4.52.4","rollup-plugin-dts":"^6.2.3","tslib":"^2.8.1","typescript":"^5.9.3"},"homepage":"https://aamir.tech/utils","keywords":["utils","id","generator","snowflake","email","validation","string","typescript"],"_id":"@aamirtech/utils@0.1.7","gitHead":"5221bc6271740fdf89dbdafc8ab3c8339802ab29","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-uTSaT9KyW0MLIdiwhYaeQ7xAjmyL8ZOk/ZfjH3RgwRlJnr8PPcur7pPSUBOlpD7v/yGv4leS1QrJBB5bnUYUdw==","shasum":"0d5ff48cb4b306872881d6c858300059c32a195a","tarball":"https://registry.npmjs.org/@aamirtech/utils/-/utils-0.1.7.tgz","fileCount":6,"unpackedSize":22625,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDLxiivNwVf4xOkhODKcqAeXu3AzI5zRO7vroJSJ8N+TAIgY17bgOK154w5rrNw/3T+AEa14R6TQGe+sASOmCDLyHs="}]},"_npmUser":{"name":"aamirkhan","email":"aamirmakofficial@gmail.com"},"directories":{},"maintainers":[{"name":"aamirkhan","email":"aamirmakofficial@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/utils_0.1.7_1759959293448_0.47261992274819553"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-06T13:26:16.293Z","modified":"2025-10-08T21:34:53.899Z","0.0.1":"2023-12-06T13:26:16.594Z","0.0.2":"2023-12-06T14:43:52.317Z","0.0.3":"2023-12-06T15:10:45.339Z","0.0.4":"2023-12-06T15:32:48.226Z","0.0.5":"2023-12-06T15:36:35.568Z","0.0.6":"2023-12-06T15:50:07.496Z","0.0.7":"2023-12-20T16:30:19.197Z","0.0.8":"2023-12-30T19:20:01.544Z","0.0.9":"2024-01-19T07:32:09.905Z","0.1.0":"2024-02-24T19:43:42.071Z","0.1.1":"2024-10-15T17:46:23.150Z","0.1.2":"2024-10-15T18:03:20.332Z","0.1.3":"2024-10-15T18:52:20.581Z","0.1.4":"2024-10-15T19:17:55.786Z","0.1.5":"2024-10-16T05:55:48.043Z","0.1.6":"2024-12-03T19:30:30.508Z","0.1.7":"2025-10-08T21:34:53.672Z"},"bugs":{"url":"https://github.com/aamirtech/utils/issues"},"author":{"name":"Aamir Khan","email":"aamirmakofficial@gmail.com"},"license":"MIT","homepage":"https://aamir.tech/utils","keywords":["utils","id","generator","snowflake","email","validation","string","typescript"],"repository":{"type":"git","url":"git+https://github.com/aamirtech/utils.git"},"description":"Library packed with your basic code utils.","maintainers":[{"name":"aamirkhan","email":"aamirmakofficial@gmail.com"}],"readme":"[![aamirtech](https://aamir.tech/favicon.ico)](https://aamir.tech)\n\n# @aamirtech/utils\n\n[![GitHub license](https://img.shields.io/npm/l/%40aamirtech%2Futils)](https://github.com/aamirtech/utils/blob/main/LICENSE)\n[![Maintainer](https://img.shields.io/badge/maintainer-aamirv1-green)](https://github.com/aamirv1)\n[![Downloads](https://img.shields.io/npm/dm/%40aamirtech%2Futils)](https://www.npmjs.com/package/@aamirtech/utils)\n[![Npm package version](https://img.shields.io/npm/v/%40aamirtech%2Futils)](https://npmjs.com/@aamirtech/utils)\n\nLibrary packed with your basic code utils.\n\n## Documentation\n\nThe documentation is available at [aamir.tech](https://aamir.tech/docs/utils).\n\n## Installation\n\nInstall with npm\n\n```bash\n  npm install @aamirtech/utils\n```\n\nInstall with yarn\n\n```bash\n  yarn add @aamirtech/utils\n```\n\nInstall with bun\n\n```bash\n  bun add @aamirtech/utils\n```\n\n## Usage\n\n#### All utility functions use snake_case naming:\n\n```javascript\nimport {\n  snowflake,           // lowercase object name (with backward compatibility)\n  Snowflake,           // alias for backward compatibility\n  get_public_id,\n  get_initials,\n  is_email,\n  get_sanitized_email,\n  get_base_email,\n  to_title_case,\n  to_camel_case,\n  to_pascal_case,\n  to_snake_case,\n  to_kebab_case\n} from \"@aamirtech/utils\";\n```\n\n#### Snowflake ID Generation\n\n```javascript\n// Preferred lowercase naming\nconsole.log(snowflake.generate());\n// 7167216930510602240\n\nconsole.log(snowflake.generate(1));\n// 7167216930510602241\n\n// Parse snowflake components\nconst id = snowflake.generate(1);\nconst parsed = snowflake.parse(id);\nconsole.log(parsed.nodeId); // 1\n\n// Backward compatibility also supported\nconsole.log(Snowflake.generate()); // Still works\n```\n\n#### Public ID Generation\n\n```javascript\n// Generate 6-character alphanumeric ID (default)\nget_public_id(); // \"A3B9C2\"\n\n// Generate 10-character numeric ID\nget_public_id(10, { numeric: true, alphabetic: false }); // \"1234567890\"\n\n// Generate 8-character alphabetic ID\nget_public_id(8, { numeric: false, alphabetic: true }); // \"ABCDEFGH\"\n```\n\n#### Email Validation\n\n```javascript\n// Standard email addresses\nis_email(\"user@example.com\"); // true\nis_email(\"test.email@domain.org\"); // true\n\n// Plus addressing (email filtering/sub-addressing)\nis_email(\"user+newsletter@example.com\"); // true\nis_email(\"user+tag123@domain.co.uk\"); // true\nis_email(\"test.user+promo@sub.domain.com\"); // true\nis_email(\"email+123456789@company.org\"); // true\n\n// Invalid emails\nis_email(\"invalid-email\"); // false\nis_email(\"user@\"); // false\nis_email(\"@example.com\"); // false\nis_email(\"+tag@example.com\"); // false (plus at start)\nis_email(\"user+@example.com\"); // false (plus at end)\n```\n\n#### Email Sanitization\n\n```javascript\n// Remove plus addressing and normalize email\nget_sanitized_email(\"user+123456789@company.org\"); // \"user@company.org\"\nget_sanitized_email(\"test.user+newsletter@DOMAIN.COM\"); // \"test.user@domain.com\"\n\n// Handle multiple plus signs and dots\nget_sanitized_email(\"user+tag1+tag2@sub.domain.com\"); // \"user@sub.domain.com\"\nget_sanitized_email(\"user..name@domain.com\"); // \"user.name@domain.com\"\nget_sanitized_email(\".user.name.@domain.com\"); // \"user.name@domain.com\"\n\n// Remove subdomains (optional)\nget_sanitized_email(\"user@sub.domain.com\", { keepSubdomains: false }); // \"user@domain.com\"\n\n// Simple alias for common use case\nget_base_email(\"user+123456789@company.org\"); // \"user@company.org\"\n```\n\n#### Initials Extraction\n\n```javascript\nget_initials(\"John Doe\"); // \"JD\"\nget_initials(\"Alice Mary Smith\"); // \"AS\"\nget_initials(\"Bob\"); // \"B\"\nget_initials(\"Mary-Jane Watson\"); // \"MW\"\n```\n\n#### String Case Conversion\n\n```javascript\nto_title_case(\"hello_world\"); // \"Hello World\"\nto_camel_case(\"hello_world\"); // \"helloWorld\"\nto_pascal_case(\"hello_world\"); // \"HelloWorld\"\nto_snake_case(\"Hello World\"); // \"hello_world\"\nto_kebab_case(\"Hello World\"); // \"hello-world\"\n```\n\n## Tests\n\nTests are written in Bun Test. To run tests, run the following command:\n\n```bash\n  bun test\n```\n\nTo run tests with coverage, run the following command:\n\n```bash\n  bun test:coverage\n```\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\nThe project contains part based on a fork off of (snowflake-generator)[https://github.com/FatAussieFatBoy/snowflake-generator].\n\n```\n\n```\n","readmeFilename":"README.md"}