Struct overview
A simple extension to the Effect Struct module
Table of contents
Constructors
make
Builds a one-key struct
Signature
export declare const make: <K extends string | symbol>(key: K) => <V>(value: V) => { readonly [key in K]: V }
Utils
append
Appends that
to self
. If that
contains fields that already exist in self
, they will prevail. Use instead of the spread operator because it does not copy the prototype but returns a type containing the properties borne by the prototype.
Signature
export declare const append: <O1 extends MTypes.NonPrimitive>(
that: O1
) => <O extends MTypes.NonPrimitive>(self: O) => MTypes.Data<Omit<O, keyof O1> & O1>
enrichWith
Calculates a ‘fields’ struct whose values are based on functions taking self
as argument and appends it to self
.
Signature
export declare const enrichWith: <
O extends MTypes.NonPrimitive,
O1 extends Record<string | symbol, MTypes.OneArgFunction<O, any>>
>(
fields: O1
) => (self: O) => MTypes.Data<Omit<O, keyof O1> & { readonly [key in keyof O1]: ReturnType<O1[key]> }>
evolve
Same as Struct.evolve but we remove from the return type any property borne by the prototype as it does not get copied. If property to evolve is not in target obj
, it is ignored.
Signature
export declare const evolve: {
<O, T>(t: PartialTransform<O, T>): (obj: O) => MTypes.Data<Transformed<O, T>>
<O, T>(obj: O, t: PartialTransform<O, T>): MTypes.Data<Transformed<O, T>>
}
mutableEnrichWith
Same as enrichWith but mutates self
. To use in extreme situations only
Signature
export declare const mutableEnrichWith: <
O extends MTypes.NonPrimitive,
O1 extends Record<string | symbol, MTypes.OneArgFunction<O, any>>
>(
fields: O1
) => (self: O) => Omit<O, keyof O1> & { readonly [key in keyof O1]: ReturnType<O1[key]> }
mutableSet
Same as set but mutates self
. To use in extreme situations only
Signature
export declare const mutableSet: <O extends MTypes.NonPrimitive, O1 extends Partial<O>>(
that: O1
) => (self: O) => Omit<O, keyof O1> & O1
prepend
Prepends that
to self
. If that
contains fields that already exist in self
, they will not be taken into account. Use instead of the spread operator because it does not copy the prototype but returns a type containing the properties borne by the prototype.
Signature
export declare const prepend: <O extends MTypes.NonPrimitive>(
that: O
) => <O1 extends MTypes.NonPrimitive>(self: O1) => MTypes.Data<Omit<O, keyof O1> & O1>
set
Same as append but only existing properties of self
can be overriden.
Signature
export declare const set: <O extends MTypes.NonPrimitive, O1 extends Partial<O>>(
that: O1
) => (self: O) => MTypes.Data<Omit<O, keyof O1> & O1>