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

slice-file

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slice-file

stream file slices by line number indexes

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
173
increased by239.22%
Maintainers
1
Weekly downloads
 
Created
Source

slice-file

stream file slices by line number indexes

build status

example

positive slice

var sf = require('slice-file');
var words = sf('/usr/share/dict/words');
words.slice(22398,22408).pipe(process.stdout);
beep
beep's
beeped
beeper
beeper's
beepers
beeping
beeps
beer
beer's

tail

var sf = require('slice-file');
var xs = sf('/usr/share/dict/words');
xs.slice(-10).pipe(process.stdout);
élan's
émigré
émigré's
émigrés
épée
épée's
épées
étude
étude's
études

methods

var sf = require('slice-file')

var xs = sf(filename, opts={})

Create a slice-file instance xs from a filename and some options opts.

These opts are passed to fs.open():

  • opts.flags - string flags to open the file with, default "r"
  • opts.mode - mask to open the file with, default 0666

If you already have a file descriptor open you can pass opts.fd to skip calling fs.open().

Use opts.bufsize to set how much data to read in each chunk. Default 4096.

var stream = xs.slice(i, j, cb)

Return a readable stream that emits each line between line numbers [i,j) exactly like Array.prototype.slice(). Each line data buffer includes a trailing "\n" except for the last line if there is no trailing newline before the EOF.

Just like Array.prototype.slice(), i and j may be negative.

If cb(err, lines) is given, the lines will be buffered into lines.

install

With npm do:

npm install slice-file

license

MIT

Keywords

FAQs

Package last updated on 11 Apr 2013

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