libdiff

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeleteTag     = "!delete"
	InsertTag     = "!insert"
	ReplaceTag    = "!replace"
	TagDeleteTag  = "!rmtag"
	TagInsertTag  = "!addtag"
	TagReplaceTag = "!retag"
	StringDiffTag = "!strdiff"
	ArrayDiffTag  = "!arraydiff"
)

Variables

This section is empty.

Functions

func DiffArrayByIndex

func DiffArrayByIndex(from, to *ir.Node, df DiffFunc) *ir.Node

we use int keyed map and

  1. record the type of each node, for non-string scalar types... we use the summary value <type>-<value> where <value> is the string representation
  2. diff the sequence of summaries
  3. For every matching type in the result, if that type is not scalar, we recurse
  4. For every non-matching type, we add an int-keyed map item with the corresponding diff operation tagged

func DiffArrayByKey

func DiffArrayByKey(from, to *ir.Node, key string, df DiffFunc) (*ir.Node, error)

func DiffNumber

func DiffNumber(from *ir.Node, to *ir.Node) *ir.Node

func DiffObject

func DiffObject(from, to *ir.Node, df DiffFunc) *ir.Node

1 diff field names for every different field name add node for every same field name, recurse on the value

func DiffString

func DiffString(from, to *ir.Node) *ir.Node

func MakeDiff

func MakeDiff(from, to *ir.Node) *ir.Node

func MakeTagDiff

func MakeTagDiff(from, to string) string

func PatchArrayByIndex

func PatchArrayByIndex(doc, patch *ir.Node, df DiffFunc) (*ir.Node, error)

func PatchStringMultiLine

func PatchStringMultiLine(doc, patch *ir.Node) (*ir.Node, error)

func PatchStringRunes

func PatchStringRunes(doc, patch *ir.Node) (*ir.Node, error)

func Reverse

func Reverse(diff *ir.Node) (*ir.Node, error)

func YKeyOf

func YKeyOf(y *ir.Node, key string) (string, string, error)

Types

type DiffFunc

type DiffFunc func(*ir.Node, *ir.Node) *ir.Node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL