New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hkt-toolbelt

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hkt-toolbelt - npm Package Compare versions

Comparing version

to
0.3.0

11

changelog.md
# Changelog
## 0.3.0
- Added `String.Append` and `String.Prepend` types.
- Improved `Test.Expect` behavior and error messages.
## 0.2.1
- Renamed `Kind.Input` to `Kind.InputOf` and `Kind.Output` to `Kind.OutputOf`.
## 0.2.0

@@ -9,3 +18,3 @@

- First experimental release
- First experimental release.
- Introduced `Boolean`, `Cast`, `Conditional`, `Function`, `Kind`, `List`, `String`, and `Test` core components.

2

package.json
{
"name": "hkt-toolbelt",
"version": "0.2.0",
"version": "0.3.0",
"description": "A collection of useful HKT utilities and building blocks",

@@ -5,0 +5,0 @@ "main": "./src/index.ts",

import { Kind } from "hkt-toolbelt";
export type $<F extends Kind, X extends Kind.Input<F>> = ReturnType<
export type $<F extends Kind, X extends Kind.InputOf<F>> = ReturnType<
(F & {

@@ -5,0 +5,0 @@ readonly [Kind._]: X;

@@ -14,9 +14,9 @@ import $, { Cast, Function, List } from "hkt-toolbelt";

Cast<Init, Kind[]>,
$<Cast<Last, Kind>, Cast<X, Input<Cast<Last, Kind>>>>
$<Cast<Last, Kind>, Cast<X, InputOf<Cast<Last, Kind>>>>
>
: X;
type _$composablePair<F extends [Kind, Kind]> = Kind.Output<
type _$composablePair<F extends [Kind, Kind]> = Kind.OutputOf<
F[1]
> extends Kind.Input<F[0]>
> extends Kind.InputOf<F[0]>
? true

@@ -44,3 +44,3 @@ : false;

abstract f: (
x: Cast<this[Kind._], FX extends [] ? unknown : Input<List._$last<FX>>>
x: Cast<this[Kind._], FX extends [] ? unknown : InputOf<List._$last<FX>>>
) => _$compose<FX, typeof x>;

@@ -52,6 +52,6 @@ }

x: Cast<this[Kind._], Kind<(x: X) => unknown>>
) => $<typeof x, Cast<X, Input<typeof x>>>;
) => $<typeof x, Cast<X, InputOf<typeof x>>>;
}
export type Input<F extends Kind> = F extends {
export type InputOf<F extends Kind> = F extends {
f: (x: infer X) => unknown;

@@ -62,3 +62,3 @@ }

export type Output<F extends Kind> = F extends {
export type OutputOf<F extends Kind> = F extends {
f: (x: never) => infer X;

@@ -65,0 +65,0 @@ }

@@ -5,3 +5,3 @@ import $, { Boolean, Kind, Cast } from "hkt-toolbelt";

export type _$map<F extends Kind, X extends unknown[]> = {
[key in keyof X]: $<F, Cast<X[key], Kind.Input<F>>>;
[key in keyof X]: $<F, Cast<X[key], Kind.InputOf<F>>>;
};

@@ -17,3 +17,3 @@

]
? $<F, Cast<Head, Kind.Input<F>>> extends true
? $<F, Cast<Head, Kind.InputOf<F>>> extends true
? Head

@@ -33,3 +33,3 @@ : _$find<F, Tail>

]
? $<F, Cast<Head, Kind.Input<F>>> extends true
? $<F, Cast<Head, Kind.InputOf<F>>> extends true
? [Head, ..._$filter<F, Tail>]

@@ -49,3 +49,3 @@ : _$filter<F, Tail>

]
? $<F, Cast<Head, Kind.Input<F>>> extends true
? $<F, Cast<Head, Kind.InputOf<F>>> extends true
? true

@@ -103,3 +103,3 @@ : _$includes<F, Tail>

> = T extends [infer Head, ...infer Rest]
? Boolean._$and<$<F, Cast<Head, Kind.Input<F>>>, _$every<F, Rest>>
? Boolean._$and<$<F, Cast<Head, Kind.InputOf<F>>>, _$every<F, Rest>>
: true;

@@ -111,3 +111,3 @@

abstract f: (
x: Cast<this[Kind._], Kind.Input<F>[]>
x: Cast<this[Kind._], Kind.InputOf<F>[]>
) => _$every<F, typeof x>;

@@ -114,0 +114,0 @@ }

@@ -32,4 +32,22 @@ import { Cast, Kind } from "hkt-toolbelt";

}
export type _$append<
Suffix extends string,
S extends string
> = `${S}${Suffix}`;
export abstract class Append<Suffix extends string> extends Kind {
abstract f: (x: Cast<this[Kind._], string>) => _$append<Suffix, typeof x>;
}
export type _$prepend<
Prefix extends string,
S extends string
> = `${Prefix}${S}`;
export abstract class Prepend<Prefix extends string> extends Kind {
abstract f: (x: Cast<this[Kind._], string>) => _$prepend<Prefix, typeof x>;
}
}
export default String;

@@ -5,10 +5,22 @@ import { Conditional } from "hkt-toolbelt";

declare abstract class TypeError<_S extends string> {
static readonly _: unique symbol;
}
export declare namespace Test {
export type Expect<X extends true> = IsNever<X> extends true ? Expect<X> : X;
export type Expect<
X extends Conditional._$equals<X, V> extends true
? V
: V & [_: TypeError<"NotEqual">],
V = true
> = IsNever<X> extends true ? Expect<X, V> : X;
export type ExpectNot<X extends false> = IsNever<X> extends true
? ExpectNot<X>
: X;
export type ExpectNot<
X extends Conditional._$equals<X, V> extends true
? V
: V & [_: TypeError<"Equal">],
V = false
> = IsNever<X> extends true ? Expect<X, V> : X;
}
export default Test;