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

fp-ts-contrib

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fp-ts-contrib - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

5

CHANGELOG.md

@@ -16,2 +16,7 @@ # Changelog

# 0.1.4
- **New Feature**
- add some combinators to `TaskOption`, #22 (@bwlt)
# 0.1.3

@@ -18,0 +23,0 @@

@@ -5,2 +5,3 @@ import { Alt1 } from 'fp-ts/lib/Alt';

import { Option } from 'fp-ts/lib/Option';
import { TaskEither } from 'fp-ts/lib/TaskEither';
declare module 'fp-ts/lib/HKT' {

@@ -49,2 +50,26 @@ interface URItoKind<A> {

/**
* @since 0.1.4
*/
export declare function fromNullable<A>(a: A | null | undefined): TaskOption<A>;
/**
* @since 0.1.4
*/
export declare function fromTaskEither<A>(ma: TaskEither<any, A>): TaskOption<A>;
/**
* @since 0.1.4
*/
export declare function toUndefined<A>(ma: TaskOption<A>): Task<A | undefined>;
/**
* @since 0.1.4
*/
export declare function toNullable<A>(ma: TaskOption<A>): Task<A | null>;
/**
* @since 0.1.4
*/
export declare function chainTask<A, B>(f: (a: A) => Task<B>): (ma: TaskOption<A>) => TaskOption<B>;
/**
* @since 0.1.4
*/
export declare function chainOption<A, B>(f: (a: A) => Option<B>): (ma: TaskOption<A>) => TaskOption<B>;
/**
* @since 0.1.0

@@ -51,0 +76,0 @@ */

import { task, of } from 'fp-ts/lib/Task';
import { fromEither as optionFromEither, fromNullable as optionFromNullable, toUndefined as optionToUndefined, toNullable as optionToNullable, chain as optionChain } from 'fp-ts/lib/Option';
import { getOptionM } from 'fp-ts/lib/OptionT';

@@ -38,2 +39,38 @@ import { pipeable } from 'fp-ts/lib/pipeable';

/**
* @since 0.1.4
*/
export function fromNullable(a) {
return fromOption(optionFromNullable(a));
}
/**
* @since 0.1.4
*/
export function fromTaskEither(ma) {
return task.map(ma, optionFromEither);
}
/**
* @since 0.1.4
*/
export function toUndefined(ma) {
return task.map(ma, optionToUndefined);
}
/**
* @since 0.1.4
*/
export function toNullable(ma) {
return task.map(ma, optionToNullable);
}
/**
* @since 0.1.4
*/
export function chainTask(f) {
return ma => T.chain(ma, a => fromTask(f(a)));
}
/**
* @since 0.1.4
*/
export function chainOption(f) {
return ma => task.map(ma, optionChain(f));
}
/**
* @since 0.1.0

@@ -40,0 +77,0 @@ */

@@ -5,2 +5,3 @@ import { Alt1 } from 'fp-ts/lib/Alt';

import { Option } from 'fp-ts/lib/Option';
import { TaskEither } from 'fp-ts/lib/TaskEither';
declare module 'fp-ts/lib/HKT' {

@@ -49,2 +50,26 @@ interface URItoKind<A> {

/**
* @since 0.1.4
*/
export declare function fromNullable<A>(a: A | null | undefined): TaskOption<A>;
/**
* @since 0.1.4
*/
export declare function fromTaskEither<A>(ma: TaskEither<any, A>): TaskOption<A>;
/**
* @since 0.1.4
*/
export declare function toUndefined<A>(ma: TaskOption<A>): Task<A | undefined>;
/**
* @since 0.1.4
*/
export declare function toNullable<A>(ma: TaskOption<A>): Task<A | null>;
/**
* @since 0.1.4
*/
export declare function chainTask<A, B>(f: (a: A) => Task<B>): (ma: TaskOption<A>) => TaskOption<B>;
/**
* @since 0.1.4
*/
export declare function chainOption<A, B>(f: (a: A) => Option<B>): (ma: TaskOption<A>) => TaskOption<B>;
/**
* @since 0.1.0

@@ -51,0 +76,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Task_1 = require("fp-ts/lib/Task");
var Option_1 = require("fp-ts/lib/Option");
var OptionT_1 = require("fp-ts/lib/OptionT");

@@ -42,2 +43,44 @@ var pipeable_1 = require("fp-ts/lib/pipeable");

/**
* @since 0.1.4
*/
function fromNullable(a) {
return exports.fromOption(Option_1.fromNullable(a));
}
exports.fromNullable = fromNullable;
/**
* @since 0.1.4
*/
function fromTaskEither(ma) {
return Task_1.task.map(ma, Option_1.fromEither);
}
exports.fromTaskEither = fromTaskEither;
/**
* @since 0.1.4
*/
function toUndefined(ma) {
return Task_1.task.map(ma, Option_1.toUndefined);
}
exports.toUndefined = toUndefined;
/**
* @since 0.1.4
*/
function toNullable(ma) {
return Task_1.task.map(ma, Option_1.toNullable);
}
exports.toNullable = toNullable;
/**
* @since 0.1.4
*/
function chainTask(f) {
return function (ma) { return T.chain(ma, function (a) { return exports.fromTask(f(a)); }); };
}
exports.chainTask = chainTask;
/**
* @since 0.1.4
*/
function chainOption(f) {
return function (ma) { return Task_1.task.map(ma, Option_1.chain(f)); };
}
exports.chainOption = chainOption;
/**
* @since 0.1.0

@@ -44,0 +87,0 @@ */

2

package.json
{
"name": "fp-ts-contrib",
"version": "0.1.3",
"version": "0.1.4",
"description": "A community driven utility package for fp-ts",

@@ -5,0 +5,0 @@ "files": [

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