MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / CombineFn_ArrayAppend

Function CombineFn_ArrayAppend

pkg/ijson/ijson.go:257–273  ·  view source on GitHub ↗
(data any, value any, pp pathWithPos, opts SetPathOpts)

Source from the content-addressed store, hash-verified

255}
256
257func CombineFn_ArrayAppend(data any, value any, pp pathWithPos, opts SetPathOpts) (any, error) {
258 if !checkAndModifyBudget(&opts, pp, 1) {
259 return nil, MakeBudgetError("trying to append to array", pp.Path, pp.Index)
260 }
261 if data == nil {
262 data = make([]any, 0)
263 }
264 arrVal, ok := data.([]any)
265 if !ok && !opts.Force {
266 return nil, MakeSetTypeError(fmt.Sprintf("expected array, but got %T", data), pp.Path, pp.Index)
267 }
268 if !ok {
269 arrVal = make([]any, 0)
270 }
271 arrVal = append(arrVal, value)
272 return arrVal, nil
273}
274
275func CombineFn_SetUnless(data any, value any, pp pathWithPos, opts SetPathOpts) (any, error) {
276 if data != nil {

Callers

nothing calls this directly

Calls 3

checkAndModifyBudgetFunction · 0.85
MakeBudgetErrorFunction · 0.85
MakeSetTypeErrorFunction · 0.85

Tested by

no test coverage detected