Return empty string when there are no arguments (#183)

This commit is contained in:
Kevin Mårtensson 2017-07-23 22:13:55 +02:00 committed by Sindre Sorhus
parent 5cdd9eddf8
commit e8d28f3041

View file

@ -152,7 +152,11 @@ function applyStyle() {
// Support varags, but simply cast to string in case there's only one arg
const args = arguments;
const argsLen = args.length;
let str = argsLen !== 0 && String(arguments[0]);
let str = String(arguments[0]);
if (argsLen === 0) {
return '';
}
if (argsLen > 1) {
// Don't slice `arguments`, it prevents V8 optimizations