Skip to content

Instantly share code, notes, and snippets.

@ronen-e
Last active September 17, 2016 22:45
Show Gist options
  • Select an option

  • Save ronen-e/f41173a35732c712322a3a7f2161ab44 to your computer and use it in GitHub Desktop.

Select an option

Save ronen-e/f41173a35732c712322a3a7f2161ab44 to your computer and use it in GitHub Desktop.
css classnames prefix factory
function prefixFactory(prefix) {
return function prefixer(string) {
return string.split(' ')
.map( s => prefix + s)
.join(' ');
};
}
export default prefixFactory;
import prefixFactory from 'prefix-factory';
var prefixer = prefixFactory('my-class-');
var className = 'one two three';
var prefixedClassName = prefixer(className);
console.log(prefixedClassName); // "my-class-one my-class-two my-class-three"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment