1 | ;
|
2 |
|
3 | /** @typedef {import("./index.js").InternalOptions} InternalOptions */
|
4 | /** @typedef {import("./index.js").JSONOptions} JSONOptions */
|
5 | /** @typedef {import("./index.js").MinimizedResult} MinimizedResult */
|
6 |
|
7 | const defaultMinimizerOptions = {
|
8 | // eslint-disable-next-line no-undefined
|
9 | replacer: undefined,
|
10 | // eslint-disable-next-line no-undefined
|
11 | space: undefined
|
12 | };
|
13 |
|
14 | /**
|
15 | * @param {InternalOptions} options
|
16 | * @returns {Promise<MinimizedResult>}
|
17 | */
|
18 | const minify = async options => {
|
19 | const {
|
20 | input,
|
21 | minimizerOptions
|
22 | } = options;
|
23 | const {
|
24 | replacer,
|
25 | space
|
26 | } = {
|
27 | ...defaultMinimizerOptions,
|
28 | ...minimizerOptions
|
29 | };
|
30 | const result = JSON.stringify(JSON.parse(input), replacer, space);
|
31 | return {
|
32 | code: result
|
33 | };
|
34 | };
|
35 | module.exports = {
|
36 | minify
|
37 | }; |
\ | No newline at end of file |