Skip to content

Commit 83e18dd

Browse files
committed
♻️ refactor: update codebase #2
1 parent ecbb31a commit 83e18dd

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

const.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"unicode/utf8"
66
)
77

8-
type result int
9-
108
var (
119
// Len is an alias for the utf8.RuneCountInString function, which returns the number of runes
1210
// (Unicode code points) in the given string. This function treats erroneous and short
@@ -32,3 +30,17 @@ const (
3230
rightMatch
3331
rightStop
3432
)
33+
34+
const (
35+
byKey byKind = 0
36+
byVal byKind = 1
37+
)
38+
39+
const (
40+
jsonNull jsonType = iota
41+
jsonFalse
42+
jNumber
43+
jsonString
44+
jsonTrue
45+
jsonJson
46+
)

pretty.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package unify4g

types.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package unify4g
2+
3+
type OptionsConfig struct {
4+
// Width is an max column width for single line arrays
5+
// Default is 80
6+
Width int `json:"width"`
7+
// Prefix is a prefix for all lines
8+
// Default is an empty string
9+
Prefix string `json:"prefix"`
10+
// Indent is the nested indentation
11+
// Default is two spaces
12+
Indent string `json:"indent"`
13+
// SortKeys will sort the keys alphabetically
14+
// Default is false
15+
SortKeys bool `json:"sort_keys"`
16+
}
17+
18+
// Style is the color style
19+
type Style struct {
20+
Key, String, Number [2]string
21+
True, False, Null [2]string
22+
Escape [2]string
23+
Brackets [2]string
24+
Append func(dst []byte, c byte) []byte
25+
}
26+
27+
type result int
28+
type byKind int
29+
type jsonType int
30+
31+
type pair struct {
32+
keyStart, keyEnd int
33+
valueStart, valueEnd int
34+
}
35+
36+
type byKeyVal struct {
37+
sorted bool
38+
json []byte
39+
buf []byte
40+
pairs []pair
41+
}
42+
43+
// DefaultOptionsConfig is the default options for pretty formats.
44+
var DefaultOptionsConfig = &OptionsConfig{Width: 80, Prefix: "", Indent: " ", SortKeys: false}
45+
46+
// TerminalStyle is for terminals
47+
var TerminalStyle *Style

0 commit comments

Comments
 (0)