
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
RxJS operator. Packs all the source Observable values into arrays. New array is emitted every time a predicate is fulfilled.
RxJS operator. Packs all the source Observable values into arrays. New array is emitted every time a predicate is fulfilled.
See RxJS
const {from} = require('rxjs');
const {splitIf} = require('split-if');
const src = from([4, 8, 1, 3, 5, 1, 1, 6, 8]).pipe(splitIf(x => x === 1));
const res = [];
src.subscribe(x => res.push(x));
console.log(res);
//=> [ [ 4, 8 ], [ 1, 3, 5 ], [ 1 ], [ 1, 6, 8 ] ]
We can easily make a partitionN RxJS operator using splitIf:
import {OperatorFunction} from 'rxjs';
import {splitIf} from 'split-if';
const partitionN = <T>(n: number): OperatorFunction<T, T[]> =>
splitIf((_: T, i: number) => i % n === 0);
Let's use it:
import {from} from 'rxjs';
const src = from([4, 8, 1, 3, 5, 4, 1, 6, 8, -1, 2]).pipe(partitionN(3));
const res: number[][] = [];
src.subscribe((x: number[]) => res.push(x));
console.log(res);
//=> [ [ 4, 8, 1 ], [ 3, 5, 4 ], [ 1, 6, 8 ], [ -1, 2 ] ]
d.ts for Javascript.$ npm install split-if
Typescript / ES module:
import {splitIf} from 'split-if';
Javascript / CommonJS:
const {splitIf} = require('split-if');
function splitIf<T>(
predicate: (value: T, index: number) => boolean,
thisArg?: any
): OperatorFunction<T, T[]>;
Where its OperatorFunction<T, T[]> can be substituted for:
(source: Observable<T>) => Observable<T[]>;
See: RxJS OperatorFunction
| T | {any} | The type of Observable's value. |
| predicate | {(value: T, index: number) => boolean} | A function that evaluates each value emitted by the source Observable. If it returns true, a new array of previous 'buffered' values is emitted. The index parameter is the number i for the i-th source emission that has happened since the subscription, starting from the number 0. |
| thisArg | {any} | Optional. Default is undefined. An optional argument to determine the value of this in the predicate function. |
A function that returns an Observable that emits arrays of all items from the source Observable. These arrays are emitted every time a predicate is fulfilled.
FAQs
RxJS operator. Packs all the source Observable values into arrays. New array is emitted every time a predicate is fulfilled.
We found that split-if demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.