Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nwc-l

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nwc-l

Count new lines in a file sync or async.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

nwc-l

Lighweight Node.js module for counting the number of lines in a file either sync or async. This module doesn't have any external dependencies, it uses only the native fs module.

Install with npm install nwc-l


Documentation

wcl.sync(fileLocation);

  • fileLocation - String path to the file you want to read from
  • Returns: <integer> number of lines

wcl.async(fileLocation);

  • fileLocation - String path to the file you want to read from
  • Returns: <Promise> number of lines

Example

const nwcl = require('nwc-l');

// Synchronous
let count = nwcl.sync('./myfile-7lines.txt');
console.log('Number of lines: ' + count);

// Asyncronious Promise
nwcl.async('./myfile-7lines.txt').then((count) => {
    console.log('Number of lines: ' + count);
});
// Asyncronious await
async function countAsync() {
    let asyncCount = await nwcl.async('./myfile-7lines.txt');
    console.log('Number of lines: ' + asyncCount);
}
countAsync();

will print

Number of lines: 7
Number of lines: 7
Number of lines: 7

FAQs

Package last updated on 15 Nov 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc