andreypopp / andreypopp/deps-topo-sort
Unpredictable sorting order with exposed modules
- Lingua principale
- JavaScript
- Stelle
- 5
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
When using `.require('./path/to/module', {expose: 'my-module'})` syntax module id becomes the 'my-module' string. It breaks the `cmp` function:
```js
function cmp (a, b) {
return a.id < b.id ? -1 : 1;
}
```
Which always returns `false`, when comparing String to a Number (other ids are numbers).
Proposed fix:
```js
function isString (o) {
return toString.call(o) === '[object String]'
}
function cmp (a, b) {
if (isString(a.id) && !isString(b.id))
return -1
if (!isString(a.id) && isString(b.id))
return 1
return a.id < b.id ? -1 : 1
}
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.