You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

try-typescript

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

try-typescript - npm Package Compare versions

Comparing version

to
1.0.0

4

dist/lib/Try.d.ts

@@ -25,4 +25,4 @@ export declare class Try<T> {

mapFailureWith<E extends Error, U extends Error>(errorType: new (...args: any[]) => E, func: (ex: E) => U | Promise<U>): Try<T>;
filter(predicateFunc: (value: T) => boolean | Promise<boolean>, throwbackFunction?: (value: T) => void): Try<T>;
filterNot(predicateFunc: (value: T) => boolean | Promise<boolean>, throwbackFunction?: (value: T) => void): Try<T>;
filter(predicateFunc: (value: T) => boolean | Promise<boolean>, throwbackFunction?: (value: T) => Error): Try<T>;
filterNot(predicateFunc: (value: T) => boolean | Promise<boolean>, throwbackFunction?: (value: T) => Error): Try<T>;
peek(fn: (value: T) => void): Try<T>;

@@ -29,0 +29,0 @@ andThen(fn: (value: T) => any): Try<T>;

@@ -103,3 +103,3 @@ "use strict";

if (yield executionElement.functionData.func(this.value)) {
yield executionElement.functionData.fallbackFunction(this.value);
throw yield executionElement.functionData.fallbackFunction(this.value);
}

@@ -111,3 +111,3 @@ }

if (!(yield executionElement.functionData.func(this.value))) {
yield executionElement.functionData.fallbackFunction(this.value);
throw yield executionElement.functionData.fallbackFunction(this.value);
}

@@ -114,0 +114,0 @@ }

@@ -189,3 +189,3 @@ "use strict";

test("filter should throw custom exception if predicate does not hold", () => __awaiter(void 0, void 0, void 0, function* () {
const result = __1.Try.success(2).filterNot(v => v > 2, v => { throw new Error("Custom Predicate does not hold for " + v); });
const result = __1.Try.success(2).filterNot(v => v > 2, v => Error("Custom Predicate does not hold for " + v));
yield expect(result.get()).rejects.toThrow("Custom Predicate does not hold for 2");

@@ -207,3 +207,3 @@ expect(result.isFailure()).toBe(true);

test("filterNot should throw custom exception if predicate does not hold", () => __awaiter(void 0, void 0, void 0, function* () {
const result = __1.Try.success(2).filter(v => v <= 2, v => { throw new Error("Custom Predicate does not hold for " + v); });
const result = __1.Try.success(2).filter(v => v <= 2, v => Error("Custom Predicate does not hold for " + v));
yield expect(result.get()).rejects.toThrow("Custom Predicate does not hold for 2");

@@ -210,0 +210,0 @@ expect(result.isFailure()).toBe(true);

{
"name": "try-typescript",
"version": "0.8.0",
"version": "1.0.0",
"description": "This repository implements a Try class inspired by the Vavr library in Java. The Try class is a functional programming construct for handling computations that may succeed or fail. It encapsulates exceptions and streamlines error handling, reducing boilerplate code and enhancing code readability. ",

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