Skip to content

Commit

Permalink
Change Lodash map Methods to forOwn
Browse files Browse the repository at this point in the history
  • Loading branch information
casesandberg committed Mar 5, 2017
1 parent 8f69d06 commit 13bc8cb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"es2015",
"stage-0",
"react"
],
"plugins": [
"lodash"
]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
"devDependencies": {
"@case/eslint-config": "^0.1.4",
"babel": "^6.0.15",
"babel-cli": "^6.23.0",
"babel-core": "^6.1.2",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.0.1",
"babel-plugin-lodash": "^3.2.11",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"babel-preset-stage-0": "^6.1.18",
Expand Down
6 changes: 3 additions & 3 deletions src/autoprefix.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import map from 'lodash/map'
import _ from 'lodash'

const transforms = {
borderRadius: (value) => {
Expand Down Expand Up @@ -94,9 +94,9 @@ const transforms = {

export const autoprefix = (elements) => {
const prefixed = {}
map(elements, (styles, element) => {
_.forOwn(elements, (styles, element) => {
let expanded = {}
map(styles, (value, key) => {
_.forOwn(styles, (value, key) => {
const transform = transforms[key]
if (transform) {
expanded = { ...expanded, ...transform(value) }
Expand Down
8 changes: 3 additions & 5 deletions src/flattenNames.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import map from 'lodash/map'
import isPlainObject from 'lodash/isPlainObject'
import isString from 'lodash/isString'
import _ from 'lodash'

export const flattenNames = (things) => {
const names = []

things.map((thing) => {
Array.isArray(thing) && flattenNames(thing).map(name => names.push(name))
isPlainObject(thing) && map(thing, (value, key) => {
_.isPlainObject(thing) && _.forOwn(thing, (value, key) => {
value === true && names.push(key)
names.push(`${ key }-${ value }`)
})
isString(thing) && names.push(thing)
_.isString(thing) && names.push(thing)
return thing
})

Expand Down
7 changes: 3 additions & 4 deletions src/mergeClasses.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import map from 'lodash/map'
import cloneDeep from 'lodash/cloneDeep'
import _ from 'lodash'

export const mergeClasses = (classes, activeNames = []) => {
const styles = (classes.default && cloneDeep(classes.default)) || {}
const styles = (classes.default && _.cloneDeep(classes.default)) || {}
activeNames.map((name) => {
const toMerge = classes[name]
if (toMerge) {
map(toMerge, (value, key) => {
_.forOwn(toMerge, (value, key) => {
if (!styles[key]) {
styles[key] = {}
}
Expand Down

0 comments on commit 13bc8cb

Please sign in to comment.