npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bemcn

v1.0.3

Published

bemcn is an utility for creating BEM class names.

Downloads

1

Readme

view on npm npm module downloads Build Status Coverage Status Dependency Status Join the chat at https://gitter.im/bemcn

bemcn

bemcn is an utility for creating BEM class names.

Explanation

var bc = bemcn('__', '--');

bc('b')()()             // b
bc('b')()('m')          // b--m
bc('b')()('m', true)    // b b--m
bc('b')('e')()          // b__e
bc('b')('e')('m')       // b__e--m
bc('b')('e')('m', true) // b__e b__e--m
var bc = bemcn('__', '--', true);

bc('b')()()              // b
bc('b')()('m', false)    // b--m
bc('b')()('m')           // b b--m
bc('b')('e')()           // b__e
bc('b')('e')('m', false) // b__e--m
bc('b')('e')('m')        // b__e b__e--m

Install

$ npm install --save bemcn

Usage

Browser

<script src="path/to/bemcn.js"></script>
<script>
    var bcn = bemcn('__', '--');
    bcn('block')('element')('modifier');
</script>

AMD

requirejs(['path/to/bemcn'], function(bemcn) {
    var bcn = bemcn('__', '--');
    bcn('block')('element')('modifier');
});

Node.js

var bemcn = require('bemcn');
var bcn = bemcn('__', '--');
bcn('block')('element')('modifier');

Functions

bemcn(ep, mp, [wbd]) ⇒ b

BEM class names

Kind: global function
Returns: b - - block creator

| Param | Type | Description | | --- | --- | --- | | ep | string | element prefix | | mp | string | modifier prefix | | [wbd] | boolean | with base class name (default value) |

b(v) ⇒ e

block creator

Kind: global function
Returns: e - - element creator

| Param | Type | Description | | --- | --- | --- | | v | string | block name |

e([v]) ⇒ m

element creator

Kind: global function
Returns: m - - modifier and result creator

| Param | Type | Description | | --- | --- | --- | | [v] | string | element name |

m([v], [wb]) ⇒ string

modifier and result creator

Kind: global function
Returns: string - - result

| Param | Type | Description | | --- | --- | --- | | [v] | string | modifier name | | [wb] | boolean | with base class name (default wbd) |

Example

var bcn = bemcn('__', '--', true);
var form = bcn('form');
var field = form('field');
var label = form('label');

form()('inline') // form form--inline
field()          // form__field
field('error')   // form__field form__field--error
label()          // form__label
label('hidden')  // form__label form__label--hidden

Note on Patches/Pull Requests

  1. Fork the project.
  2. Make your feature addition or bug fix.
  3. Send me a pull request.

© 2017 Vasily Shilov