highlight-es

Highlight ECMAScript syntax for the console or any other medium.

MIT 3 个版本
安装
npm install highlight-es
yarn add highlight-es
pnpm add highlight-es
bun add highlight-es
README

highlight-es

Build Status

Highlight ECMAScript syntax for the console or any other medium.

Install

npm install highlight-es

Usage

const highlight = require('highlight-es');

function testFunc () {
    const re    = /(.+) awesome$/;
    const match = 'You are awesome'.match(re);

    return match[1];
}

const code = testFunc.toString();

console.log('\n' + highlight(code));

example

You can pass custom renderer to target other medium, e.g.:

highlight(code, {
    string:     str => ...,
    punctuator: str => ...,
    keyword:    str => ...,
    number:     str => ...,
    regex:      str => ...,
    comment:    str => ...,
    invalid:    str => ...
});

is-es2016-keyword - Determine if string is an ES2016 keyword.

Author

Ivan Nikulin (ifaaan@gmail.com)

版本列表
1.0.3 2018-04-22
1.0.1 2017-01-25
1.0.0 2016-02-12