clsx/lite spread

Benchmark created on


Setup

function clsx() {
	var i=0, tmp, str='', len=arguments.length;
	for (; i < len; i++) {
		if (tmp = arguments[i]) {
			if (typeof tmp === 'string') {
				str += (str && ' ') + tmp;
			}
		}
	}
	return str;
}

Test runner

Ready to run.

Testing in
TestOps/sec
clsx twice
var a = ['asdf', false, 'asdfasd', null, undefined, 'b'];

clsx(clsx(a), 'c', 'asdf', 'asd', null)
ready
spread
var a = ['asdf', false, 'asdfasd', null, undefined, 'b'];

clsx(...a, 'c', 'asdf', 'asd', null)
ready
All inline
clsx('asdf', false, 'asdfasd', null, undefined, 'b', 'c', 'asdf', 'asd', null)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.