[gjs] format.printf(): New API



commit 2166fe92b4a26938f5ca7812a5865b5af9a4b435
Author: Colin Walters <walters verbum org>
Date:   Tue Dec 4 17:39:31 2012 -0500

    format.printf(): New API
    
    While writing an app, I kept finding myself doing:
    
    print(format.vprintf("%s %s", [arg1, arg2]))
    
    So this lets me do just:
    
    format.printf("%s %s", arg1, arg2)
    
    which is obviously way better.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689664

 modules/format.js |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/modules/format.js b/modules/format.js
index bf3d0a7..430b5d7 100644
--- a/modules/format.js
+++ b/modules/format.js
@@ -64,6 +64,11 @@ function vprintf(str, args) {
     });
 }
 
+function printf() {
+    let args = Array.prototype.slice.call(arguments);
+    let fmt = args.shift();
+    print(vprintf(fmt, args));
+}
 
 /*
  * This function is intended to extend the String object and provide


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