aboutsummaryrefslogtreecommitdiff
path: root/model/arrayNode.go
diff options
context:
space:
mode:
authorNeonXP <i@neonxp.dev>2022-12-27 02:37:02 +0300
committerNeonXP <i@neonxp.dev>2022-12-27 02:40:03 +0300
commit76a7f461ebbde70ea0e3d4f9b79c08139acaee7c (patch)
tree5e6dcb05f00be5109b3465ef16a6e9169a27497e /model/arrayNode.go
parent6f1d1df79f161cfc695f74d271d689ba72c44d09 (diff)
Completely rewritedv0.1.0
Diffstat (limited to 'model/arrayNode.go')
-rw-r--r--model/arrayNode.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/model/arrayNode.go b/model/arrayNode.go
deleted file mode 100644
index 319f223..0000000
--- a/model/arrayNode.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package model
-
-import (
- "bytes"
- "fmt"
-)
-
-type ArrayNode struct {
- Value NodeArrayValue
-}
-
-func (n ArrayNode) Type() NodeType {
- return ArrayType
-}
-
-func (n *ArrayNode) MarshalJSON() ([]byte, error) {
- result := make([][]byte, 0, len(n.Value))
- for _, v := range n.Value {
- b, err := v.MarshalJSON()
- if err != nil {
- return nil, err
- }
- result = append(result, b)
- }
- return bytes.Join(
- [][]byte{
- []byte("["),
- bytes.Join(result, []byte(", ")),
- []byte("]"),
- }, []byte("")), nil
-}
-
-func (n *ArrayNode) Set(v any) error {
- val, ok := v.(NodeArrayValue)
- if !ok {
- return fmt.Errorf("%v is not array", v)
- }
- n.Value = val
- return nil
-}
-
-func (n *ArrayNode) Index(idx int) (Node, error) {
- if len(n.Value) <= idx {
- return nil, fmt.Errorf("index %d out of range [0...%d]", idx, len(n.Value)-1)
- }
- return n.Value[idx], nil
-}
-
-func (n *ArrayNode) Merge(n2 *ArrayNode) {
- n.Value = append(n.Value, n2.Value...)
-}
-
-func (n *ArrayNode) Len() int {
- return len(n.Value)
-}
-
-type NodeArrayValue []Node