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

asyncjoin

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asyncjoin - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

4

index.d.ts
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

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