( declarator: Node, binding: Binding, module: SourceModule, kindOfKey: KindOfKey )
| 1871 | } |
| 1872 | |
| 1873 | private iteratedKindOf( |
| 1874 | declarator: Node, |
| 1875 | binding: Binding, |
| 1876 | module: SourceModule, |
| 1877 | kindOfKey: KindOfKey |
| 1878 | ): KindBits { |
| 1879 | const loop = declarator.parent?.parent |
| 1880 | if ( |
| 1881 | loop?.type !== "ForOfStatement" || |
| 1882 | loop.left !== declarator.parent || |
| 1883 | declarator.type !== "VariableDeclarator" |
| 1884 | ) |
| 1885 | return kinds.data |
| 1886 | const iterated = this.literalOf(loop.right, module, kindOfKey) |
| 1887 | // each element, so a pattern destructures what it holds |
| 1888 | if ( |
| 1889 | iterated?.node.type === "ArrayExpression" && |
| 1890 | iterated.node.elements.every(element => element?.type !== "SpreadElement") |
| 1891 | ) { |
| 1892 | let result = 0 |
| 1893 | for (const element of iterated.node.elements) { |
| 1894 | if (!element) continue |
| 1895 | const source = { ...iterated, node: element } |
| 1896 | result |= this.patternKindOf( |
| 1897 | binding.id, |
| 1898 | declarator.id, |
| 1899 | this.transfer(element, iterated.module, iterated.kindOfKey), |
| 1900 | module, |
| 1901 | kindOfKey, |
| 1902 | source |
| 1903 | ) |
| 1904 | } |
| 1905 | return result |
| 1906 | } |
| 1907 | const element = |
| 1908 | iterated?.node.type === "ArrayExpression" ? |
| 1909 | this.heldKindOf(iterated) |
| 1910 | : memberKindOf(this.transfer(loop.right, module, kindOfKey), undefined) |
| 1911 | return this.patternKindOf( |
| 1912 | binding.id, |
| 1913 | declarator.id, |
| 1914 | element, |
| 1915 | module, |
| 1916 | kindOfKey |
| 1917 | ) |
| 1918 | } |
| 1919 | |
| 1920 | // e.g. `A | B` for `t` given `f(A)` and `f(B)`, or any if `f` escapes |
| 1921 | private paramKindOf( |
no test coverage detected