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

@mitm/common

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mitm/common - npm Package Compare versions

Comparing version 1.8.0 to 2.0.0

48

index.esm.js

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

import { tap } from 'rxjs';
import { tap, map, filter, ignoreElements } from 'rxjs';
import { shareReplay } from 'rxjs/operators';

@@ -400,3 +400,14 @@

function shareReplayOne() {
/**
* Just maps an observable to an `undefined` value.
*/
function toVoid() {
return source => source.pipe(map(() => undefined));
}
/**
* Shortcut for {@link shareReplay} with options bufferSize: 1 and refCount: true.
*/
function shareReplayLast() {
return source => source.pipe(shareReplay({

@@ -407,4 +418,29 @@ bufferSize: 1,

}
/**
* Like RxJS' filter(value => value != null) but acts as a "type guard" too, so the type of the value is refined into a
* non-nullable.
* Note: Both undefined & null values are discarded.
*/
function filterNonNull() {
return source => source.pipe(filter(value => value != null));
}
/**
* Just like {@link ignoreElements} but typed with a generic for the incoming value.
* This avoids breaking the pipeline's type on the previous operator's argument (when generic), but only when TS'
* `strictFunctionTypes` is disabled.
* In short:
* - Always use this operator if you have `strictFunctionTypes` disabled, this will save you type errors that aren't
* easy to apprehend.
* - Always use RxJS' {@link ignoreElements} if you have `strictFunctionTypes` enabled.
*
* Note: it was decided to give it a very different name from {@link ignoreElements} even if it's doing the same thing,
* so no confusion is made, and to preserve simple auto-importing.
*/
function silenceEmits() {
return source => source.pipe(ignoreElements());
}
/**
* Checks that a given value is not strictly null OR strictly undefined.

@@ -414,3 +450,3 @@ *

*/
function ensureNotNull(value) {
function ensureNonNull(value) {
if (value === undefined || value === null) {

@@ -423,4 +459,4 @@ throw expectedValueTypeMismatchError('not null or undefined', value);

ensureNotNull.assert = function (value) {
ensureNotNull(value);
ensureNonNull.assert = function (value) {
ensureNonNull(value);
};

@@ -504,2 +540,2 @@ /**

export { MetadataError, MetadataKeyError, RolesHierarchy, Stopwatch, StopwatchMutexMap, all, any, arrayContainsId, arrayPairwise, debug, ensureBoolean, ensureInEnum, ensureNotNull, ensureNumber, ensureString, equalIds, ethrow, evalThunk, filterOutNullArrayEntries, getStacktrace, getUnknownValue, getValue, hasKey, normalizeToArray, requireValue, shareReplayOne, swallowException, throwThisShouldNeverHappenError, throwUnexpectedTypeError, wait, waitThenReject };
export { MetadataError, MetadataKeyError, RolesHierarchy, Stopwatch, StopwatchMutexMap, all, any, arrayContainsId, arrayPairwise, debug, ensureBoolean, ensureInEnum, ensureNonNull, ensureNumber, ensureString, equalIds, ethrow, evalThunk, filterNonNull, filterOutNullArrayEntries, getStacktrace, getUnknownValue, getValue, hasKey, normalizeToArray, requireValue, shareReplayLast, silenceEmits, swallowException, throwThisShouldNeverHappenError, throwUnexpectedTypeError, toVoid, wait, waitThenReject };

@@ -636,3 +636,14 @@ (function (global, factory) {

function shareReplayOne() {
/**
* Just maps an observable to an `undefined` value.
*/
function toVoid() {
return source => source.pipe(rxjs.map(() => undefined));
}
/**
* Shortcut for {@link shareReplay} with options bufferSize: 1 and refCount: true.
*/
function shareReplayLast() {
return source => source.pipe(operators.shareReplay({

@@ -643,4 +654,29 @@ bufferSize: 1,

}
/**
* Like RxJS' filter(value => value != null) but acts as a "type guard" too, so the type of the value is refined into a
* non-nullable.
* Note: Both undefined & null values are discarded.
*/
function filterNonNull() {
return source => source.pipe(rxjs.filter(value => value != null));
}
/**
* Just like {@link ignoreElements} but typed with a generic for the incoming value.
* This avoids breaking the pipeline's type on the previous operator's argument (when generic), but only when TS'
* `strictFunctionTypes` is disabled.
* In short:
* - Always use this operator if you have `strictFunctionTypes` disabled, this will save you type errors that aren't
* easy to apprehend.
* - Always use RxJS' {@link ignoreElements} if you have `strictFunctionTypes` enabled.
*
* Note: it was decided to give it a very different name from {@link ignoreElements} even if it's doing the same thing,
* so no confusion is made, and to preserve simple auto-importing.
*/
function silenceEmits() {
return source => source.pipe(rxjs.ignoreElements());
}
/**
* Checks that a given value is not strictly null OR strictly undefined.

@@ -650,3 +686,3 @@ *

*/
function ensureNotNull(value) {
function ensureNonNull(value) {
if (value === undefined || value === null) {

@@ -659,4 +695,4 @@ throw expectedValueTypeMismatchError('not null or undefined', value);

ensureNotNull.assert = function (value) {
ensureNotNull(value);
ensureNonNull.assert = function (value) {
ensureNonNull(value);
};

@@ -752,3 +788,3 @@ /**

exports.ensureInEnum = ensureInEnum;
exports.ensureNotNull = ensureNotNull;
exports.ensureNonNull = ensureNonNull;
exports.ensureNumber = ensureNumber;

@@ -759,2 +795,3 @@ exports.ensureString = ensureString;

exports.evalThunk = evalThunk;
exports.filterNonNull = filterNonNull;
exports.filterOutNullArrayEntries = filterOutNullArrayEntries;

@@ -767,6 +804,8 @@ exports.getStacktrace = getStacktrace;

exports.requireValue = requireValue;
exports.shareReplayOne = shareReplayOne;
exports.shareReplayLast = shareReplayLast;
exports.silenceEmits = silenceEmits;
exports.swallowException = swallowException;
exports.throwThisShouldNeverHappenError = throwThisShouldNeverHappenError;
exports.throwUnexpectedTypeError = throwUnexpectedTypeError;
exports.toVoid = toVoid;
exports.wait = wait;

@@ -773,0 +812,0 @@ exports.waitThenReject = waitThenReject;

2

package.json
{
"name": "@mitm/common",
"version": "1.8.0",
"version": "2.0.0",
"peerDependencies": {

@@ -5,0 +5,0 @@ "rxjs": "^7.4.0"

@@ -7,4 +7,12 @@ # @mitm/common

### 2.0.0
- BREAKING: renommage de la fonction `ensureNotNull()` en `ensureNonNull()`.
- BREAKING: renommage de l'opérateur `shareReplayOne()` en `shareReplayLast()`.
- Ajout de l'opérateur `toVoid()`.
- Ajout de l'opérateur `filterNonNull()`.
- Ajout de l'opérateur `silenceEmits()`, un alias de `ignoreElements()` mais avec un type plus tolérant avec `strictFunctionTypes: false`.
### 1.8.0
- Cible de compilation plus moderne.

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

import { MonoTypeOperatorFunction } from 'rxjs';
export declare function shareReplayOne<T>(): MonoTypeOperatorFunction<T>;
import { MonoTypeOperatorFunction, OperatorFunction } from 'rxjs';
/**
* Just maps an observable to an `undefined` value.
*/
export declare function toVoid<T>(): OperatorFunction<T, void>;
/**
* Shortcut for {@link shareReplay} with options bufferSize: 1 and refCount: true.
*/
export declare function shareReplayLast<T>(): MonoTypeOperatorFunction<T>;
/**
* Like RxJS' filter(value => value != null) but acts as a "type guard" too, so the type of the value is refined into a
* non-nullable.
* Note: Both undefined & null values are discarded.
*/
export declare function filterNonNull<T>(): OperatorFunction<T | null | undefined, T>;
/**
* Just like {@link ignoreElements} but typed with a generic for the incoming value.
* This avoids breaking the pipeline's type on the previous operator's argument (when generic), but only when TS'
* `strictFunctionTypes` is disabled.
* In short:
* - Always use this operator if you have `strictFunctionTypes` disabled, this will save you type errors that aren't
* easy to apprehend.
* - Always use RxJS' {@link ignoreElements} if you have `strictFunctionTypes` enabled.
*
* Note: it was decided to give it a very different name from {@link ignoreElements} even if it's doing the same thing,
* so no confusion is made, and to preserve simple auto-importing.
*/
export declare function silenceEmits<T>(): OperatorFunction<T, never>;

@@ -6,4 +6,4 @@ /**

*/
export declare function ensureNotNull<TNonNull>(value: TNonNull | null | undefined): TNonNull;
export declare namespace ensureNotNull {
export declare function ensureNonNull<TNonNull>(value: TNonNull | null | undefined): TNonNull;
export declare namespace ensureNonNull {
var assert: <TNonNull>(value: TNonNull | null | undefined) => asserts value is TNonNull;

@@ -10,0 +10,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