Skip to content

Commit

Permalink
refactor: remove lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
ambar committed Apr 12, 2024
1 parent d91af16 commit ae4b57c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/reiconify/lib/defaultConfig.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const pascalCase = require('pascal-case')
const {pascalCase} = require('pascal-case')

const template = (data) => {
if (data.native) {
Expand Down
4 changes: 2 additions & 2 deletions packages/reiconify/lib/resolveConfig.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const cosmiconfig = require('cosmiconfig')
const merge = require('lodash/merge')
const merge = require('concat-merge')
const pkg = require('../package.json')
const defaultConfig = require('./defaultConfig')

module.exports = async (cwd = process.cwd()) => {
const result = await cosmiconfig(pkg.name).load(cwd)
return merge({}, defaultConfig, result && result.config)
return merge(defaultConfig, result && result.config)
}
12 changes: 8 additions & 4 deletions packages/reiconify/lib/svg2jsx.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const svgo = require('svgo')
const hash = require('string-hash')
const JSON5 = require('json5')
const mapKeys = require('lodash/mapKeys')
const camelCase = require('lodash/camelCase')
// TODO: upgrade to ESM `change-case` package
const {camelCase} = require('camel-case')
const {pascalCase} = require('pascal-case')
const styleToObject = require('style-to-object')
const pascalCase = require('pascal-case')

const toCamelCase = (s) =>
s.replace(/([-_:])([a-z])/g, (s, a, b) => b.toUpperCase())
Expand Down Expand Up @@ -117,7 +117,11 @@ const defaults = {
}

const styleToJSXStyle = (style) => {
return JSON5.stringify(mapKeys(styleToObject(style), (v, k) => camelCase(k)))
return JSON5.stringify(
Object.fromEntries(
Object.entries(styleToObject(style)).map(([k, v]) => [camelCase(k), v])
)
)
}

const replaceInlineStyles = (svg) =>
Expand Down
5 changes: 3 additions & 2 deletions packages/reiconify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
"preset": "es-jest"
},
"dependencies": {
"camel-case": "^4.1.2",
"concat-merge": "^1.1.0",
"cosmiconfig": "^3.1.0",
"esbuild": "^0.8.34",
"fancy-log": "^1.3.0",
"fast-glob": "^3.2.12",
"json5": "^2.2.1",
"lodash": "^4.17.4",
"pascal-case": "^2.0.1",
"pascal-case": "^3.1.2",
"prettier": "^3.2.5",
"string-hash": "^1.1.3",
"style-to-object": "^0.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const pascalCase = require('pascal-case')
const {pascalCase} = require('pascal-case')

module.exports = {
filenameTemplate: (name) => `Md${pascalCase(name)}`,
Expand Down

0 comments on commit ae4b57c

Please sign in to comment.