GovTechSG / mcf-boilerplate-js

JavaScript boilerplates used in MyCareersFuture, moved to https://gitlab.com/mycf.sg/mcf-boilerplate-js
MIT License
3 stars 6 forks source link

Unnecessary use of lodash flow() in @mcf/constants #67

Closed zephinzer closed 3 years ago

zephinzer commented 4 years ago

Referencing: https://github.com/GovTechSG/mcf-boilerplate-js/blob/100ab62f7d68191e74c8c4164a9f8188e42ea275/packages/constants/src/mcf.ts#L676

Could we use the native .reduce() over the lodash flow(...)? I imagine it would be like:

return [
    removeWordsInBracket,
    removeStopWords,
    removePunctuations,
    removeExcessWhitespaces,
    joinWords,
    removeRepeatedHyphens,
    encodeURIComponent,
 ].reduce((currentState, currentItem) => currentItem(currentState), currentStr)

Arguably less readable but this together with #66 removes the need for a 14MB lodash dependency.

shonoru commented 3 years ago

Going to close this issue since there's no lodash dependencies