{"id":22710574,"url":"https://github.com/smallhelm/to-js-identifier","last_synced_at":"2025-08-07T15:31:25.523Z","repository":{"id":42411042,"uuid":"62072240","full_name":"smallhelm/to-js-identifier","owner":"smallhelm","description":"Convert any string (even reserved words) to a valid javascript identifier.","archived":false,"fork":false,"pushed_at":"2016-06-27T18:14:18.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-13T09:59:05.629Z","etag":null,"topics":["code-generation","compile-to-js","compiler"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/smallhelm.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":null,"support":null}},"created_at":"2016-06-27T16:47:36.000Z","updated_at":"2018-03-21T01:30:57.000Z","dependencies_parsed_at":"2022-09-01T01:11:03.100Z","dependency_job_id":null,"html_url":"https://github.com/smallhelm/to-js-identifier","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallhelm%2Fto-js-identifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallhelm%2Fto-js-identifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallhelm%2Fto-js-identifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallhelm%2Fto-js-identifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallhelm","download_url":"https://codeload.github.com/smallhelm/to-js-identifier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229057638,"owners_count":18013289,"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":["code-generation","compile-to-js","compiler"],"created_at":"2024-12-10T12:10:38.230Z","updated_at":"2024-12-10T12:10:38.822Z","avatar_url":"https://github.com/smallhelm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# to-js-identifier\n\n[![build status](https://secure.travis-ci.org/smallhelm/to-js-identifier.svg)](https://travis-ci.org/smallhelm/to-js-identifier)\n[![dependency status](https://david-dm.org/smallhelm/to-js-identifier.svg)](https://david-dm.org/smallhelm/to-js-identifier)\n\nConvert any string (even reserved words) to a valid javascript identifier.\n\nUseful when writing compile to JS languages.\n\n```js\nvar toId = require('to-js-identifier');\n\n//valid ids just go right through\ntoId('foo') === 'foo'\n\n//convert your string to a valid js identifier\ntoId('not-js') === 'not$45$js'\n\n//as use can see it wraps invalid chars with '$' + c.charCodeAt(0) + '$'\n//Even though $ is a valid identifier, this function will escape it, so it\n//is not possible that 2 inputs generate the same output\ntoId('$') === '$36$'\n\n//reserved words are escaped\ntoId('null') === '$null$'\ntoId('var')  === '$var$'\n\n// yes I know undefined is technically an identifier, but it shouldn't be!!!\ntoId('undefined') === '$undefined$'\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallhelm%2Fto-js-identifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallhelm%2Fto-js-identifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallhelm%2Fto-js-identifier/lists"}