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

@bitty/either

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitty/either - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

types/Falsy.d.ts

41

dist/Either.esm.js
/**
* Check if value is nullish (`void`, `null` or `undefined`).
* @param {*} value - Value that will be checked.
* Union of values that is considered false when converted to `Boolean`.
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy}.
* @typedef {false | void | '' | 0 | 0n | null | undefined} Falsy
*/
/**
* Check if value is falsy (`""`, `null`, `false`, `0`, `NaN` or `undefined`).
* @param {*} value - The value that will be checked.
* @returns {Boolean}
*/
function isNullish(value) {
return value == null;
function isFalsy(value) {
return !value;
}

@@ -79,2 +84,26 @@

* Receives a default value and returns a function to create `Either` instances
* from values that can be falsy (`""`, `null`, `false`, `0`, `-0`, `0n`, `NaN`
* or `undefined`). If so, it returns a `Left` with the received default value,
* otherwise a `Right` with non-falsy value.
* @param {L} defaultValue - The value used as `Left` if value is falsy.
* @returns {function(R | Falsy): Either.<L, R>}
* @template L, R
*/
function fromFalsy(defaultValue) {
return function (value) {
return isFalsy(value) ? Left(defaultValue) : Right(value);
};
}
/**
* Check if value is nullish (`void`, `null` or `undefined`).
* @param {*} value - Value that will be checked.
* @returns {Boolean}
*/
function isNullish(value) {
return value == null;
}
/**
* Receives a default value and returns a function to create `Either` instances
* from values that can be nullish (`void`, `null` or `undefined`). If so, it

@@ -84,3 +113,3 @@ * returns a `Left` with the received default value, otherwise a `Right` with

* @param {L} defaultValue - The value used as `Left` if value is nullish.
* @returns {function(R | null | undefined | void): Either.<L, R>}
* @returns {function(R | Nullish): Either.<L, R>}
* @template L, R

@@ -117,3 +146,3 @@ */

export { Left, Right, fromNullish, fromPredicate, tryCatch };
export { Left, Right, fromFalsy, fromNullish, fromPredicate, tryCatch };
//# sourceMappingURL=Either.esm.js.map

@@ -6,8 +6,13 @@ 'use strict';

/**
* Check if value is nullish (`void`, `null` or `undefined`).
* @param {*} value - Value that will be checked.
* Union of values that is considered false when converted to `Boolean`.
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy}.
* @typedef {false | void | '' | 0 | 0n | null | undefined} Falsy
*/
/**
* Check if value is falsy (`""`, `null`, `false`, `0`, `NaN` or `undefined`).
* @param {*} value - The value that will be checked.
* @returns {Boolean}
*/
function isNullish(value) {
return value == null;
function isFalsy(value) {
return !value;
}

@@ -84,2 +89,26 @@

* Receives a default value and returns a function to create `Either` instances
* from values that can be falsy (`""`, `null`, `false`, `0`, `-0`, `0n`, `NaN`
* or `undefined`). If so, it returns a `Left` with the received default value,
* otherwise a `Right` with non-falsy value.
* @param {L} defaultValue - The value used as `Left` if value is falsy.
* @returns {function(R | Falsy): Either.<L, R>}
* @template L, R
*/
function fromFalsy(defaultValue) {
return function (value) {
return isFalsy(value) ? Left(defaultValue) : Right(value);
};
}
/**
* Check if value is nullish (`void`, `null` or `undefined`).
* @param {*} value - Value that will be checked.
* @returns {Boolean}
*/
function isNullish(value) {
return value == null;
}
/**
* Receives a default value and returns a function to create `Either` instances
* from values that can be nullish (`void`, `null` or `undefined`). If so, it

@@ -89,3 +118,3 @@ * returns a `Left` with the received default value, otherwise a `Right` with

* @param {L} defaultValue - The value used as `Left` if value is nullish.
* @returns {function(R | null | undefined | void): Either.<L, R>}
* @returns {function(R | Nullish): Either.<L, R>}
* @template L, R

@@ -124,2 +153,3 @@ */

exports.Right = Right;
exports.fromFalsy = fromFalsy;
exports.fromNullish = fromNullish;

@@ -126,0 +156,0 @@ exports.fromPredicate = fromPredicate;

@@ -8,8 +8,13 @@ (function (global, factory) {

/**
* Check if value is nullish (`void`, `null` or `undefined`).
* @param {*} value - Value that will be checked.
* Union of values that is considered false when converted to `Boolean`.
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy}.
* @typedef {false | void | '' | 0 | 0n | null | undefined} Falsy
*/
/**
* Check if value is falsy (`""`, `null`, `false`, `0`, `NaN` or `undefined`).
* @param {*} value - The value that will be checked.
* @returns {Boolean}
*/
function isNullish(value) {
return value == null;
function isFalsy(value) {
return !value;
}

@@ -86,2 +91,26 @@

* Receives a default value and returns a function to create `Either` instances
* from values that can be falsy (`""`, `null`, `false`, `0`, `-0`, `0n`, `NaN`
* or `undefined`). If so, it returns a `Left` with the received default value,
* otherwise a `Right` with non-falsy value.
* @param {L} defaultValue - The value used as `Left` if value is falsy.
* @returns {function(R | Falsy): Either.<L, R>}
* @template L, R
*/
function fromFalsy(defaultValue) {
return function (value) {
return isFalsy(value) ? Left(defaultValue) : Right(value);
};
}
/**
* Check if value is nullish (`void`, `null` or `undefined`).
* @param {*} value - Value that will be checked.
* @returns {Boolean}
*/
function isNullish(value) {
return value == null;
}
/**
* Receives a default value and returns a function to create `Either` instances
* from values that can be nullish (`void`, `null` or `undefined`). If so, it

@@ -91,3 +120,3 @@ * returns a `Left` with the received default value, otherwise a `Right` with

* @param {L} defaultValue - The value used as `Left` if value is nullish.
* @returns {function(R | null | undefined | void): Either.<L, R>}
* @returns {function(R | Nullish): Either.<L, R>}
* @template L, R

@@ -126,2 +155,3 @@ */

exports.Right = Right;
exports.fromFalsy = fromFalsy;
exports.fromNullish = fromNullish;

@@ -128,0 +158,0 @@ exports.fromPredicate = fromPredicate;

2

dist/Either.umd.min.js

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).Either={})}(this,(function(n){"use strict";function t(n){return{_kind:"Left",map:function(){return t(n)},then:function(){return t(n)},chain:function(){return t(n)},mapLeft:function(r){return t(r(n))},isLeft:function(){return!0},isRight:function(){return!1},match:function(t){return(0,t.left)(n)},fold:function(t){return t(n)},getOrElse:function(t){return t(n)},orElse:function(t){return t(n)},unwrap:function(){return n}}}function r(n){return{_kind:"Right",map:function(t){return r(t(n))},then:function(t){var u=t(n);return function(n){var t,r;return"Left"===(null===(t=n)||void 0===t?void 0:t._kind)||"Right"===(null===(r=n)||void 0===r?void 0:r._kind)}(u)?u:r(u)},chain:function(t){return t(n)},mapLeft:function(){return r(n)},isLeft:function(){return!1},isRight:function(){return!0},match:function(t){return(0,t.right)(n)},fold:function(t,r){return r(n)},getOrElse:function(){return n},orElse:function(){return r(n)},unwrap:function(){return n}}}n.Left=t,n.Right=r,n.fromNullish=function(n){return function(u){return function(n){return null==n}(u)?t(n):r(u)}},n.fromPredicate=function(n,u){return function(e){return n(e)?r(e):t(u(e))}},n.tryCatch=function(n,u){try{return r(n())}catch(n){return t(u(n))}},Object.defineProperty(n,"__esModule",{value:!0})}));
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).Either={})}(this,(function(n){"use strict";function t(n){return{_kind:"Left",map:function(){return t(n)},then:function(){return t(n)},chain:function(){return t(n)},mapLeft:function(r){return t(r(n))},isLeft:function(){return!0},isRight:function(){return!1},match:function(t){return(0,t.left)(n)},fold:function(t){return t(n)},getOrElse:function(t){return t(n)},orElse:function(t){return t(n)},unwrap:function(){return n}}}function r(n){return{_kind:"Right",map:function(t){return r(t(n))},then:function(t){var u=t(n);return function(n){var t,r;return"Left"===(null===(t=n)||void 0===t?void 0:t._kind)||"Right"===(null===(r=n)||void 0===r?void 0:r._kind)}(u)?u:r(u)},chain:function(t){return t(n)},mapLeft:function(){return r(n)},isLeft:function(){return!1},isRight:function(){return!0},match:function(t){return(0,t.right)(n)},fold:function(t,r){return r(n)},getOrElse:function(){return n},orElse:function(){return r(n)},unwrap:function(){return n}}}n.Left=t,n.Right=r,n.fromFalsy=function(n){return function(u){return function(n){return!n}(u)?t(n):r(u)}},n.fromNullish=function(n){return function(u){return function(n){return null==n}(u)?t(n):r(u)}},n.fromPredicate=function(n,u){return function(e){return n(e)?r(e):t(u(e))}},n.tryCatch=function(n,u){try{return r(n())}catch(n){return t(u(n))}},Object.defineProperty(n,"__esModule",{value:!0})}));
//# sourceMappingURL=Either.umd.min.js.map
{
"name": "@bitty/either",
"version": "0.0.1",
"version": "0.0.2",
"description": "Either monad implementation.",

@@ -35,3 +35,4 @@ "sideEffects": false,

"type": "git",
"url": "git+https://github.com/VitorLuizC/bitty.git"
"url": "git+https://github.com/VitorLuizC/bitty.git",
"directory": "packages/either"
},

@@ -49,10 +50,11 @@ "author": {

"devDependencies": {
"@bitty/nullish": "0.0.1",
"@rollup/plugin-node-resolve": "^8.0.0",
"ava": "^3.8.2",
"@bitty/falsy": "0.0.0",
"@bitty/nullish": "0.0.3",
"@rollup/plugin-node-resolve": "^8.1.0",
"ava": "^3.9.0",
"prettier": "^2.0.5",
"rollup": "^2.13.1",
"rollup": "^2.18.1",
"rollup-plugin-terser": "^6.1.0",
"typescript": "^3.9.3"
"typescript": "^3.9.5"
}
}

@@ -9,3 +9,3 @@ import type Either from './Either.js';

* @param {L} defaultValue - The value used as `Left` if value is nullish.
* @returns {function(R | null | undefined | void): Either.<L, R>}
* @returns {function(R | Nullish): Either.<L, R>}
* @template L, R

@@ -12,0 +12,0 @@ */

export type { default as Either } from './Either.js';
export { default as fromFalsy } from './fromFalsy.js';
export { default as fromNullish } from './fromNullish.js';

@@ -3,0 +4,0 @@ export { default as fromPredicate } from './fromPredicate.js';

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

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