Socket
Socket
Sign inDemoInstall

wonka

Package Overview
Dependencies
0
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0-canary-20230327135055 to 0.0.0-canary-20230327141302

7

CHANGELOG.md
# wonka
## 0.0.0-canary-20230327135055
## 0.0.0-canary-20230327141302
### Minor Changes
- Add `addOne` argument to `takeWhile`, allowing an additional value to be issued
Submitted by [@kitten](https://github.com/kitten) (See [#156](https://github.com/0no-co/wonka/pull/156))
### Patch Changes

@@ -6,0 +11,0 @@

@@ -961,2 +961,3 @@ /**

* @param predicate - A function returning a boolean per value.
* @param addOne - Lets an additional input value pass on.
* @returns An {@link Operator}.

@@ -969,2 +970,5 @@ *

*
* If `addOne` is set to `true`, the value for which the `predicate` first returned `false` is
* issued and passed on as well instead of being omitted.
*
* @example

@@ -981,3 +985,3 @@ * ```ts

*/
declare function takeWhile<T>(predicate: (value: T) => boolean): Operator<T, T>;
declare function takeWhile<T>(predicate: (value: T) => boolean, addOne?: boolean): Operator<T, T>;
/** Debounces a Source by omitting values until a given timeframe has passed.

@@ -984,0 +988,0 @@ *

31

dist/wonka.js

@@ -1175,19 +1175,22 @@ Object.defineProperty(exports, "__esModule", {

exports.takeWhile = function takeWhile(r) {
return t => i => {
var s = e;
var a = !1;
t((e => {
if (a) {} else if (0 === e) {
a = !0;
i(0);
exports.takeWhile = function takeWhile(r, t) {
return i => s => {
var a = e;
var f = !1;
i((e => {
if (f) {} else if (0 === e) {
f = !0;
s(0);
} else if (0 === e.tag) {
s = e[0];
i(e);
a = e[0];
s(e);
} else if (!r(e[0])) {
a = !0;
i(0);
s(1);
f = !0;
if (t) {
s(e);
}
s(0);
a(1);
} else {
i(e);
s(e);
}

@@ -1194,0 +1197,0 @@ }));

{
"name": "wonka",
"description": "A tiny but capable push & pull stream library for TypeScript and Flow",
"version": "0.0.0-canary-20230327135055",
"version": "0.0.0-canary-20230327141302",
"author": "0no.co <hi@0no.co>",

@@ -6,0 +6,0 @@ "source": "./src/index.ts",

@@ -775,5 +775,23 @@ import { describe, it, expect, beforeEach, vi } from 'vitest';

next(2);
next(3);
expect(fn.mock.calls).toEqual([[start(expect.any(Function))], [push(1)], [SignalKind.End]]);
});
it('emits values while a predicate passes for all values plus an additional one', () => {
const { source, next } = sources.makeSubject<number>();
const fn = vi.fn();
operators.takeWhile((x: any) => x < 2, true)(source)(fn);
next(1);
next(2);
next(3);
expect(fn.mock.calls).toEqual([
[start(expect.any(Function))],
[push(1)],
[push(2)],
[SignalKind.End],
]);
});
});

@@ -780,0 +798,0 @@

@@ -1257,2 +1257,3 @@ import { Push, Source, Sink, Operator, SignalKind, TalkbackKind, TalkbackFn } from './types';

* @param predicate - A function returning a boolean per value.
* @param addOne - Lets an additional input value pass on.
* @returns An {@link Operator}.

@@ -1265,2 +1266,5 @@ *

*
* If `addOne` is set to `true`, the value for which the `predicate` first returned `false` is
* issued and passed on as well instead of being omitted.
*
* @example

@@ -1277,3 +1281,3 @@ * ```ts

*/
export function takeWhile<T>(predicate: (value: T) => boolean): Operator<T, T> {
export function takeWhile<T>(predicate: (value: T) => boolean, addOne?: boolean): Operator<T, T> {
return source => sink => {

@@ -1293,2 +1297,3 @@ let talkback = talkbackPlaceholder;

ended = true;
if (addOne) sink(signal);
sink(SignalKind.End);

@@ -1295,0 +1300,0 @@ talkback(TalkbackKind.Close);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc