Giter Site home page Giter Site logo

node-green's Introduction

node-green

Check Node.js ECMAScript compatibility.

License NPM Version

Installation

Using Yarn:

yarn add node-green

Using npm:

npm install node-green

Usage

const nodeGreen = require('node-green')
;(async () => {
  // Use the version of Node.js you're running by default
  let result = await nodeGreen('Array.prototype.includes')
  console.log(result)

  let result = await nodeGreen('Array.prototype.includes', { nodeVersion: '6.4.0' })
  console.log(result)

  // Allow `harmony` flag
  let result = await nodeGreen('Array.prototype.includes', { allowHarmony: true })
  console.log(result)
})

API

nodeGreen(feature, [options])

Fetch williamkapke/node-compat-table and returns query result.

feature

Type: string

ES feature you want to search.

options

Type: object

allowHarmony

Type: boolean

Allow using --harmony flag for Node.js.

nodeVersion

Type: string

Specify Node.js version. If it is omitted, use the version of Node.js you are running currently.

Return Type

Type: object

nodeVersion

Type: string

Node.js verison.

v8Version

Type: string

V8 version.

result

Type: Array

An array of query result.

esVersion

Type: string

It will be one of ESNEXT, ES2018, ES2017, ES2016, ES2015.

featureType

Type: string

It may be one of misc, syntax, functions and so on.

category

Type: string

feature

Type: string

passed

Type: boolean

Indicates whether the feature was passed under that Node.js.

Related Projects

node-green-cli - CLI for this module.

Credits

Thanks @williamkapke's work: williamkapke/node-compat-table.

License

MIT License

Copyright (c) 2018-present Pig Fang

node-green's People

Contributors

0xdevalias avatar g-plane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-green's Issues

Add support for latest ES_VERSIONS (eg. everything after ES2018)

Looking at the code here, it will only check against a hardcoded list of ES_VERSIONS:

const ES_VERSIONS = [
'ESNEXT',
'ES2018',
'ES2017',
'ES2016',
'ES2015',
]

ES_VERSIONS.forEach(ver => {

Yet looking at the .json data for a recent (19.1.0) version of node in node-compat-table, there are many more keys supported:

โ‡’  curl --silent https://raw.githubusercontent.com/williamkapke/node-compat-table/gh-pages/results/v8/19.1.0.json | jq 'keys'
[
  "ES2015",
  "ES2016",
  "ES2017",
  "ES2018",
  "ES2019",
  "ES2020",
  "ES2021",
  "ES2022",
  "ES2023",
  "ESNEXT",
  "_engine",
  "_version"
]

It would be great if you could update this package (and ensure the node-green-cli uses the newer version) so that we can check features that only came into existence in these newer versions.

Ideally we could probably do away with the hardcoded ES_VERSIONS and just extract the keys to check automagically from the .json, something like this might work:

const esVersions = Object.keys(result).filter(key => !key.startsWith('_')).reverse();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.