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

aline

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aline - npm Package Compare versions

Comparing version 0.0.2 to 0.0.4

test/aline.js

48

index.js
var util = require('util'),
Transform = require('stream').Transform;
const Transform = require('stream').Transform;
util.inherits(Aline, Transform);
class Aline extends Transform {
constructor(options) {
super();
function Aline(options) {
if (!(this instanceof Aline))
return new Aline(options);
Transform.call(this, options);
this._tail = Buffer.alloc(0);
this._separator = (options && options.separator) || '\n';
}
Aline.prototype._transform = function (chunk, encoding, callback) {
var index = chunk.lastIndexOf(this._separator);
if (index === chunk.length) {
this._tail = Buffer.alloc(0);
return callback(null, chunk);
this._separator = (options && options.separator) || '\n';
}
_transform(chunk, encoding, callback) {
const index = chunk.lastIndexOf(this._separator);
if (index === chunk.length || index === -1) {
callback(null, Buffer.concat([this._tail, chunk]));
this._tail = Buffer.alloc(0);
return;
}
var head = Buffer.concat([this._tail, chunk.slice(0, index)]);
this._tail = Buffer.from(chunk.slice(index + 1));
const head = Buffer.concat([this._tail, chunk.slice(0, index)]);
this._tail = Buffer.from(chunk.slice(index + 1));
callback(null, head);
};
callback(null, head);
}
_flush(callback) {
callback(null, this._tail);
}
}
Aline.prototype._flush = function(callback) {
callback(null, this._tail);
};
module.exports = Aline;
{
"name": "aline",
"version": "0.0.2",
"version": "0.0.4",
"description": "Align stream chunks to bound of lines",
"main": "index.js",
"engines": {
"node": ">=v6.4.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},

@@ -23,3 +26,6 @@ "repository": {

},
"homepage": "https://github.com/tugrul/node-aline#readme"
"homepage": "https://github.com/tugrul/node-aline#readme",
"devDependencies": {
"mocha": "^7.1.1"
}
}

@@ -5,6 +5,31 @@ # node-aline

![](https://tugrul.github.io/node-aline/assets/img/node-aline.gif)
## Install
### NPM
```
npm install aline
```
```
### Yarn
```
yarn add aline
```
## Sample
```javascript
const Aline = require('aline');
const {Readable} = require('stream');
const stream = Readable.from(async function* () {
yield 'foo\nba';
yield 'ar\nbaz';
}).pipe(new Aline());
stream.on('data', function(chunk) {
console.log(chunk.toString());
});
```
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