MCPcopy Create free account
hub / github.com/dop251/goja / arrayproto_toLocaleString

Method arrayproto_toLocaleString

builtin_array.go:268–297  ·  view source on GitHub ↗
(call FunctionCall)

Source from the content-addressed store, hash-verified

266}
267
268func (r *Runtime) arrayproto_toLocaleString(call FunctionCall) Value {
269 array := call.This.ToObject(r)
270
271 if r.pushToStringStack(array) {
272 // Circular reference detected, return empty string to avoid infinite recursion
273 return stringEmpty
274 }
275 defer r.popFromStringStack()
276
277 var buf StringBuilder
278 if a := r.checkStdArrayObj(array); a != nil {
279 for i, item := range a.values {
280 if i > 0 {
281 buf.WriteRune(',')
282 }
283 r.writeItemLocaleString(item, &buf)
284 }
285 } else {
286 length := toLength(array.self.getStr("length", nil))
287 for i := int64(0); i < length; i++ {
288 if i > 0 {
289 buf.WriteRune(',')
290 }
291 item := array.self.getIdx(valueInt(i), nil)
292 r.writeItemLocaleString(item, &buf)
293 }
294 }
295
296 return buf.String()
297}
298
299func isConcatSpreadable(obj *Object) bool {
300 spreadable := obj.self.getSym(SymIsConcatSpreadable, nil)

Callers

nothing calls this directly

Calls 11

pushToStringStackMethod · 0.95
popFromStringStackMethod · 0.95
checkStdArrayObjMethod · 0.95
WriteRuneMethod · 0.95
writeItemLocaleStringMethod · 0.95
StringMethod · 0.95
toLengthFunction · 0.85
valueIntTypeAlias · 0.85
ToObjectMethod · 0.65
getStrMethod · 0.65
getIdxMethod · 0.65

Tested by

no test coverage detected