Skip to content

Commit 5e2a9e5

Browse files
committed
Remove lodash dependency
1 parent c59e0b9 commit 5e2a9e5

File tree

4 files changed

+34
-27
lines changed

4 files changed

+34
-27
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
React hook for logging per component lifecycle
2323

2424
## Features
25-
- 🪶 **Lightweight** — under *500B* gzipped
25+
- 🪶 **Lightweight** — under *1Kb* gzipped
2626
- 🗂️ **Typed** — made with TypeScript, ships with types
2727
- 🥰 **Simple** — don't worry about any changes in your props & state
2828
- 🔧 **Customizable** — work in progress 😉
2929
- 🔬 **Tested** — up to 100% coverage
3030
- 🏎️ **Fast** — native react hooks & optimized
31-
- 📭 **Minimal dependecies** — only some lodash functions
31+
- 📭 **No dependecies**
3232

3333

3434

package-lock.json

Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,5 @@
111111
"path": "dist/module.js",
112112
"limit": "1 kB"
113113
}
114-
],
115-
"dependencies": {
116-
"lodash": "^4.17.21"
117-
}
114+
]
118115
}

src/index.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import cloneDeep from 'lodash/cloneDeep'
21
import { useEffect, useRef } from 'react'
32

43
const CSS_COMPONENT = 'color: DodgerBlue'
@@ -23,23 +22,22 @@ export enum PrintTypes {
2322
}
2423

2524
export function useLog(): UseLogReturn {
26-
const componentName = (function getComponentName() {
27-
try {
28-
throw new Error()
29-
} catch (error) {
30-
if (error instanceof Error) {
31-
const re = /(\w+)@|at (\w+) \(/g
32-
33-
re.exec(error?.stack ?? '')
34-
re.exec(error?.stack ?? '')
35-
const m = re.exec(error?.stack ?? '') ?? []
36-
37-
return String(m[1] || m[2])
25+
const componentName =
26+
(function getComponentName() {
27+
try {
28+
throw new Error()
29+
} catch (error) {
30+
if (error instanceof Error) {
31+
const re = /(\w+)@|at (\w+) \(/g
32+
33+
re.exec(error?.stack ?? '')
34+
re.exec(error?.stack ?? '')
35+
const m = re.exec(error?.stack ?? '') ?? []
36+
37+
return String(m[1] || m[2])
38+
}
3839
}
39-
40-
return ''
41-
}
42-
})()
40+
})() ?? ''
4341

4442
const getGroupLabel = (type: PrintTypes): string => {
4543
return `${String(type)} ${
@@ -59,7 +57,7 @@ export function useLog(): UseLogReturn {
5957
}
6058

6159
function log<T>(value: T): void {
62-
const clonedValue = cloneDeep(value)
60+
const clonedValue = JSON.parse(JSON.stringify(value))
6361

6462
return (() => {
6563
const isUnmounting = useRef(false)

0 commit comments

Comments
 (0)