(ast: AST, encoding: Encoding)
| 3435 | export function mapOrSame<A>(as: ReadonlyArray<A>, f: (a: A) => A): ReadonlyArray<A> |
| 3436 | export 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 */ |
| 3451 | export 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, |
no test coverage detected
searching dependent graphs…