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

hotscript

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotscript - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

dist/index.js

3

dist/index.d.ts

@@ -9,2 +9,3 @@ import { Apply, Call, Call2, Eval, Fn, Pipe, PipeRight } from "./internals/core/Core";

import { Booleans } from "./internals/booleans/Booleans";
export { Fn, Pipe, PipeRight, Call, Call2, Apply, Eval, Booleans, Objects, Unions, Strings, Numbers, Tuples, Functions, Booleans as B, Objects as O, Unions as U, Strings as S, Numbers as N, Tuples as T, Functions as F, };
import { Args } from "./internals/args/Args";
export { Fn, Pipe, PipeRight, Call, Call2, Apply, Eval, Booleans, Objects, Unions, Strings, Numbers, Tuples, Functions, Args, Booleans as B, Objects as O, Unions as U, Strings as S, Numbers as N, Tuples as T, Functions as F, };

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

import { Equal, Every, Some } from "../../helpers";
import { Fn, MergeArgs, placeholder } from "../core/Core";
import { Equal, Every, Some } from "../helpers";
import { Fn, MergeArgs } from "../core/Core";
import { Functions } from "../functions/Functions";
export declare namespace Booleans {
type ExtendsImpl<a, b> = a extends b ? true : false;
export interface Extends<a = placeholder, b = placeholder> extends Fn {
type ExtendsImpl<a, b> = [a] extends [b] ? true : false;
export interface Extends<a = never, b = never> extends Fn {
output: MergeArgs<this["args"], [a, b]> extends [

@@ -14,7 +14,7 @@ infer first,

type NotImpl<a> = a extends true ? false : true;
export interface Not<a = placeholder> extends Fn {
export interface Not<a = never> extends Fn {
output: MergeArgs<this["args"], [a]> extends [infer first, ...any] ? NotImpl<first> : never;
}
type EqualsImpl<a, b> = Equal<a, b>;
export interface Equals<a = placeholder, b = placeholder> extends Fn {
export interface Equals<a = never, b = never> extends Fn {
output: MergeArgs<this["args"], [a, b]> extends [

@@ -27,3 +27,3 @@ infer first,

export type DoesNotExtends<T> = Functions.Compose<[Not, Extends<T>]>;
export interface And<a = placeholder, b = placeholder> extends Fn {
export interface And<a = never, b = never> extends Fn {
output: MergeArgs<this["args"], [a, b]> extends [

@@ -35,3 +35,3 @@ infer first extends boolean,

}
export interface Or<a = placeholder, b = placeholder> extends Fn {
export interface Or<a = never, b = never> extends Fn {
output: MergeArgs<this["args"], [a, b]> extends [

@@ -38,0 +38,0 @@ infer first extends boolean,

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

import { RemoveUnknownArrayConstraint } from "../../helpers";
import { RemoveUnknownArrayConstraint } from "../helpers";
import { Booleans } from "../booleans/Booleans";

@@ -8,3 +8,3 @@ import { Tuples } from "../tuples/Tuples";

}
export type Apply<fn extends Fn, args> = (fn & {
export type Apply<fn extends Fn, args extends unknown[]> = (fn & {
args: args;

@@ -43,3 +43,19 @@ })["output"];

] : MergeArgsRec<inputArgs, partialRest, [...output, partialFirst]> : [...output, ...inputArgs];
export type MergeArgs<inputArgs extends any[], partialArgs extends any[]> = MergeArgsRec<RemoveUnknownArrayConstraint<inputArgs>, partialArgs>;
interface NeverIntoPlaceholder extends Fn {
output: this["args"] extends [infer value, ...any] ? [value] extends [never] ? placeholder : value : never;
}
/**
* Special case if the arity of the function is 2, we want the first
* partial argument to be position as the second one so that expressions
* like:
* - Call<Booleans.Extends<string>, 2>
* - Call<Number.GreaterThan<5>, 10>
* - etc
* return `true` instead of false.
*/
type UpdatePartialArgs<partialArgs extends any[]> = partialArgs extends [
infer a,
never
] ? [placeholder, Call<NeverIntoPlaceholder, a>] : Call<Tuples.Map<NeverIntoPlaceholder>, partialArgs>;
export type MergeArgs<inputArgs extends any[], partialArgs extends any[]> = MergeArgsRec<RemoveUnknownArrayConstraint<inputArgs>, UpdatePartialArgs<partialArgs>>;
export {};

@@ -1,4 +0,3 @@

import { Apply, Fn, MergeArgs, placeholder } from "../core/Core";
import { Apply, Fn, MergeArgs } from "../core/Core";
export declare namespace Functions {
export type _ = placeholder;
export interface Identity extends Fn {

@@ -23,3 +22,3 @@ output: this["args"][0];

type Head<xs> = xs extends [infer first, ...any] ? first : never;
type ComposeImpl<fns extends Fn[], args> = fns extends [
type ComposeImpl<fns extends Fn[], args extends any[]> = fns extends [
...infer rest extends Fn[],

@@ -31,3 +30,3 @@ infer last extends Fn

}
type ComposeLeftImpl<fns extends Fn[], args> = fns extends [
type ComposeLeftImpl<fns extends Fn[], args extends any[]> = fns extends [
infer first extends Fn,

@@ -34,0 +33,0 @@ ...infer rest extends Fn[]

import { Fn, MergeArgs, placeholder } from "../core/Core";
import { Tuples } from "../tuples/Tuples";
import * as Impl from "./impl/numbers";
export declare namespace Numbers {
type Add2Impl<a, b> = [...Tuples.Range<a>, ...Tuples.Range<b>]["length"];
export interface Add<n1 extends number | placeholder = placeholder, n2 extends number | placeholder = placeholder> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [infer a, infer b, ...any] ? Add2Impl<a, b> : never;
interface Add<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.Add<a, b> : never;
}
export {};
interface Sub<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.Sub<a, b> : never;
}
interface Mul<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.Mul<a, b> : never;
}
interface Div<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.Div<a, b> : never;
}
interface Mod<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.Mod<a, b> : never;
}
interface Negate<n extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n]> extends [
infer a extends number | bigint,
...any
] ? Impl.Negate<a> : never;
}
interface Abs<n extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n]> extends [
infer a extends number | bigint,
...any
] ? Impl.Abs<a> : never;
}
interface Power<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.Power<a, b> : never;
}
interface Compare<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.Compare<a, b> : never;
}
interface Equal<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.Equal<a, b> : never;
}
interface NotEqual<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.NotEqual<a, b> : never;
}
interface LessThan<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.LessThan<a, b> : never;
}
interface LessThanOrEqual<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.LessThanOrEqual<a, b> : never;
}
interface GreaterThan<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.GreaterThan<a, b> : never;
}
interface GreaterThanOrEqual<n1 extends number | bigint | placeholder = never, n2 extends number | bigint | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends number | bigint,
infer b extends number | bigint,
...any
] ? Impl.GreaterThanOrEqual<a, b> : never;
}
}

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

import { IsArrayStrict, Prettify, UnionToIntersection } from "../../helpers";
import { GetFromPath, IsArrayStrict, Prettify, UnionToIntersection } from "../helpers";
import { Call, Call2, Fn, MergeArgs, placeholder } from "../core/Core";

@@ -30,9 +30,9 @@ import { Std } from "../std/Std";

}
export interface KebabizeKeys extends Fn {
export interface KebabCase extends Fn {
output: Call<MapKeys<Strings.KebabCase>, this["args"][0]>;
}
export interface SnakizeKeys extends Fn {
export interface SnakeCase extends Fn {
output: Call<MapKeys<Strings.SnakeCase>, this["args"][0]>;
}
export interface CamelizeKeys extends Fn {
export interface CamelCase extends Fn {
output: Call<MapKeys<Strings.CamelCase>, this["args"][0]>;

@@ -46,9 +46,9 @@ }

}
export interface KebabizeKeysDeep extends Fn {
export interface KebabCaseDeep extends Fn {
output: Call<MapKeysDeep<Strings.KebabCase>, this["args"][0]>;
}
export interface SnakizeKeysDeep extends Fn {
export interface SnakeCaseDeep extends Fn {
output: Call<MapKeysDeep<Strings.SnakeCase>, this["args"][0]>;
}
export interface CamelizeKeysDeep extends Fn {
export interface CamelCaseDeep extends Fn {
output: Call<MapKeysDeep<Strings.CamelCase>, this["args"][0]>;

@@ -79,3 +79,3 @@ }

type AssignImpl<xs extends readonly any[]> = Prettify<UnionToIntersection<xs[number]>>;
export interface Assign<arg1 = placeholder, arg2 = placeholder, arg3 = placeholder> extends Fn {
export interface Assign<arg1 = never, arg2 = never, arg3 = never> extends Fn {
output: AssignImpl<MergeArgs<this["args"], [arg1, arg2, arg3]>>;

@@ -96,3 +96,10 @@ }

}
export interface Get<_path extends string | placeholder = never, _obj = never> extends Fn {
output: MergeArgs<this["args"], [_obj, _path]> extends [
infer obj,
infer path extends string,
...any
] ? GetFromPath<obj, path> : never;
}
export {};
}

@@ -0,0 +0,0 @@ export declare namespace Std {

@@ -1,5 +0,6 @@

import { Fn } from "../core/Core";
import { Fn, MergeArgs, Pipe, placeholder } from "../core/Core";
import { Std } from "../std/Std";
import { Tuples } from "../tuples/Tuples";
import * as H from "../../helpers";
import * as H from "../helpers";
import * as Impl from "./impl/strings";
export declare namespace Strings {

@@ -13,42 +14,446 @@ export type Stringifiable = string | number | boolean | bigint | null | undefined;

}
/**
* Get the length of a string.
* @param args[0] - The string to get the length of.
* @returns The length of the string.
* @example
* ```ts
* type T0 = Call<Strings.Length,"abc">; // 3
* ```
*/
export interface Length extends Fn {
output: Impl.StringToTuple<this["args"][0]>["length"];
}
/**
* Trim the left side of a string.
* @param args[0] - The string to trim.
* @param Sep - The separator to trim.
* @returns The trimmed string.
* @example
* ```ts
* type T0 = Call<Strings.TrimLeft," abc">; // "abc"
* ```
*/
export interface TrimLeft<Sep extends string = " "> extends Fn {
output: Impl.TrimLeft<this["args"][0], Sep>;
}
/**
* Trim the right side of a string.
* @param args[0] - The string to trim.
* @param Sep - The separator to trim.
* @returns The trimmed string.
* @example
* ```ts
* type T0 = Call<Strings.TrimRight,"abc ">; // "abc"
* ```
*/
export interface TrimRight<Sep extends string = " "> extends Fn {
output: Impl.TrimRight<this["args"][0], Sep>;
}
/**
* Trim a string.
* @param args[0] - The string to trim.
* @param Sep - The separator to trim.
* @returns The trimmed string.
* @example
* ```ts
* type T0 = Call<Strings.Trim," abc ">; // "abc"
* ```
*/
export interface Trim<Sep extends string = " "> extends Fn {
output: Impl.Trim<this["args"][0], Sep>;
}
/**
* Join a tuple of strings into a single string.
* @param args[0] - The tuple of strings to join.
* @param sep - The separator to join the strings with.
* @returns The joined string.
* @example
* ```ts
* type T0 = Call<Strings.Join<",">,["a","b","c"]>; // "a,b,c"
* ```
*/
export interface Join<sep extends string> extends Fn {
output: Tuples.ReduceImpl<this["args"][0], "", JoinReducer<sep>>;
}
/**
* Replace all instances of a substring in a string.
* @param args[0] - The string to replace.
* @param from - The substring to replace.
* @param to - The substring to replace with.
* @returns The replaced string.
* @example
* ```ts
* type T0 = Call<Strings.Replace<".","/">,"a.b.c.d">; // "a/b/c/d"
*/
export interface Replace<from extends string, to extends string> extends Fn {
output: Impl.Replace<this["args"][0], from, to>;
}
/**
* Cut a slice of a string out from a start index to an end index.
* @param args[0] - The string to slice.
* @param start - The start index.
* @param end - The end index.
* @returns The sliced string.
* @example
* ```ts
* type T0 = Call<Strings.Slice<1,9>,"1234567890">; // "23456789"
*/
export interface Slice<start extends number, end extends number> extends Fn {
output: Pipe<Impl.StringToTuple<this["args"][0]>, [
Tuples.Take<end>,
Tuples.Drop<start>,
Join<"">
]>;
}
/**
* Split a string into a tuple of strings.
* @param args[0] - The string to split.
* @param sep - The separator to split the string with.
* @returns The split string.
* @example
* ```ts
* type T0 = Call<Strings.Split<",">,"a,b,c">; // ["a","b","c"]
* ```
*/
export interface Split<sep extends string> extends Fn {
output: H.Split<this["args"][0], sep>;
output: Impl.Split<this["args"][0], sep>;
}
/**
* Repeat a string a number of times.
* @param args[0] - The string to repeat.
* @param times - The number of times to repeat the string.
* @returns The repeated string.
* @example
* ```ts
* type T0 = Call<Strings.Repeat<3>,"Hello! ">; // "Hello! Hello! Hello! "
* ```
*/
export interface Repeat<times extends number> extends Fn {
output: Impl.Repeat<this["args"][0], H.Iterator.Iterator<times>>;
}
/**
* Check if a string starts with a substring.
* @param args[0] - The string to check.
* @param str - The substring to check for.
* @returns Whether the string starts with the substring.
* @example
* ```ts
* type T0 = Call<Strings.StartsWith<"abc">,"abcdef">; // true
* type T1 = Call<Strings.StartsWith<"abc">,"defabc">; // false
* ```
*/
export interface StartsWith<str extends string> extends Fn {
output: this["args"][0] extends `${str}${string}` ? true : false;
}
/**
* Check if a string ends with a substring.
* @param args[0] - The string to check.
* @param str - The substring to check for.
* @returns Whether the string ends with the substring.
* @example
* ```ts
* type T0 = Call<Strings.EndsWith<"abc">,"abcdef">; // false
* type T1 = Call<Strings.EndsWith<"abc">,"defabc">; // true
* ```
*/
export interface EndsWith<str extends string> extends Fn {
output: this["args"][0] extends `${string}${str}` ? true : false;
}
/**
* Split a string into a tuple of each character.
* @param args[0] - The string to split.
* @returns The splited string.
* @example
* ```ts
* type T0 = Call<Strings.ToTuple,"abc">; // ["a","b","c"]
*/
export interface ToTuple extends Fn {
output: Impl.StringToTuple<this["args"][0]>;
}
/**
* Convert a string to a number or bigint.
* @param args[0] - The string to convert.
* @returns The converted number or bigint.
* @example
* ```ts
* type T0 = Call<Strings.ToNumber,"123">; // 123
* type T1 = Call<Strings.ToNumber,"12367543547677078675456656790">; // 12367543547677078675456656790n
* ```
*/
export interface ToNumber extends Fn {
output: this["args"][0] extends `${infer n extends number}` ? n : never;
output: this["args"][0] extends `${infer n extends number | bigint}` ? n : never;
}
/**
* Convert a stringifiable literal to a string.
* @param args[0] - The stringifiable literal to convert.
* @returns The converted string.
* @example
* ```ts
* type T0 = Call<Strings.ToString,123>; // "123"
* type T1 = Call<Strings.ToString,true>; // "true"
* type T2 = Call<Strings.ToString,null>; // "null"
* ```
*/
export interface ToString extends Fn {
output: `${Extract<this["args"][0], Strings.Stringifiable>}`;
}
/**
* Prepend a string to another string.
* @param args[0] - The string to be prepended to.
* @param str - The string to prepend.
* @returns The prepended string.
* @example
* ```ts
* type T0 = Call<Strings.Prepend<"abc">,"def">; // "abcdef"
* ```
*/
export interface Prepend<str extends string> extends Fn {
output: `${str}${Extract<this["args"][0], Strings.Stringifiable>}`;
}
/**
* Append a string to another string.
* @param args[0] - The string to be appended to.
* @param str - The string to append.
* @returns The appended string.
* @example
* ```ts
* type T0 = Call<Strings.Append<"abc">,"def">; // "defabc"
* ```
*/
export interface Append<str extends string> extends Fn {
output: `${Extract<this["args"][0], Strings.Stringifiable>}${str}`;
}
/**
* Transform a string to uppercase.
* @param args[0] - The string to transform.
* @returns The transformed string.
* @example
* ```ts
* type T0 = Call<Strings.Uppercase,"abc">; // "ABC"
* ```
*/
export interface Uppercase extends Fn {
output: Std._Uppercase<Extract<this["args"][0], string>>;
}
/**
* Transform a string to lowercase.
* @param args[0] - The string to transform.
* @returns The transformed string.
* @example
* ```ts
* type T0 = Call<Strings.Lowercase,"ABC">; // "abc"
* ```
*/
export interface Lowercase extends Fn {
output: Std._Lowercase<Extract<this["args"][0], string>>;
}
/**
* Capitalize a string.
* @param args[0] - The string to capitalize.
* @returns The capitalized string.
* @example
* ```ts
* type T0 = Call<Strings.Capitalize,"abc">; // "Abc"
* ```
*/
export interface Capitalize extends Fn {
output: Std._Capitalize<Extract<this["args"][0], string>>;
}
/**
* Uncapitalize a string.
* @param args[0] - The string to uncapitalize.
* @returns The uncapitalized string.
* @example
* ```ts
* type T0 = Call<Strings.Uncapitalize,"AddTop">; // "addTop"
* ```
*/
export interface Uncapitalize extends Fn {
output: Std._Uncapitalize<Extract<this["args"][0], string>>;
}
/**
* Convert a string to snake case.
* @param args[0] - The string to convert.
* @returns The converted string.
* @example
* ```ts
* type T0 = Call<Strings.SnakeCase,"AddTop">; // "add_top"
* ```
*/
export interface SnakeCase extends Fn {
output: H.SnakeCase<this["args"][0]>;
}
/**
* Convert a string to camel case.
* @param args[0] - The string to convert.
* @returns The converted string.
* @example
* ```ts
* type T0 = Call<Strings.CamelCase,"add_top">; // "addTop"
* ```
*/
export interface CamelCase extends Fn {
output: H.CamelCase<this["args"][0]>;
}
/**
* Convert a string to kebab case.
* @param args[0] - The string to convert.
* @returns The converted string.
* @example
* ```ts
* type T0 = Call<Strings.KebabCase,"add_top">; // "add-top"
* type T1 = Call<Strings.KebabCase,"AddTop">; // "add-top"
* type T2 = Call<Strings.KebabCase,"addTop">; // "add-top"
* ```
*/
export interface KebabCase extends Fn {
output: H.KebabCase<this["args"][0]>;
}
/**
* Compare two strings. (only works with ascii extended characters)
* @param args[0] - The first string to compare.
* @param args[1] - The second string to compare.
* @n1 - The first string to compare or placeholder.
* @n2 - The second string to compare or placeholder.
* @returns The result of the comparison.
* @example
* ```ts
* type T0 = Call2<Strings.Compare,"abc","def">; // -1
* type T1 = Call2<Strings.Compare,"def","abc">; // 1
* type T2 = Call2<Strings.Compare,"abc","abc">; // 0
* ```
*/
export interface Compare<n1 extends string | placeholder = never, n2 extends string | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends string,
infer b extends string,
...any
] ? Impl.Compare<a, b> : never;
}
/**
* Check if two strings are equal. (only works with ascii extended characters)
* @param args[0] - The first string to compare.
* @param args[1] - The second string to compare.
* @n1 - The first string to compare or placeholder.
* @n2 - The second string to compare or placeholder.
* @returns True if the strings are equal, false otherwise.
* @example
* ```ts
* type T0 = Call2<Strings.Equal,"abc","def">; // false
* type T1 = Call2<Strings.Equal,"def","abc">; // false
* type T2 = Call2<Strings.Equal,"abc","abc">; // true
*/
export interface Equal<n1 extends string | placeholder = never, n2 extends string | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends string,
infer b extends string,
...any
] ? Impl.Equal<a, b> : never;
}
/**
* Check if two strings are not equal. (only works with ascii extended characters)
* @param args[0] - The first string to compare.
* @param args[1] - The second string to compare.
* @n1 - The first string to compare or placeholder.
* @n2 - The second string to compare or placeholder.
* @returns True if the strings are not equal, false otherwise.
* @example
* ```ts
* type T0 = Call2<Strings.NotEqual,"abc","def">; // true
* type T1 = Call2<Strings.NotEqual,"def","abc">; // true
* type T2 = Call2<Strings.NotEqual,"abc","abc">; // false
* ```
*/
export interface NotEqual<n1 extends string | placeholder = never, n2 extends string | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends string,
infer b extends string,
...any
] ? Impl.NotEqual<a, b> : never;
}
/**
* Check if a string is lexically less than another string. (only works with ascii extended characters)
* @param args[0] - The first string to compare.
* @param args[1] - The second string to compare.
* @n1 - The first string to compare or placeholder.
* @n2 - The second string to compare or placeholder.
* @returns True if the first string is lexically less than the second string, false otherwise.
* @example
* ```ts
* type T0 = Call2<Strings.LessThan,"abc","def">; // true
* type T1 = Call2<Strings.LessThan,"def","abc">; // false
* type T2 = Call2<Strings.LessThan,"abc","abc">; // false
* ```
*/
export interface LessThan<n1 extends string | placeholder = never, n2 extends string | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends string,
infer b extends string,
...any
] ? Impl.LessThan<a, b> : never;
}
/**
* Check if a string is lexically less than or equal to another string. (only works with ascii extended characters)
* @param args[0] - The first string to compare.
* @param args[1] - The second string to compare.
* @n1 - The first string to compare or placeholder.
* @n2 - The second string to compare or placeholder.
* @returns True if the first string is lexically less than or equal to the second string, false otherwise.
* @example
* ```ts
* type T0 = Call2<Strings.LessThanOrEqual,"abc","def">; // true
* type T1 = Call2<Strings.LessThanOrEqual,"def","abc">; // false
* type T2 = Call2<Strings.LessThanOrEqual,"abc","abc">; // true
*/
export interface LessThanOrEqual<n1 extends string | placeholder = never, n2 extends string | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends string,
infer b extends string,
...any
] ? Impl.LessThanOrEqual<a, b> : never;
}
/**
* Check if a string is lexically greater than another string. (only works with ascii extended characters)
* @param args[0] - The first string to compare.
* @param args[1] - The second string to compare.
* @n1 - The first string to compare or placeholder.
* @n2 - The second string to compare or placeholder.
* @returns True if the first string is lexically greater than the second string, false otherwise.
* @example
* ```ts
* type T0 = Call2<Strings.GreaterThan,"abc","def">; // false
* type T1 = Call2<Strings.GreaterThan,"def","abc">; // true
* type T2 = Call2<Strings.GreaterThan,"abc","abc">; // false
* ```
*/
export interface GreaterThan<n1 extends string | placeholder = never, n2 extends string | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends string,
infer b extends string,
...any
] ? Impl.GreaterThan<a, b> : never;
}
/**
* Check if a string is lexically greater than or equal to another string. (only works with ascii extended characters)
* @param args[0] - The first string to compare.
* @param args[1] - The second string to compare.
* @n1 - The first string to compare or placeholder.
* @n2 - The second string to compare or placeholder.
* @returns True if the first string is lexically greater than or equal to the second string, false otherwise.
* @example
* ```ts
* type T0 = Call2<Strings.GreaterThanOrEqual,"abc","def">; // false
* type T1 = Call2<Strings.GreaterThanOrEqual,"def","abc">; // true
* type T2 = Call2<Strings.GreaterThanOrEqual,"abc","abc">; // true
* ```
*/
export interface GreaterThanOrEqual<n1 extends string | placeholder = never, n2 extends string | placeholder = never> extends Fn {
output: MergeArgs<this["args"], [n1, n2]> extends [
infer a extends string,
infer b extends string,
...any
] ? Impl.GreaterThanOrEqual<a, b> : never;
}
export {};
}
import { Call, Call2, Fn } from "../core/Core";
import { Numbers } from "../numbers/Numbers";
import { Iterator } from "../../helpers";
import { Iterator } from "../helpers";
export declare namespace Tuples {

@@ -72,3 +72,20 @@ type HeadImpl<xs> = xs extends readonly [infer head, ...any] ? head : never;

}
export interface Some<fn extends Fn> extends Fn {
output: true extends Call<Tuples.Map<fn>, this["args"][0]>[number] ? true : false;
}
export interface Every<fn extends Fn> extends Fn {
output: false extends Call<Tuples.Map<fn>, this["args"][0]>[number] ? false : true;
}
type SortImpl<xs extends any[]> = xs extends [
infer head extends number,
...infer tail
] ? [
...SortImpl<Call<Tuples.Filter<Numbers.LessThanOrEqual<head>>, tail>>,
head,
...SortImpl<Call<Tuples.Filter<Numbers.GreaterThan<head>>, tail>>
] : [];
export interface Sort extends Fn {
output: this["args"] extends [infer xs extends any[]] ? SortImpl<xs> : never;
}
export {};
}

@@ -0,0 +0,0 @@ import { Call, Fn } from "../core/Core";

{
"name": "hotscript",
"version": "1.0.1",
"version": "1.0.2",
"description": "Type-level madness",
"type": "module",
"source": "src/index.ts",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.module.js",
"types": "./dist/index.d.ts",
"default": "./dist/index.modern.js"
},
"./package.json": "./package.json"
},
"main": "./dist/index.cjs",
"main": "./dist/index.js",
"types": "dist/index.d.ts",
"module": "./dist/index.module.js",
"unpkg": "./dist/index.umd.js",
"scripts": {
"build": "microbundle",
"dev": "microbundle watch",
"prepublishOnly": "npm run test && npm run build",
"build": "tsc src/index.ts -d --emitDeclarationOnly --outDir dist",
"prepublishOnly": "npm run build",
"test": "jest",

@@ -46,3 +34,2 @@ "clear-test": "jest --clearCache",

"jest": "^29.4.2",
"microbundle": "^0.15.1",
"prettier": "^2.8.4",

@@ -49,0 +36,0 @@ "ts-jest": "^29.0.5",

@@ -9,12 +9,12 @@ # Higher-Order TypeScript (HOTScript)

// prettier-ignore
type result = Pipe<
// ^? 78
type res1 = Pipe<
// ^? 95
[1, 2, 3, 4, 3, 4],
[
T.Map<Add<3>>,
S.Join<'.'>,
S.Split<'.'>,
T.Map<S.ToNumber>,
T.Map<N.Add<10>>,
T.Sum
Tuples.Map<Numbers.Add<3>>,
Strings.Join<".">,
Strings.Split<".">,
Tuples.Map<Strings.ToNumber>,
Tuples.Map<Numbers.Add<10>>,
Tuples.Sum
]

@@ -28,4 +28,30 @@ >;

type result = Call<T.FlatMap<Duplicate>, [1, 2, 3, 4]>;
type result1 = Call<Tuples.Map<Duplicate>, [1, 2, 3, 4]>;
// ^? [[1, 1], [2, 2], [3, 3], [4, 4]]
type result2 = Call<Tuples.FlatMap<Duplicate>, [1, 2, 3, 4]>;
// ^? [1, 1, 2, 2, 3, 3, 4, 4]
// Let's compose some functions to transform an object type:
type ToAPIPayload<T> = Pipe<
T,
[
Objects.OmitBy<Booleans.Equals<symbol>>,
Objects.Assign<{ metadata: { newUser: true } }>,
Objects.SnakeCaseDeep,
Objects.Assign<{ id: string }>
]
>;
type T = ToAPIPayload<{
id: symbol;
firstName: string;
lastName: string;
}>;
// Returns:
type T = {
id: string;
metadata: { new_user: true };
first_name: string;
last_name: string;
};
```

@@ -46,2 +72,3 @@

- [ ] Partition
- [x] Sort
- [x] Head

@@ -61,2 +88,4 @@ - [x] Tail

- [x] ReduceRight
- [x] Every
- [x] Some
- [ ] Object

@@ -73,8 +102,8 @@ - [x] FromEntries

- [x] OmitBy
- [x] CamelizeKeys
- [x] CamelizeKeysDeep
- [x] SnakizeKeys
- [x] SnakizeKeysDeep
- [x] KebabizeKeys
- [x] KebabizeKeysDeep
- [x] CamelCase
- [x] CamelCaseDeep
- [x] SnakeCase
- [x] SnakeCaseDeep
- [x] KebabCase
- [x] KebabCaseDeep
- [ ] Union

@@ -87,6 +116,18 @@ - [x] Map

- [ ] String
- [x] Length
- [x] TrimLeft
- [x] TrimRight
- [x] Trim
- [x] Join
- [x] Replace
- [x] Slice
- [x] Split
- [x] Repeat
- [x] StartsWith
- [x] EndsWith
- [x] ToTuple
- [x] ToNumber
- [x] ToString
- [x] ToNumber
- [x] Prepend
- [x] Append
- [x] Prepend
- [x] Uppercase

@@ -99,12 +140,23 @@ - [x] Lowercase

- [x] KebabCase
- [x] Split separator
- [ ] Words
- [x] Compare
- [x] Equal
- [x] NotEqual
- [x] LessThan
- [x] LessThanOrEqual
- [x] GreaterThan
- [x] GreaterThanOrEqual
- [ ] Number
- [x] Add
- [ ] Multiply
- [ ] Subtract
- [ ] GreaterThan
- [ ] GreaterThanOrEqual
- [ ] LessThan
- [ ] LessThanOrEqual
- [x] Multiply
- [x] Subtract
- [x] Negate
- [x] Power
- [x] Div
- [x] Mod
- [x] Abs
- [x] Compare
- [x] GreaterThan
- [x] GreaterThanOrEqual
- [x] LessThan
- [x] LessThanOrEqual
- [ ] Boolean

@@ -111,0 +163,0 @@ - [x] And

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