@perfective/fp
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -0,4 +1,6 @@ | ||
import { Proposition } from './proposition'; | ||
export declare type Predicate<T> = (value: T) => boolean; | ||
export declare function is<T>(input: T): Predicate<T>; | ||
export declare function isNot<T>(input: T): Predicate<T>; | ||
export declare function negative(value: Proposition): boolean; | ||
export declare function not<T>(predicate: Predicate<T>): Predicate<T>; | ||
@@ -5,0 +7,0 @@ export declare function all<T>(...predicates: Predicate<T>[]): Predicate<T>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.exactly = exports.atMost = exports.atLeast = exports.neither = exports.either = exports.all = exports.not = exports.isNot = exports.is = void 0; | ||
exports.exactly = exports.atMost = exports.atLeast = exports.neither = exports.either = exports.all = exports.not = exports.negative = exports.isNot = exports.is = void 0; | ||
const nullary_1 = require("./nullary"); | ||
const proposition_1 = require("./proposition"); | ||
@@ -13,2 +14,6 @@ function is(input) { | ||
exports.isNot = isNot; | ||
function negative(value) { | ||
return !nullary_1.valueOf(value); | ||
} | ||
exports.negative = negative; | ||
function not(predicate) { | ||
@@ -15,0 +20,0 @@ return (value) => !predicate(value); |
@@ -5,4 +5,2 @@ import { Value } from './nullary'; | ||
export declare function isFalse(proposition: Proposition): boolean; | ||
export declare function always(): boolean; | ||
export declare function never(): boolean; | ||
//# sourceMappingURL=proposition.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.never = exports.always = exports.isFalse = exports.isTrue = void 0; | ||
exports.isFalse = exports.isTrue = void 0; | ||
const nullary_1 = require("./nullary"); | ||
@@ -13,10 +13,2 @@ function isTrue(proposition) { | ||
exports.isFalse = isFalse; | ||
function always() { | ||
return true; | ||
} | ||
exports.always = always; | ||
function never() { | ||
return false; | ||
} | ||
exports.never = never; | ||
//# sourceMappingURL=proposition.js.map |
export declare type Type<T> = new (...args: any[]) => T; | ||
export declare function isInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is T; | ||
export declare function isNotInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is T; | ||
export declare function isNotInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is V; | ||
//# sourceMappingURL=type.d.ts.map |
export { isFunction, isNotFunction, } from './function/function'; | ||
export { Nullary, Value, constant, empty, valueOf, } from './function/nullary'; | ||
export { Predicate, all, atLeast, atMost, either, exactly, is, isNot, neither, not, } from './function/predicate'; | ||
export { Proposition, always, isFalse, isTrue, never, } from './function/proposition'; | ||
export { Predicate, all, atLeast, atMost, either, exactly, is, isNot, negative, neither, not, } from './function/predicate'; | ||
export { Proposition, isFalse, isTrue, } from './function/proposition'; | ||
export { Type, isInstanceOf, isNotInstanceOf, } from './function/type'; | ||
@@ -6,0 +6,0 @@ export { TypeGuard, } from './function/type-guard'; |
@@ -18,9 +18,8 @@ "use strict"; | ||
Object.defineProperty(exports, "isNot", { enumerable: true, get: function () { return predicate_1.isNot; } }); | ||
Object.defineProperty(exports, "negative", { enumerable: true, get: function () { return predicate_1.negative; } }); | ||
Object.defineProperty(exports, "neither", { enumerable: true, get: function () { return predicate_1.neither; } }); | ||
Object.defineProperty(exports, "not", { enumerable: true, get: function () { return predicate_1.not; } }); | ||
var proposition_1 = require("./function/proposition"); | ||
Object.defineProperty(exports, "always", { enumerable: true, get: function () { return proposition_1.always; } }); | ||
Object.defineProperty(exports, "isFalse", { enumerable: true, get: function () { return proposition_1.isFalse; } }); | ||
Object.defineProperty(exports, "isTrue", { enumerable: true, get: function () { return proposition_1.isTrue; } }); | ||
Object.defineProperty(exports, "never", { enumerable: true, get: function () { return proposition_1.never; } }); | ||
var type_1 = require("./function/type"); | ||
@@ -27,0 +26,0 @@ Object.defineProperty(exports, "isInstanceOf", { enumerable: true, get: function () { return type_1.isInstanceOf; } }); |
@@ -0,4 +1,6 @@ | ||
import { Proposition } from './proposition'; | ||
export declare type Predicate<T> = (value: T) => boolean; | ||
export declare function is<T>(input: T): Predicate<T>; | ||
export declare function isNot<T>(input: T): Predicate<T>; | ||
export declare function negative(value: Proposition): boolean; | ||
export declare function not<T>(predicate: Predicate<T>): Predicate<T>; | ||
@@ -5,0 +7,0 @@ export declare function all<T>(...predicates: Predicate<T>[]): Predicate<T>; |
@@ -0,1 +1,2 @@ | ||
import { valueOf } from './nullary'; | ||
import { isFalse, isTrue } from './proposition'; | ||
@@ -8,2 +9,5 @@ export function is(input) { | ||
} | ||
export function negative(value) { | ||
return !valueOf(value); | ||
} | ||
export function not(predicate) { | ||
@@ -10,0 +14,0 @@ return (value) => !predicate(value); |
@@ -5,4 +5,2 @@ import { Value } from './nullary'; | ||
export declare function isFalse(proposition: Proposition): boolean; | ||
export declare function always(): boolean; | ||
export declare function never(): boolean; | ||
//# sourceMappingURL=proposition.d.ts.map |
@@ -8,8 +8,2 @@ import { valueOf } from './nullary'; | ||
} | ||
export function always() { | ||
return true; | ||
} | ||
export function never() { | ||
return false; | ||
} | ||
//# sourceMappingURL=proposition.js.map |
export declare type Type<T> = new (...args: any[]) => T; | ||
export declare function isInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is T; | ||
export declare function isNotInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is T; | ||
export declare function isNotInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is V; | ||
//# sourceMappingURL=type.d.ts.map |
export { isFunction, isNotFunction, } from './function/function'; | ||
export { Nullary, Value, constant, empty, valueOf, } from './function/nullary'; | ||
export { Predicate, all, atLeast, atMost, either, exactly, is, isNot, neither, not, } from './function/predicate'; | ||
export { Proposition, always, isFalse, isTrue, never, } from './function/proposition'; | ||
export { Predicate, all, atLeast, atMost, either, exactly, is, isNot, negative, neither, not, } from './function/predicate'; | ||
export { Proposition, isFalse, isTrue, } from './function/proposition'; | ||
export { Type, isInstanceOf, isNotInstanceOf, } from './function/type'; | ||
@@ -6,0 +6,0 @@ export { TypeGuard, } from './function/type-guard'; |
export { isFunction, isNotFunction, } from './function/function'; | ||
export { constant, empty, valueOf, } from './function/nullary'; | ||
export { all, atLeast, atMost, either, exactly, is, isNot, neither, not, } from './function/predicate'; | ||
export { always, isFalse, isTrue, never, } from './function/proposition'; | ||
export { all, atLeast, atMost, either, exactly, is, isNot, negative, neither, not, } from './function/predicate'; | ||
export { isFalse, isTrue, } from './function/proposition'; | ||
export { isInstanceOf, isNotInstanceOf, } from './function/type'; | ||
export { same, } from './function/unary'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@perfective/fp", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Functions and types for functional programming", | ||
@@ -26,4 +26,4 @@ "keywords": [ | ||
"exports": { | ||
"import": "dist/mjs/index.js", | ||
"require": "dist/cjs/index.js" | ||
"import": "./dist/mjs/index.js", | ||
"require": "./dist/cjs/index.js" | ||
}, | ||
@@ -30,0 +30,0 @@ "files": [ |
@@ -19,5 +19,5 @@ # Perfective Functional Programming | ||
* `Type<T> = new(...args: any[]) => T` | ||
— definition for a type reference: | ||
— definition for a type reference: | ||
* `isInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is T` | ||
* `isNotInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is T` | ||
* `isNotInstanceOf<T, V = unknown>(type: Type<T>): (value: T | V) => value is V` | ||
@@ -29,7 +29,7 @@ ## Nullary functions | ||
* `constant<T>(value: T): Nullary<T>` | ||
— creates a function that returns that same value. | ||
— creates a function that returns that same value. | ||
* `empty(): Nullary<void>` | ||
— creates a function that always returns `void` (`undefined`). | ||
* `Value<T> = T | Nullary<T>` | ||
— represent a value, or a function that returns a value | ||
— represent a value, or a function that returns a value | ||
(e.g. for lazy evaluation). | ||
@@ -42,5 +42,5 @@ * `valueOf<T>(value: Value<T>): T` | ||
* `Unary<X, V>` | ||
— a function with one argument: | ||
— a function with one argument: | ||
* `value<T>(): Unary<T, T>` | ||
— creates a function that returns its argument. | ||
— creates a function that returns its argument. | ||
@@ -55,3 +55,3 @@ ## Binary functions | ||
* `Ternary<X, Y, Z, V>` | ||
— a function with three arguments (`X`, `Y`, and `Z`). | ||
— a function with three arguments (`X`, `Y`, and `Z`). | ||
@@ -63,6 +63,2 @@ ## Logic types and functions | ||
* `isFalse(proposition: Proposition): boolean` | ||
* `always(): boolean` | ||
— a function that returns `true`. | ||
* `never(): boolean` | ||
— a function that returns `false. | ||
* `Predicate<T> = (value: T) => boolean` | ||
@@ -74,15 +70,17 @@ — a predicate on type T: | ||
— creates a predicate that is `true` when its argument is not the same as the `input`. | ||
* `negative(value: Proposition): boolean` | ||
— negates the given proposition value. | ||
* `not<T>(predicate: Predicate<T>): Predicate<T>` | ||
— creates a predicate that negates the given predicate. | ||
* `all<T>(...predicates: Predicate<T>[]): Predicate<T>` | ||
— creates a predicate that is `true` when all predicates are `true` (logical `AND`). | ||
— creates a predicate that is `true` when all predicates are `true` (logical `AND`). | ||
* `either<T>(...predicates: Predicate<T>[]): Predicate<T>` | ||
— creates a predicate that is `true` when at least one predicate is `true` (logical `OR`). | ||
— creates a predicate that is `true` when at least one predicate is `true` (logical `OR`). | ||
* `neither<T>(...predicates: Predicate<T>[]): Predicate<T>` | ||
— creates a predicate that is `true` when none of the predicates is `true`. | ||
— creates a predicate that is `true` when none of the predicates is `true`. | ||
* `atLeast<T>(minimum: number, ...predicates: Predicate<T>[]): Predicate<T>` | ||
— creates a predicate that is `true` when at least the `minimum` number of predicates are `true`. | ||
— creates a predicate that is `true` when at least the `minimum` number of predicates are `true`. | ||
* `atMost<T>(maximum: number, ...predicates: Predicate<T>[]): Predicate<T>` | ||
— creates a predicate that is `true` when at most the `maximum` number of predicates are `true`. | ||
— creates a predicate that is `true` when at most the `maximum` number of predicates are `true`. | ||
* `exactly<T>(count: number, ...predicates: Predicate<T>[]): Predicate<T>` | ||
— creates a predicate that is `true` when exact `count` of predicates are `true`. | ||
— creates a predicate that is `true` when exact `count` of predicates are `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
44991
292
81