[gjs/april-maintenance: 2/11] js: Replace trimLeft and trimRight with trimStart and trimEnd



commit b429587199750e941929a5356ac68df8434aed09
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Apr 5 22:41:29 2020 -0700

    js: Replace trimLeft and trimRight with trimStart and trimEnd
    
    Starting with SpiderMonkey 68, the standards-compliant trimStart() and
    trimEnd() replace the old trimLeft() and trimRight().

 modules/core/overrides/GLib.js        | 12 ++++--------
 modules/script/_bootstrap/debugger.js |  6 +++---
 2 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/modules/core/overrides/GLib.js b/modules/core/overrides/GLib.js
index 5e8e9cdb..b6073d56 100644
--- a/modules/core/overrides/GLib.js
+++ b/modules/core/overrides/GLib.js
@@ -419,17 +419,13 @@ function _init() {
     };
 
     this.strchug = function (string) {
-        // COMPAT: replace with trimStart() in mozjs68
-        _warnNotIntrospectable('GLib.strchug()',
-            'String.trimLeft() until SpiderMonkey 68, then String.trimStart()');
-        return string.trimLeft();
+        _warnNotIntrospectable('GLib.strchug()', 'String.trimStart()');
+        return string.trimStart();
     };
 
     this.strchomp = function (string) {
-        // COMPAT: replace with trimEnd() in mozjs68
-        _warnNotIntrospectable('GLib.strchomp()',
-            'String.trimRight() until SpiderMonkey 68, then String.trimEnd()');
-        return string.trimRight();
+        _warnNotIntrospectable('GLib.strchomp()', 'String.trimEnd()');
+        return string.trimEnd();
     };
 
     // g_strstrip() is a macro and therefore doesn't even appear in the GIR
diff --git a/modules/script/_bootstrap/debugger.js b/modules/script/_bootstrap/debugger.js
index ed407cab..6538feeb 100644
--- a/modules/script/_bootstrap/debugger.js
+++ b/modules/script/_bootstrap/debugger.js
@@ -233,7 +233,7 @@ function splitPrintOptions(s, style) {
         style.pretty = true;
     if (m[1].startsWith('b'))
         style.brief = true;
-    return [s.substr(m[0].length).trimLeft(), style];
+    return [s.substr(m[0].length).trimStart(), style];
 }
 
 function doPrint(expr, style) {
@@ -749,9 +749,9 @@ PARAMETERS
 //   print/b x       => ['print', '/b x']
 //
 function breakcmd(cmd) {
-    cmd = cmd.trimLeft();
+    cmd = cmd.trimStart();
     if ("!@#$%^&*_+=/?.,<>:;'\"".includes(cmd.substr(0, 1)))
-        return [cmd.substr(0, 1), cmd.substr(1).trimLeft()];
+        return [cmd.substr(0, 1), cmd.substr(1).trimStart()];
     var m = /\s+|(?=\/)/.exec(cmd);
     if (m === null)
         return [cmd, ''];


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]