summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/ast/node.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-06-30 15:19:09 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-06-30 15:19:09 +0200
commit8b0ea560279a5bf4479555d3924c763ddeecfcad (patch)
tree005e26d4a658e565594fb259cc17948659195822 /vendor/github.com/bytedance/sonic/ast/node.go
parent[chore] bumps ncruces/go-sqlite3 v0.26.1 => v0.26.3 (#4302) (diff)
downloadgotosocial-8b0ea560279a5bf4479555d3924c763ddeecfcad.tar.xz
[chore] update go dependencies (#4304)
- github.com/KimMachineGun/automemlimit v0.7.2 => v0.7.3 - github.com/gin-contrib/cors v1.7.5 => v1.7.6 - github.com/minio/minio-go/v7 v7.0.92 => v7.0.94 - github.com/spf13/cast v1.8.0 => v1.9.2 - github.com/uptrace/bun{,/*} v1.2.11 => v1.2.14 - golang.org/x/image v0.27.0 => v0.28.0 - golang.org/x/net v0.40.0 => v0.41.0 - code.superseriousbusiness.org/go-swagger v0.31.0-gts-go1.23-fix => v0.32.3-gts-go1.23-fix Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4304 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast/node.go')
-rw-r--r--vendor/github.com/bytedance/sonic/ast/node.go29
1 files changed, 23 insertions, 6 deletions
diff --git a/vendor/github.com/bytedance/sonic/ast/node.go b/vendor/github.com/bytedance/sonic/ast/node.go
index 17964c32f..1c5ff6439 100644
--- a/vendor/github.com/bytedance/sonic/ast/node.go
+++ b/vendor/github.com/bytedance/sonic/ast/node.go
@@ -509,6 +509,23 @@ func (self *Node) Float64() (float64, error) {
}
}
+func (self *Node) StrictBool() (bool, error) {
+ if err := self.checkRaw(); err!= nil {
+ return false, err
+ }
+ switch self.t {
+ case types.V_TRUE : return true, nil
+ case types.V_FALSE : return false, nil
+ case _V_ANY :
+ any := self.packAny()
+ switch v := any.(type) {
+ case bool : return v, nil
+ default : return false, ErrUnsupportType
+ }
+ default : return false, ErrUnsupportType
+ }
+}
+
// Float64 exports underlying float64 value, including V_NUMBER, V_ANY
func (self *Node) StrictFloat64() (float64, error) {
if err := self.checkRaw(); err != nil {
@@ -776,7 +793,7 @@ func (self *Node) Pop() error {
}
// Move moves the child at src index to dst index,
-// meanwhile slides sliblings from src+1 to dst.
+// meanwhile slides siblings from src+1 to dst.
//
// WARN: this will change address of elements, which is a dangerous action.
func (self *Node) Move(dst, src int) error {
@@ -816,7 +833,7 @@ func (self *Node) Move(dst, src int) error {
return nil
}
-// SetAny wraps val with V_ANY node, and Add() the node.
+// AddAny wraps val with V_ANY node, and Add() the node.
func (self *Node) AddAny(val interface{}) error {
return self.Add(NewAny(val))
}
@@ -938,7 +955,7 @@ func (self *Node) Map() (map[string]interface{}, error) {
return self.toGenericObject()
}
-// MapUseNumber loads all keys of an object node, with numeric nodes casted to json.Number
+// MapUseNumber loads all keys of an object node, with numeric nodes cast to json.Number
func (self *Node) MapUseNumber() (map[string]interface{}, error) {
if self.isAny() {
any := self.packAny()
@@ -1083,7 +1100,7 @@ func (self *Node) Array() ([]interface{}, error) {
return self.toGenericArray()
}
-// ArrayUseNumber loads all indexes of an array node, with numeric nodes casted to json.Number
+// ArrayUseNumber loads all indexes of an array node, with numeric nodes cast to json.Number
func (self *Node) ArrayUseNumber() ([]interface{}, error) {
if self.isAny() {
any := self.packAny()
@@ -1149,7 +1166,7 @@ func (self *Node) unsafeArray() (*linkedNodes, error) {
// Interface loads all children under all paths from this node,
// and converts itself as generic type.
-// WARN: all numeric nodes are casted to float64
+// WARN: all numeric nodes are cast to float64
func (self *Node) Interface() (interface{}, error) {
if err := self.checkRaw(); err != nil {
return nil, err
@@ -1193,7 +1210,7 @@ func (self *Node) packAny() interface{} {
}
// InterfaceUseNumber works same with Interface()
-// except numeric nodes are casted to json.Number
+// except numeric nodes are cast to json.Number
func (self *Node) InterfaceUseNumber() (interface{}, error) {
if err := self.checkRaw(); err != nil {
return nil, err