{"id":17442391,"url":"https://github.com/louisbrunner/babel-plugin-transform-nullish-operator","last_synced_at":"2026-02-08T11:02:48.410Z","repository":{"id":39699442,"uuid":"304604906","full_name":"LouisBrunner/babel-plugin-transform-nullish-operator","owner":"LouisBrunner","description":"A Babel plugin which emulates the `a?` existence check from CoffeeScript using the `??` syntax","archived":false,"fork":false,"pushed_at":"2024-06-12T11:08:29.000Z","size":1730,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T17:47:35.671Z","etag":null,"topics":["babel","babel-plugin","coffeescript","exists","javascript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/babel-plugin-transform-nullish-operator","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/LouisBrunner.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-16T11:18:47.000Z","updated_at":"2024-06-12T11:08:26.000Z","dependencies_parsed_at":"2024-06-12T13:25:56.427Z","dependency_job_id":"806747dc-3b1e-4591-b7dd-2cf0e1bb13e5","html_url":"https://github.com/LouisBrunner/babel-plugin-transform-nullish-operator","commit_stats":{"total_commits":21,"total_committers":4,"mean_commits":5.25,"dds":0.4285714285714286,"last_synced_commit":"7b609063728a6ffc0c28aebca7a29075365d2e16"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Fbabel-plugin-transform-nullish-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Fbabel-plugin-transform-nullish-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Fbabel-plugin-transform-nullish-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Fbabel-plugin-transform-nullish-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LouisBrunner","download_url":"https://codeload.github.com/LouisBrunner/babel-plugin-transform-nullish-operator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246358251,"owners_count":20764366,"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":["babel","babel-plugin","coffeescript","exists","javascript"],"created_at":"2024-10-17T16:05:43.336Z","updated_at":"2026-02-08T11:02:44.288Z","avatar_url":"https://github.com/LouisBrunner.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `babel-plugin-transform-nullish-operator` [![NPM Version][npm-image]][npm-url] ![Build Status][ci-image] [![Coverage Status][coveralls-image]][coveralls-url]\n\nThis package is a `babel` plugin which can be used to emulate the Coffeescript existence operator (`a?`) in Babel using the new [coalescing nullish operator](https://babeljs.io/docs/en/next/babel-plugin-proposal-nullish-coalescing-operator.html) ([Stage 4 proposal](https://github.com/tc39/proposal-nullish-coalescing)).\n\nThis is completely non-standard, experimental and could break at any time.\n\n## Example\n\n**In**\n\n```javascript\nvar fooExists = object.foo ?? EXISTS;\n```\n\n**Out**\n\n```javascript\nvar _object$foo;\n\nvar fooExists = (_object$foo = object.foo) !== null \u0026\u0026 _object$foo !== void 0;\n```\n\n\u003e **NOTE:** We cannot use `!= null` here because `document.all == null` and\n\u003e `document.all` has been deemed not \"nullish\".\n\n## Installation\n\n```sh\nnpm install --save-dev babel-plugin-transform-nullish-operator\n```\n\n## Usage\n\n### With a configuration file (Recommended)\n\n```json\n{\n  \"plugins\": [\"babel-plugin-transform-nullish-operator\"]\n}\n```\n\n### Via CLI\n\n```sh\nbabel --plugins babel-plugin-transform-nullish-operator script.js\n```\n\n### Via Node API\n\n```javascript\nrequire(\"@babel/core\").transform(\"code\", {\n  plugins: [\"babel-plugin-transform-nullish-operator\"]\n});\n```\n\n## Options\n\n### `identifier`\n\n`string`, defaults to `EXISTS`.\n\nCan be used to change the identifier which is used to trigger this alternative behavior of the nullish coalescing operator.\n\n#### Example with `{\"identifier\": \"DO_YOU_EXIST\"}`\n\n**In**\n\n```javascript\nvar fooExists = object.foo ?? DO_YOU_EXIST;\n```\n\n**Out**\n\n```javascript\nvar _object$foo;\n\nvar fooExists = (_object$foo = object.foo) !== null \u0026\u0026 _object$foo !== void 0;\n```\n\n## Linting\n\nYour linter might `EXISTS` as undefined (which is true, the symbol doesn't actually exists, it is only a placeholder), in that case you will need to explicitely add it in your config.\n\nExample using `eslint`:\n\n```json\n{\n  ...\n  \"globals\": {\n    \"EXISTS\": \"readonly\"\n  },\n  ...\n}\n```\n\n## References \u0026 Thanks\n\nThis is project is heavily based on Babel's [`@babel/plugin-proposal-nullish-coalescing-operator`](https://babeljs.io/docs/en/next/babel-plugin-proposal-nullish-coalescing-operator.html) (including code, tests, usage, etc).\n\n## License\n\nMIT, Copyright (c) 2020-2020 Louis Brunner\n\n\n\n[npm-image]: https://img.shields.io/npm/v/babel-plugin-transform-nullish-operator.svg\n[npm-url]: https://npmjs.org/package/babel-plugin-transform-nullish-operator\n[ci-image]: https://github.com/LouisBrunner/babel-plugin-transform-nullish-operator/workflows/Build/badge.svg\n[coveralls-image]: https://coveralls.io/repos/github/LouisBrunner/babel-plugin-transform-nullish-operator/badge.svg?branch=main\n[coveralls-url]: https://coveralls.io/github/LouisBrunner/babel-plugin-transform-nullish-operator?branch=main\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisbrunner%2Fbabel-plugin-transform-nullish-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flouisbrunner%2Fbabel-plugin-transform-nullish-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisbrunner%2Fbabel-plugin-transform-nullish-operator/lists"}