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

co-readline

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-readline

Read a file line by line in generator/co style

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35
increased by40%
Maintainers
1
Weekly downloads
 
Created
Source

co-readline

Build Status

codecov

Read a file line by line in generator/co style.

install

$ npm i co-readline

easy example

var coReadline = require('co-readline')
var co = require('co')

co(function * () {
  var NORMAL_FILE_PATH = 'absolute_path_to_file'
  var rlGen = coReadline(NORMAL_FILE_PATH)

  var lines = []

  for (var line of rlGen) {
    if (line.then) { // `line` could be Promise or String
      line = yield line;
    }

    lines.push(line)
  }

  var fileContent = yield fs.readFile(NORMAL_FILE_PATH, 'utf-8')
  fileContent.should.equal(lines.join('\n'))
})

api

coReadline(filePath) return a generator, then do for..of to it

benchmark

About 1/3 speed of build-in readline module

About 1/6 speed of fs.readFileSync

Read about 1 million lines per second

FAQs

Package last updated on 02 Dec 2016

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