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

Function checkAndModifyBudget

pkg/ijson/ijson.go:242–255  ·  view source on GitHub ↗
(opts *SetPathOpts, pp pathWithPos, cost int)

Source from the content-addressed store, hash-verified

240}
241
242func checkAndModifyBudget(opts *SetPathOpts, pp pathWithPos, cost int) bool {
243 if opts.Budget == 0 {
244 return true
245 }
246 opts.Budget -= cost
247 if opts.Budget < 0 {
248 return false
249 }
250 if opts.Budget == 0 {
251 // 0 is weird since it means unlimited, so we set it to -1 to fail the next operation
252 opts.Budget = -1
253 }
254 return true
255}
256
257func CombineFn_ArrayAppend(data any, value any, pp pathWithPos, opts SetPathOpts) (any, error) {
258 if !checkAndModifyBudget(&opts, pp, 1) {

Callers 2

CombineFn_ArrayAppendFunction · 0.85
setPathInternalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected