ts-fn-source-code-range-recorder
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ts-fn-source-code-range-recorder

Introduction

This transformer records all code range of function declarations and arrow functions into a json file named .file-fn-range.json in the project root.

Sample:

|---my-app
|   |---src
|   |   |---inner
|   |   |   |---b.ts
|   |   |---a.ts

src/a.ts:

export function add(a: number, b: number): number {
  return a + b;
}

src/inner/b.ts:

export const add = (a: number, b: number): number => {
  return a + b;
}

export class Calc {
  add(a: number, b: number): number {
    return a + b;
  }
}

_fileFnRange.json:

{
  "src/a.ts": [
    {
      "start": 0,
      "end": 69
    }
  ],
  "src/inner/b.ts": [
    {
      "start": 6,
      "end": 72
    },
    {
      "start": 18,
      "end": 72
    },
    {
      "start": 93,
      "end": 153
    }
  ]
}

Installation

$ npm i -D ts-fn-source-code-range-recorder

Usage

Assumes that your source code directory is src and tsconfig.json is in the project root.

Creates a new file named "compile.ts" in the project root with following content:s

import { compile } from "ts-fn-source-code-range-recorder";

compile("src", "tsconfig.json");

Then run

$ ts-node compile.ts

to compile your code into JS.

Readme

Keywords

none

Package Sidebar

Install

npm i ts-fn-source-code-range-recorder

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

17.2 kB

Total Files

19

Last publish

Collaborators

  • ethan.zhang