diff options
Diffstat (limited to 'deps/v8/src/builtins/string-slice.tq')
-rw-r--r-- | deps/v8/src/builtins/string-slice.tq | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/deps/v8/src/builtins/string-slice.tq b/deps/v8/src/builtins/string-slice.tq index ea95d44a823..71442a28faa 100644 --- a/deps/v8/src/builtins/string-slice.tq +++ b/deps/v8/src/builtins/string-slice.tq @@ -3,33 +3,32 @@ // found in the LICENSE file. namespace string { - // ES6 #sec-string.prototype.slice ( start, end ) - // https://tc39.github.io/ecma262/#sec-string.prototype.slice - transitioning javascript builtin StringPrototypeSlice( - js-implicit context: NativeContext, - receiver: JSAny)(...arguments): String { - // 1. Let O be ? RequireObjectCoercible(this value). - // 2. Let S be ? ToString(O). - const string: String = ToThisString(receiver, 'String.prototype.slice'); +// ES6 #sec-string.prototype.slice ( start, end ) +// https://tc39.github.io/ecma262/#sec-string.prototype.slice +transitioning javascript builtin StringPrototypeSlice( + js-implicit context: NativeContext, receiver: JSAny)(...arguments): String { + // 1. Let O be ? RequireObjectCoercible(this value). + // 2. Let S be ? ToString(O). + const string: String = ToThisString(receiver, 'String.prototype.slice'); - // 3. Let len be the number of elements in S. - const length: uintptr = string.length_uintptr; + // 3. Let len be the number of elements in S. + const length: uintptr = string.length_uintptr; - // Convert {start} to a relative index. - const arg0 = arguments[0]; - const start: uintptr = - arg0 != Undefined ? ConvertToRelativeIndex(arg0, length) : 0; + // Convert {start} to a relative index. + const arg0 = arguments[0]; + const start: uintptr = + arg0 != Undefined ? ConvertToRelativeIndex(arg0, length) : 0; - // 5. If end is undefined, let intEnd be len; - // else Convert {end} to a relative index. - const arg1 = arguments[1]; - const end: uintptr = - arg1 != Undefined ? ConvertToRelativeIndex(arg1, length) : length; + // 5. If end is undefined, let intEnd be len; + // else Convert {end} to a relative index. + const arg1 = arguments[1]; + const end: uintptr = + arg1 != Undefined ? ConvertToRelativeIndex(arg1, length) : length; - if (end <= start) { - return kEmptyString; - } - - return SubString(string, start, end); + if (end <= start) { + return kEmptyString; } + + return SubString(string, start, end); +} } |