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

lil-fp

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lil-fp - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

dist/bool-729d4744.d.ts

2

dist/bool.d.ts

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

export { n as not, o as or } from './bool-38e9ed29.js';
export { a as and, n as not, o as or } from './bool-729d4744.js';

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

__export(bool_exports, {
and: () => and,
not: () => not,

@@ -29,6 +30,10 @@ or: () => or

var not = (predicate) => (arg) => !predicate(arg);
function and(...predicates) {
return (arg) => predicates.every((predicate) => predicate(arg));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
and,
not,
or
});
export { a as Arr } from './arr-bf7e48d4.js';
export { b as Bool } from './bool-38e9ed29.js';
export { b as Bool } from './bool-729d4744.js';
export { cast, flow, log, memo, noop, pipe, tap, tryCatch } from './func.js';
export { isArr, isBool, isFunc, isNum, isObj, isStr } from './is.js';
export { alt, match, otherwise, when } from './logic.js';
export { match, orElse, otherwise, when } from './logic.js';
export { o as Obj } from './obj-40a953aa.js';
export { o as Opt } from './opt-e7bb6428.js';
export { o as Opt } from './opt-0ed56d5d.js';
import './types.js';

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

Opt: () => opt_exports,
alt: () => alt,
cast: () => cast,

@@ -38,2 +37,3 @@ flow: () => flow,

noop: () => noop,
orElse: () => orElse,
otherwise: () => otherwise,

@@ -77,2 +77,3 @@ pipe: () => pipe,

__export(bool_exports, {
and: () => and,
not: () => not,

@@ -85,2 +86,5 @@ or: () => or

var not = (predicate) => (arg) => !predicate(arg);
function and(...predicates) {
return (arg) => predicates.every((predicate) => predicate(arg));
}

@@ -116,3 +120,3 @@ // src/func.ts

let x = fn(v);
if (x !== void 0)
if (x != null)
return x;

@@ -127,3 +131,3 @@ }

}
var otherwise = (fn) => (v) => when(() => !0, fn)(v), alt = (u) => (v) => v === void 0 ? typeof u == "function" ? u() : u : v;
var otherwise = (fn) => (v) => when(() => !0, fn)(v), orElse = (u) => (v) => v ?? (typeof u == "function" ? u() : u);

@@ -215,3 +219,2 @@ // src/obj.ts

__export(opt_exports, {
alt: () => alt2,
flatMap: () => flatMap,

@@ -228,2 +231,3 @@ from: () => from3,

none: () => none,
orElse: () => orElse2,
some: () => some2,

@@ -242,3 +246,3 @@ tap: () => tap2

return o.value;
}, match2 = (onSome, onNone) => (o) => isNone(o) ? onNone() : onSome(o.value), alt2 = (v) => (o) => {
}, match2 = (onSome, onNone) => (o) => isNone(o) ? onNone() : onSome(o.value), orElse2 = (v) => (o) => {
let vv = v();

@@ -253,3 +257,2 @@ return isOption(vv) ? isNone(o) ? vv : o : isNone(o) ? some2(vv) : o;

Opt,
alt,
cast,

@@ -267,2 +270,3 @@ flow,

noop,
orElse,
otherwise,

@@ -269,0 +273,0 @@ pipe,

@@ -1,7 +0,7 @@

declare const match: <T, R>(...fns: ((v: T) => R)[]) => (v: T) => (R & ({} | null)) | undefined;
declare const match: <T, R>(...fns: ((v: T) => R)[]) => (v: T) => NonNullable<R> | undefined;
declare function when<T, U extends T, R>(predicate: (v: T) => boolean, fn: (v: U) => R): (v: T) => R | undefined;
declare function when<T, U extends T, R>(predicate: (v: T) => v is U, fn: (v: U) => R): (v: T) => R | undefined;
declare const otherwise: <T, R>(fn: (v: T) => R) => (v: T) => R | undefined;
declare const alt: <T, U>(u: U | (() => U)) => (v: T | undefined) => T | U;
declare const orElse: <T, U>(u: U | (() => U)) => (v: T | null | undefined) => T | U;
export { alt, match, otherwise, when };
export { match, orElse, otherwise, when };

@@ -20,4 +20,4 @@ "use strict";

__export(logic_exports, {
alt: () => alt,
match: () => match,
orElse: () => orElse,
otherwise: () => otherwise,

@@ -30,3 +30,3 @@ when: () => when

let x = fn(v);
if (x !== void 0)
if (x != null)
return x;

@@ -41,9 +41,9 @@ }

}
var otherwise = (fn) => (v) => when(() => !0, fn)(v), alt = (u) => (v) => v === void 0 ? typeof u == "function" ? u() : u : v;
var otherwise = (fn) => (v) => when(() => !0, fn)(v), orElse = (u) => (v) => v ?? (typeof u == "function" ? u() : u);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
alt,
match,
orElse,
otherwise,
when
});

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

export { j as alt, d as flatMap, f as from, b as fromExecution, a as fromNullable, g as getOrElse, e as getOrThrow, i as isNone, c as isSome, m as map, h as match, n as none, s as some, t as tap } from './opt-e7bb6428.js';
export { d as flatMap, f as from, b as fromExecution, a as fromNullable, g as getOrElse, e as getOrThrow, i as isNone, c as isSome, m as map, h as match, n as none, j as orElse, s as some, t as tap } from './opt-0ed56d5d.js';

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

__export(opt_exports, {
alt: () => alt,
flatMap: () => flatMap,

@@ -33,2 +32,3 @@ from: () => from,

none: () => none,
orElse: () => orElse,
some: () => some,

@@ -48,3 +48,3 @@ tap: () => tap

return o.value;
}, match = (onSome, onNone) => (o) => isNone(o) ? onNone() : onSome(o.value), alt = (v) => (o) => {
}, match = (onSome, onNone) => (o) => isNone(o) ? onNone() : onSome(o.value), orElse = (v) => (o) => {
let vv = v();

@@ -55,3 +55,2 @@ return isOption(vv) ? isNone(o) ? vv : o : isNone(o) ? some(vv) : o;

0 && (module.exports = {
alt,
flatMap,

@@ -68,4 +67,5 @@ from,

none,
orElse,
some,
tap
});
{
"name": "lil-fp",
"version": "1.3.1",
"version": "1.4.0",
"description": "Functional programming utilities for TypeScript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -24,1 +24,22 @@ export function or<A, B extends A, C extends A>(

!predicate(arg)
export function and<A, B extends A, C extends A, D extends A, E extends A>(
a: (v: A) => v is B,
b: (v: A) => v is C,
c: (v: A) => v is D,
d: (v: A) => v is E
): (v: A) => v is B & C & D & E
export function and<A, B extends A, C extends A, D extends A>(
a: (v: A) => v is B,
b: (v: A) => v is C,
c: (v: A) => v is D
): (v: A) => v is B & C & D
export function and<A, B extends A, C extends A>(
a: (v: A) => v is B,
b: (v: A) => v is C
): (v: A) => v is B & C
export function and<T>(
...predicates: ((arg: T) => boolean)[]
): (arg: T) => boolean {
return (arg: T) => predicates.every((predicate) => predicate(arg))
}

@@ -5,3 +5,3 @@ export const match = <T, R>(...fns: ((v: T) => R)[]) => {

const x = fn(v)
if (x !== undefined) return x
if (x != null) return x
}

@@ -30,6 +30,6 @@ }

export const alt =
export const orElse =
<T, U>(u: U | (() => U)) =>
(v: T | undefined): T | U =>
(v: T | null | undefined): T | U =>
// @ts-ignore
v === undefined ? (typeof u === 'function' ? u() : u) : v
v == null ? (typeof u === 'function' ? u() : u) : v

@@ -54,3 +54,3 @@ type Option<T> = None | Some<T>

export const alt =
export const orElse =
<T>(v: () => Option<T> | T) =>

@@ -57,0 +57,0 @@ (o: Option<T>): Option<T> => {

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