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

ts-results

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-results - npm Package Compare versions

Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.2

2

package.json
{
"name": "ts-results",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"description": "A typescript implementation of Rust's Result object.",

@@ -5,0 +5,0 @@ "main": "index.js",

import { ObservableInput, OperatorFunction } from 'rxjs';
import { Result, ResultErrType, ResultOkType } from './index';
export declare function resultMap<R extends Result<any, any>, T>(mapper: (val: ResultOkType<R>) => T): OperatorFunction<R, Result<T, ResultErrType<R>>>;
export declare function resultMap<R extends Result<any, any>, T2>(mapper: null | undefined, errMapper: (val: ResultErrType<R>) => T2): OperatorFunction<R, Result<ResultOkType<R>, T2>>;
export declare function resultMap<R extends Result<any, any>, T, T2>(mapper: (val: ResultOkType<R>) => T, errMapper: (val: ResultErrType<R>) => T2): OperatorFunction<R, Result<T, T2>>;
export declare function resultMapErr<R extends Result<any, any>, E>(mapper: (val: ResultErrType<R>) => E): OperatorFunction<R, Result<ResultOkType<R>, E>>;
export declare function resultMapTo<R extends Result<any, any>, T>(value: T): OperatorFunction<R, Result<T, ResultErrType<R>>>;
export declare function resultMapErrTo<R extends Result<any, any>, T>(value: T): OperatorFunction<R, Result<ResultOkType<R>, T>>;
export declare function elseMap<R extends Result<any, any>, T>(mapper: (val: ResultErrType<R>) => T): OperatorFunction<R, ResultOkType<R> | T>;

@@ -13,1 +13,3 @@ export declare function elseMapTo<R extends Result<any, any>, T>(value: T): OperatorFunction<R, ResultOkType<R> | T>;

export declare function resultMergeMap<R extends Result<any, any>, T>(mapper: (val: ResultOkType<R>) => ObservableInput<T>): OperatorFunction<R, Result<T, ResultErrType<R>>>;
export declare function filterResultOk<R extends Result<any, any>>(): OperatorFunction<R, ResultOkType<R>>;
export declare function filterResultErr<R extends Result<any, any>>(): OperatorFunction<R, ResultErrType<R>>;
import { of } from 'rxjs';
import { map, mergeMap, switchMap } from 'rxjs/operators';
import { filter, map, mergeMap, switchMap } from 'rxjs/operators';
import { Err, Ok } from './index';
export function resultMap(mapper, errMapper) {
export function resultMap(mapper) {
return (source) => {
return source.pipe(map(result => {
if (result.ok) {
if (mapper) {
const newVal = mapper(result.val);
return new Ok(newVal);
}
else {
return result;
}
}
else {
if (errMapper) {
return new Err(errMapper(result.val));
}
else {
return result;
}
}
}));
return source.pipe(map(result => result.map(mapper)));
};
}
export function resultMapErr(mapper) {
return (source) => {
return source.pipe(map(result => result.mapErr(mapper)));
};
}
export function resultMapTo(value) {
return (source) => {
return source.pipe(map(result => {
if (result.ok) {
return new Ok(value);
}
else {
return result;
}
}));
return source.pipe(map(result => result.map(() => value)));
};
}
export function resultMapErrTo(value) {
return (source) => {
return source.pipe(map(result => result.mapErr(() => value)));
};
}
export function elseMap(mapper) {

@@ -101,2 +86,12 @@ return (source) => {

}
export function filterResultOk() {
return (source) => {
return source.pipe(filter(result => result.ok), map(result => result.val));
};
}
export function filterResultErr() {
return (source) => {
return source.pipe(filter(result => result.err), map(result => result.val));
};
}
//# sourceMappingURL=rxjs-operators.js.map

Sorry, the diff of this file is not supported yet

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