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

bem-react-helper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bem-react-helper - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

7

CHANGELOG.md

@@ -7,8 +7,13 @@ # Change Log

## [1.1.1] - 2017-06-30
### Fixed
- Faulty modification of the `props` object.
## [1.1.0] - 2017-06-29
### Added
- Support for numberic keys & values for modifiers.
- Support for numeric keys & values for modifiers.
## 1.0.0 - 2017-02-16
[1.1.1]: https://github.com/igoradamenko/bem-react-helper/compare/v1.1.0...v1.1.1
[1.1.0]: https://github.com/igoradamenko/bem-react-helper/compare/v1.0.0...v1.1.0

57

index.js
'use strict';
module.exports = function(name, props, defaultMods) {
if (!name) return '';
Object.defineProperty(exports, "__esModule", {
value: true
});
module.exports = b;
exports.default = b;
props = props || {};
defaultMods = defaultMods || {};
var mods = props.mods || {};
var mix = props.mix;
function b(name) {
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var defaultMods = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var result = [name];
var _props$mix = props.mix,
mix = _props$mix === undefined ? [] : _props$mix,
_props$mods = props.mods,
mods = _props$mods === undefined ? {} : _props$mods;
for (var key in defaultMods) {
if (!mods.hasOwnProperty(key)) mods[key] = defaultMods[key];
}
var addMod = function addMod(key, value) {
var mod = [name, camelToKebab(key)];
for (var key in mods) {
if (mods[key]) {
var mod = [name, camelToKebab(key)];
if (typeof value !== 'boolean') {
mod.push(camelToKebab(value));
}
if (typeof mods[key] !== 'boolean') {
mod.push(camelToKebab(mods[key]));
}
result.push(mod.join('_'));
};
result.push(mod.join('_'));
Object.keys(defaultMods).forEach(function (key) {
if (!mods.hasOwnProperty(key) && defaultMods[key]) {
addMod(key, defaultMods[key]);
}
}
});
Object.keys(mods).forEach(function (key) {
if (mods[key]) {
addMod(key, mods[key]);
}
});
if (mix) {
if (Array.isArray(mix)) {
mix.forEach(function(item) {
result.push(item);
});
} else {
result.push(mix);
}
result = result.concat(mix);
}
return result.join(' ');
};
}

@@ -42,0 +49,0 @@ function camelToKebab(str) {

{
"name": "bem-react-helper",
"version": "1.1.0",
"version": "1.1.1",
"description": "Allows you to easily manage BEM mods & mixes in React",
"main": "index.js",
"scripts": {
"test": "jasmine"
"dev": "nodemon --exec 'npm run test' --watch bem-react-helper.js --watch tests.js",
"build": "babel bem-react-helper.js -o index.js",
"pretest": "npm run build",
"test": "jasmine",
"prepublish": "npm run test && npm run build"
},
"babel": {
"presets": [
"env"
],
"plugins": [
"transform-object-rest-spread"
]
},
"repository": {

@@ -30,3 +42,7 @@ "type": "git",

"devDependencies": {
"jasmine": "^2.5.3"
"babel-cli": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.5.2",
"jasmine": "^2.5.3",
"nodemon": "^1.11.0"
},

@@ -33,0 +49,0 @@ "files": [

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