0.9.0 • Published 8 years ago

es6-modernizr v0.9.0

Weekly downloads
25
License
MIT
Repository
github
Last release
8 years ago

ES6 Modernizr - ECMAScript 6 Feature Detection Library

Powered by Node.js and me.

What is the purpose of this project?

The main purpose of this project is to detect the compatibility of your node.js runtime with the new ECMASscript 6 features, bringing new possibilities with current build systems transpilers (see es6-tools for more information about transpilers). This way, you can detect supported (and unsupported) ES6 features in your current environment to prevent the transpilation of the whole project. It also provides a CLI app to quickly view the compatibility of your node.js runtime and enable all V8 flags to achieve maximum compatibility.

How does it works under the hood?

When you test for a specific ES6 feature the library maps a file inside the features folder, which usually exports/returns a boolean. Since most ES6 features include new syntax features, they usually throw a SyntaxException, during the evaluation process, when there is no support. So, to load the test files a require hook is used (implemented in misc/js/require-boolean.js). This hook exports/returns the exported/returned object by the test file, but doubly negated (implying an implicit type cast) and returns false if an exception is thrown.

How do I install it?

If you want to use the CLI app we recommend you to install the package globally.

    $ npm install -g es6-modernizr

If you want to use it as a dependency in your own project and use it at runtime.

    $ npm install --save es6-modernizr

If you want to use it as a dev dependency in your own project to use as a build step.

    $ npm install --save-dev es6-modernizr

If you want to install it from source.

    $ https://github.com/EgaLabs/ES6-Modernizr.git
    cd ES6-Modernizr
    npm install -g
    cd ..
    rm -rf ES6-Modernizr

How do I use it? - CLI

When using the CLI app you may see yourself in any of these four situations.

You know nothing about the usage.

You don't even know how to get the typical help information. In that case, if you write something invalid, or nothing at all, after the command $ es6-modernizr it will show you three possible actions and information to save you time (next time).

You want to see the help.

If you want to see information about the CLI app just add the --help flag.

    $ es6-modernizr --help

You want to view the compatibility of your node.js runtime.

If you want to view the compatibility of your current node.js runtime just type any of the commands below.

    $ es6-modernizr view-compatibility
    $ es6-modernizr view
    $ es6-modernizr compatibility
    $ es6-modernizr compat

You want to enable maximum compatibility of your node.js runtime.

To enable maximum compatibility with ES6 features you must source the CLI app in order to override the node alias. You can even use the . (just a dot) instead of source.

    $ source es6-modernizr maximum-compatibility
    $ source es6-modernizr enable-harmony
    $ source es6-modernizr enable-es6
    $ source es6-modernizr enable

Since "use strict" mode may break some modules (which should not happen if they are well coded; there are some exceptions) the flag --use-strict is not added by default to the node alias. If you want to force all modules to run on strict mode, which enables let and const support in some node.js versions, you must add the --use-strict flag to the commands above.

Known bugs.

There is a couple of known bugs in the project. Before saying anything you must better know that they are not really bugs but more like the limitations it has on Microsoft Windows.

Access denied error.

Microsoft Windows always sometimes will give you an Access denied warning/error when trying to maximize the compatibility of your node command using $ es6-modernizr maximum-compatibility. The origin of this issue is the default install location of npm packages which is under C:\Program Files\nodejs, C:\Program Files (x86)\nodejs or one of its subfolders. Since these folders are protected against unauthorized modifications (by non-administrators users) the temporal file used to write the necessary flags to maximize the compatibility can't be created and fails giving the Access denied warning/error. The solution is as simple as the issue: change the install location of npm modules using the prefix variable of the npmrc file (since executing the Windows command line as administrator every time is a pain in the ass and even impossible if we are talking about embedded terminals in IDEs).

Windows DOSKEY limitations.

On platforms with an available Bash Shell the library can be used without limitations thanks to the alias command, which let us create a temporary node alias containing all the possible V8 flags to enable maximum compatibility. In Windows there is no alias command, and on top of that, the only one whose behaviour is quite the same doesn't works inside Batch scripts (yes, I'm talking about the DOSKEY utility). So, the only way you can use the "alias" in Windows is using the temporary variable %node% or %__node__%.

Planning.

  • Add CLI app. View file here.
  • Add Bash support. View file here.
  • Add Batch support. View file here.
  • Add post-install script. View file here.
  • Add synchronous API to test ES6 features. View file here.
  • Add asynchronous API to test ES6 features.
  • Add API to read/write test results (to know asynchronous test results using synchronous API).
  • Add feature Constants. View file here.
  • Add category Scoping. View file here.
  • Add feature Block-Scoped Variables. View file here.
  • Add feature Block-Scoped Functions. View file here.
  • Add category Arrow Functions. View file here.
  • Add feature Expression Bodies. View file here.
  • Add feature Statement Bodies. View file here.
  • Add feature Lexical this. View file here.
  • Add category Extended Parameter Handling. View file here.
  • Add feature Default Parameter Values. View file here.
  • Add feature Rest Parameters. View file here.
  • Add feature Spread Operator. View file here.
  • Add category Template Literals. View file here.
  • Add feature String Interpolation. View file here.
  • Add feature Custom Interpolation. View file here.
  • Add feature Raw String Access. View file here.
  • Add category Extended Literals. View file here.
  • Add feature Binary & Octal Literals. View file here.
  • Add feature Unicode String & RegExp Literal. View file here.
  • Add category Enhanced Regular Expressions. View file here.
  • Add feature Regular Expression Sticky Matching.
  • Add category Enhanced Object Properties. View file here.
  • Add feature Property Shorthand. View file here.
  • Add feature Computed Property Names. View file here.
  • Add feature Method Properties. View file here.
  • Add category Destructuring Assignment. View file here.
  • Add feature Array Matching. View file here.
  • Add feature Object Matching, Shorthand Notation. View file here.
  • Add feature Object Matching, Deep Matching. View file here.
  • Add feature Parameter Context Matching. View file here.
  • Add feature Fail-Soft Destructuring. View file here.
  • Add category Modules. View file here.
  • Add feature Value Export/Import. View file here.
  • Add feature Default & Wildcard. View file here.
  • Add category Classes. View file here.
  • Add feature Class Definition. View file here.
  • Add feature Class Inheritance. View file here.
  • Add feature Class Inheritance, From Expressions.
  • Add feature Base Class Access. View file here.
  • Add feature Static Members. View file here.
  • Add feature Getter/Setter. View file here.
  • Add category Symbol Types. View file here.
  • Add feature Symbol Type. View file here.
  • Add feature Global Symbols. View file here.
  • Add category Iterators. View file here.
  • Add feature Iterator & For-Of Operator. View file here.
  • Add category Generators. View file here.
  • Add feature Generator Function. View file here.
  • Add feature Generator Function, Iterator Protocol. View file here.
  • Add feature Generator Function, Direct Use. View file here.
  • Add feature Generator Matching. View file here.
  • Add feature Generator Control-Flow (only asynchronous or read/write API).
  • Add feature Generator Methods. View file here.
  • Add category Map/Set & WeakMap/WeakSet. View file here.
  • Add feature Set Data-Structure. View file here.
  • Add feature Map Data-Structure. View file here.
  • Add feature Weak-Link Data-Structures. View file here.
  • Add feature Typed Arrays. View file here.
  • Add category New Built-In Methods. View file here.
  • Add feature Object Property Assignment. View file here.
  • Add feature Array Element Finding. View file here.
  • Add feature String Repeating. View file here.
  • Add feature String Searching. View file here.
  • Add feature Number Type Checking. View file here.
  • Add feature Number Safety Checking. View file here.
  • Add feature Number Comparison. View file here.
  • Add feature Number Truncation. View file here.
  • Add feature Number Sign Determination. View file here.
  • Add category Promises. View file here.
  • Add feature Promise Usage. View file here.
  • Add feature Promise Combination. View file here.
  • Add category Meta-Programming. View file here.
  • Add feature Proxying. View file here.
  • Add feature Reflection. View file here.
  • Add category Internationalization & Localization. View file here.
  • Add feature Collation. View file here.
  • Add feature Number Formatting. View file here.
  • Add feature Currency Formatting. View file here.
  • Add feature Date/Time Formatting. View file here.