From 9b6ae6d5fea407fc6cc8c8fbd93ef05db2e17946 Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Mon, 30 Mar 2026 11:31:17 +0200 Subject: [PATCH] Fix accumulating spread in transform function Spread syntax should be avoided on accumulators (like those in `.reduce`) because it causes a time complexity of `O(n^2)`. --- .changeset/calm-clocks-battle.md | 5 +++++ src/index.ts | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .changeset/calm-clocks-battle.md diff --git a/.changeset/calm-clocks-battle.md b/.changeset/calm-clocks-battle.md new file mode 100644 index 0000000..eb6c8e6 --- /dev/null +++ b/.changeset/calm-clocks-battle.md @@ -0,0 +1,5 @@ +--- +'css-to-react-native': patch +--- + +Refactor transform to avoid accumulator-based object merging. diff --git a/src/index.ts b/src/index.ts index dc6be3b..31c0612 100644 --- a/src/index.ts +++ b/src/index.ts @@ -105,15 +105,20 @@ export const getPropertyName = (propName: string): string => { const transform = ( rules: StyleTuple[], shorthandBlacklist: string[] = [] -): Style => - rules.reduce