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

@typed/maybe

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typed/maybe - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

yarn-error.log

5

lib.es2015/ap.js
import { chain } from './chain';
import { curry2 } from '@typed/functions';
import { map } from './map';

@@ -8,5 +9,3 @@ /**

*/
export var ap = function ap(fn, maybe) {
return maybe ? __ap(fn, maybe) : function (maybe) { return __ap(fn, maybe); };
};
export var ap = curry2(__ap);
function __ap(fn, maybe) {

@@ -13,0 +12,0 @@ return chain(function (f) { return map(f, maybe); }, fn);

4

lib.es2015/chain.d.ts
import { Maybe } from './Maybe';
/**
* Maps a `Maybe` to another `Maybe`.
* @name chain<A, B>(f: (value: A) => Maybe<B>, maybe: Maybe<A>): Maybe<B>
*/
export declare const chain: MaybeChain;

@@ -3,0 +7,0 @@ export interface MaybeChain {

@@ -0,6 +1,9 @@

import { curry2 } from '@typed/functions';
import { fromJust } from './fromJust';
import { isNothing } from './isNothing';
export var chain = function chain(f, maybe) {
return maybe ? __chain(f, maybe) : function (maybe) { return __chain(f, maybe); };
};
/**
* Maps a `Maybe` to another `Maybe`.
* @name chain<A, B>(f: (value: A) => Maybe<B>, maybe: Maybe<A>): Maybe<B>
*/
export var chain = curry2(__chain);
function __chain(f, maybe) {

@@ -7,0 +10,0 @@ return isNothing(maybe) ? maybe : f(fromJust(maybe));

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

import { curry2 } from '@typed/functions';
import { fromJust } from './fromJust';

@@ -8,7 +9,3 @@ import { isJust } from './isJust';

*/
export var fromMaybe = function fromMaybe(defaultValue, maybe) {
if (!maybe)
return function (maybe) { return __fromMaybe(defaultValue, maybe); };
return __fromMaybe(defaultValue, maybe);
};
export var fromMaybe = curry2(__fromMaybe);
function __fromMaybe(defaultValue, maybe) {

@@ -15,0 +12,0 @@ return isJust(maybe) ? fromJust(maybe) : defaultValue;

@@ -1,9 +0,3 @@

/**
* A JSON-serializable Just data-structure
* @name Just
* @type
*/
export interface Just<A> {
readonly '@typed/Just': A;
}
import * as types from '@typed/core';
export declare type Just<A> = types.Just<A>;
export declare namespace Just {

@@ -10,0 +4,0 @@ /**

import { Maybe } from './Maybe';
/**
* Applies a function to the value possibly contained in a `Maybe`. If the
* maybe is a `Nothing` just the `Nothing` is returned.
* @name map<A, B>(f: (value: A) => B, maybe: Maybe<A>): Maybe<B>
*/
export declare const map: MaybeMap;

@@ -3,0 +8,0 @@ export interface MaybeMap {

import { Maybe } from './Maybe';
import { chain } from './chain';
export var map = function map(f, maybe) {
return maybe ? __map(f, maybe) : function (maybe) { return __map(f, maybe); };
};
import { curry2 } from '@typed/functions';
/**
* Applies a function to the value possibly contained in a `Maybe`. If the
* maybe is a `Nothing` just the `Nothing` is returned.
* @name map<A, B>(f: (value: A) => B, maybe: Maybe<A>): Maybe<B>
*/
export var map = curry2(__map);
function __map(f, maybe) {

@@ -7,0 +11,0 @@ return chain(function (a) { return Maybe.of(f(a)); }, maybe);

@@ -1,9 +0,3 @@

import { Just } from './Just';
import { Nothing } from './Nothing';
/**
* Maybe type. Very useful when errors can occur.
* @name Maybe<A>
* @type
*/
export declare type Maybe<A> = Just<A> | Nothing;
import * as types from '@typed/core';
export declare type Maybe<A> = types.Maybe<A>;
export declare namespace Maybe {

@@ -10,0 +4,0 @@ /**

@@ -1,9 +0,3 @@

/**
* The Nothing type, used in place of nulls or undefined.
* @name Nothing
* @type
*/
export interface Nothing {
readonly '@typed/Nothing': true;
}
import * as types from '@typed/core';
export declare type Nothing = types.Nothing;
export declare const Nothing: Nothing;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var chain_1 = require("./chain");
var functions_1 = require("@typed/functions");
var map_1 = require("./map");

@@ -10,5 +11,3 @@ /**

*/
exports.ap = function ap(fn, maybe) {
return maybe ? __ap(fn, maybe) : function (maybe) { return __ap(fn, maybe); };
};
exports.ap = functions_1.curry2(__ap);
function __ap(fn, maybe) {

@@ -15,0 +14,0 @@ return chain_1.chain(function (f) { return map_1.map(f, maybe); }, fn);

import { Maybe } from './Maybe';
/**
* Maps a `Maybe` to another `Maybe`.
* @name chain<A, B>(f: (value: A) => Maybe<B>, maybe: Maybe<A>): Maybe<B>
*/
export declare const chain: MaybeChain;

@@ -3,0 +7,0 @@ export interface MaybeChain {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var functions_1 = require("@typed/functions");
var fromJust_1 = require("./fromJust");
var isNothing_1 = require("./isNothing");
exports.chain = function chain(f, maybe) {
return maybe ? __chain(f, maybe) : function (maybe) { return __chain(f, maybe); };
};
/**
* Maps a `Maybe` to another `Maybe`.
* @name chain<A, B>(f: (value: A) => Maybe<B>, maybe: Maybe<A>): Maybe<B>
*/
exports.chain = functions_1.curry2(__chain);
function __chain(f, maybe) {

@@ -9,0 +12,0 @@ return isNothing_1.isNothing(maybe) ? maybe : f(fromJust_1.fromJust(maybe));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var functions_1 = require("@typed/functions");
var fromJust_1 = require("./fromJust");

@@ -10,7 +11,3 @@ var isJust_1 = require("./isJust");

*/
exports.fromMaybe = function fromMaybe(defaultValue, maybe) {
if (!maybe)
return function (maybe) { return __fromMaybe(defaultValue, maybe); };
return __fromMaybe(defaultValue, maybe);
};
exports.fromMaybe = functions_1.curry2(__fromMaybe);
function __fromMaybe(defaultValue, maybe) {

@@ -17,0 +14,0 @@ return isJust_1.isJust(maybe) ? fromJust_1.fromJust(maybe) : defaultValue;

@@ -1,9 +0,3 @@

/**
* A JSON-serializable Just data-structure
* @name Just
* @type
*/
export interface Just<A> {
readonly '@typed/Just': A;
}
import * as types from '@typed/core';
export declare type Just<A> = types.Just<A>;
export declare namespace Just {

@@ -10,0 +4,0 @@ /**

import { Maybe } from './Maybe';
/**
* Applies a function to the value possibly contained in a `Maybe`. If the
* maybe is a `Nothing` just the `Nothing` is returned.
* @name map<A, B>(f: (value: A) => B, maybe: Maybe<A>): Maybe<B>
*/
export declare const map: MaybeMap;

@@ -3,0 +8,0 @@ export interface MaybeMap {

@@ -5,5 +5,9 @@ "use strict";

var chain_1 = require("./chain");
exports.map = function map(f, maybe) {
return maybe ? __map(f, maybe) : function (maybe) { return __map(f, maybe); };
};
var functions_1 = require("@typed/functions");
/**
* Applies a function to the value possibly contained in a `Maybe`. If the
* maybe is a `Nothing` just the `Nothing` is returned.
* @name map<A, B>(f: (value: A) => B, maybe: Maybe<A>): Maybe<B>
*/
exports.map = functions_1.curry2(__map);
function __map(f, maybe) {

@@ -10,0 +14,0 @@ return chain_1.chain(function (a) { return Maybe_1.Maybe.of(f(a)); }, maybe);

@@ -1,9 +0,3 @@

import { Just } from './Just';
import { Nothing } from './Nothing';
/**
* Maybe type. Very useful when errors can occur.
* @name Maybe<A>
* @type
*/
export declare type Maybe<A> = Just<A> | Nothing;
import * as types from '@typed/core';
export declare type Maybe<A> = types.Maybe<A>;
export declare namespace Maybe {

@@ -10,0 +4,0 @@ /**

@@ -1,9 +0,3 @@

/**
* The Nothing type, used in place of nulls or undefined.
* @name Nothing
* @type
*/
export interface Nothing {
readonly '@typed/Nothing': true;
}
import * as types from '@typed/core';
export declare type Nothing = types.Nothing;
export declare const Nothing: Nothing;
{
"name": "@typed/maybe",
"version": "2.0.0",
"version": "3.0.0",
"description": "Well-typed Maybe data structure",

@@ -17,2 +17,6 @@ "main": "lib/index.js",

},
"dependencies": {
"@typed/core": "2.0.0",
"@typed/functions": "1.0.0"
},
"repository": {

@@ -19,0 +23,0 @@ "type": "git",

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

# @typed/maybe -- 2.0.0
# @typed/maybe -- 3.0.0

@@ -16,20 +16,2 @@ Well-typed Maybe data structure

#### Just
<p>
A JSON-serializable Just data-structure
</p>
```typescript
export interface Just<A> {
readonly '@typed/Just': A
}
```
#### Just.of\<A\>(value: A): Just\<A\>

@@ -83,7 +65,8 @@

#### Maybe\<A\>
#### ap\<A, B\>(fn: Maybe\<(value: A) =\> B\>, value: Maybe\<A\>): Maybe\<B\>
<p>
Maybe type. Very useful when errors can occur.
Applies the function contained in a `Maybe` to the value contained in a
second `Maybe`.

@@ -93,35 +76,29 @@ </p>

<details>
<summary>See the code</summary>
```typescript
export type Maybe<A> = Just<A> | Nothing
export const ap: MaybeAp = curry2(__ap)
```
function __ap<A, B>(fn: Maybe<(value: A) => B>, maybe: Maybe<A>): Maybe<B> {
return chain(f => map(f, maybe), fn)
}
#### Nothing
<p>
The Nothing type, used in place of nulls or undefined.
</p>
```typescript
export interface Nothing {
readonly '@typed/Nothing': true
export interface MaybeAp {
<A, B>(fn: Maybe<(value: A) => B>, value: Maybe<A>): Maybe<B>
<A, B>(fn: Maybe<(value: A) => B>): (value: Maybe<A>) => Maybe<B>
}
export const Nothing: Nothing = { '@typed/Nothing': true }
```
</details>
<hr />
#### ap\<A, B\>(fn: Maybe\<(value: A) =\> B\>, value: Maybe\<A\>): Maybe\<B\>
#### chain\<A, B\>(f: (value: A) =\> Maybe\<B\>, maybe: Maybe\<A\>): Maybe\<B\>
<p>
Applies the function contained in a `Maybe` to the value contained in a
second `Maybe`.
Maps a `Maybe` to another `Maybe`.

@@ -136,13 +113,11 @@ </p>

export const ap: MaybeAp = function ap<A, B>(fn: Maybe<(value: A) => B>, maybe?: Maybe<A>): any {
return maybe ? __ap(fn, maybe) : (maybe: Maybe<A>) => __ap(fn, maybe)
}
export const chain: MaybeChain = curry2(__chain)
function __ap<A, B>(fn: Maybe<(value: A) => B>, maybe: Maybe<A>): Maybe<B> {
return chain(f => map(f, maybe), fn)
function __chain<A, B>(f: (value: A) => Maybe<B>, maybe: Maybe<A>): Maybe<B> {
return isNothing(maybe) ? maybe : f(fromJust(maybe))
}
export interface MaybeAp {
<A, B>(fn: Maybe<(value: A) => B>, value: Maybe<A>): Maybe<B>
<A, B>(fn: Maybe<(value: A) => B>): (value: Maybe<A>) => Maybe<B>
export interface MaybeChain {
<A, B>(f: (value: A) => Maybe<B>, maybe: Maybe<A>): Maybe<B>
<A, B>(f: (value: A) => Maybe<B>): (maybe: Maybe<A>) => Maybe<B>
}

@@ -207,8 +182,4 @@

export const fromMaybe: FromMaybe = function fromMaybe<A>(defaultValue: A, maybe?: Maybe<A>) {
if (!maybe) return (maybe: Maybe<A>) => __fromMaybe(defaultValue, maybe)
export const fromMaybe: FromMaybe = curry2(__fromMaybe)
return __fromMaybe(defaultValue, maybe)
}
function __fromMaybe<A>(defaultValue: A, maybe: Maybe<A>): A {

@@ -301,1 +272,33 @@ return isJust(maybe) ? fromJust(maybe) : defaultValue

<hr />
#### map\<A, B\>(f: (value: A) =\> B, maybe: Maybe\<A\>): Maybe\<B\>
<p>
Applies a function to the value possibly contained in a `Maybe`. If the
maybe is a `Nothing` just the `Nothing` is returned.
</p>
<details>
<summary>See the code</summary>
```typescript
export const map: MaybeMap = curry2(__map)
function __map<A, B>(f: (value: A) => B, maybe: Maybe<A>): Maybe<B> {
return chain(a => Maybe.of(f(a)), maybe)
}
export interface MaybeMap {
<A, B>(f: (value: A) => B, maybe: Maybe<A>): Maybe<B>
<A, B>(f: (value: A) => B): (maybe: Maybe<A>) => Maybe<B>
}
```
</details>
<hr />
import { Maybe } from './Maybe'
import { chain } from './chain'
import { curry2 } from '@typed/functions'
import { map } from './map'

@@ -10,5 +11,3 @@

*/
export const ap: MaybeAp = function ap<A, B>(fn: Maybe<(value: A) => B>, maybe?: Maybe<A>): any {
return maybe ? __ap(fn, maybe) : (maybe: Maybe<A>) => __ap(fn, maybe)
}
export const ap: MaybeAp = curry2(__ap)

@@ -15,0 +14,0 @@ function __ap<A, B>(fn: Maybe<(value: A) => B>, maybe: Maybe<A>): Maybe<B> {

import { Maybe } from './Maybe'
import { curry2 } from '@typed/functions'
import { fromJust } from './fromJust'
import { isNothing } from './isNothing'
export const chain: MaybeChain = function chain<A, B>(
f: (value: A) => Maybe<B>,
maybe?: Maybe<A>
): any {
return maybe ? __chain(f, maybe) : (maybe: Maybe<A>) => __chain(f, maybe)
}
/**
* Maps a `Maybe` to another `Maybe`.
* @name chain<A, B>(f: (value: A) => Maybe<B>, maybe: Maybe<A>): Maybe<B>
*/
export const chain: MaybeChain = curry2(__chain)

@@ -12,0 +12,0 @@ function __chain<A, B>(f: (value: A) => Maybe<B>, maybe: Maybe<A>): Maybe<B> {

import { Maybe } from './Maybe'
import { curry2 } from '@typed/functions'
import { fromJust } from './fromJust'

@@ -10,8 +11,4 @@ import { isJust } from './isJust'

*/
export const fromMaybe: FromMaybe = function fromMaybe<A>(defaultValue: A, maybe?: Maybe<A>) {
if (!maybe) return (maybe: Maybe<A>) => __fromMaybe(defaultValue, maybe)
export const fromMaybe: FromMaybe = curry2(__fromMaybe)
return __fromMaybe(defaultValue, maybe)
}
function __fromMaybe<A>(defaultValue: A, maybe: Maybe<A>): A {

@@ -18,0 +15,0 @@ return isJust(maybe) ? fromJust(maybe) : defaultValue

@@ -1,10 +0,5 @@

/**
* A JSON-serializable Just data-structure
* @name Just
* @type
*/
export interface Just<A> {
readonly '@typed/Just': A
}
import * as types from '@typed/core'
export type Just<A> = types.Just<A>
export namespace Just {

@@ -11,0 +6,0 @@ /**

import { Maybe } from './Maybe'
import { chain } from './chain'
import { curry2 } from '@typed/functions'
export const map: MaybeMap = function map<A, B>(f: (value: A) => B, maybe?: Maybe<A>): any {
return maybe ? __map(f, maybe) : (maybe: Maybe<A>) => __map(f, maybe)
}
/**
* Applies a function to the value possibly contained in a `Maybe`. If the
* maybe is a `Nothing` just the `Nothing` is returned.
* @name map<A, B>(f: (value: A) => B, maybe: Maybe<A>): Maybe<B>
*/
export const map: MaybeMap = curry2(__map)

@@ -8,0 +12,0 @@ function __map<A, B>(f: (value: A) => B, maybe: Maybe<A>): Maybe<B> {

@@ -0,10 +1,6 @@

import * as types from '@typed/core'
import { Just } from './Just'
import { Nothing } from './Nothing'
/**
* Maybe type. Very useful when errors can occur.
* @name Maybe<A>
* @type
*/
export type Maybe<A> = Just<A> | Nothing
export type Maybe<A> = types.Maybe<A>

@@ -11,0 +7,0 @@ export namespace Maybe {

@@ -1,10 +0,4 @@

/**
* The Nothing type, used in place of nulls or undefined.
* @name Nothing
* @type
*/
export interface Nothing {
readonly '@typed/Nothing': true
}
import * as types from '@typed/core'
export type Nothing = types.Nothing
export const Nothing: Nothing = { '@typed/Nothing': true }

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

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

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