clsx
clsx copied to clipboard
Feature: clsx.arr() to return class names in array format
Motivation
When using it in Svelte attachments that apply classes imperatively using element.classList.add|remove, we need the list of classes in array format. Surely one can do clsx(...).split(' ').filter(x => x.trim().length > 0), but this adds an extra loop that can potentially be avoided.
Proposal
A new function, clsx.arr() or whatever people like best that returns the calculations in array format, with one CSS class per array slot.
I can PR this if approved.