Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions js2py/prototypes/jstypedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,25 @@ def reduceRight(callbackfn):
k -= 1
return accumulator

def subarray(begin, end):
return slice(begin, end)

def set(array, offset = 0):
offset = 0 if (offset.is_undefined() or offset.is_null()) else offset.to_int()
target = this.to_object()
target_len = target.get("length").to_uint32()
vals = to_arr(array)
vals_len = len(vals)

if offset + vals_len > target_len:
raise this.MakeError(
'RangeError', 'Trying to store values beyond target array length.')

n = 0
while n < vals_len:
this.put(str(n + offset), vals[n])
n += 1


def sort_compare(a, b, comp):
if a is None:
Expand Down