{"id":46324022,"url":"https://github.com/hichemtab-tech/namecrement","last_synced_at":"2026-03-04T16:02:41.718Z","repository":{"id":290413801,"uuid":"974339325","full_name":"HichemTab-tech/Namecrement","owner":"HichemTab-tech","description":"A smart JavaScript utility that generates unique incremental names, preventing naming collisions by automatically appending incremental suffixes.","archived":false,"fork":false,"pushed_at":"2025-09-02T23:52:35.000Z","size":142,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-03T00:23:13.594Z","etag":null,"topics":["auto-increment","collision","duplicate","filename","generator","increment","incremental","javascript","name","names","naming","package","unique","utility"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HichemTab-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"buy_me_a_coffee":"hichemtabtech","github":"hichemtab-tech"}},"created_at":"2025-04-28T16:12:48.000Z","updated_at":"2025-09-02T23:45:55.000Z","dependencies_parsed_at":"2025-07-10T22:18:55.799Z","dependency_job_id":"837b6f8c-92f4-4fac-832c-afe837959061","html_url":"https://github.com/HichemTab-tech/Namecrement","commit_stats":null,"previous_names":["hichemtab-tech/namecrement"],"tags_count":5,"template":false,"template_full_name":"HichemTab-tech/npm-package-skeleton","purl":"pkg:github/HichemTab-tech/Namecrement","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HichemTab-tech","download_url":"https://codeload.github.com/HichemTab-tech/Namecrement/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HichemTab-tech%2FNamecrement/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30085824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T15:40:14.053Z","status":"ssl_error","status_checked_at":"2026-03-04T15:40:13.655Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto-increment","collision","duplicate","filename","generator","increment","incremental","javascript","name","names","naming","package","unique","utility"],"created_at":"2026-03-04T16:02:41.515Z","updated_at":"2026-03-04T16:02:41.697Z","avatar_url":"https://github.com/HichemTab-tech.png","language":"TypeScript","funding_links":["https://buymeacoffee.com/hichemtabtech","https://github.com/sponsors/hichemtab-tech"],"categories":[],"sub_categories":[],"readme":"# Namecrement\n\n\u003cp align=\"center\"\u003e\n\n![Tests](https://github.com/HichemTab-tech/Namecrement/workflows/Test/badge.svg) \n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/HichemTab-tech/Namecrement/blob/main/LICENSE)\n[![NPM Version](https://img.shields.io/npm/v/namecrement.svg)](https://www.npmjs.com/package/namecrement)\n\n\u003c/p\u003e\n\n**Smart and simple unique name generator.**  \nIf a name already exists, Namecrement automatically increments it,\nlike `\"file\"` → `\"file (1)\"`, `\"file (2)\"`, and so on.\n\n---\n\n## ✨ Features\n\n- Automatically avoids naming collisions\n- Smart incremental naming (`(1)`, `(2)`, etc.)\n- Lightweight and dependency-free\n- Works for filenames, labels, identifiers, and more\n\n---\n\n### 📦 Also Available\n\n* PHP: [Namecrement-php](https://github.com/HichemTab-tech/Namecrement-php)\n* Python: [Namecrement-py](https://github.com/HichemTab-tech/Namecrement-py)\n\n## 📦 Installation\n\n```bash\nnpm install namecrement\n```\n\nor\n\n```bash\npnpm add namecrement\n```\n\n---\n\n## 🚀 Usage\n\n```javascript\nimport { namecrement } from 'namecrement';\n\n// Example list of existing names\nconst existing = ['file', 'file (1)', 'file (2)'];\n\n// Generate a unique name\nconst newName = namecrement('file', existing);\n\nconsole.log(newName); // Output: \"file (3)\"\n```\n\n---\n\n## 🧠 Advanced Usage\n\n```ts\nnamecrement('file', ['file', 'file -1-', 'file -2-'], ' -%N%-');\n// → 'file -3-'\n```\n\nYou can customize how numbers are added by using the `%N%` placeholder in a `suffixFormat`:\n\n| Format Example    | Output             |\n|-------------------|--------------------|\n| `\" (%N%)\"`        | `file (1)`         |\n| `\"-%N%\"`          | `file-1`           |\n| `\"_v%N%\"`         | `file_v1`          |\n| `\"\u003c%N%\u003e\"`         | `file\u003c1\u003e`          |\n\n---\n\n### ✅ Type-Safe Format\n\n\u003e `suffixFormat` must include the `%N%` placeholder, or the function will throw an error.\n\nThis ensures that all generated names include the incremented number in the format you define.\n\n```ts\nnamecrement('log', ['log', 'log_1'], '_%N%_'); // → log_2\n```\n\n---\n\n## 📚 API\n\n### `namecrement(baseName: string, existingNames: string[]): string`\n\n| Parameter        | Type                  | Description                                               |\n|------------------|-----------------------|-----------------------------------------------------------|\n| `baseName`       | `string`              | The proposed name                                         |\n| `existingNames`  | `string[]`            | The list of names to check against                        |\n| `suffixFormat`   | `string`              | The format for the incremented name (optional)            |\n| `startingNumber` | `number \\| undefined` | The starting number for incrementing (default: undefined) |\n\nReturns a **unique** name based on the proposed one.\n\n---\n\n## 🛠️ Examples\n\n```javascript\nnamecrement('report', ['report', 'report (1)']); \n// → 'report (2)'\n\nnamecrement('image', ['photo', 'image', 'image (1)', 'image (2)']);\n// → 'image (3)'\n\nnamecrement('new', []);\n// → 'new'\n\nnamecrement('document', ['document', 'document -1-', 'document (2)'], ' -%N%-');\n// → 'document -2-'\n\nnamecrement('file', [], ' (%N%)', 5);\n// → 'file (5)'\n```\n\n---\n\n## 📄 License\n\nMIT License © 2025 Hichem Taboukouyout\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhichemtab-tech%2Fnamecrement","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhichemtab-tech%2Fnamecrement","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhichemtab-tech%2Fnamecrement/lists"}