New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

debussy

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debussy - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

42

index.js

@@ -9,9 +9,19 @@ /* eslint: handle-callback-err: 0 */

**
** // or pass in options to override defaults.
** // refer to fs.createReadStream() documentation.
** const FileReader = new Debussy(filename, {encoding: 'utf-8'});
**
** FileReader.on('line', line => {
** process line...
** // process line...
**
** // found what you need; stop the stream.
** FileReader.stop();
** });
**
** FileReader.on('end', () => {
** do something after last line has been read...
** // do something after last line has been read...
** });
**
** The MIT License (MIT)
** Copyright (c) 2016-Eternity Gerry Gold
**/

@@ -24,14 +34,36 @@

class Debussy extends EventEmitter {
constructor(filename) {
constructor(filename, userOptions = {}) {
super();
// Based on: https://nodejs.org/api/fs.html
const defaultCreateReadStreamOptions = {
flags: 'r',
encoding: null,
fd: null,
mode: 0o666,
autoClose: true
};
const mergedOptions = {};
Object.assign(mergedOptions, defaultCreateReadStreamOptions, userOptions);
this.inputStream = fs.createReadStream(filename, mergedOptions);
const rd = readline.createInterface({
input: fs.createReadStream(filename),
input: this.inputStream,
output: process.stdout,
terminal: false
});
rd.on('line', line => this.emit('line', line));
rd.on('close', () => this.emit('end'));
}
};
stop() {
// destroy() marks the object as destroyed and then calls close()
// Based on: https://github.com/nodejs/node/blob/master/lib/fs.js
this.inputStream.destroy();
}
}
module.exports = Debussy;

7

package.json
{
"name": "debussy",
"version": "1.1.0",
"version": "2.0.0",
"description": "simple, fast, and efficient file reader, line by line",

@@ -31,3 +31,6 @@ "main": "index.js",

},
"homepage": "https://github.com/gold/debussy#readme"
"homepage": "https://github.com/gold/debussy#readme",
"devDependencies": {
"eslint": "^3.6.0"
}
}

@@ -14,7 +14,7 @@ debussy

You want to read files line by line. And you cannot be bothered with memory
limitations because of the size of the file.
You want to read files line by line. And you cannot be bothered with
memory limitations because of the size of the file.
This module neatly does the trick for you, even if you need to parse a 20 GB log
file.
This module neatly does the trick for you, even if you need to parse a
20 GB log file.

@@ -28,13 +28,20 @@ Usage

// or pass in options to override defaults.
// refer to fs.createReadStream() documentation.
const FileReader = new Debussy(filename, {encoding: 'utf-8'});
FileReader.on('line', line => {
process line...
// process line...
// found what you need; stop the stream.
FileReader.stop();
});
FileReader.on('end', () => {
do whatever you want after last line has been read...
// do whatever you want after last line has been read...
});
```
As of node v6.2.0, `import` statement still not implemented. And not gonna
complicate things transpiling to ES5.
As of node v6.2.0, `import` statement still not implemented. And not
gonna complicate things transpiling to ES5.

@@ -44,19 +51,18 @@ Technical Notes

We're using node's built-in streaming, readline, and event emit tech. The module
is tiny. The inspiration for creating this npm package was so I wouldn't have to
keep looking up and repeating the same stream and readline node syntax every
time I needed to parse a file.
We're using node's built-in streaming, readline, and event emit tech.
The module is very small. The inspiration for creating this npm package
was so I wouldn't have to keep looking up and repeating the same stream
and readline node syntax every time I needed to parse a file.
Module Name: An Explanation
---------------------------
Why Name the Module Debussy?
----------------------------
Why `debussy`?
After researching similar npm modules, I discovered I really didn't have
to write this at all and I could be using someone else's npm package
instead. But that's no fun. Also, I get to make my interface the way I
think it should be done. And giving the module a name which represented
its functionality would have lost my version in a sea of names like
file-reader, line-read, file-line-read, stream-line-reader,
line-reader-stream, read-by-line, reader-line-stuff, etc.
After researching similar npm modules, I discovered I really didn't have to
write this at all and I could be using someone else's npm package instead. But
that's no fun. And giving the module a name which represented its functionality
would have lost my version in a sea of names like file-reader, line-read,
file-line-read, stream-line-reader, line-reader-stream, read-by-line,
reader-line-stuff, etc.
I therefore paid homage to one of the greatest composers.

@@ -63,0 +69,0 @@

Sorry, the diff of this file is not supported yet

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