A filesystem `list` capability can lead to computational irreproducibility if the order of entries returned differs between invocations and implementations. It is better to sort the entries using a deterministic sort.
It may be tempting to try to author a "drop-in" replacement for some interface available in one host environment, but not available in the other. This is probably a bad idea. For example, if you really want to use a utility class `TextEncoder` which exists in some runtimes but not others, then avoid simply re-implementing `TextEncoder` and writing a multiplexed conditional to select whether to use the native implementation or the "softcoded" one. If you've already done the work to do the re-implementation and are paying the cost of carrying it around, and it truly is a acceptable implementation for use on platforms where it does not exist, then you should probably route execution through your softcoded implementation under all circumstances. Subtle, unintentional differences between implementations (or performance characteristics) can lead to irreproducibility.