Skip to content

Commit

Permalink
Memoize normalize
Browse files Browse the repository at this point in the history
  • Loading branch information
soluml committed May 11, 2021
1 parent 3b57c08 commit 19ceed1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/module/normalize.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const CSSO = require('csso');
const memoize = require('lodash/memoize');

const fn = memoize((cssStr) =>
CSSO.minify(cssStr, { restructure: true })
);

module.exports = function Normalize(cssObj) {
return Promise.resolve(CSSO.minify(
cssObj.toString()
), {
restructure: true
});
return Promise.resolve(
fn(cssObj.toString())
);
};

0 comments on commit 19ceed1

Please sign in to comment.