Skip to content

Instantly share code, notes, and snippets.

@stucox
Created May 7, 2012 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stucox/2631190 to your computer and use it in GitHub Desktop.
Save stucox/2631190 to your computer and use it in GitHub Desktop.
Patch for pyjon to support Underscore.js
diff --git a/pyjon/interpr.py b/pyjon/interpr.py
index 5520d95..4c639b4 100644
--- a/pyjon/interpr.py
+++ b/pyjon/interpr.py
@@ -1467,6 +1467,11 @@ class array_proto(list, Prototype):
def pop(self): return list.pop(self)
@publicmethod
+ def sort(self, sortfn=None):
+ list.sort(self, sortfn)
+ return self
+
+ @publicmethod
def slice(this, s=0, i=None):
if i == None: i = len(this)
return array_proto(*this[s:i])
@@ -1518,6 +1523,7 @@ class Array(JS_Function):
def __getattr__(self, k):
if k == 'constructor': return array
elif k == '__proto__': return array_prototype
+ elif k == 'isArray': return isArray
else: Prototype.__getattr__(self, k)
def __newInstance__(self, *args):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment