Try to interpret this code:
const [,startOfPP,,log] = jobList.reduce(
([acu, pp, prev, ppPrev], cur) =>
[
[...acu, cur]
,
cur.type === EVENT_TYPE.postProcess && prev.type !== EVENT_TYPE.postProcess
? cur
: pp
,
cur
,
[...ppPrev, [pp, prev, cur]]
]
, [[], null , {}, []]);
At this moment I sad STOP! That is carzy! The base idea was I wrote a single pure reducer, which is give back startOfPP value and log. So I started 4 variable in local state: [[],
, but after take look back to code, I found this over engineered reducer solution.
null , {}, []]
Top comments (0)