(args []super.Value)
| 133 | } |
| 134 | |
| 135 | func (s *Split) Call(args []super.Value) super.Value { |
| 136 | args = underAll(args) |
| 137 | sVal, sepVal := args[0], args[1] |
| 138 | if sVal.IsNull() || sepVal.IsNull() { |
| 139 | return super.Null |
| 140 | } |
| 141 | if sVal.Type().Kind() == super.ErrorKind { |
| 142 | return sVal |
| 143 | } |
| 144 | if sepVal.Type().Kind() == super.ErrorKind { |
| 145 | return sVal |
| 146 | } |
| 147 | for i := range args { |
| 148 | if !args[i].IsString() { |
| 149 | return s.sctx.WrapError("split: string arg required", args[i]) |
| 150 | } |
| 151 | } |
| 152 | str := super.DecodeString(sVal.Bytes()) |
| 153 | sep := super.DecodeString(sepVal.Bytes()) |
| 154 | splits := strings.Split(str, sep) |
| 155 | var b scode.Bytes |
| 156 | for _, substr := range splits { |
| 157 | b = scode.Append(b, super.EncodeString(substr)) |
| 158 | } |
| 159 | return super.NewValue(s.typ, b) |
| 160 | } |
| 161 | |
| 162 | type Join struct { |
| 163 | sctx *super.Context |
nothing calls this directly
no test coverage detected