Skip to content

Commit

Permalink
async/customAlphabet - ensure browser version returns Promise (#229)
Browse files Browse the repository at this point in the history
To ensure consistency in the functions exported by async/browser.index
and to not catch out users expecting a Thenable returned by functions
claimed to be async, ensure that the final value returned by 
`customAlphabet()` is a Promise resolving to the value, not the value
itself
  • Loading branch information
LoneRifle committed Jul 27, 2020
1 parent 5282c5a commit 1530b7d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion async/index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let customAlphabet = (alphabet, size) => {
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
id += alphabet[bytes[i] & mask] || ''
// `id.length + 1 === size` is a more compact option.
if (id.length === +size) return id
if (id.length === +size) return Promise.resolve(id)
}
}
}
Expand Down

0 comments on commit 1530b7d

Please sign in to comment.