Lens overview
Zoom into an object.
Added in v1.0.0
Table of contents
array
append
Signature
export declare const append: {
<Self, A>(
lens: Lens<Self, Array.NonEmptyArray<A>> | Lens<Self, ReadonlyArray<A>> | Lens<Self, Array<A>>,
self: Self,
last: A
): Self
<Self, A>(
lens: Lens<Self, Array.NonEmptyArray<A>> | Lens<Self, ReadonlyArray<A>> | Lens<Self, Array<A>>
): { (self: Self, last: A): Self; (last: A): (self: Self) => Self }
}
Added in v1.0.0
appendAll
Signature
export declare const appendAll: {
<Self, A>(lens: Lens<Self, ReadonlyArray<A>> | Lens<Self, Array<A>>, self: Self, that: ReadonlyArray<A>): Self
<Self, A>(
lens: Lens<Self, ReadonlyArray<A>> | Lens<Self, Array<A>>
): { (self: Self, that: ReadonlyArray<A>): Self; (that: ReadonlyArray<A>): (self: Self) => Self }
}
Added in v1.0.0
headNonEmpty
Signature
export declare const headNonEmpty: <Self, A>(
lens: Lens<Self, Array.NonEmptyReadonlyArray<A>> | Lens<Self, Array.NonEmptyArray<A>>
) => Lens<Self, A>
Added in v1.0.0
combinators
filter
Signature
export declare const filter: {
<A, B extends A, Self>(lens: Lens<Self, A>, refinement: Predicate.Refinement<A, B>): Optional.Optional<Self, B>
<A, B extends A>(refinement: Predicate.Refinement<A, B>): <Self>(lens: Lens<Self, A>) => Optional.Optional<Self, B>
<A, Self>(lens: Lens<Self, A>, predicate: Predicate.Predicate<A>): Optional.Optional<Self, A>
<A>(predicate: Predicate.Predicate<A>): <Self>(lens: Lens<Self, A>) => Optional.Optional<Self, A>
}
Added in v1.0.0
composition
compose
Signature
export declare const compose: {
<B, C>(that: Lens<B, C>): <A>(self: Lens<A, B>) => Lens<A, C>
<A, B, C>(self: Lens<A, B>, that: Lens<B, C>): Lens<A, C>
}
Added in v1.0.0
constructors
id
Signature
export declare const id: <Self>() => Lens<Self, Self>
Added in v1.0.0
make
Signature
export declare const make: <Self, Value>(
get: (self: Self) => Value,
set: (self: Self, value: Value) => Self
) => Lens<Self, Value>
Added in v1.0.0
models
Lens (interface)
Signature
export interface Lens<Self, Value> extends Lens.Variance<Self, Value>, Pipeable.Pipeable {
readonly get: (self: Self) => Value
readonly set: {
(self: Self, value: Value): Self
(value: Value): (self: Self) => Self
}
// derived
readonly modify: {
(self: Self, f: (value: Value) => Value): Self
(f: (value: Value) => Value): (self: Self) => Self
}
}
Added in v1.0.0
Lens (namespace)
Added in v1.0.0
Variance (interface)
Signature
export interface Variance<Self, Value> {
readonly [TypeId]: {
readonly _Self: Types.Invariant<Self>
readonly _Value: Types.Invariant<Value>
}
}
Added in v1.0.0
Any (type alias)
Signature
export type Any = Lens<any, any>
Added in v1.0.0
option
some
Signature
export declare const some: <A, B>(lens: Lens<A, Option.Option<B>>) => Optional.Optional<A, B>
Added in v1.0.0
struct
extract
Signature
export declare const extract: {
<Self, Value, const Tag extends keyof Value, const TagValues extends readonly [Value[Tag], ...Array<Value[Tag]>]>(
lens: Lens<Self, Value>,
tag: Tag,
...tagValue: TagValues
): Optional.Optional<Self, Extract<Value, { [K in Tag]: TagValues[number] }>>
<Value, const Tag extends keyof Value, const TagValues extends readonly [Value[Tag], ...Array<Value[Tag]>]>(
tag: Tag,
...tagValue: TagValues
): <Self>(lens: Lens<Self, Value>) => Optional.Optional<Self, Extract<Value, { [K in Tag]: TagValues[number] }>>
}
Added in v1.0.0
pick
L.props
alternative
Signature
export declare const pick: {
<Value, Keys extends keyof Value>(
keys_0: Keys,
keys_1: Keys,
...keys_2: Keys[]
): <Self>(lens: Lens<Self, Value>) => Lens<Self, { [K in Keys]: Value[K] }>
<Self, Value, Keys extends keyof Value>(
lens: Lens<Self, Value>,
keys_0: Keys,
keys_1: Keys,
...keys_2: Keys[]
): Lens<Self, { [K in Keys]: Value[K] }>
}
Added in v1.0.0
prop
Signature
export declare const prop: {
<Value, A extends keyof Value>(prop: A): <Self>(lens: Lens<Self, Value>) => Lens<Self, Value[A]>
<Value, A extends keyof Value, B extends keyof Value[A]>(
a: A,
b: B
): <Self>(lens: Lens<Self, Value>) => Lens<Self, Value[A][B]>
<Value, A extends keyof Value, B extends keyof Value[A], C extends keyof Value[A][B]>(
a: A,
b: B,
c: C
): <Self>(lens: Lens<Self, Value>) => Lens<Self, Value[A][B][C]>
<Value, A extends keyof Value, B extends keyof Value[A], C extends keyof Value[A][B], D extends keyof Value[A][B][C]>(
a: A,
b: B,
c: C,
d: D
): <Self>(lens: Lens<Self, Value>) => Lens<Self, Value[A][B][C][D]>
<
Value,
A extends keyof Value,
B extends keyof Value[A],
C extends keyof Value[A][B],
D extends keyof Value[A][B][C],
E extends keyof Value[A][B][C][D]
>(
a: A,
b: B,
c: C,
d: D,
e: E
): <Self>(lens: Lens<Self, Value>) => Lens<Self, Value[A][B][C][D][E]>
<Self, Value, A extends keyof Value>(lens: Lens<Self, Value>, a: A): Lens<Self, Value[A]>
<Self, Value, A extends keyof Value, B extends keyof Value[A]>(
lens: Lens<Self, Value>,
a: A,
b: B
): Lens<Self, Value[A][B]>
<Self, Value, A extends keyof Value, B extends keyof Value[A], C extends keyof Value[A][B]>(
lens: Lens<Self, Value>,
a: A,
b: B,
c: C
): Lens<Self, Value[A][B][C]>
<
Self,
Value,
A extends keyof Value,
B extends keyof Value[A],
C extends keyof Value[A][B],
D extends keyof Value[A][B][C]
>(
lens: Lens<Self, Value>,
a: A,
b: B,
c: C,
d: D
): Lens<Self, Value[A][B][C][D]>
<
Self,
Value,
A extends keyof Value,
B extends keyof Value[A],
C extends keyof Value[A][B],
D extends keyof Value[A][B][C],
E extends keyof Value[A][B][C][D]
>(
lens: Lens<Self, Value>,
a: A,
b: B,
c: C,
d: D,
e: E
): Lens<Self, Value[A][B][C][D][E]>
}
Added in v1.0.0
type id
TypeId
Signature
export declare const TypeId: typeof TypeId
Added in v1.0.0
TypeId (type alias)
Signature
export type TypeId = typeof TypeId
Added in v1.0.0