MCPcopy Create free account
hub / github.com/effect-app/libs / flipEncoding

Function flipEncoding

repos/effect/packages/effect/src/SchemaAST.ts:3437–3453  ·  view source on GitHub ↗
(ast: AST, encoding: Encoding)

Source from the content-addressed store, hash-verified

3435export function mapOrSame<A>(as: ReadonlyArray<A>, f: (a: A) => A): ReadonlyArray<A>
3436export function mapOrSame<A>(as: ReadonlyArray<A>, f: (a: A) => A): ReadonlyArray<A> {
3437 let changed = false
3438 const out: Array<A> = new Array(as.length)
3439 for (let i = 0; i < as.length; i++) {
3440 const a = as[i]
3441 const fa = f(a)
3442 if (fa !== a) {
3443 changed = true
3444 }
3445 out[i] = fa
3446 }
3447 return changed ? out : as
3448}
3449
3450/** @internal */
3451export function annotateKey<A extends AST>(ast: A, annotations: Schema.Annotations.Key<unknown>): A {
3452 const context = ast.context ?
3453 new Context(
3454 ast.context.isOptional,
3455 ast.context.isMutable,
3456 ast.context.constructorDefault,

Callers 1

SchemaAST.tsFile · 0.85

Calls 3

replaceEncodingFunction · 0.85
flipFunction · 0.70
flipMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…