Answers for "count file lines in typescript"

0

count file lines in typescript

'use strict';

import * as fs from 'fs';

function linesNumber(fileName: string): number {
  try {
    let fileLines = fs.readFileSync(fileName, 'utf-8').split('\n');
    return fileLines.length;
  } catch (err) {
    return 0;
  }
}
console.log(linesNumber('my-file.txt'))
Posted by: Guest on December-01-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language