Skip to content

Commit 781964d

Browse files
committed
refactor: tweak the code and remove comments
1 parent b814e84 commit 781964d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import type { Properties } from 'csstype';
22

3-
const style = (node: HTMLElement, parameters: Properties<string | number>) => {
4-
function update (parameters: Properties<string | number>) {
3+
type Parameters = Properties<string | number>;
4+
5+
const style = (node: HTMLElement, parameters: Parameters) => {
6+
const setStyle = (parameters: Parameters) => {
57
Object.entries(parameters).forEach(([key, value]) => {
68
key = key.replace(/[A-Z]/, (substring) => '-' + substring.toLowerCase());
79

810
node.style.setProperty(key, value);
911
});
10-
}
12+
};
1113

12-
update(parameters); // invoked when component is first mounted
14+
setStyle(parameters);
1315

14-
return { update } // to be invoked whenever component is updated
16+
return { update: setStyle };
1517
};
1618

1719
export default style;

0 commit comments

Comments
 (0)