opened
aik099
username_0
Currently the `WebMidi.getInputById` and `WebMidi.getOutputById` methods use exact match (the `===` operator), when comparing given input/output ID to discovered ones.

In theory that sounds perfect. However in real-life scenario usually we have some sort of UI (e.g. dropdown) for selecting MIDI device and then we use that dropdown to get ID of device, that user wants.

On the iPad the ID of an output device (but applies to input as well) looked like this:

```
-2112946881
```

Not sure why, but after storing inside `<option value="...">` or maybe due some other operation it was converted to string. The `WebMidi.getOutputById` no longer found desired MIDI device, because type wasn't matching.

I of course can do `parseInt` on the option's value, but I'm not 100% sure, that input/output ID will always be an integer.
Search inputs/outputs by id ignoring type
issue
created
djipco
username_1
As per the [Web MIDI API specification](https://www.w3.org/TR/webmidi/#widl-MIDIPort-id), the ID is required to be a string. This means the result you are getting is the normal behaviour. 

As a convenience, what I could do is call `toString()` on the parameter. In doing so, I just want to be sure I do not introduce further issues though...
comment
created
djipco
username_1
I made a [new release](https://github.com/username_1/webmidi/releases/tag/2.3.1) that introduces the changes discussed above. Please tell me if it works for you. Cheers.
comment
closed
djipco
username_1
issue
created
djipco
username_1
The `toString()` approach was working fine except in cases where `id` is `null` or `undefined`. That's why I changed it to `String(id)`.
comment
created
aik099
username_0
Ah, it's the other way around. Got it. Thanks. Will test in a few days.
comment