Giter Club home page Giter Club logo

es-comments's Introduction

es-comments

Parses a list of comments from an ECMAScript (JavaScript) source file. 0 dependencies, 482 bytes minified + gzipped.

Install

npm install es-comments

Usage

const parseESComments = require('es-comments');
const someSourceCode = `
    // Some single line comment
    console.log('hello world');
`;
const comments = parseESComments(someSourceCode);
/* Outputs:
    [
      {
        "value": "// Some single line comment",
        "start": 9,
        "end": 36
      }
    ]
*/

Benchmarks

Benchmarks run on a mid-2015 MacBook Pro. Benchmarks compare running time to other similar npm packages.

+--------------+----------------------------+------------------+---------------+---------------+
|              │ es-comments (this package) │ extract-comments │ get-comments  │ comment-regex |
+--------------+----------------------------+------------------+---------------+---------------+
| jQuery 1.7.2 │ 49.36 ops/sec              │ 9.27 ops/sec     │ 22.05 ops/sec │ 1,474 ops/sec |
+--------------+----------------------------+------------------+---------------+---------------+

tl;dr: If location information is not necessary, and some misses are ok, use a RegExp. Otherwise, this package is a good alternative.

es-comments's People

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.