JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6151
  • Score
    100M100P100Q122566F
  • License MIT

A helper function to print strings of dynamic and optional classes

Package Exports

  • dynamic-class-list

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dynamic-class-list) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dynamic-class-list

Simple, fast module for extracting strings of dynamic and optional class list.

Features:

  • Support for string arguments.
  • Support Object syntax.
  • Supports array of strings.
  • Zero-dependency.
npm install dynamic-class-list

Then require it in your module ...

const getClassnames = require('dynamic-class-list');

API

Arguments as strings

const getClassnames = require('dynamic-class-list');

// As Arguments
getClassnames('class1', 'class2');

// Output : "class1 class2"

Arguments as an array of strings

const getClassnames = require('dynamic-class-list');

// As an Array
getClassnames(['class1', 'class2']);

// Output : "class1 class2"

Arguments as an object

Note that the key is used as the class if the value is truthy*\

const getClassnames = require('dynamic-class-list');

// As an Object
getClassnames({class1: true, class2 : false});

// Output : "class1"
const getClassnames = require('dynamic-class-list');

// As an Object
getClassnames({ 
    class1: function() { return false; },
    class2 : function() { return true; }
});

// Output : "class2"

Hybrid Arguments

const getClassnames = require('dynamic-class-list');

// As Everything
getClassnames('class1', 'class2', ['class3', 'class4'], { 
    class5 : function() { return false; },
    class6 : function() { return true; }
});

// Output : "class1 class2 class3 class4 class6"

Markdown generated from README_js.md by RunMD Logo