Comparing version 2.0.3 to 2.1.0
@@ -24,7 +24,7 @@ import { Either } from './Either.js'; | ||
/** Creates a codec for any type, you can add your own deserialization/validation logic in the decode argument */ | ||
custom<T_1>({ decode, encode, schema }: { | ||
decode: (value: unknown) => Either<string, T_1>; | ||
encode: (value: T_1) => any; | ||
schema?: (() => object) | undefined; | ||
}): Codec<T_1>; | ||
custom<T>({ decode, encode, schema }: { | ||
decode: (value: unknown) => Either<string, T>; | ||
encode: (value: T) => any; | ||
schema?: () => object; | ||
}): Codec<T>; | ||
}; | ||
@@ -47,7 +47,7 @@ /** A codec for any string value. Most of the time you will use it to implement an interface codec (see the Codec#interface example above). Encoding a string acts like the identity function */ | ||
/** A codec combinator that receives a list of codecs and runs them one after another during decode and resolves to whichever returns Right or to Left if all fail */ | ||
export declare const oneOf: <T extends [Codec<any>, ...Codec<any>[]]>(codecs: T) => Codec<GetType<T extends (infer U)[] ? U : never>>; | ||
export declare const oneOf: <T extends [Codec<any>, ...Codec<any>[]]>(codecs: T) => Codec<GetType<T extends Array<infer U> ? U : never>>; | ||
/** A codec for an array */ | ||
export declare const array: <T>(codec: Codec<T>) => Codec<T[]>; | ||
export declare const array: <T>(codec: Codec<T>) => Codec<Array<T>>; | ||
/** A codec for an object without specific properties, its restrictions are equivalent to the Record<K, V> type so you can only check for number and string keys */ | ||
export declare const record: <K extends string | number | symbol, V>(keyCodec: Codec<K>, valueCodec: Codec<V>) => Codec<Record<K, V>>; | ||
export declare const record: <K extends keyof any, V>(keyCodec: Codec<K>, valueCodec: Codec<V>) => Codec<Record<K, V>>; | ||
/** A codec that only succeeds decoding when the value is exactly what you've constructed the codec with */ | ||
@@ -54,0 +54,0 @@ export declare const exactly: <T extends (string | number | boolean)[]>(...expectedValues: T) => Codec<T[number]>; |
import { Either, EitherPatterns } from './Either.js'; | ||
import { MaybeAsync } from './MaybeAsync.js'; | ||
/** You can use this to extract the type of the `Right` value out of an `EitherAsync`. */ | ||
export type ExtractRight<T> = T extends PromiseLike<Either<any, infer R>> ? R : never; | ||
/** You can use this to extract the type of the `Left` value out of an `EitherAsync`. */ | ||
export type ExtractLeft<T> = T extends PromiseLike<Either<infer L, any>> ? L : never; | ||
export interface EitherAsyncTypeRef { | ||
@@ -4,0 +8,0 @@ /** Constructs an `EitherAsync` object from a function that takes an object full of helpers that let you lift things into the `EitherAsync` context and returns a Promise */ |
@@ -151,3 +151,3 @@ "use strict"; | ||
toMaybeAsync() { | ||
return (0, MaybeAsync_js_1.MaybeAsync)(({ liftMaybe }) => __awaiter(this, void 0, void 0, function* () { | ||
return (0, MaybeAsync_js_1.MaybeAsync)((_b) => __awaiter(this, [_b], void 0, function* ({ liftMaybe }) { | ||
const either = yield this.run(); | ||
@@ -154,0 +154,0 @@ return liftMaybe(either.toMaybe()); |
@@ -24,7 +24,7 @@ import { Either } from './Either.js'; | ||
/** Creates a codec for any type, you can add your own deserialization/validation logic in the decode argument */ | ||
custom<T_1>({ decode, encode, schema }: { | ||
decode: (value: unknown) => Either<string, T_1>; | ||
encode: (value: T_1) => any; | ||
schema?: (() => object) | undefined; | ||
}): Codec<T_1>; | ||
custom<T>({ decode, encode, schema }: { | ||
decode: (value: unknown) => Either<string, T>; | ||
encode: (value: T) => any; | ||
schema?: () => object; | ||
}): Codec<T>; | ||
}; | ||
@@ -47,7 +47,7 @@ /** A codec for any string value. Most of the time you will use it to implement an interface codec (see the Codec#interface example above). Encoding a string acts like the identity function */ | ||
/** A codec combinator that receives a list of codecs and runs them one after another during decode and resolves to whichever returns Right or to Left if all fail */ | ||
export declare const oneOf: <T extends [Codec<any>, ...Codec<any>[]]>(codecs: T) => Codec<GetType<T extends (infer U)[] ? U : never>>; | ||
export declare const oneOf: <T extends [Codec<any>, ...Codec<any>[]]>(codecs: T) => Codec<GetType<T extends Array<infer U> ? U : never>>; | ||
/** A codec for an array */ | ||
export declare const array: <T>(codec: Codec<T>) => Codec<T[]>; | ||
export declare const array: <T>(codec: Codec<T>) => Codec<Array<T>>; | ||
/** A codec for an object without specific properties, its restrictions are equivalent to the Record<K, V> type so you can only check for number and string keys */ | ||
export declare const record: <K extends string | number | symbol, V>(keyCodec: Codec<K>, valueCodec: Codec<V>) => Codec<Record<K, V>>; | ||
export declare const record: <K extends keyof any, V>(keyCodec: Codec<K>, valueCodec: Codec<V>) => Codec<Record<K, V>>; | ||
/** A codec that only succeeds decoding when the value is exactly what you've constructed the codec with */ | ||
@@ -54,0 +54,0 @@ export declare const exactly: <T extends (string | number | boolean)[]>(...expectedValues: T) => Codec<T[number]>; |
import { Either, EitherPatterns } from './Either.js'; | ||
import { MaybeAsync } from './MaybeAsync.js'; | ||
/** You can use this to extract the type of the `Right` value out of an `EitherAsync`. */ | ||
export type ExtractRight<T> = T extends PromiseLike<Either<any, infer R>> ? R : never; | ||
/** You can use this to extract the type of the `Left` value out of an `EitherAsync`. */ | ||
export type ExtractLeft<T> = T extends PromiseLike<Either<infer L, any>> ? L : never; | ||
export interface EitherAsyncTypeRef { | ||
@@ -4,0 +8,0 @@ /** Constructs an `EitherAsync` object from a function that takes an object full of helpers that let you lift things into the `EitherAsync` context and returns a Promise */ |
/** The identity function, returns the value it was given */ | ||
export declare const identity: <T>(x: T) => T; | ||
/** Returns a function that always returns the same value. Also known as `const` in other languages */ | ||
export declare const always: <T>(x: T) => <U>(y: U) => T; | ||
export declare const enum Order { | ||
LT = "LT", | ||
EQ = "EQ", | ||
GT = "GT" | ||
} | ||
export declare const always: <T>(x: T) => (<U>(y: U) => T); | ||
export declare const Order: { | ||
readonly LT: "LT"; | ||
readonly EQ: "EQ"; | ||
readonly GT: "GT"; | ||
}; | ||
export type Order = 'LT' | 'EQ' | 'GT'; | ||
/** Compares two values using the default "<" and ">" operators */ | ||
@@ -11,0 +12,0 @@ export declare const compare: <T>(x: T, y: T) => Order; |
@@ -5,8 +5,7 @@ /** The identity function, returns the value it was given */ | ||
export const always = (x) => () => x; | ||
export var Order; | ||
(function (Order) { | ||
Order["LT"] = "LT"; | ||
Order["EQ"] = "EQ"; | ||
Order["GT"] = "GT"; | ||
})(Order || (Order = {})); | ||
export const Order = { | ||
LT: 'LT', | ||
EQ: 'EQ', | ||
GT: 'GT' | ||
}; | ||
/** Compares two values using the default "<" and ">" operators */ | ||
@@ -13,0 +12,0 @@ export const compare = (x, y) => { |
@@ -18,7 +18,7 @@ import { Tuple } from './Tuple.js'; | ||
init: <T>(list: readonly T[]) => Maybe<T[]>; | ||
uncons: <T_1>(list: readonly T_1[]) => Maybe<Tuple<T_1, T_1[]>>; | ||
uncons: <T>(list: readonly T[]) => Maybe<Tuple<T, T[]>>; | ||
at: typeof at; | ||
head: <T_2>(list: readonly T_2[]) => Maybe<T_2>; | ||
last: <T_3>(list: readonly T_3[]) => Maybe<T_3>; | ||
tail: <T_4>(list: readonly T_4[]) => Maybe<T_4[]>; | ||
head: <T>(list: readonly T[]) => Maybe<T>; | ||
last: <T>(list: readonly T[]) => Maybe<T>; | ||
tail: <T>(list: readonly T[]) => Maybe<T[]>; | ||
find: typeof find; | ||
@@ -25,0 +25,0 @@ findIndex: typeof findIndex; |
@@ -107,4 +107,4 @@ import { Either } from './Either.js'; | ||
private __value; | ||
isJust(): boolean; | ||
isNothing(): boolean; | ||
isJust(): this is AlwaysJust; | ||
isNothing(): this is Nothing; | ||
inspect(): string; | ||
@@ -111,0 +111,0 @@ toString(): string; |
import { Maybe, MaybePatterns } from './Maybe.js'; | ||
import { EitherAsync } from './EitherAsync.js'; | ||
/** You can use this to extract the type of the `Just` value out of an `MaybeAsync`. */ | ||
export type ExtractJust<T> = T extends PromiseLike<Maybe<infer U>> ? U : never; | ||
export interface MaybeAsyncTypeRef { | ||
@@ -4,0 +6,0 @@ /** Constructs a MaybeAsync object from a function that takes an object full of helpers that let you lift things into the MaybeAsync context and returns a Promise */ |
/** The identity function, returns the value it was given */ | ||
export declare const identity: <T>(x: T) => T; | ||
/** Returns a function that always returns the same value. Also known as `const` in other languages */ | ||
export declare const always: <T>(x: T) => <U>(y: U) => T; | ||
export declare const enum Order { | ||
LT = "LT", | ||
EQ = "EQ", | ||
GT = "GT" | ||
} | ||
export declare const always: <T>(x: T) => (<U>(y: U) => T); | ||
export declare const Order: { | ||
readonly LT: "LT"; | ||
readonly EQ: "EQ"; | ||
readonly GT: "GT"; | ||
}; | ||
export type Order = 'LT' | 'EQ' | 'GT'; | ||
/** Compares two values using the default "<" and ">" operators */ | ||
@@ -11,0 +12,0 @@ export declare const compare: <T>(x: T, y: T) => Order; |
@@ -10,18 +10,17 @@ "use strict"; | ||
exports.always = always; | ||
var Order; | ||
(function (Order) { | ||
Order["LT"] = "LT"; | ||
Order["EQ"] = "EQ"; | ||
Order["GT"] = "GT"; | ||
})(Order || (exports.Order = Order = {})); | ||
exports.Order = { | ||
LT: 'LT', | ||
EQ: 'EQ', | ||
GT: 'GT' | ||
}; | ||
/** Compares two values using the default "<" and ">" operators */ | ||
const compare = (x, y) => { | ||
if (x > y) { | ||
return Order.GT; | ||
return exports.Order.GT; | ||
} | ||
else if (x < y) { | ||
return Order.LT; | ||
return exports.Order.LT; | ||
} | ||
else { | ||
return Order.EQ; | ||
return exports.Order.EQ; | ||
} | ||
@@ -33,7 +32,7 @@ }; | ||
switch (order) { | ||
case Order.LT: | ||
case exports.Order.LT: | ||
return -1; | ||
case Order.EQ: | ||
case exports.Order.EQ: | ||
return 0; | ||
case Order.GT: | ||
case exports.Order.GT: | ||
return 1; | ||
@@ -40,0 +39,0 @@ } |
@@ -18,7 +18,7 @@ import { Tuple } from './Tuple.js'; | ||
init: <T>(list: readonly T[]) => Maybe<T[]>; | ||
uncons: <T_1>(list: readonly T_1[]) => Maybe<Tuple<T_1, T_1[]>>; | ||
uncons: <T>(list: readonly T[]) => Maybe<Tuple<T, T[]>>; | ||
at: typeof at; | ||
head: <T_2>(list: readonly T_2[]) => Maybe<T_2>; | ||
last: <T_3>(list: readonly T_3[]) => Maybe<T_3>; | ||
tail: <T_4>(list: readonly T_4[]) => Maybe<T_4[]>; | ||
head: <T>(list: readonly T[]) => Maybe<T>; | ||
last: <T>(list: readonly T[]) => Maybe<T>; | ||
tail: <T>(list: readonly T[]) => Maybe<T[]>; | ||
find: typeof find; | ||
@@ -25,0 +25,0 @@ findIndex: typeof findIndex; |
@@ -107,4 +107,4 @@ import { Either } from './Either.js'; | ||
private __value; | ||
isJust(): boolean; | ||
isNothing(): boolean; | ||
isJust(): this is AlwaysJust; | ||
isNothing(): this is Nothing; | ||
inspect(): string; | ||
@@ -111,0 +111,0 @@ toString(): string; |
import { Maybe, MaybePatterns } from './Maybe.js'; | ||
import { EitherAsync } from './EitherAsync.js'; | ||
/** You can use this to extract the type of the `Just` value out of an `MaybeAsync`. */ | ||
export type ExtractJust<T> = T extends PromiseLike<Maybe<infer U>> ? U : never; | ||
export interface MaybeAsyncTypeRef { | ||
@@ -4,0 +6,0 @@ /** Constructs a MaybeAsync object from a function that takes an object full of helpers that let you lift things into the MaybeAsync context and returns a Promise */ |
@@ -111,3 +111,3 @@ "use strict"; | ||
toEitherAsync(error) { | ||
return (0, EitherAsync_js_1.EitherAsync)(({ liftEither }) => __awaiter(this, void 0, void 0, function* () { | ||
return (0, EitherAsync_js_1.EitherAsync)((_b) => __awaiter(this, [_b], void 0, function* ({ liftEither }) { | ||
const maybe = yield this.run(); | ||
@@ -114,0 +114,0 @@ return liftEither(maybe.toEither(error)); |
{ | ||
"name": "purify-ts", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "Functional programming standard library for TypeScript ", | ||
@@ -41,9 +41,9 @@ "repository": "https://github.com/gigobyte/purify.git", | ||
"devDependencies": { | ||
"@vitest/coverage-v8": "1.1.1", | ||
"ajv": "8.12.0", | ||
"ajv-formats": "2.1.1", | ||
"@vitest/coverage-v8": "1.6.0", | ||
"ajv": "8.16.0", | ||
"ajv-formats": "3.0.1", | ||
"coveralls": "3.1.1", | ||
"prettier": "3.1.1", | ||
"typescript": "5.3.3", | ||
"vitest": "1.1.1" | ||
"prettier": "3.3.2", | ||
"typescript": "5.5.2", | ||
"vitest": "1.6.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "dependencies": { |
@@ -5,10 +5,2 @@ <h3 align="center"> | ||
<p align="center"> | ||
<a href="https://travis-ci.org/gigobyte/purify"> | ||
<img src="https://travis-ci.org/gigobyte/purify.svg?branch=master" alt="Build Status"> | ||
<img src="https://coveralls.io/repos/github/gigobyte/purify/badge.svg?branch=master" alt="Coverage Status" /> | ||
<img src="https://camo.githubusercontent.com/41c68e9f29c6caccc084e5a147e0abd5f392d9bc/68747470733a2f2f62616467656e2e6e65742f62616467652f547970655363726970742f7374726963742532302546302539462539322541412f626c7565" alt="Built with Typescript"> | ||
</a> | ||
</p> | ||
# What is purify? | ||
@@ -15,0 +7,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
197751
4566
48