MCPcopy Create free account
hub / github.com/araddon/qlbridge / stripEval

Function stripEval

expr/builtins/string.go:234–248  ·  view source on GitHub ↗
(ctx expr.EvalContext, vals []value.Value)

Source from the content-addressed store, hash-verified

232 return stripEval, nil
233}
234func stripEval(ctx expr.EvalContext, vals []value.Value) (value.Value, bool) {
235
236 switch val := vals[0].(type) {
237 case value.StringValue:
238 sv := strings.Trim(val.ToString(), " \n\t\r")
239 return value.NewStringValue(sv), true
240 case value.StringsValue:
241 svs := make([]string, val.Len())
242 for i, sv := range val.Val() {
243 svs[i] = strings.Trim(sv, " \n\t\r")
244 }
245 return value.NewStringsValue(svs), true
246 }
247 return nil, false
248}
249
250// Replace a string(s). Replace occurences of 2nd arg In first with 3rd.
251// 3rd arg "what to replace with" is optional

Callers

nothing calls this directly

Calls 5

NewStringValueFunction · 0.92
NewStringsValueFunction · 0.92
ToStringMethod · 0.65
LenMethod · 0.65
ValMethod · 0.45

Tested by

no test coverage detected