New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

failable

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

failable - npm Package Compare versions

Comparing version 2.2.1 to 2.3.0

mut/lazy.d.ts

2

dispatcher/index.d.ts

@@ -12,3 +12,3 @@ export interface Handler<T> {

*/
handlersOf(state: State): Handler<any>[];
handlersOf(state: State): Array<Handler<any>>;
/**

@@ -15,0 +15,0 @@ * Remove every handler for every state. This is behaviorally equivalent to

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

import { Success, Pending, Failure } from '../common';
import { Failure, Pending, Success } from '../common';
import { Handler } from '../dispatcher';

@@ -3,0 +3,0 @@ /**

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

pending: function () { return dispatch('pending', undefined); },
failure: function (data) { return dispatch('failure', data); }
failure: function (data) { return dispatch('failure', data); },
};

@@ -22,0 +22,0 @@ /**

import { Future } from './future';
import { Lazy } from './lazy';
/**

@@ -75,2 +76,16 @@ * Failable is a reactive MobX counterpart to a Promise. It has three states:

accept(promise: PromiseLike<T>): this;
/**
* Returns this Failable's success value if it is a success, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-success
* @returns This Future's success value or the provided default value
*/
successOr<U>(defaultValue: Lazy<U>): T | U;
/**
* Returns this Failable's error value if it is a failure, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-failure
* @returns this Failable's failure error or the provided default value
*/
failureOr<U>(defaultValue: Lazy<U>): Error | U;
}

@@ -11,2 +11,3 @@ "use strict";

var future_1 = require("./future");
var lazy_1 = require("./lazy");
var State = future_1.Future.State;

@@ -129,2 +130,28 @@ /**

};
/**
* Returns this Failable's success value if it is a success, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-success
* @returns This Future's success value or the provided default value
*/
Failable.prototype.successOr = function (defaultValue) {
return this.match({
success: function (v) { return v; },
failure: function () { return lazy_1.Lazy.force(defaultValue); },
pending: function () { return lazy_1.Lazy.force(defaultValue); },
});
};
/**
* Returns this Failable's error value if it is a failure, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-failure
* @returns this Failable's failure error or the provided default value
*/
Failable.prototype.failureOr = function (defaultValue) {
return this.match({
success: function () { return lazy_1.Lazy.force(defaultValue); },
failure: function (e) { return e; },
pending: function () { return lazy_1.Lazy.force(defaultValue); },
});
};
return Failable;

@@ -131,0 +158,0 @@ }());

import { Enum } from 'typescript-string-enums';
import { Lazy } from './lazy';
/**

@@ -55,2 +56,16 @@ * Future is a reactive counterpart to a Promise with MobX semantics. It has

accept(promise: PromiseLike<T>): this;
/**
* Returns this Future's success value if it is a success, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-success
* @returns This Future's success value or the provided default value
*/
successOr<U>(defaultValue: Lazy<U>): T | U;
/**
* Returns this Future's error value if it is a failure, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-failure
* @returns this Future's failure error or the provided default value
*/
failureOr<U>(defaultValue: Lazy<U>): Error | U;
}

@@ -57,0 +72,0 @@ export declare namespace Future {

export * from './future';
export * from './lazy';
export * from './failable';
export * from './loadable';

@@ -7,3 +7,4 @@ "use strict";

__export(require("./future"));
__export(require("./lazy"));
__export(require("./failable"));
__export(require("./loadable"));
import { Enum } from 'typescript-string-enums';
import { Future } from './future';
import { Lazy } from './lazy';
/**

@@ -90,2 +91,16 @@ * Loadable is an extension of Failable. It has six states: empty, pending,

accept(promise: PromiseLike<T>): this;
/**
* Returns this Loadable's success value if it is a success, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-success
* @returns This Future's success value or the provided default value
*/
successOr<U>(defaultValue: Lazy<U>): T | U;
/**
* Returns this Loadable's error value if it is a failure, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-failure
* @returns this Loadable's failure error or the provided default value
*/
failureOr<U>(defaultValue: Lazy<U>): Error | U;
}

@@ -92,0 +107,0 @@ export declare namespace Loadable {

@@ -11,2 +11,3 @@ "use strict";

var typescript_string_enums_1 = require("typescript-string-enums");
var lazy_1 = require("./lazy");
/**

@@ -175,2 +176,28 @@ * Loadable is an extension of Failable. It has six states: empty, pending,

};
/**
* Returns this Loadable's success value if it is a success, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-success
* @returns This Future's success value or the provided default value
*/
Loadable.prototype.successOr = function (defaultValue) {
return this.match({
success: function (v) { return v; },
failure: function () { return lazy_1.Lazy.force(defaultValue); },
pending: function () { return lazy_1.Lazy.force(defaultValue); },
});
};
/**
* Returns this Loadable's error value if it is a failure, or the provided
* default value if it is not.
* @param defaultValue A possibly lazy value to use in case of non-failure
* @returns this Loadable's failure error or the provided default value
*/
Loadable.prototype.failureOr = function (defaultValue) {
return this.match({
success: function () { return lazy_1.Lazy.force(defaultValue); },
failure: function (e) { return e; },
pending: function () { return lazy_1.Lazy.force(defaultValue); },
});
};
return Loadable;

@@ -236,3 +263,3 @@ }());

*/
retrying: 'retrying'
retrying: 'retrying',
});

@@ -239,0 +266,0 @@ })(Loadable = exports.Loadable || (exports.Loadable = {}));

{
"name": "failable",
"version": "2.2.1",
"version": "2.3.0",
"description": "Simplify error state handling",

@@ -9,3 +9,3 @@ "main": "index.js",

"test": "mocha --require ts-node/register ./src/**/*.spec.ts",
"lint": "globstar --node --nodir -- tslint './src/**/*.ts'",
"lint": "tslint --project tsconfig.json",
"build": "rm -r lib; tsc",

@@ -32,3 +32,2 @@ "package": "npm run build && ts-node prepare.ts"

"fs-extra": "^2.0.0",
"globstar": "^1.0.0",
"mocha": "3.0.2",

@@ -38,3 +37,3 @@ "sinon": "^2.1.0",

"ts-node": "1.3.0",
"tslint": "4.5.1",
"tslint": "5.1.0",
"typescript": "2.2.2"

@@ -41,0 +40,0 @@ },

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

import { Success, Failure } from '../common';
import { Failure, Success } from '../common';
/**

@@ -3,0 +3,0 @@ * A Result represents a successful value or a failure with an error.

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