Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bem-names

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bem-names - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

rollup.config.js

8

CHANGELOG.md

@@ -0,1 +1,9 @@

### 1.3.0
* Update README.md
* Update packages
* Bundle the library as [UMD](https://github.com/umdjs/umd) with [rollup](https://github.com/rollup/rollup)
* Clean and unify packages, those provided by npm are the same as those from cdn
* FIX: remove undocumented `bemNamesEnums` and restore `StringModifiers` and `StylesPolicy`
### 1.2.0

@@ -2,0 +10,0 @@

347

dist/bem-names.js

@@ -1,110 +0,7 @@

(function(e, a) { for(var i in a) e[i] = a[i]; }(this, /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.window = global.window || {})));
}(this, (function (exports) { 'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.bemNamesEnums = exports.bemNamesFactory = exports.customBemNames = exports.bemNames = undefined;
var _bemNames = __webpack_require__(1);
var bemNamesEnums = {
StringModifiers: _bemNames.StringModifiers,
StylesPolicy: _bemNames.StylesPolicy
};
_bemNames.bemNames.factory = _bemNames.bemNamesFactory;
_bemNames.bemNames.custom = _bemNames.customBemNames;
_bemNames.bemNames.StringModifiers = _bemNames.StringModifiers;
_bemNames.bemNames.StylesPolicy = _bemNames.StylesPolicy;
exports.bemNames = _bemNames.bemNames;
exports.customBemNames = _bemNames.customBemNames;
exports.bemNamesFactory = _bemNames.bemNamesFactory;
exports.bemNamesEnums = bemNamesEnums;
exports.default = _bemNames.bemNames;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -114,10 +11,2 @@

exports.bemNames = bemNames;
exports.bemNamesFactory = bemNamesFactory;
exports.customBemNames = customBemNames;
exports.customBemNamesInner = customBemNamesInner;
exports.applyMods = applyMods;
exports.applyStyles = applyStyles;
exports.extractModifiers = extractModifiers;
exports.defaultParseModifier = defaultParseModifier;
/*

@@ -129,3 +18,3 @@ Copyright (C) 2016 Piotr Tomasz Monarski.

var StringModifiers = exports.StringModifiers = {
var StringModifiers = {
WARN: 'warn',

@@ -136,3 +25,3 @@ ALLOW: 'allow',

var StylesPolicy = exports.StylesPolicy = {
var StylesPolicy = {
WARN: 'warn',

@@ -142,3 +31,3 @@ IGNORE: 'ignore'

var defaultConfig = exports.defaultConfig = {
var defaultConfig = {
separators: { element: '__', modifier: '--', keyValue: '-' },

@@ -155,3 +44,3 @@ states: {},

function bemNames() {
function bemNames$1() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

@@ -319,211 +208,17 @@ args[_key] = arguments[_key];

}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)))
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
bemNames$1.factory = bemNamesFactory;
bemNames$1.custom = customBemNames;
bemNames$1.StringModifiers = StringModifiers;
bemNames$1.StylesPolicy = StylesPolicy;
"use strict";
exports.bemNames = bemNames$1;
exports.customBemNames = customBemNames;
exports.bemNamesFactory = bemNamesFactory;
exports.StringModifiers = StringModifiers;
exports.StylesPolicy = StylesPolicy;
exports['default'] = bemNames$1;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, "__esModule", {
value: true
});
var _ = __webpack_require__(0);
Object.defineProperty(exports, 'bemNames', {
enumerable: true,
get: function get() {
return _.bemNames;
}
});
/***/ }),
/* 3 */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ })
/******/ ])));
})));

@@ -1,1 +0,1 @@

!function(e,r){for(var t in r)e[t]=r[t]}(this,function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var t={};return r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=2)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.bemNamesEnums=r.bemNamesFactory=r.customBemNames=r.bemNames=void 0;var n=t(1),o={StringModifiers:n.StringModifiers,StylesPolicy:n.StylesPolicy};n.bemNames.factory=n.bemNamesFactory,n.bemNames.custom=n.customBemNames,n.bemNames.StringModifiers=n.StringModifiers,n.bemNames.StylesPolicy=n.StylesPolicy,r.bemNames=n.bemNames,r.customBemNames=n.customBemNames,r.bemNamesFactory=n.bemNamesFactory,r.bemNamesEnums=o,r.default=n.bemNames},function(e,r,t){"use strict";function n(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];return s(d,r[0],r.slice(1))}function o(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=y({},d,r,{separators:y({},d.separators,r.separators)});return t.bemLike&&!f(e)&&console.error('block name: "'+e+'" is not a string'),function(){for(var r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];return s(t,e,n)}}function i(e,r){for(var t=y({},d,e,{separators:y({},d.separators,e.separators)}),n=arguments.length,o=Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];return s(t,r,o)}function s(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e.bemLike&&f(t[0])){return a(e,r+e.separators.element+t.shift(),t)}return e.bemLike?a(e,r,t):a(e,void 0,[r].concat(t))}function a(e,r,t){var n=e.bemLike,o=e.parseModifier,i=e.joinWith,s=e.stringModifiers,a=e.styles,m=e.stylesPolicy,l=t,y=[];n&&s===p.PASS_THROUGH&&(y=t.filter(f));var b=l.reduce(c(e),[]),d=b,v=d;return n&&(d=d.map(function(t){return o(e,r,t)}),v=[r].concat(d,y)),void 0!=a&&(v=u(v,a,m)),v.join(i)}function u(e,r,t){if(t===b.WARN){var n=function(e,t){return t in r&&e.push(r[t]),e};return e.reduce(n,[])}var o=(b.WARN,function(e,t){return t in r?e.push(r[t])&&e:e});return e.reduce(o,[])}function c(e){var r=e.separators.keyValue;return function(t,n){if(Array.isArray(n))return t.concat(n);if("object"==(void 0===n?"undefined":l(n))&&null!==n){var o=function(e){return!!n[e]&&t.push(e)};return e.bemLike&&e.keyValue&&(o=function(e){var o=n[e];!0===o?t.push(e):o&&t.push(e+r+o)}),Object.keys(n).forEach(o),t}e.stringModifiers,p.WARN;return e.bemLike,e.bemLike&&e.stringModifiers!=p.ALLOW||t.push(n),t}}function f(e){return"string"==typeof e||e instanceof String}function m(e,r,t){return t in e.states?e.states[t]:r+e.separators.modifier+t}Object.defineProperty(r,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e};r.bemNames=n,r.bemNamesFactory=o,r.customBemNames=i,r.customBemNamesInner=s,r.applyMods=a,r.applyStyles=u,r.extractModifiers=c,r.defaultParseModifier=m;var p=r.StringModifiers={WARN:"warn",ALLOW:"allow",PASS_THROUGH:"passThrough"},b=r.StylesPolicy={WARN:"warn",IGNORE:"ignore"},d=r.defaultConfig={separators:{element:"__",modifier:"--",keyValue:"-"},states:{},styles:void 0,stylesPolicy:b.WARN,joinWith:" ",bemLike:!0,keyValue:!1,stringModifiers:p.WARN,parseModifier:m}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(0);Object.defineProperty(r,"bemNames",{enumerable:!0,get:function(){return n.bemNames}})}]));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.window=e.window||{})}(this,function(e){"use strict";function r(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return o(p,r[0],r.slice(1))}function n(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=f({},p,r,{separators:f({},p.separators,r.separators)});return n.bemLike&&!u(e)&&console.error('block name: "'+e+'" is not a string'),function(){for(var r=arguments.length,t=Array(r),i=0;i<r;i++)t[i]=arguments[i];return o(n,e,t)}}function t(e,r){for(var n=f({},p,e,{separators:f({},p.separators,e.separators)}),t=arguments.length,i=Array(t>2?t-2:0),s=2;s<t;s++)i[s-2]=arguments[s];return o(n,r,i)}function o(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return e.bemLike&&u(n[0])?i(e,r+e.separators.element+n.shift(),n):e.bemLike?i(e,r,n):i(e,void 0,[r].concat(n))}function i(e,r,n){var t=e.bemLike,o=e.parseModifier,i=e.joinWith,c=e.stringModifiers,f=e.styles,y=e.stylesPolicy,p=n,d=[];t&&c===l.PASS_THROUGH&&(d=n.filter(u));var m=p.reduce(a(e),[]),v=m;return t&&(m=m.map(function(n){return o(e,r,n)}),v=[r].concat(m,d)),void 0!=f&&(v=s(v,f,y)),v.join(i)}function s(e,r,n){if(n===y.WARN){return e.reduce(function(e,n){return n in r?e.push(r[n]):"production"!==process.env.NODE_ENV&&console.warn("Key "+n+" is missing in styles"),e},[])}n!==y.WARN&&"production"!==process.env.NODE_ENV&&console.warn('StylePolicy: "'+n+'" has invalid value');return e.reduce(function(e,n){return n in r?e.push(r[n])&&e:e},[])}function a(e){var r=e.separators.keyValue;return function(n,t){if(Array.isArray(t))return n.concat(t);if("object"==(void 0===t?"undefined":c(t))&&null!==t){var o=function(e){return!!t[e]&&n.push(e)};return e.bemLike&&e.keyValue&&(o=function(e){var o=t[e];!0===o?n.push(e):o&&n.push(e+r+o)}),Object.keys(t).forEach(o),n}var i=e.stringModifiers==l.WARN;return e.bemLike&&i&&"production"!==process.env.NODE_ENV?(console.warn('Provided modifier "'+t+'" is now allowed!'),n):(e.bemLike&&e.stringModifiers!=l.ALLOW||n.push(t),n)}}function u(e){return"string"==typeof e||e instanceof String}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},l={WARN:"warn",ALLOW:"allow",PASS_THROUGH:"passThrough"},y={WARN:"warn",IGNORE:"ignore"},p={separators:{element:"__",modifier:"--",keyValue:"-"},states:{},styles:void 0,stylesPolicy:y.WARN,joinWith:" ",bemLike:!0,keyValue:!1,stringModifiers:l.WARN,parseModifier:function(e,r,n){return n in e.states?e.states[n]:r+e.separators.modifier+n}};r.factory=n,r.custom=t,r.StringModifiers=l,r.StylesPolicy=y,e.bemNames=r,e.customBemNames=t,e.bemNamesFactory=n,e.StringModifiers=l,e.StylesPolicy=y,e.default=r,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "bem-names",
"version": "1.2.0",
"version": "1.3.0",
"description": "Advanced generator of BEM-like class names",
"main": "lib/index.js",
"main": "dist/bem-names.js",
"scripts": {
"test": "mocha --compilers js:babel-register './test/test.js'",
"test": "NODE_ENV='test' mocha --compilers js:babel-register './test/test.js'",
"speed": "node ./test/speed.js",
"build": "babel src --out-dir lib; webpack",
"build": "rollup -c; NODE_ENV='production' rollup -c",
"lint": "eslint ."

@@ -33,3 +33,3 @@ },

"babel-cli": "6.24.1",
"babel-core": "6.24.1",
"babel-core": "6.25.0",
"babel-preset-es2015": "6.24.1",

@@ -41,8 +41,12 @@ "babel-preset-stage-3": "6.24.1",

"bem-cn": "2.1.3",
"chai": "3.5.0",
"chai": "4.0.2",
"classnames": "2.2.5",
"eslint": "3.19.0",
"mocha": "3.4.1",
"webpack": "2.5.1"
"eslint": "4.0.0",
"mocha": "3.4.2",
"rollup": "0.43.0",
"rollup-plugin-babel": "2.7.1",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-replace": "1.1.1",
"rollup-plugin-uglify": "2.0.1"
}
}

@@ -17,3 +17,2 @@ # bemNames

```
Or use it directly with [secondary api](#secondary-api)
```html

@@ -55,3 +54,3 @@ <script src="https://cdn.jsdelivr.net/npm/bem-names/dist/bem-names.min.js"></script>

With secondary API:
With [secondary API](#secondary-api):

@@ -63,3 +62,3 @@ ```js

'custom-block'
{ stringModifiers: bemNames.StringModifiers.PASS_THROUGH },
{ stringModifiers: 'passThrough' },
);

@@ -126,4 +125,4 @@

|bem-classname | 13ms | 11ms |
|bem-classanmes | 72ms | 11ms |
|bem-cn | 23ms | 12ms |
|bem-classanmes | 101ms | 13ms |
|bem-cn | 23ms | 26ms |
|classnames | 3ms | 7ms |

@@ -130,0 +129,0 @@

@@ -184,1 +184,3 @@ /*

}
export default bemNames;

@@ -9,7 +9,2 @@ import {

const bemNamesEnums = {
StringModifiers,
StylesPolicy,
};
bemNames.factory = bemNamesFactory;

@@ -24,5 +19,6 @@ bemNames.custom = customBemNames;

bemNamesFactory,
bemNamesEnums,
StringModifiers,
StylesPolicy,
};
export default bemNames;

@@ -7,3 +7,3 @@ /* eslint-disable max-len */

const bemClassnames = require('bem-classnames');
const dist = require('../lib');
const dist = require('../dist/bem-names.min');

@@ -10,0 +10,0 @@ const runCount = 10 * 1000;

/* eslint-env mocha */
import { assert } from 'chai';
import {
const { assert } = require('chai');
const {
defaultConfig,

@@ -15,3 +15,3 @@ StringModifiers,

bemNames,
} from '../src/bem-names';
} = require('../src/bem-names');

@@ -18,0 +18,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc