{"id":24874640,"url":"https://github.com/dirheimerb/class-mergesort","last_synced_at":"2025-07-18T08:37:49.896Z","repository":{"id":203853857,"uuid":"710547635","full_name":"dirheimerb/class-mergesort","owner":"dirheimerb","description":"A css class utility for sorting arrays of objects by a given key","archived":false,"fork":false,"pushed_at":"2023-10-27T01:11:26.000Z","size":83,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T02:15:38.869Z","etag":null,"topics":["classname-to-css","classnames","css-utility-classes"],"latest_commit_sha":null,"homepage":"https://dirheimerb.github.io/class-mergesort/","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/dirheimerb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2023-10-26T23:35:24.000Z","updated_at":"2023-10-27T01:09:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"d2bdce07-9693-4c35-8cc4-ccaf579a3cb7","html_url":"https://github.com/dirheimerb/class-mergesort","commit_stats":null,"previous_names":["dirheimerb/classname-x"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dirheimerb/class-mergesort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fclass-mergesort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fclass-mergesort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fclass-mergesort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fclass-mergesort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirheimerb","download_url":"https://codeload.github.com/dirheimerb/class-mergesort/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fclass-mergesort/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265728985,"owners_count":23818733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["classname-to-css","classnames","css-utility-classes"],"created_at":"2025-02-01T07:28:05.344Z","updated_at":"2025-07-18T08:37:49.871Z","avatar_url":"https://github.com/dirheimerb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Class MergeSort\n\n[![npm version](https://badge.fury.io/js/class-mergesort.svg)](https://badge.fury.io/js/class-mergesort)\n\n- [Class MergeSort](#class-mergesort)\n  - [Installation](#installation)\n  - [Documentation](#documentation)\n  - [API Overview](#api-overview)\n    - [`toggleClass`](#toggleclass)\n    - [`prefixClass`](#prefixclass)\n    - [`suffixClass`](#suffixclass)\n    - [`filterClass`](#filterclass)\n    - [`mergeClass`](#mergeclass)\n    - [`classNameX`](#classnamex)\n  - [License](#license)\n\nClass MergeSort is a utility library designed to facilitate the manipulation and combination of CSS classes in TypeScript and JavaScript applications. It provides various utilities to toggle, prefix, suffix, filter, merge, and more.\n\n## Installation\n\nChoose your package manager to install `class-mergesort`.\n\n```bash\nnpm i -D class-mergesort\n```\n\n```bash\nyarn add -D class-mergesort\n```\n\n```bash\npnpm i -D class-mergesort\n```\n\n## Documentation\n\n[Docs](https://dirheimerb.github.io/class-mergesort)\n\n## API Overview\n\n### `toggleClass`\n\nTakes a class name and a boolean condition. If the condition is true, it returns the class name; otherwise, an empty string is returned.\n\n```typescript\nconst isActive = true;\nconst activeClass = toggleClass('active', isActive);\n// Output: \"active\" if isActive is true, \"\" otherwise.\n```\n\n### `prefixClass`\n\nPrepends a specified prefix to each class name in the list. Particularly useful for frameworks like Bootstrap.\n\n```typescript\nconst prefixedClasses = prefixClass('btn-', 'primary', 'large');\n// Output: \"btn-primary btn-large\"\n```\n\n### `suffixClass`\n\nAppends a specified suffix to each class name in the list. Useful for BEM methodology.\n\n```typescript\nconst suffixedClasses = suffixClass('--disabled', 'button', 'input');\n// Output: \"button--disabled input--disabled\"\n```\n\n### `filterClass`\n\nFilters class names based on a custom condition function. Only the class names that meet the condition will be included in the result.\n\n```typescript\nconst filteredClasses = filterClass(\n  (name) =\u003e !name.includes('omit'),\n  'button',\n  'omit-me',\n);\n// Output: \"button\"\n```\n\n### `mergeClass`\n\nCombines multiple class names into a single string, while eliminating duplicates and empty strings.\n\n```typescript\n// Multiple class name strings\nconst merged1 = mergeClass('btn btn-primary', 'btn-secondary', 'btn');\n// Output: \"btn btn-primary btn-secondary\"\n\n// Array of class names\nconst merged2 = mergeClass(['btn', 'btn-large'], ['btn-small', 'btn']);\n// Output: \"btn btn-large btn-small\"\n\n// Mixed types\nconst merged3 = mergeClass('btn btn-primary', ['btn-secondary', 'btn-large']);\n// Output: \"btn btn-primary btn-secondary btn-large\"\n```\n\n### `classNameX`\n\nActs similar to `mergeClass` but allows more complex structures and types for combining class names.\n\n```typescript\n// Check API documentation for examples.\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirheimerb%2Fclass-mergesort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirheimerb%2Fclass-mergesort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirheimerb%2Fclass-mergesort/lists"}