UNPKG

@code-to-json/core

Version:

[![Build Status](https://travis-ci.org/code-to-json/code-to-json.svg?branch=master)](https://travis-ci.org/code-to-json/code-to-json) [![Build Status](https://dev.azure.com/code-to-json/code-to-json/_apis/build/status/code-to-json.code-to-json)](https://d

19 lines (17 loc) 492 B
import { getLineAndCharacterOfPosition, SourceFile } from 'typescript'; import { CodeRange } from '../types'; export default function serializeLocation( sourceFile: SourceFile, pos: number, end: number ): CodeRange { const posStart = getLineAndCharacterOfPosition(sourceFile, pos + 1); const posEnd = getLineAndCharacterOfPosition(sourceFile, end); return [ sourceFile.fileName, posStart.line + 1, posStart.character, posEnd.line + 1, posEnd.character ]; }