0.0.0 • Published 8 months ago
@neoncitylights/types v0.0.0
types
A small library of utility types for TypeScript.
Install
npm install @neoncitylights/types
API
Functions (fn.d.ts
)
FnArity1<T1, R>
- A type representing a function with an arity of 1, or a function that takes 1 argument (T1
) and a return type ofR
.FnArity2<T1, T2, R>
- A type representing a function with an arity of 2, or a function that takes 2 arguments (T1
,T2
) and a return type ofR
.FnArity3<T1, T2, T3, R>
- A type representing a function with an arity of 3, or a function that takes 3 arguments (T1
,T2
,T3
) and a return type ofR
.FnArity4<T1, T2, T3, T4, R>
- A type representing a function with an arity of 4, or a function that takes 4 arguments (T1
,T2
,T3
,T4
) and a return type ofR
.PredicateFnArity1<T1>
- A type representing a predicate function with an arity of 1, or a function that takes 1 argument (T1
) and returns aboolean
.PredicateFnArity2<T1, T2>
- A type representing a predicate function with an arity of 2, or a function that takes 2 arguments (T1
,T2
) and returns aboolean
.PredicateFnArity3<T1, T2, T3>
- A type representing a predicate function with an arity of 3, or a function that takes 3 arguments (T1
,T2
,T3
) and returns aboolean
.PredicateFnArity4<T1, T2, T3, T4>
- A type representing a predicate function with an arity of 4, or a function that takes 4 arguments (T1
,T2
,T3
,T4
) and returns aboolean
.
Logic gates (logic.d.ts
)
Not<A>
: A type representing the logical NOT gate ofA
, or logical negation.And<A, B>
: A type representing the logical AND gate ofA
andB
, or logical conjunction.Or<A, B>
: A type representing the logical OR gate ofA
andB
, or logical disjunction.Nor<A, B>
: A type representing the logical NOR gate ofA
andB
, or logical non-disjunction. A special type of gate that is functionally complete (capable of expressing all possible truth tables).Nand<A, B>
: A type representing the logical NAND gate ofA
andB
. A special type of gate that is functionally complete (capable of expressing all possible truth tables).Xor<A, B>
: A type representing the logical XOR gate ofA
andB
, or exclusive disjunction/exclsuive OR.Xnor<A, B>
: A type representing the logical XNOR gate ofA
andB
, or logical biconditional.
Strings (strings.d.ts
)
Affix
: A string union type representing the possible affixes of a string:'prefix'
or'suffix'
. Intended for use with generic types such asAffixedWith
orRemoveAffix
.StartsWith<V, P>
: A conditional type representing whether a string valueV
starts with a prefixP
; evaluates to aboolean
.EndsWith<V, S>
: A conditional type representing whether a string valueV
ends with a suffixS
; evaluates to aboolean
.AffixedWith<V, Lit, A>
: A conditional type representing whether a string valueV
is affixed with an affixLit
with an affix kind ofA
; evaluates to aboolean
.PrefixWith<V, Lit>
: A template literal type representing the result of prefixing a string valueV
with a prefixLit
; evaluates to a string literal.SuffixWith<V, Lit>
: A template literal type representing the result of suffixing a string valueV
with a suffixS
; evaluates to a string literal.RemovePrefix<V, Lit>
: A template literal type representing the result of removing a prefixLit
from a string valueV
; evaluates to a string literal.RemoveSuffix<V, Lit>
: A template literal type representing the result of removing a suffixLit
from a string valueV
; evaluates to a string literal.RemoveAffix<V, Lit, A>
: A template literal type representing the result of removing an affixLit
from a string valueV
with an affix kind ofA
; evaluates to a string literal.
License
This library is licensed under the MIT license (LICENSE-MIT
or http://opensource.org/licenses/MIT).
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.
0.0.0
8 months ago