node-feature-detect

Feature detection for Node.js

Usage no npm install needed!

<script type="module">
  import nodeFeatureDetect from 'https://cdn.skypack.dev/node-feature-detect';
</script>

README

node-feature-detect

Checks for features.

var detect = require('node-feature-detect')

detect.features
// [ 'generators', 'let', 'fat arrow', ... ]

detect('class', 'generators')
// { unsupported: 'class', minVersion: '4.0.0' }

or:

var unsupported = detect('let')
if (unsupported) {
  // ...
}

Or you can automatically fail:

detect.fail('class', 'generators')

// Error: Your platform doesn't support these features: generators, class.
// Please upgrade to Node.js v4.0.0 or above.

Features:

  • class
  • fat arrow
  • generators
  • let
  • object.assign
  • promise
  • symbol
  • template string
  • weakmap

Thanks

node-feature-detect © 2015+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz