Skip to content

Immutable Clean #1073

Answered by sinclairzx81
crishoj asked this question in Q&A
Discussion options

You must be logged in to vote

@crishoj Hi,

You can use either structuredClone(...) or Value.Clone(...) prior to calling Value.Clean(T, ...). There isn't really an established idiom for this (just Clone the value before calling mutable Value functions). However, if you're interested, TypeBox internally handles value pipeline operations in the following way (for it's Parse function)

https://github.com/sinclairzx81/typebox/blob/master/src/value/parse/parse.ts#L43-L57

const ParseReducer: ReducerFunction[] = [
  (_schema, _references, value) => Clone(value),
  (schema, references, value) => Default(schema, references, value),
  (schema, references, value) => Clean(schema, references, value),
  (schema, references, value) => 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by crishoj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants