-
Notifications
You must be signed in to change notification settings - Fork 47
/
operation.go
46 lines (36 loc) · 1.16 KB
/
operation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Copyright (c) 2021 - Present. Blend Labs, Inc. All rights reserved
Use of this source code is governed by a MIT license that can be found in the LICENSE file.
*/
package diff
import "strconv"
// Operation defines the operation of a diff item.
type Operation int8
// Operation constants.
const (
// DiffDelete item represents a delete diff.
DiffDelete Operation = -1
// DiffInsert item represents an insert diff.
DiffInsert Operation = 1
// DiffEqual item represents an equal diff.
DiffEqual Operation = 0
//IndexSeparator is used to separate the array indexes in an index string
IndexSeparator = ","
)
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[DiffDelete - -1]
_ = x[DiffInsert-1]
_ = x[DiffEqual-0]
}
const operationName = "DeleteEqualInsert"
var operationIndex = [...]uint8{0, 6, 11, 17}
func (i Operation) String() string {
i -= -1
if i < 0 || i >= Operation(len(operationIndex)-1) {
return "Operation(" + strconv.FormatInt(int64(i+-1), 10) + ")"
}
return operationName[operationIndex[i]:operationIndex[i+1]]
}