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

@azothjs/channels

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azothjs/channels - npm Package Compare versions

Comparing version 0.3.7 to 0.3.8

23

branch.js
import { Multicast } from './Multicast.js';
import { AsyncTypeError } from './throw.js';
import { channel } from './channel.js';
import { SyncAsync } from '@azothjs/maya/compose';
export function branch(async, ...transforms) {
if(async instanceof SyncAsync) {
const sync = async.sync;
async = async.async;
transforms = transforms.map(transform => {
let options = null;
if(Array.isArray(transform)) {
options = transform[1];
transform = transform[0];
}
options ? options.init = sync : (options = { init: sync });
return [transform, options];
});
}
return makeBranches(async, transforms);
}
export function makeBranches(async, transforms) {
switch(true) {

@@ -28,4 +49,2 @@ case async instanceof Promise:

const branches = transforms.map(transform => {
const iterator = multicast.subscriber();
if(Array.isArray(transform)) { // #[transform, options];

@@ -32,0 +51,0 @@ return multicast.subscriber(transform[0], transform[1]);

13

channel.js

@@ -1,2 +0,2 @@

import { Sync } from '../maya/compose/compose.js';
import { SyncAsync } from '@azothjs/maya/compose';
import { resolveArgs } from './resolve-args.js';

@@ -13,9 +13,8 @@ import { AsyncTypeError, InitOptionWithSyncWrappedAsyncProviderError } from './throw.js';

if(async instanceof Sync) {
const { initial, input } = async;
if(async instanceof SyncAsync) {
if(hasInit) {
throw new InitOptionWithSyncWrappedAsyncProviderError();
}
sync = initial;
async = input;
sync = async.sync;
async = async.async;
}

@@ -35,4 +34,4 @@

if(hasStart) return Sync.wrap(start, out);
if(hasSync) return Sync.wrap(sync, out);
if(hasStart) return SyncAsync.from(start, out);
if(hasSync) return SyncAsync.from(sync, out);
return out;

@@ -39,0 +38,0 @@ }

@@ -1,2 +0,2 @@

import { Sync } from '../maya/compose/compose.js';
import { SyncAsync } from '@azothjs/maya/compose';
import { resolveArgs } from './resolve-args.js';

@@ -17,7 +17,6 @@ import { AsyncTypeError, InitOptionWithSyncWrappedAsyncProviderError } from './throw.js';

let sync = init;
if(async instanceof Sync) {
if(async instanceof SyncAsync) {
if(hasInit) throw new InitOptionWithSyncWrappedAsyncProviderError();
const { initial, input } = async;
sync = initial;
async = input;
sync = async.sync;
async = async.async;
}

@@ -24,0 +23,0 @@

@@ -1,2 +0,2 @@

import { Sync } from '../maya/compose/compose.js';
import { SyncAsync } from '@azothjs/maya/compose';
import { resolveArgs } from './resolve-args.js';

@@ -46,3 +46,3 @@

if(hasStart) {
return [Sync.wrap(start, asyncIterator), dispatch];
return [SyncAsync.from(start, asyncIterator), dispatch];
}

@@ -52,3 +52,3 @@

const value = transform ? transform(init) : init;
return [Sync.wrap(value, asyncIterator), dispatch];
return [SyncAsync.from(value, asyncIterator), dispatch];
}

@@ -55,0 +55,0 @@

@@ -1,2 +0,2 @@

import { Sync } from '../maya/compose/compose.js';
import { SyncAsync } from '@azothjs/maya/compose';
import { generator } from './generator.js';

@@ -9,3 +9,3 @@

constructor(iter) {
this.#iter = (iter instanceof Sync) ? iter.input : iter;
this.#iter = (iter instanceof SyncAsync) ? iter.async : iter;
this.start();

@@ -12,0 +12,0 @@ }

{
"name": "@azothjs/channels",
"version": "0.3.7",
"version": "0.3.8",
"description": "Asynchronous layout channels",

@@ -32,2 +32,5 @@ "author": "Marty Nelson",

},
"dependencies": {
"@azothjs/maya": "^0.3.9"
},
"scripts": {

@@ -34,0 +37,0 @@ "test": "vitest"

@@ -1,2 +0,2 @@

import { Sync } from '../maya/compose/compose.js';
import { SyncAsync } from '@azothjs/maya/compose';
import { generator } from './generator.js';

@@ -12,3 +12,3 @@ import { TransformNotFunctionArgumentError } from './throw.js';

const [iter, dispatch] = generator(action => state = reducer(state, action));
return [Sync.wrap(state, iter), dispatch];
return [SyncAsync.from(state, iter), dispatch];
}

@@ -1,2 +0,2 @@

import { Sync } from '../maya/compose/compose.js';
import { SyncAsync } from '@azothjs/maya/compose';
import { Multicast } from './Multicast.js';

@@ -6,26 +6,25 @@ import { AsyncTypeError, BadTeeCountArgumentError } from './throw.js';

export function tee(async, count = 2) {
const repeat = parseInt(count);
if(!(count >= 2)) {
const num = parseInt(count);
if(!(num >= 2)) {
throw new BadTeeCountArgumentError(count);
}
let init;
if(async instanceof Sync) {
const { initial, input } = async;
init = initial;
async = input;
let sync;
if(async instanceof SyncAsync) {
sync = async.sync;
async = async.async;
}
return makeTee(async, count, init);
return makeTee(async, num, sync);
}
function makeTee(asyncProvider, count, init) {
const type = typeof asyncProvider;
function makeTee(async, count, init) {
const type = typeof async;
switch(true) {
case asyncProvider instanceof Promise:
return teePromise(asyncProvider, count, init);
case !!asyncProvider?.[Symbol.asyncIterator]:
return teeAsyncIterator(asyncProvider, count, init);
case async instanceof Promise:
return teePromise(async, count, init);
case !!async?.[Symbol.asyncIterator]:
return teeAsyncIterator(async, count, init);
default:
throw new AsyncTypeError(asyncProvider);
throw new AsyncTypeError(async);
}

@@ -37,4 +36,3 @@ }

for(let i = 0; i < count; i++) {
init ? Sync.wrap(init, promise) : promise;
tees.push(init ? Sync.wrap(init, promise) : promise);
tees.push(init !== undefined ? SyncAsync.from(init, promise) : promise);
}

@@ -49,3 +47,3 @@ return tees;

const subscriber = multicast.subscriber();
tees.push(init ? Sync.wrap(init, subscriber) : subscriber);
tees.push(init ? SyncAsync.from(init, subscriber) : subscriber);
}

@@ -52,0 +50,0 @@ multicast.start();

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