(data: object, ctx: InternalTraversal)
| 707 | } |
| 708 | |
| 709 | tTransform(data: object, ctx: InternalTraversal): unknown { |
| 710 | const errN = ctx.errN |
| 711 | const copies = !this.writesInto(ctx) |
| 712 | let out: any = data |
| 713 | const tfKey = ( |
| 714 | k: Key, |
| 715 | value: unknown, |
| 716 | node: BaseNode, |
| 717 | input = value, |
| 718 | pathKey: PropertyKey = k |
| 719 | ) => { |
| 720 | let transformed = travKey(pathKey, () => transform(ctx, node, input), ctx) |
| 721 | if (input !== value) |
| 722 | transformed = mergeTransformed(input, value, transformed) |
| 723 | if (Object.is(transformed, value)) return value |
| 724 | if (out === data && copies) out = this.copy(data) |
| 725 | setOwnValue(out, k, transformed) |
| 726 | return transformed |
| 727 | } |
| 728 | const hasIndexedProp = this.hasIndexedProp |
| 729 | const props = this.inOrder |
| 730 | for (let i = 0; i < props.length; i++) { |
| 731 | const prop = props[i] |
| 732 | // a value its default replaces isn't transformed first |
| 733 | if (!hasIndexedProp) { |
| 734 | if (prop.value.tfs && prop.holdsValue(data)) |
| 735 | tfKey(prop.key, data[prop.key as never], prop.value) |
| 736 | continue |
| 737 | } |
| 738 | if (!prop.holdsValue(data)) continue |
| 739 | const keyErrorCount = ctx.errN |
| 740 | const input: unknown = data[prop.key as never] |
| 741 | let value = input |
| 742 | const steps = this.tfsOf(prop) |
| 743 | const listed = |
| 744 | steps.some(step => step.indexed) && isDeletableKeyOf(data, prop.key) |
| 745 | for (const step of steps) { |
| 746 | if (ctx.errN > keyErrorCount) break |
| 747 | if (step.indexed && !listed) continue |
| 748 | if (step.signature && !allowsInBranch(ctx, step.signature, prop.key)) |
| 749 | continue |
| 750 | value = tfKey( |
| 751 | prop.key, |
| 752 | value, |
| 753 | step.node, |
| 754 | value === input || (step.node as BaseRoot).allows(value) ? |
| 755 | value |
| 756 | : input |
| 757 | ) |
| 758 | } |
| 759 | } |
| 760 | if (this.slicesSeq) |
| 761 | out = this.sequence!.tfElems(data as array, ctx, sliceOf) |
| 762 | else if (this.sequence?.tfs) { |
| 763 | const transformedSequence = |
| 764 | this.undeclared === "delete" && ctx.inPlace ? |
| 765 | this.sequence.tfElems( |
| 766 | out as array, |
nothing calls this directly
no test coverage detected