(call FunctionCall)
| 680 | } |
| 681 | |
| 682 | func (r *Runtime) stringproto_replace(call FunctionCall) Value { |
| 683 | r.checkObjectCoercible(call.This) |
| 684 | searchValue := call.Argument(0) |
| 685 | replaceValue := call.Argument(1) |
| 686 | if _, ok := searchValue.(*Object); ok { |
| 687 | if replacer := toMethod(r.getV(searchValue, SymReplace)); replacer != nil { |
| 688 | return replacer(FunctionCall{ |
| 689 | This: searchValue, |
| 690 | Arguments: []Value{call.This, replaceValue}, |
| 691 | }) |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | s := call.This.toString() |
| 696 | var found []regexpResult |
| 697 | searchStr := searchValue.toString() |
| 698 | pos := s.index(searchStr, 0) |
| 699 | if pos != -1 { |
| 700 | found = append(found, regexpResult{indexes: []int{pos, pos + searchStr.Length()}}) |
| 701 | } |
| 702 | |
| 703 | str, rcall := getReplaceValue(replaceValue) |
| 704 | return r.stringReplace(s, found, str, rcall) |
| 705 | } |
| 706 | |
| 707 | func (r *Runtime) stringproto_replaceAll(call FunctionCall) Value { |
| 708 | r.checkObjectCoercible(call.This) |
nothing calls this directly
no test coverage detected