refactor: replace .forEach()
with for-of
(#39691)
* refactor: replace `.forEach()` with `for-of` * refactor docs/fiddles/features/web-hid/renderer.js
This commit is contained in:
parent
7858921a1f
commit
0b0707145b
32 changed files with 144 additions and 132 deletions
|
@ -1,19 +1,10 @@
|
|||
async function testIt () {
|
||||
const grantedDevices = await navigator.hid.getDevices()
|
||||
let grantedDeviceList = ''
|
||||
grantedDevices.forEach(device => {
|
||||
grantedDeviceList += `<hr>${device.productName}</hr>`
|
||||
})
|
||||
document.getElementById('granted-devices').innerHTML = grantedDeviceList
|
||||
const grantedDevices2 = await navigator.hid.requestDevice({
|
||||
filters: []
|
||||
})
|
||||
function formatDevices (devices) {
|
||||
return devices.map(device => device.productName).join('<hr>')
|
||||
}
|
||||
|
||||
grantedDeviceList = ''
|
||||
grantedDevices2.forEach(device => {
|
||||
grantedDeviceList += `<hr>${device.productName}</hr>`
|
||||
})
|
||||
document.getElementById('granted-devices2').innerHTML = grantedDeviceList
|
||||
async function testIt () {
|
||||
document.getElementById('granted-devices').innerHTML = formatDevices(await navigator.hid.getDevices())
|
||||
document.getElementById('granted-devices2').innerHTML = formatDevices(await navigator.hid.requestDevice({ filters: [] }))
|
||||
}
|
||||
|
||||
document.getElementById('clickme').addEventListener('click', testIt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue