{"id":30157422,"url":"https://github.com/tokimon/es-feature-detection","last_synced_at":"2025-08-11T13:38:28.499Z","repository":{"id":8436751,"uuid":"58220885","full_name":"Tokimon/es-feature-detection","owner":"Tokimon","description":"ECMAScript feature and API detection","archived":false,"fork":false,"pushed_at":"2023-03-04T02:54:28.000Z","size":1190,"stargazers_count":19,"open_issues_count":21,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-18T12:10:52.398Z","etag":null,"topics":["check","detect","ecmascript","es2015","es2016","es2017","es2018","es2019","feature","test"],"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/Tokimon.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":"2016-05-06T16:38:08.000Z","updated_at":"2023-11-21T12:55:04.000Z","dependencies_parsed_at":"2024-06-20T19:14:29.215Z","dependency_job_id":null,"html_url":"https://github.com/Tokimon/es-feature-detection","commit_stats":{"total_commits":92,"total_committers":4,"mean_commits":23.0,"dds":"0.19565217391304346","last_synced_commit":"534fd73fb570d6f4f78ec206976ab8c64ec38f96"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/Tokimon/es-feature-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tokimon%2Fes-feature-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tokimon%2Fes-feature-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tokimon%2Fes-feature-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tokimon%2Fes-feature-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tokimon","download_url":"https://codeload.github.com/Tokimon/es-feature-detection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tokimon%2Fes-feature-detection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269899084,"owners_count":24493073,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["check","detect","ecmascript","es2015","es2016","es2017","es2018","es2019","feature","test"],"created_at":"2025-08-11T13:38:24.836Z","updated_at":"2025-08-11T13:38:28.494Z","avatar_url":"https://github.com/Tokimon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# es-feature-detection\n\n[![Build Status](https://github.com/Tokimon/es-feature-detection/actions/workflows/validation.yml/badge.svg)](https://travis-ci.org/Tokimon/es-feature-detection)\n[![Coverage](https://coveralls.io/repos/github/Tokimon/es-feature-detection/badge.svg?branch=master)](https://coveralls.io/github/Tokimon/es-feature-detection)\n[![install size](https://packagephobia.now.sh/badge?p=es-feature-detection)](https://packagephobia.now.sh/result?p=es-feature-detection)\n\nECMAScript feature and API detection in the browser.\n\nIt detects which syntax features and built-in components are supported in the current\nbrowser.\n\n## Installation\n\n```\nnpm i es-feature-detection\n```\n\n## How to use\nThe different tests are divided into several sections:\n\n- **builtins:** Native core JS objects and constructors (_Array_, _Math_, _object_, etc.)\n- **dom:** DOM (browser environment) specific objects and constructors.\n- **localization:** _Intl_ implementations\n- **syntax:** Syntax implementations (_Promise_, _Arrow Function_, _for..of_, etc.)\n\nYou can either run all tests for a specific section by addressing its `index.js` file.\nWhen called will it return an object where each key is a specific feature,\nand its value a _boolean_ indicating if the feature is supported or not (eg. `Intl.Collator: true`).\n\n```js\nimport localization from 'es-feature-detection/localization';\n\nconst supportedIntlFeatures = localization();\n```\n\nOr you can access specific tests individually for fine grained testing:\n\n```js\nimport mathLog2 from 'es-feature-detection/builtins/Math.log2';\n\nconst mathLog2IsSupported = mathLog2();\n```\n\n### All OK\nFor convenience a `allOk` function is added in the `utils` folder, which can be\nhandy if you want to check if all values in an object is _true_:\n\n```js\nimport localization from 'es-feature-detection/localization';\nimport allOk from 'es-feature-detection/utils/allOk';\n\nconst fullIntlSupport = allOk(localization());\n```\n\nIf not every property is supported an array of unsupported fields is returned instead of _true_:\n\n```js\nif (fullIntlSupport !== true) {\n  console.log('Unsupported features:')\n  fullIntlSupport.forEach((key) =\u003e console.log(key));\n}\n```\n\n### Test custom expression\nIf you have a specific feature you want to test, you can use the `testExpression` function,\nplaced in the `utils` folder, to validate a specific string (it is the one used for all tests in this module):\n\n```js\nimport testExpression from 'es-feature-detection/utils/testExpression';\n// Ok this is a lame example, but it illustrates how to use it\nconst myFeatureIsSupported = testExpression('return MyFeature.someThingToTest()');\n```\n\nThe expression you pass in must be passed as a string and it can either _return true/false_\nor it can fail or not. Both cases the test will return _true_ or _false_\n\n### Need to test all features of a given ES version?\nIf you need to test the features introduced in a given EchmaScript version a file\nfor each version has been placed at the root of the module:\n\n```js\nimport es2020 from 'es-feature-detection/es2020';\nimport allOk from 'es-feature-detection/utils/allOk';\n\nconst fullES2020Support = allOk(es2020());\n```\n\nThese **_esXX_** files includes both builtins and syntax features introduces in the given version.\n\n## The reason for this module\nThe idea behind this module is to facilitate the detection of what a given browser\nsupport of JS features. Does it support the ES6 syntax and what kind of polyfills\nwould the browser need?\n\nThe norm is and have been for quite a while to just transpile your ES6 into ES5 and\nthen just fill you script with the polyfills you need and you are good to go.\nThis works pretty well and you don't have to worry about cross browser support of\nyour code. But there are several drawbacks by doing so:\n\n1. You don't leverage the performance gain of the optimized ES6 syntax, as everything stays in ES5\n2. You bloat your script with polyfills you don't need\n3. You bloat your script with transpiler code, that you don't need as many modern\nbrowsers already support the new syntax. Yes IE (edge) as well.\n\nPersonally I needed a proper tool to detect features that was actually used in the script file,\nso I could decide what to load, so I build this.\n\n## Why not just use babel-env?\n`babel-env` is really great tool and should definitely be the first choice. Sometimes,\nthough, you might have some modules (mostly 3rd party) you don't want to run through\nthe transpiler, but might use some built-in methods that are not necessarily\nsupported by all browsers. In this case there are some polyfills that are not detected\nand added at compile-time.\nSo having the `builtins` (or `dom`) detection which can detect which polyfills you need\nto load can be a good backup.\n\nThe `syntax` is useful for when you want to have two separate builds: One for newer\nbrowsers that understand the new goodies. And one that use plain old ES 5.\n\n## Ideas?\nHave any ideas, improvement request or bugs you have found, don't hesitate to file\nan issue in the [issue list](https://github.com/Tokimon/es-feature-detection/issues)\nor throw me a [PR](https://github.com/Tokimon/es-feature-detection/pulls) if you\nhave done some improvements you want to bring to the script.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokimon%2Fes-feature-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftokimon%2Fes-feature-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokimon%2Fes-feature-detection/lists"}