New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ts-comment

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-comment

utils for comments in TypeScript/JavaScript file

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
978
23.95%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

comment

FAQs

Package last updated on 20 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts