generated from haraka/haraka-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- merged in ChunkEmitter, only used here - copied in indexOfLF, removed haraka-utils dependency - LGTM: remove unused variable
- Loading branch information
Showing
8 changed files
with
1,888 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"name": "haraka-message-stream", | ||
"version": "1.1.0", | ||
"description": "Haraka message stream library", | ||
"version": "1.2.0", | ||
"description": "Haraka email message stream", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "npx eslint *.js test/*.js", | ||
"lint": "npx eslint *.js test", | ||
"lintfix": "npx eslint --fix *.js test", | ||
"versions": "npx dependency-version-checker check", | ||
"test": "npx mocha" | ||
|
@@ -15,6 +15,7 @@ | |
}, | ||
"keywords": [ | ||
"haraka", | ||
"email", | ||
"message-stream" | ||
], | ||
"author": "Haraka Team <[email protected]>", | ||
|
@@ -29,8 +30,5 @@ | |
"haraka-test-fixtures": "*", | ||
"mocha": ">=9" | ||
}, | ||
"dependencies": { | ||
"haraka-chunk-emitter": "^1.0.1", | ||
"haraka-utils": "^1.0.3" | ||
} | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
const assert = require('assert') | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const ChunkEmitter = require('../index').ChunkEmitter | ||
|
||
describe('chunk-emitter', function () { | ||
|
||
beforeEach(function () { | ||
this.ce = new ChunkEmitter() | ||
this._written = 0 | ||
}) | ||
|
||
it('loads', function () { | ||
assert.ok(this.ce) | ||
}) | ||
|
||
it('emits all unbuffered bytes', function (done) { | ||
const msgPath = path.join(__dirname, 'fixtures', 'haraka-icon-attach.eml') | ||
const eml = fs.readFileSync(msgPath, 'utf8'); | ||
|
||
this._write = (data) => { | ||
this._written = (this._written || 0) + data.length | ||
if (eml.length === this._written) { | ||
assert.equal(eml.length, this._written) | ||
done() | ||
} | ||
} | ||
|
||
this.ce.on('data', chunk => { | ||
this._write(chunk); | ||
}) | ||
|
||
this.ce.fill(eml) | ||
this.ce.end() | ||
}) | ||
|
||
it('emits all bigger than buffer bytes', function (done) { | ||
const msgPath = path.join(__dirname, 'fixtures', 'haraka-tarball-attach.eml') | ||
// console.log(`msgPath: ${msgPath}`) | ||
const eml = fs.readFileSync(msgPath, 'utf8'); | ||
// console.log(`length: ${eml.length}`) | ||
|
||
this._write = (data) => { | ||
// console.log(`_write: ${data.length} bytes`) | ||
this._written = this._written + data.length | ||
// console.log(`_written: ${this._written}`) | ||
if (eml.length === this._written) { | ||
assert.equal(eml.length, this._written) | ||
// console.log(this.ce) | ||
done() | ||
} | ||
} | ||
|
||
this.ce.on('data', chunk => { | ||
// console.log(`ce.on.data: ${chunk.length} bytes`) | ||
this._write(chunk); | ||
}) | ||
|
||
this.ce.fill(eml) | ||
this.ce.end() | ||
}) | ||
}) |
Oops, something went wrong.