Comparing version 0.3.0 to 1.0.0
import { AsyncIterator, MultiTransformIterator, SimpleTransformIterator } from 'asynciterator'; | ||
import {AsyncIterator, MultiTransformIterator, MultiTransformOptions, SimpleTransformIterator} from 'asynciterator'; | ||
@@ -21,3 +21,3 @@ export class DynamicNestedLoopJoin<L, R, T> extends MultiTransformIterator<L, T> | ||
{ | ||
constructor(left: AsyncIterator<L>, right: AsyncIterator<R>, funJoin: (left: L, right: R) => T); | ||
constructor(left: AsyncIterator<L>, right: AsyncIterator<R>, funJoin: (left: L, right: R) => T, options?: MultiTransformOptions<L, T>); | ||
close(): void; | ||
@@ -24,0 +24,0 @@ |
let AsyncIterator = require('asynciterator'); | ||
let AsyncIterator = require('asynciterator').AsyncIterator; | ||
@@ -9,4 +9,5 @@ // https://en.wikipedia.org/wiki/Hash_join | ||
{ | ||
super(right); | ||
super(); | ||
this.addedDataListener = false; | ||
this.left = left; | ||
@@ -25,14 +26,5 @@ this.right = right; | ||
this.readable = false; | ||
this.left.on('end', allowJoining.bind(this)); | ||
this.left.on('data', addItem.bind(this)); | ||
function addItem (item) | ||
{ | ||
let hash = this.funHash(item); | ||
if (!this.leftMap.has(hash)) | ||
this.leftMap.set(hash, []); | ||
let arr = this.leftMap.get(hash); | ||
arr.push(item); | ||
} | ||
function allowJoining () | ||
@@ -46,2 +38,11 @@ { | ||
} | ||
this.on('newListener', (eventName) => | ||
{ | ||
if (eventName === 'data' && !this.addedDataListener) | ||
{ | ||
this.addedDataListener = true; | ||
this._addDataListener(); | ||
} | ||
}) | ||
} | ||
@@ -63,2 +64,8 @@ | ||
{ | ||
if (!this.addedDataListener) | ||
{ | ||
this.addedDataListener = true; | ||
this._addDataListener(); | ||
} | ||
if (this.ended || !this.readable) | ||
@@ -74,3 +81,3 @@ return null; | ||
} | ||
if (!this.hasResults()) | ||
@@ -94,4 +101,18 @@ this._end(); | ||
} | ||
_addDataListener() | ||
{ | ||
this.left.on('data', addItem.bind(this)); | ||
function addItem(item) | ||
{ | ||
let hash = this.funHash(item); | ||
if (!this.leftMap.has(hash)) | ||
this.leftMap.set(hash, []); | ||
let arr = this.leftMap.get(hash); | ||
arr.push(item); | ||
} | ||
} | ||
} | ||
module.exports = HashJoin; |
@@ -9,5 +9,5 @@ | ||
{ | ||
constructor (left, right, funJoin) | ||
constructor (left, right, funJoin, options) | ||
{ | ||
super(left); | ||
super(left, options); | ||
@@ -14,0 +14,0 @@ this.right = right; |
let AsyncIterator = require('asynciterator'); | ||
let AsyncIterator = require('asynciterator').AsyncIterator; | ||
@@ -26,6 +26,13 @@ // https://en.wikipedia.org/wiki/Symmetric_Hash_Join | ||
this.matchIdx = 0; | ||
if (this.left.readable || this.right.readable) | ||
{ | ||
this.readable = true; | ||
} | ||
else | ||
{ | ||
this.left.on('readable', () => this.readable = true); | ||
this.right.on('readable', () => this.readable = true); | ||
} | ||
this.left.on ('readable', () => this.readable = true); | ||
this.right.on('readable', () => this.readable = true); | ||
// this needs to be here since it's possible the left/right streams only get ended after there are no more results left | ||
@@ -32,0 +39,0 @@ this.left.on ('end', () => { if (!this.hasResults()) this._end(); }); |
{ | ||
"name": "asyncjoin", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "Join library for asynciterator", | ||
@@ -11,6 +11,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"asynciterator": "^2.0.0" | ||
"asynciterator": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/asynciterator": "^1.1.1", | ||
"lodash": "^4.17.10", | ||
@@ -17,0 +16,0 @@ "mocha": "^5.2.0", |
let AsyncIterator = require('asynciterator'); | ||
let AsyncIterator = require('asynciterator').AsyncIterator; | ||
@@ -4,0 +4,0 @@ // merges the contents of multiple streams |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11680
3
320
1
+ Addedasynciterator@3.9.0(transitive)
- Removedasynciterator@2.0.1(transitive)
Updatedasynciterator@^3.0.0