(Context cx, VarScope scope, Scriptable source, double depth)
| 1864 | } |
| 1865 | |
| 1866 | private static Scriptable flat(Context cx, VarScope scope, Scriptable source, double depth) { |
| 1867 | long length = getLengthProperty(cx, source); |
| 1868 | |
| 1869 | Scriptable result; |
| 1870 | result = ArrayLikeAbstractOperations.arraySpeciesCreate(cx, scope, source, 0); |
| 1871 | long j = 0; |
| 1872 | for (long i = 0; i < length; i++) { |
| 1873 | Object elem = getRawElem(source, i); |
| 1874 | if (elem == Scriptable.NOT_FOUND) { |
| 1875 | continue; |
| 1876 | } |
| 1877 | if (depth >= 1 && js_isArray(elem)) { |
| 1878 | Scriptable arr = flat(cx, scope, (Scriptable) elem, depth - 1); |
| 1879 | long arrLength = getLengthProperty(cx, arr); |
| 1880 | for (long k = 0; k < arrLength; k++) { |
| 1881 | Object temp = getRawElem(arr, k); |
| 1882 | defineElemOrThrow(cx, result, j++, temp); |
| 1883 | } |
| 1884 | } else { |
| 1885 | defineElemOrThrow(cx, result, j++, elem); |
| 1886 | } |
| 1887 | } |
| 1888 | setLengthProperty(cx, result, j); |
| 1889 | return result; |
| 1890 | } |
| 1891 | |
| 1892 | private static Object js_flatMap( |
| 1893 | Context cx, JSFunction f, Object nt, VarScope s, Object thisObj, Object[] args) { |
no test coverage detected