diff --git a/src/duktape/__init__.py b/src/duktape/__init__.py index 9a81a34ca6..b414d813a0 100644 --- a/src/duktape/__init__.py +++ b/src/duktape/__init__.py @@ -95,9 +95,10 @@ class Context(object): self.g.Duktape.readfile = readfile self.eval(''' console = { log: function() { print(Array.prototype.join.call(arguments, ' ')); } }; - Duktape.modSearch = function (id, require, exports, module) { - return Duktape.load_file(id); - } + Duktape.modSearch = function (id, require, exports, module) { return Duktape.load_file(id); } + String.prototype.trimLeft = function() { return this.replace(/^\s+/, ''); }; + String.prototype.trimRight = function() { return this.replace(/\s+$/, ''); }; + String.prototype.trim = function() { return this.replace(/^\s+/, '').replace(/\s+$/, ''); }; ''') def eval(self, code='', fname='', noreturn=False):