def Js(val, Clamped=False):
if isinstance(val, PyJs):<EOL><INDENT>return val<EOL><DEDENT>elif val is None:<EOL><INDENT>return undefined<EOL><DEDENT>elif isinstance(val, basestring):<EOL><INDENT>return PyJsString(val, StringPrototype)<EOL><DEDENT>elif isinstance(val, bool):<EOL><INDENT>return true if val else false<EOL><DEDENT>elif isinstance(val, float) or isinstance(val, int) or isinstance(<EOL>val, long) or (NUMPY_AVAILABLE and isinstance(<EOL>val,<EOL>(numpy.int8, numpy.uint8, numpy.int16, numpy.uint16,<EOL>numpy.int32, numpy.uint32, numpy.float32, numpy.float64))):<EOL><INDENT>if val in NUM_BANK:<EOL><INDENT>return NUM_BANK[val]<EOL><DEDENT>return PyJsNumber(float(val), NumberPrototype)<EOL><DEDENT>elif isinstance(val, FunctionType):<EOL><INDENT>return PyJsFunction(val, FunctionPrototype)<EOL><DEDENT>elif isinstance(val, dict):  <EOL><INDENT>temp = PyJsObject({}, ObjectPrototype)<EOL>for k, v in six.iteritems(val):<EOL><INDENT>temp.put(Js(k), Js(v))<EOL><DEDENT>return temp<EOL><DEDENT>elif isinstance(val, (list, tuple)):  <EOL><INDENT>return PyJsArray(val, ArrayPrototype)<EOL><DEDENT>elif isinstance(val, JsObjectWrapper):<EOL><INDENT>return val.__dict__['<STR_LIT>']<EOL><DEDENT>elif NUMPY_AVAILABLE and isinstance(val, numpy.ndarray):<EOL><INDENT>if val.dtype == numpy.int8:<EOL><INDENT>return PyJsInt8Array(val, Int8ArrayPrototype)<EOL><DEDENT>elif val.dtype == numpy.uint8 and not Clamped:<EOL><INDENT>return PyJsUint8Array(val, Uint8ArrayPrototype)<EOL><DEDENT>elif val.dtype == numpy.uint8 and Clamped:<EOL><INDENT>return PyJsUint8ClampedArray(val, Uint8ClampedArrayPrototype)<EOL><DEDENT>elif val.dtype == numpy.int16:<EOL><INDENT>return PyJsInt16Array(val, Int16ArrayPrototype)<EOL><DEDENT>elif val.dtype == numpy.uint16:<EOL><INDENT>return PyJsUint16Array(val, Uint16ArrayPrototype)<EOL><DEDENT>elif val.dtype == numpy.int32:<EOL><INDENT>return PyJsInt32Array(val, Int32ArrayPrototype)<EOL><DEDENT>elif val.dtype == numpy.uint32:<EOL><INDENT>return PyJsUint16Array(val, Uint32ArrayPrototype)<EOL><DEDENT>elif val.dtype == numpy.float32:<EOL><INDENT>return PyJsFloat32Array(val, Float32ArrayPrototype)<EOL><DEDENT>elif val.dtype == numpy.float64:<EOL><INDENT>return PyJsFloat64Array(val, Float64ArrayPrototype)<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>return py_wrap(val)<EOL><DEDENT>
Converts Py type to PyJs type