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

@perfective/maybe

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@perfective/maybe - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

4

dist/maybe/maybe.d.ts

@@ -6,3 +6,3 @@ export declare type Nullary<T> = () => T;

export declare type Bind<T, R> = Unary<T, Maybe<R>> | Unary<T, R | undefined | null>;
export declare class Maybe<T> implements Maybe<T> {
export declare class Maybe<T> {
readonly value?: T | null | undefined;

@@ -14,2 +14,4 @@ constructor(value?: T | null | undefined);

otherwise(fallback: Fallback<T>): T;
or(nothing: null): T | null;
or(nothing: undefined): T | undefined;
maybe<R>(next: Bind<T | undefined | null, R>): Maybe<R>;

@@ -16,0 +18,0 @@ optional<R>(next: Bind<T | undefined, R>): Maybe<R>;

@@ -29,2 +29,8 @@ "use strict";

};
Maybe.prototype.or = function (nothing) {
if (value_1.isPresent(this.value)) {
return this.value;
}
return nothing;
};
Maybe.prototype.maybe = function (next) {

@@ -31,0 +37,0 @@ return maybeOf(next(this.value));

@@ -105,2 +105,12 @@ "use strict";

});
describe('or', function () {
it('returns the Maybe value instead of null', function () {
expect(maybe_1.just(3.14).or(null))
.toEqual(3.14);
});
it('returns the Maybe value instead of undefined', function () {
expect(maybe_1.just(3.14).or(undefined))
.toEqual(3.14);
});
});
describe('maybe', function () {

@@ -175,2 +185,12 @@ it('passes defined value as is', function () {

});
describe('or', function () {
it('returns undefined', function () {
expect(maybe_1.nothing().or(undefined))
.toBeUndefined();
});
it('returns null instead of undefined', function () {
expect(maybe_1.nothing().or(null))
.toBeNull();
});
});
describe('maybe', function () {

@@ -245,2 +265,12 @@ it('passes the undefined value', function () {

});
describe('or', function () {
it('returns undefined instead of null', function () {
expect(maybe_1.nil().or(undefined))
.toBeUndefined();
});
it('returns null', function () {
expect(maybe_1.nil().or(null))
.toBeNull();
});
});
describe('maybe', function () {

@@ -247,0 +277,0 @@ it('passes the null value', function () {

{
"name": "@perfective/maybe",
"version": "0.1.4",
"version": "0.1.5",
"description": "Maybe monad-like container",

@@ -5,0 +5,0 @@ "author": "Andrey Mikheychik <a.mikheychik@gmail.com>",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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