{"id":17963695,"url":"https://github.com/bramstein/characterset","last_synced_at":"2025-03-25T05:32:20.852Z","repository":{"id":6930237,"uuid":"8181433","full_name":"bramstein/characterset","owner":"bramstein","description":"A library for creating and manipulating character sets","archived":false,"fork":false,"pushed_at":"2023-04-25T08:08:40.000Z","size":46,"stargazers_count":30,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-19T09:14:21.044Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bramstein.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-02-13T15:16:43.000Z","updated_at":"2024-08-22T12:15:17.000Z","dependencies_parsed_at":"2024-06-18T16:52:37.047Z","dependency_job_id":null,"html_url":"https://github.com/bramstein/characterset","commit_stats":{"total_commits":48,"total_committers":5,"mean_commits":9.6,"dds":"0.27083333333333337","last_synced_commit":"30f9157f3fbd688ae5a9087823282f5c15859c83"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fcharacterset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fcharacterset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fcharacterset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramstein%2Fcharacterset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramstein","download_url":"https://codeload.github.com/bramstein/characterset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407667,"owners_count":20610231,"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":[],"created_at":"2024-10-29T11:43:43.416Z","updated_at":"2025-03-25T05:32:20.602Z","avatar_url":"https://github.com/bramstein.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## CharacterSet\n\nCharacterSet is a library for creating and manipulating Unicode character sets in JavaScript. Its main purpose is to help in building regular expressions for validation and matching. It fully supports all Unicode characters and correctly handles surrogate pairs in JavaScript strings and regular expressions.\n\n## Installation\n\nIf you are using Node.js you can install it using npm:\n\n```sh\nnpm install characterset\n```\n\nIf you want to use CharacterSet in the browser, use the global `CharacterSet` constructor or include CharacterSet as an ES6 module.\n\n## API\n\nThe constructor takes a single input value, which can either be a number, a string or a range. A range is an array of numbers or number pairs.\n\n```js\nimport CharacterSet from 'characterset';\n\n// Creates a character set with a single code point for [97]\nvar cs = new CharacterSet(97);\n\n// Creates a character set for the code points [97, 98, 99]\nvar cs = new CharacterSet('abc');\n\n// Creates a character set for the code points [97, 98, 99]\nvar cs = new CharacterSet([97, 98, 99]);\n\n// Creates a character set for the code points [97, 98, 99] using a range\nvar cs = new CharacterSet([[97, 99]]);\n\n// Combines pairs and numbers in ranges for [0, 97, 98, 99]\nvar cs = new CharacterSet([48, [97, 99]]);\n```\n\nOr you can use the `parseUnicodeRange` method to return a CharacterSet instance from a comma-delimited unicode range string.\n\n```js\nimport CharacterSet from 'characterset';\n\n// Creates a character set for the code points [34, 35]\nvar cs = CharacterSet.parseUnicodeRange('u+23,u+22');\n\n// Creates a character set for the code points [34, 35, 36, 37]\nvar cs = CharacterSet.parseUnicodeRange('u+22-25');\n```\n\nOnce you have an instance of `CharacterSet` you can use the following methods on it:\n\n\u003cdl\u003e\n  \u003cdt\u003egetSize()\u003c/dt\u003e\n  \u003cdd\u003eReturns the number of code points in this set.\u003c/dd\u003e\n\n  \u003cdt\u003etoArray()\u003c/dt\u003e\n  \u003cdd\u003eReturns all code points in this set as a sorted array.\u003c/dd\u003e\n\n  \u003cdt\u003etoRange()\u003c/dt\u003e\n  \u003cdd\u003eReturns all code points in this set as a range (i.e. compressed.)\u003c/dd\u003e\n\n  \u003cdt\u003eisEmpty()\u003c/dt\u003e\n  \u003cdd\u003eReturns true if this set is empty.\u003c/dd\u003e\n\n  \u003cdt\u003eadd(codePoint, ...)\u003c/dt\u003e\n  \u003cdd\u003eAdds the given code point(s) to this set.\u003c/dd\u003e\n\n  \u003cdt\u003eremove(codePoint, ...)\u003c/dt\u003e\n  \u003cdd\u003eRemoves the given code point(s) from this set.\u003c/dd\u003e\n\n  \u003cdt\u003econtains(codePoint)\u003c/dt\u003e\n  \u003cdd\u003eReturns true if the given code point is in this set.\u003c/dd\u003e\n\n  \u003cdt\u003eequals(other)\u003c/dt\u003e\n  \u003cdd\u003eReturns true if the `other` set is equal to this set.\u003c/dd\u003e\n\n  \u003cdt\u003eunion(other)\u003c/dt\u003e\n  \u003cdd\u003eReturns a new character set from the combined code points from `other` and this character set.\u003c/dd\u003e\n\n  \u003cdt\u003eintersect(other)\u003c/dt\u003e\n  \u003cdd\u003eReturns a new character set containing only the code points `other` and this character set have in common.\u003c/dd\u003e\n\n  \u003cdt\u003edifference(other)\u003c/dt\u003e\n  \u003cdd\u003eReturns a new character set containing only the code points from this that are not in `other`.\u003c/dd\u003e\n\n  \u003cdt\u003esubset(other)\u003c/dt\u003e\n  \u003cdd\u003eReturns true if this character set is a subset of `other`.\u003c/dd\u003e\n\n  \u003cdt\u003etoRegExp()\u003c/dt\u003e\n  \u003cdd\u003eReturns a RegExp matching the code points in this character set\u003c/dd\u003e\n\n  \u003cdt\u003etoString()\u003c/dt\u003e\n  \u003cdd\u003eReturns a string representation of this character set.\u003c/dd\u003e\n\n  \u003cdt\u003etoHexString()\u003c/dt\u003e\n  \u003cdd\u003eReturns a hex string representation of this character set.\u003c/dd\u003e\n\n  \u003cdt\u003etoHexRangeString()\u003c/dt\u003e\n  \u003cdd\u003eReturns a hex string representation with ranges of this character set.\u003c/dd\u003e\n\u003c/dl\u003e\n\n## License\n\nCharacterSet is licensed under the three clause BSD license (see [BSD.txt](BSD.txt).)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramstein%2Fcharacterset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramstein%2Fcharacterset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramstein%2Fcharacterset/lists"}