Notorious Penguin Magicians
    Have ideas to improve npm?Join in the discussion! »

    @kikiki_kiki/class-names

    1.0.0 • Public • Published

    NPM version Build Status Coverage Status MIT License

    classNames

    classNames is a simple modulem, which returns classnames string with merged arguments.

    install

    $ npm install @kikiki_kiki/class-names
    import classNames from '@kikiki_kiki/class-names';

    useage

    classNames() return merged arguments.

    classNames('foo');
    // => "foo"
     
    classNames('foo', 'bar');
    // => "foo bar"
     
    classNames('foo', 'bar', 'baz');
    // => "foo bar baz"
     
    classNames('foo', 'bar', 'foo');
    // => "foo bar"

    classNames() return Number to String

    classNames(1, 0, -1, 1.2, -2.3);
    // => "1 0 -1 1.2 -2.3"

    classNames() ignore null, undefined, NaN, Boolean

    classNames(null, undefined, NaN, true, false);
    // => ""

    Array arguments

    classNames map array value to class name strings

    classNames([]);
    // => ""
     
    classNames(['foo', 'bar', 'baz']);
    // => "foo bar baz"
     
    classNames('foo', ['bar', 'baz', 'foo']);
    // => "foo bar baz"
     
    classNames(['foo', 0, 'bar', null], ['baz', 1, 'foo']);
    // => "foo 0 bar baz 1"

    Nested Array arguments

    classNames(['foo', ['bar', 'baz'], 'bar']);
    // => "foo bar baz"
     
    classNames(['foo', ['bar', 'baz'], 'bar'], [0, [1, 3], 2, 3]);
    // => "foo bar baz 0 1 3 2"

    Object arguments

    classNames return true values key as a class name.

    classNames({
      foo: true,
      bar: false,
      baz: true,
    });
    // => "foo baz"
     
    classNames('baz', {
      foo: true,
      bar: false,
      baz: true
    });
    // => "baz foo"
     
    classNames(['foo', 'bar', {
      foo: true,
      bar: false,
      baz: true
    });
    // => "foo bar baz"

    When argument is Function (Object).

    classNames( function() {return "foo"} );
    // => ""
     
    classNames( (function() { return "foo" })() );
    // => "foo"

    When argument is RegExp Object.

    classNames(/ab+c/i);
    // => ""
     
    const regex = new RegExp(/ab+c/, 'i');
    classNames(regex);
    // => ""

    Install

    npm i @kikiki_kiki/class-names

    DownloadsWeekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    15 kB

    Total Files

    9

    Last publish

    Collaborators

    • avatar