1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 * Take any number of parameters and returns a space-concatenated string.
8 * If a parameter is a non-empty string, it's automatically added to the result.
9 * If a parameter is an object, for each entry, if the value is truthy, then the key
10 * is added to the result.
12 * For example: `classnames("hi", null, undefined, false, { foo: true, bar: false })` will
16 * @param {...string|object} argss
19 module.exports = function (...args) {
22 for (const arg of args) {
27 if (typeof arg == "string") {
28 className += " " + arg;
29 } else if (Object(arg) === arg) {
30 // We don't test that we have an Object literal, so we can be as fast as we can
31 for (const key in arg) {
33 className += " " + key;
39 return className.trim();