Add some String methods that the RapydScript compiler uses

This commit is contained in:
Kovid Goyal 2015-06-20 11:25:06 +05:30
parent cb34ffd380
commit 71b7a434fa

View File

@ -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='<eval>', noreturn=False):