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

callbag-toolkit

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callbag-toolkit - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

cjs/consume.js

@@ -64,4 +64,4 @@ "use strict";

}
consumptionManagement.stop();
if (!didComplete) {
consumptionManagement.stop();
throw new Error(`Could not consume, because the source never completed synchronously.`);

@@ -68,0 +68,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -91,2 +91,7 @@ "use strict";

});
const sequence = (length) => (0, create_1.createSource)(({ next, start, complete }) => {
start();
Array.from({ length }).forEach((_, index) => void next(index));
complete();
});
const nextTick = () => new Promise((resolve) => {

@@ -139,3 +144,2 @@ setTimeout(resolve);

const rejectedPromise = Promise.reject(myError);
// eslint-disable-next-line promise/prefer-await-to-then
void rejectedPromise.catch(() => { });

@@ -214,3 +218,24 @@ it(`should switch to a new source upon error`, () => __awaiter(void 0, void 0, void 0, function* () {

}));
it(`should consume synchronously`, () => {
const source = sequence(10);
const result = (0, consume_1.consumeSynchronously)(source);
expect(result).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
});
it(`should transform as synchronous input`, () => {
const source = sequence(10);
const transformedSource = (0, create_1.createSource)(({ next, start, complete, error }) => {
const consumption = (0, consume_1.consumeSource)(source, {
start,
complete,
error,
next: (input) => {
next(input * 100);
},
});
return consumption;
});
const result = (0, consume_1.consumeSynchronously)(transformedSource);
expect(result).toEqual([0, 100, 200, 300, 400, 500, 600, 700, 800, 900]);
});
});
//# sourceMappingURL=main.test.js.map

@@ -22,16 +22,21 @@ {

"import": "./esm/main.js",
"require": "./cjs/main.js"
"require": "./cjs/main.js",
"types": "./src/main.ts"
},
"./*": {
"import": "./esm/*.js",
"require": "./cjs/*.js"
"require": "./cjs/*.js",
"types": "./src/*.ts"
},
"./cjs": {
"require": "./cjs/main.js"
"require": "./cjs/main.js",
"types": "./src/main.ts"
},
"./cjs/*": {
"require": "./cjs/*.js"
"require": "./cjs/*.js",
"types": "./src/*.ts"
},
"./esm/*": {
"import": "./esm/*.js"
"import": "./esm/*.js",
"types": "./src/*.ts"
},

@@ -50,3 +55,3 @@ "./package.json": "./package.json"

"dependencies": {
"callbag": "^1.5.0"
"callbag": "^1.5.1"
},

@@ -58,3 +63,3 @@ "devDependencies": {

},
"version": "1.1.0"
"version": "1.1.1"
}

@@ -88,5 +88,4 @@ import { createConsumer } from './create'

consumptionManagement.stop()
if (!didComplete) {
consumptionManagement.stop()
throw new Error(

@@ -93,0 +92,0 @@ `Could not consume, because the source never completed synchronously.`,

import { concat, fromIter, fromPromise } from 'callbag-basics'
import of from 'callbag-of'
import pipe from 'callbag-pipe'
import { consumeSource } from './consume'
import { consumeSource, consumeSynchronously } from './consume'
import { createSource } from './create'

@@ -84,2 +84,9 @@ import type { Source } from './types'

const sequence = (length: number) =>
createSource<number>(({ next, start, complete }) => {
start()
Array.from({ length }).forEach((_, index) => void next(index))
complete()
})
const nextTick = () =>

@@ -99,3 +106,3 @@ new Promise((resolve) => {

it(`should emit and transform values and complete correctly`, () => {
const intervalMs = 1000
const intervalMs = 1_000
const source = pipe(interval(intervalMs), multiplyBy(2), take(10))

@@ -146,3 +153,2 @@ const next = jest.fn<void, [number]>()

const rejectedPromise = Promise.reject(myError)
// eslint-disable-next-line promise/prefer-await-to-then
void rejectedPromise.catch(() => {})

@@ -251,2 +257,27 @@

})
it(`should consume synchronously`, () => {
const source = sequence(10)
const result = consumeSynchronously(source)
expect(result).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
})
it(`should transform as synchronous input`, () => {
const source = sequence(10)
const transformedSource = createSource<number>(
({ next, start, complete, error }) => {
const consumption = consumeSource(source, {
start,
complete,
error,
next: (input) => {
next(input * 100)
},
})
return consumption
},
)
const result = consumeSynchronously(transformedSource)
expect(result).toEqual([0, 100, 200, 300, 400, 500, 600, 700, 800, 900])
})
})

@@ -10,3 +10,3 @@ export type {

UnwrapSource, // https://github.com/import-js/eslint-plugin-import/issues/2132
} from 'callbag' // eslint-disable-line import/no-unresolved
} from 'callbag'

@@ -13,0 +13,0 @@ export const START = 0

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