Detalhes do pacote

ts-comment

ikatyang2.9kMIT1.1.0

utils for comments in TypeScript/JavaScript file

comment, typescript, javascript

readme (leia-me)

ts-comment

npm build coverage

utils for comments in TypeScript/JavaScript file

Changelog

Install

# using npm
npm install --save ts-comment

# using yarn
yarn add ts-comment

Usage

import * as ts_comment from 'ts-comment';

const file_content = `
  class X {}
  // comment 1
  const y = 0;
  /* comment 2 */
  function z() {}
`;

ts_comment.gets(file_content); //=> ['// comment 1', '/* comment 2 */']

API

/**
 * iterate every comment, return `false` to stop iteration
 */
function for_each(
  source: string | ts.SourceFile,
  callback: (comment: string, scanner: ts.Scanner, source_file: ts.SourceFile) => boolean | void,
  ts?: typeof ts,
): void;

/**
 * get comments from source, optional callback for custom results
 */
function gets(source: string | ts.SourceFile): string[];
function gets<T>(
  source: string | ts.SourceFile,
  callback: (comment: string, scanner: ts.Scanner, source_file: ts.SourceFile) => T,
  ts?: typeof ts,
): T[];

Development

# lint
yarn run lint

# build
yarn run build

# test
yarn run test

License

MIT © Ika

changelog (log de mudanças)

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.1.0 (2017-08-20)

Features

v1.0.1 (2017-06-13)

🏠 Internal

  • Upgrade typescript@^2.4.0

v1.0.0 (2017-06-12)

🚀 New Feature

  • Release first version