Annotates values from source. Output values will be in the form { value: TIn, annotation: TAnnotation }. Where TIn is the type of the input, and TAnnotation is the return type of the annotator function.
source
{ value: TIn, annotation: TAnnotation }
TIn
TAnnotation
Example calculating area from width & height:
const data = Rx.From.array( { w: 1, h: 3 }, { w: 1, h: 1 }, { w: 2, h: 2 });const annotated = Rx.Ops.annotate(data, v => { return { area: v.w * v.h }});const data = await Rx.toArray(annotated);// Data = [ { value: { w:1, h:3 }, annotation: { area:3 } } ...] Copy
const data = Rx.From.array( { w: 1, h: 3 }, { w: 1, h: 1 }, { w: 2, h: 2 });const annotated = Rx.Ops.annotate(data, v => { return { area: v.w * v.h }});const data = await Rx.toArray(annotated);// Data = [ { value: { w:1, h:3 }, annotation: { area:3 } } ...]
If you would rather annotate and have values merge with the input, use transform:
transform
const data = Rx.From.array( { w: 1, h: 3 }, { w: 1, h: 1 }, { w: 2, h: 2 });const withArea = Rx.Ops.transform(data, v => { return { ...v, area: v.w * v.h }});const data = await Rx.toArray(withArea);// Data = [ { w:1, h:3, area:3 }, ...] Copy
const data = Rx.From.array( { w: 1, h: 3 }, { w: 1, h: 1 }, { w: 2, h: 2 });const withArea = Rx.Ops.transform(data, v => { return { ...v, area: v.w * v.h }});const data = await Rx.toArray(withArea);// Data = [ { w:1, h:3, area:3 }, ...]
Annotates values from
source
. Output values will be in the form{ value: TIn, annotation: TAnnotation }
. WhereTIn
is the type of the input, andTAnnotation
is the return type of the annotator function.Example calculating area from width & height:
If you would rather annotate and have values merge with the input, use
transform
: