| 1413 | } |
| 1414 | |
| 1415 | static bool array_flat(JSContext *cx, unsigned argc, JS::Value *vp) { |
| 1416 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
| 1417 | |
| 1418 | JS::RootedObject proxy(cx, JS::ToObject(cx, args.thisv())); |
| 1419 | if (!proxy) { |
| 1420 | return false; |
| 1421 | } |
| 1422 | PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot); |
| 1423 | |
| 1424 | Py_ssize_t sourceLen = PyList_GET_SIZE(self); |
| 1425 | |
| 1426 | uint32_t depthNum; |
| 1427 | if (args.length() > 0) { |
| 1428 | depthNum = args[0].get().toInt32(); |
| 1429 | } |
| 1430 | else { |
| 1431 | depthNum = 1; |
| 1432 | } |
| 1433 | |
| 1434 | JSObject *retArray = JS::NewArrayObject(cx, sourceLen); // min end length |
| 1435 | |
| 1436 | FlattenIntoArray(cx, retArray, self, sourceLen, 0, depthNum); |
| 1437 | |
| 1438 | args.rval().setObject(*retArray); |
| 1439 | return true; |
| 1440 | } |
| 1441 | |
| 1442 | static bool array_flatMap(JSContext *cx, unsigned argc, JS::Value *vp) { |
| 1443 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
nothing calls this directly
no test coverage detected