@adamlui/minify.js 1.5.4 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -16
- package/dist/cli.min.js +8 -4
- package/dist/minify.min.js +2 -2
- package/docs/LICENSE.md +4 -2
- package/docs/README.md +40 -16
- package/docs/SECURITY.md +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
<img height=14 src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/earth-icon/black/icon32.svg">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
|
-
<a href="
|
|
9
|
-
<a href="
|
|
10
|
-
<a href="
|
|
11
|
-
<a href="
|
|
12
|
-
<a href="
|
|
13
|
-
<a href="
|
|
14
|
-
<a href="
|
|
8
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/zh-cn/#readme">简体中文</a> |
|
|
9
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/zh-tw/#readme">繁體中文</a> |
|
|
10
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/hi/#readme">हिंदी</a> |
|
|
11
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/bn/#readme">বাংলা</a> |
|
|
12
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/mr/#readme">मराठी</a> |
|
|
13
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/pa/#readme">ਪੰਜਾਬੀ</a> |
|
|
14
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/de/#readme">Deutsch</a> |
|
|
15
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/es/#readme">Español</a> |
|
|
16
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/fr/#readme">Français</a>
|
|
15
17
|
</h6>
|
|
16
18
|
</div>
|
|
17
19
|
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
|
|
22
24
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js"><img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fminify.js?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
23
25
|
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
24
|
-
<a href="https://github.com/adamlui/minify.js/releases/tag/node-v1.5.
|
|
26
|
+
<a href="https://github.com/adamlui/minify.js/releases/tag/node-v1.5.5"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.5-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
25
27
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fminify.js?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
26
28
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_minify.js:node.js/src/minify.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_minify.js%3Anode.js%2Fsrc%2Fminify.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
27
29
|
<a href="https://github.com/toolleeo/cli-apps#programming"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-c4a2bd?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
@@ -221,7 +223,7 @@ Searches for all unminified JavaScript files within the `searchDir` string passe
|
|
|
221
223
|
Options are boolean, passed as object properties. For example:
|
|
222
224
|
|
|
223
225
|
```js
|
|
224
|
-
// Search for unminified JS files in exactly assets/js
|
|
226
|
+
// Search for unminified JS files in exactly assets/js
|
|
225
227
|
const searchResults = minifyJS.findJS('assets/js', { recursive: false });
|
|
226
228
|
console.log(searchResults);
|
|
227
229
|
|
|
@@ -239,12 +241,12 @@ findJS() » Check returned array.
|
|
|
239
241
|
|
|
240
242
|
Available parameters (and their default settings) are:
|
|
241
243
|
|
|
242
|
-
Name | Desciption
|
|
243
|
-
|
|
244
|
-
`recursive` | Recursively search for nested files in searchDir passed.
|
|
245
|
-
`verbose` | Show logging in console/terminal.
|
|
246
|
-
`dotFolders` | Include dotfolders in file search.
|
|
247
|
-
`dotFiles` | Include dotfiles in file search.
|
|
244
|
+
Name | Type | Desciption | Default value
|
|
245
|
+
-------------|---------|----------------------------------------------------------|---------------
|
|
246
|
+
`recursive` | Boolean | Recursively search for nested files in searchDir passed. | `true`
|
|
247
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
248
|
+
`dotFolders` | Boolean | Include dotfolders in file search. | `false`
|
|
249
|
+
`dotFiles` | Boolean | Include dotfiles in file search. | `false`
|
|
248
250
|
|
|
249
251
|
<br>
|
|
250
252
|
|
|
@@ -264,6 +266,28 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
264
266
|
|
|
265
267
|
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
266
268
|
|
|
269
|
+
## 🛠️ Related utilities
|
|
270
|
+
|
|
271
|
+
### [</> minify.js (Gulp)](https://gulp.minify-js.org) <a href="https://github.com/toolleeo/cli-apps#programming"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
|
|
272
|
+
|
|
273
|
+
> Gulp plug-in to recursively minify all JavaScript files.
|
|
274
|
+
<br>[Install](https://gulp.minify-js.org/#-installation) /
|
|
275
|
+
[Readme](https://gulp.minify-js.org/#readme) /
|
|
276
|
+
[Discuss](https://github.minify-js.org/discussions)
|
|
277
|
+
|
|
278
|
+
### [{ } scss-to-css](https://github.com/adamlui/scss-to-css) <a href="https://github.com/toolleeo/cli-apps#conversion"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
|
|
279
|
+
|
|
280
|
+
> Recursively compile all SCSS files into minified CSS.
|
|
281
|
+
<br>[Install](https://github.com/adamlui/scss-to-css/#-installation) /
|
|
282
|
+
[Readme](https://github.com/adamlui/scss-to-css/#readme) /
|
|
283
|
+
[CLI usage](https://github.com/adamlui/scss-to-css/#-command-line-usage) /
|
|
284
|
+
[API usage](https://github.com/adamlui/scss-to-css/#-api-usage) /
|
|
285
|
+
[Discuss](https://github.com/adamlui/scss-to-css/discussions)
|
|
286
|
+
|
|
287
|
+
<br>
|
|
288
|
+
|
|
289
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
290
|
+
|
|
267
291
|
<picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/white/icon32x27.png"><img height=13 src="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/dark-gray/icon32x27.png"></picture> <a href="https://js-utils.com">**More JavaScript utilities**</a> /
|
|
268
|
-
<a href="https://js
|
|
292
|
+
<a href="https://github.minify-js.org/discussions">Discuss</a> /
|
|
269
293
|
<a href="#-minifyjs">Back to top ↑</a>
|
package/dist/cli.min.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* © 2023–2024 Adam Lui & contributors under the MIT license.
|
|
4
4
|
* Source: https://code.minify-js.org/node.js
|
|
5
|
-
* Documentation: https://docs.minify-js.org
|
|
5
|
+
* Documentation: https://docs.minify-js.org/node.js
|
|
6
6
|
*/
|
|
7
|
-
const pkgName="@adamlui/minify.js",docURL="https://docs.minify-js.org/#-command-line-usage",minifyJS=require(__dirname.match(/src/)?"./minify":"./minify.min"),fs=require("fs"),path=require("path"),execSync=require("child_process")["execSync"],nc="[0m",br="[1;91m",by="[1;33m",bg="[1;92m",config={},argRegex={flags:{dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,includeDotFiles:/^--?(?:df|D|(?:include-?)?dot-?files?=?(?:true|1)?)$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMangle:/^--?(?:M|(?:disable|no)-?mangle|mangle=(?:false|0))$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},paramOptions:{comment:/^--?comments?(?:=.*|$)/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(n=>{var e,i,o;n.startsWith("-")&&(e=Object.keys(argRegex.paramOptions).find(e=>argRegex.paramOptions[e].test(n)),o=Object.keys(argRegex.flags).find(e=>argRegex.flags[e].test(n)),i=Object.keys(argRegex.infoCmds).find(e=>argRegex.infoCmds[e].test(n)),o?config[o]=!0:e?(n.includes("=")||(console.error(`
|
|
7
|
+
const pkgName="@adamlui/minify.js",docURL="https://docs.minify-js.org/#-command-line-usage",minifyJS=require(__dirname.match(/src/)?"./minify":"./minify.min"),fs=require("fs"),path=require("path"),execSync=require("child_process")["execSync"],nc="[0m",br="[1;91m",by="[1;33m",bg="[1;92m",bw="[1;97m",config={},argRegex={flags:{dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,includeDotFiles:/^--?(?:df|D|(?:include-?)?dot-?files?=?(?:true|1)?)$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMangle:/^--?(?:M|(?:disable|no)-?mangle|mangle=(?:false|0))$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},paramOptions:{comment:/^--?comments?(?:=.*|$)/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(n=>{var e,i,o;n.startsWith("-")&&(e=Object.keys(argRegex.paramOptions).find(e=>argRegex.paramOptions[e].test(n)),o=Object.keys(argRegex.flags).find(e=>argRegex.flags[e].test(n)),i=Object.keys(argRegex.infoCmds).find(e=>argRegex.infoCmds[e].test(n)),o?config[o]=!0:e?(n.includes("=")||(console.error(`
|
|
8
8
|
${br}ERROR: Arg [--${n.replace(/-/g,"")}] requires '=' followed by a value.`+nc),printHelpCmdAndDocURL(),process.exit(1)),o=n.split("=")[1],config[e]=parseInt(o)||o):i||(console.error(`
|
|
9
9
|
${br}ERROR: Arg [${n}] not recognized.`+nc),console.info(`
|
|
10
10
|
${by}Valid arguments are below.`+nc),printHelpSections(["flags","paramOptions","infoCmds"]),printHelpCmdAndDocURL(),process.exit(1)))}),process.argv.some(e=>argRegex.infoCmds.help.test(e)))printHelpSections();else if(process.argv.some(e=>argRegex.infoCmds.version.test(e))){const k=execSync(`npm view ${pkgName} version`).toString().trim()||"none";let e,i=process.cwd();for(;"/"!=i;){const n=path.join(i,"package.json");if(fs.existsSync(n)){const o=require(n);e=(o.dependencies?.[pkgName]||o.devDependencies?.[pkgName])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}i=path.dirname(i)}console.info(`
|
|
@@ -17,7 +17,11 @@ ${bg}Example valid command:
|
|
|
17
17
|
${by}JS files to be minified:`+nc),s.forEach(e=>console.info(e))):console.info(by+`
|
|
18
18
|
No JS files will be minified.`+nc);else{const w=[],x=s.map(e=>{var n=minifyJS.minify(e,{verbose:!config.quietMode,mangle:!config.noMangle,comment:config.comment?.replace(/\\n/g,"\n")});return n.error&&w.push(e),n}).filter(e=>!e.error);x?.forEach(({code:e,srcPath:n})=>{var i=path.join(path.dirname(n),(/so?u?rce?$/.test(path.dirname(n))?"../":"")+(q.endsWith(".js")?path.dirname(q):q||"min")),n=(q.endsWith(".js")&&p.endsWith(".js")?path.basename(q).replace(/(\.min)?\.js$/,""):path.basename(n,".js"))+".min.js",n=path.join(i,n);fs.existsSync(i)||fs.mkdirSync(i,{recursive:!0}),fs.writeFileSync(n,e,"utf8")}),0<x?.length?(printIfNotQuiet(`
|
|
19
19
|
${bg}Minification complete!`+nc),printIfNotQuiet(`${x.length} file${1<x.length?"s":""} minified.`)):printIfNotQuiet(by+"No unminified JavaScript files processed."+nc),0<w.length&&(printIfNotQuiet(`
|
|
20
|
-
`+br+w.length+" file"+(1<w.length?"s":"")+" failed to minify:"+nc),w.forEach(e=>printIfNotQuiet(e)))}}function printHelpSections(e=["
|
|
21
|
-
${
|
|
20
|
+
`+br+w.length+" file"+(1<w.length?"s":"")+" failed to minify:"+nc),w.forEach(e=>printIfNotQuiet(e)))}}function printHelpSections(e=["usage","pathArgs","flags","paramOptions","infoCmds"]){const n={usage:[`
|
|
21
|
+
${bw}Usage:`+nc," minify-js [inputPath] [outputPath] [options]"],pathArgs:[`
|
|
22
|
+
${bw}Path arguments:`+nc," [inputPath] Path to JS file or directory containing JS files to be minified, relative to the current working directory."," [outputPath] Path to file or directory where minified files will be stored, relative to original file location (if not provided, min/ is used)."],flags:[`
|
|
23
|
+
${bw}Boolean options:`+nc," -n, --dry-run Don't actually minify the file(s), just show if they will be processed."," -d, --include-dotfolders Include dotfolders in file search."," -D, --include-dotfiles Include dotfiles in file search."," -R, --no-recursion Disable recursive file searching."," -M, --no-mangle Disable mangling names."," -q, --quiet Suppress all logging except errors."],paramOptions:[`
|
|
24
|
+
${bw}Parameter options:`+nc,' --comment="comment" Prepend comment to minified code.'],infoCmds:[`
|
|
25
|
+
${bw}Info commands:`+nc," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(e=>{n[e]?.forEach(e=>{{const o=process.stdout.columns||80,s=[],n=e.match(/\S+|\s+/g);let i="";n.forEach(e=>{var n=o-(0==s.length?0:29);i.length+e.length>n&&(s.push(0==s.length?i:i.trimStart()),i=""),i+=e}),s.push(0==s.length?i:i.trimStart()),s.forEach((e,n)=>console.info(0==n?e:" ".repeat(29)+e))}})})}function printHelpCmdAndDocURL(){console.info(`
|
|
22
26
|
${by}For more help, type 'minify-js --help' or visit
|
|
23
27
|
`+(docURL+nc))}function printIfNotQuiet(e){config.quietMode||console.info(e)}
|
package/dist/minify.min.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* © 2023–2024 Adam Lui & contributors under the MIT license.
|
|
4
4
|
* Source: https://code.minify-js.org/node.js
|
|
5
|
-
* Documentation: https://docs.minify-js.org
|
|
5
|
+
* Documentation: https://docs.minify-js.org/node.js
|
|
6
6
|
*/
|
|
7
7
|
const fs=require("fs"),path=require("path"),uglifyJS=require("uglify-js");function findJS(i,r={}){var e="https://docs.minify-js.org/#findjssearchdir-options",o={recursive:!0,verbose:!0,dotFolders:!1,dotFiles:!1};if("string"!=typeof i)console.error("findJS() » ERROR: 1st arg <searchDir> must be a string."),console.info("findJS() » For more help, please visit "+e);else{var n=path.resolve(process.cwd(),i);if(fs.existsSync(n)){if(validateOptions(r,o,e,"findJS('assets/js', { verbose: false, dotFoldes: true })")){r={...o,...r};const s=fs.readdirSync(i),t=[];return r.verbose&&!r.isRecursing&&console.info("findJS() » Searching for unminified JS files..."),s.forEach(e=>{var o=path.resolve(i,e);fs.statSync(o).isDirectory()&&"node_modules"!=e&&(r.dotFolders||!e.startsWith("."))&&r.recursive?t.push(...findJS(o,{...r,isRecursing:!0})):!/\.js(?<!\.min\.js)$/.test(e)||!r.dotFiles&&e.startsWith(".")||t.push(o)}),!r.isRecursing&&r.verbose&&(console.info("findJS() » Search complete! "+(0==t.length?"No":t.length)+` file${0==t.length||1<t.length?"s":""} found.`),"minify"==findJS.caller.name||process.argv.some(e=>e.includes("gulp"))||/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("findJS() » Check returned array.")),r.isRecursing||0<t.length?t:[]}}else console.error("findJS() » ERROR: 1st arg <searchDir> must be an existing directory."),console.error(`findJS() » ${n} does not exist.`),console.info("findJS() » For more help, please visit "+e)}}function minify(e,r={}){var o="https://docs.minify-js.org/#minifyinput-options",i={recursive:!0,verbose:!0,dotFolders:!1,dotFiles:!1,mangle:!0,comment:""};if("string"!=typeof e)console.error("minify() » ERROR: 1st arg <input> must be a string."),console.info("minify() » For more help, please visit "+o);else if(validateOptions(r,i,o,"minify('assets/js', { recursive: false, mangle: false })")){const s={mangle:(r={...i,...r}).mangle};return fs.existsSync(e)?e.endsWith(".js")?(r.verbose&&console.info(`minify() » Minifying ${e}...`),o=uglifyJS.minify(fs.readFileSync(e,"utf8"),s),r.comment&&(o.code=n(o.code)),o.error?console.error("minify() » ERROR: "+o.error.message):!r.verbose||process.argv.some(e=>e.includes("gulp"))||/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("minify() » Minification complete. Check returned object."),{code:o.code,srcPath:path.resolve(process.cwd(),e),error:o.error}):(i=findJS(e,{recursive:r.recursive,verbose:r.verbose,dotFolders:r.dotFolders,dotFiles:r.dotFiles})?.map(e=>{r.verbose&&console.info(`minify() » Minifying ${e}...`);var o=fs.readFileSync(e,"utf8"),o=uglifyJS.minify(o,s);return r.comment&&(o.code=n(o.code)),o.error&&console.error("minify() » ERROR: "+o.error.message),{code:o.code,srcPath:e,error:o.error}}).filter(e=>!e.error),r.verbose&&(0<i.length?console.info("minify() » Minification complete. Check returned object."):console.info("minify() » No unminified JavaScript files processed.")),i):(r.verbose&&!process.argv.some(e=>e.includes("gulp"))&&console.info("minify() » Minifying passed source code..."),o=uglifyJS.minify(e,s),r.comment&&(o.code=n(o.code)),o.error?console.error("minify() » ERROR: "+o.error.message):r.verbose&&!process.argv.some(e=>e.includes("gulp"))&&console.info("minify() » Minification complete. Check returned object."),{code:o.code,srcPath:void 0,error:o.error});function n(e){var o=r.comment.split("\n").map(e=>" * "+e).join("\n"),i=e.indexOf("#!");return 0<=i?(i=e.indexOf("\n",i)+1,e.slice(0,i)+`/**
|
|
8
8
|
${o}
|
|
@@ -10,4 +10,4 @@ ${o}
|
|
|
10
10
|
`+e.slice(i)):`/**
|
|
11
11
|
${o}
|
|
12
12
|
*/
|
|
13
|
-
`+e}}}function validateOptions(e,o,i,r){const n=JSON.stringify(o,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),s=Object.keys(o).join(", "),t=Object.keys(o).filter(e=>"boolean"==typeof o[e]),l=Object.keys(o).filter(e=>Number.isInteger(o[e]));let c="validateOptions() » ";try{c=validateOptions.caller?.name+"() » "}catch(e){}var f=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,a=(f+=["st","nd","rd"][f-1]||"th",()=>{console.info(`${c}Valid options: [ ${s} ]`),console.info(c+"If omitted, default settings are: "+n)}),d=()=>{console.info(c+"For more help, please visit "+i)};if("object"!=typeof e)return console.error(c+`ERROR: ${"0th"==f?"[O":f+" arg [o"}ptions] can only be an object of key/values.`),console.info(c+"Example valid call: "+r),a(),d(),!1;for(const u in e){if("isRecursing"!=u&&!Object.prototype.hasOwnProperty.call(o,u))return console.error(`${c}ERROR: \`${u}\` is an invalid option.`),a(),d(),!1;if(t.includes(u)){if("mangle"==u){var m=()=>console.error(c+"ERROR: [mangle] option can only be `true`, `false`, or an object w/ key [toplevel] set to `true` or `false`.");if("object"==typeof e.mangle){for(const p in e.mangle)if(!["toplevel"].includes(p)||"boolean"!=typeof e.mangle[p])return m(),d(),!1}else if("boolean"!=typeof e.mangle)return m(),d(),!1}else if("boolean"!=typeof e[u])return console.error(`${c}ERROR: [${u}] option can only be \`true\` or \`false\`.`),d(),!1}else if(l.includes(u)&&(e[u]=parseInt(e[u],10),isNaN(e[u])||e[u]<1))return console.error(`${c}ERROR: [${u}] option can only be an integer > 0.`),d(),!1}return!0}module.exports={minify:minify,
|
|
13
|
+
`+e}}}function validateOptions(e,o,i,r){const n=JSON.stringify(o,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),s=Object.keys(o).join(", "),t=Object.keys(o).filter(e=>"boolean"==typeof o[e]),l=Object.keys(o).filter(e=>Number.isInteger(o[e]));let c="validateOptions() » ";try{c=validateOptions.caller?.name+"() » "}catch(e){}var f=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,a=(f+=["st","nd","rd"][f-1]||"th",()=>{console.info(`${c}Valid options: [ ${s} ]`),console.info(c+"If omitted, default settings are: "+n)}),d=()=>{console.info(c+"For more help, please visit "+i)};if("object"!=typeof e)return console.error(c+`ERROR: ${"0th"==f?"[O":f+" arg [o"}ptions] can only be an object of key/values.`),console.info(c+"Example valid call: "+r),a(),d(),!1;for(const u in e){if("isRecursing"!=u&&!Object.prototype.hasOwnProperty.call(o,u))return console.error(`${c}ERROR: \`${u}\` is an invalid option.`),a(),d(),!1;if(t.includes(u)){if("mangle"==u){var m=()=>console.error(c+"ERROR: [mangle] option can only be `true`, `false`, or an object w/ key [toplevel] set to `true` or `false`.");if("object"==typeof e.mangle){for(const p in e.mangle)if(!["toplevel"].includes(p)||"boolean"!=typeof e.mangle[p])return m(),d(),!1}else if("boolean"!=typeof e.mangle)return m(),d(),!1}else if("boolean"!=typeof e[u])return console.error(`${c}ERROR: [${u}] option can only be \`true\` or \`false\`.`),d(),!1}else if(l.includes(u)&&(e[u]=parseInt(e[u],10),isNaN(e[u])||e[u]<1))return console.error(`${c}ERROR: [${u}] option can only be an integer > 0.`),d(),!1}return!0}const funcAliases={minify:["compress"],findJS:["find","findJs","findjs","search"]};module.exports={minify:minify,findJS:findJS};for(const $ in funcAliases)funcAliases[$].forEach(e=>module.exports[e]=module.exports[$]);
|
package/docs/LICENSE.md
CHANGED
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
<a href="bn/LICENSE.md">বাংলা</a> |
|
|
12
12
|
<a href="mr/LICENSE.md">मराठी</a> |
|
|
13
13
|
<a href="pa/LICENSE.md">ਪੰਜਾਬੀ</a> |
|
|
14
|
-
<a href="de/LICENSE.md">Deutsch</a>
|
|
14
|
+
<a href="de/LICENSE.md">Deutsch</a> |
|
|
15
|
+
<a href="es/LICENSE.md">Español</a> |
|
|
16
|
+
<a href="fr/LICENSE.md">Français</a>
|
|
15
17
|
</h6>
|
|
16
18
|
</div>
|
|
17
19
|
|
|
18
20
|
# 🏛️ MIT License
|
|
19
21
|
|
|
20
|
-
**Copyright © 2023–2024 [Adam Lui](https://github.com/adamlui) & contributors
|
|
22
|
+
**Copyright © 2023–2024 [Adam Lui](https://github.com/adamlui) & contributors.**
|
|
21
23
|
|
|
22
24
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
23
25
|
|
package/docs/README.md
CHANGED
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
<img height=14 src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/earth-icon/black/icon32.svg">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
|
-
<a href="
|
|
9
|
-
<a href="
|
|
10
|
-
<a href="
|
|
11
|
-
<a href="
|
|
12
|
-
<a href="
|
|
13
|
-
<a href="
|
|
14
|
-
<a href="
|
|
8
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/zh-cn/#readme">简体中文</a> |
|
|
9
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/zh-tw/#readme">繁體中文</a> |
|
|
10
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/hi/#readme">हिंदी</a> |
|
|
11
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/bn/#readme">বাংলা</a> |
|
|
12
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/mr/#readme">मराठी</a> |
|
|
13
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/pa/#readme">ਪੰਜਾਬੀ</a> |
|
|
14
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/de/#readme">Deutsch</a> |
|
|
15
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/es/#readme">Español</a> |
|
|
16
|
+
<a href="https://github.minify-js.org/tree/main/node.js/docs/fr/#readme">Français</a>
|
|
15
17
|
</h6>
|
|
16
18
|
</div>
|
|
17
19
|
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
|
|
22
24
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js"><img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fminify.js?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
23
25
|
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
24
|
-
<a href="https://github.com/adamlui/minify.js/releases/tag/node-v1.5.
|
|
26
|
+
<a href="https://github.com/adamlui/minify.js/releases/tag/node-v1.5.5"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.5-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
25
27
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fminify.js?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
26
28
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_minify.js:node.js/src/minify.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_minify.js%3Anode.js%2Fsrc%2Fminify.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
27
29
|
<a href="https://github.com/toolleeo/cli-apps#programming"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-c4a2bd?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
@@ -221,7 +223,7 @@ Searches for all unminified JavaScript files within the `searchDir` string passe
|
|
|
221
223
|
Options are boolean, passed as object properties. For example:
|
|
222
224
|
|
|
223
225
|
```js
|
|
224
|
-
// Search for unminified JS files in exactly assets/js
|
|
226
|
+
// Search for unminified JS files in exactly assets/js
|
|
225
227
|
const searchResults = minifyJS.findJS('assets/js', { recursive: false });
|
|
226
228
|
console.log(searchResults);
|
|
227
229
|
|
|
@@ -239,12 +241,12 @@ findJS() » Check returned array.
|
|
|
239
241
|
|
|
240
242
|
Available parameters (and their default settings) are:
|
|
241
243
|
|
|
242
|
-
Name | Desciption
|
|
243
|
-
|
|
244
|
-
`recursive` | Recursively search for nested files in searchDir passed.
|
|
245
|
-
`verbose` | Show logging in console/terminal.
|
|
246
|
-
`dotFolders` | Include dotfolders in file search.
|
|
247
|
-
`dotFiles` | Include dotfiles in file search.
|
|
244
|
+
Name | Type | Desciption | Default value
|
|
245
|
+
-------------|---------|----------------------------------------------------------|---------------
|
|
246
|
+
`recursive` | Boolean | Recursively search for nested files in searchDir passed. | `true`
|
|
247
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
248
|
+
`dotFolders` | Boolean | Include dotfolders in file search. | `false`
|
|
249
|
+
`dotFiles` | Boolean | Include dotfiles in file search. | `false`
|
|
248
250
|
|
|
249
251
|
<br>
|
|
250
252
|
|
|
@@ -264,6 +266,28 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
264
266
|
|
|
265
267
|
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
266
268
|
|
|
269
|
+
## 🛠️ Related utilities
|
|
270
|
+
|
|
271
|
+
### [</> minify.js (Gulp)](https://gulp.minify-js.org) <a href="https://github.com/toolleeo/cli-apps#programming"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
|
|
272
|
+
|
|
273
|
+
> Gulp plug-in to recursively minify all JavaScript files.
|
|
274
|
+
<br>[Install](https://gulp.minify-js.org/#-installation) /
|
|
275
|
+
[Readme](https://gulp.minify-js.org/#readme) /
|
|
276
|
+
[Discuss](https://github.minify-js.org/discussions)
|
|
277
|
+
|
|
278
|
+
### [{ } scss-to-css](https://github.com/adamlui/scss-to-css) <a href="https://github.com/toolleeo/cli-apps#conversion"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
|
|
279
|
+
|
|
280
|
+
> Recursively compile all SCSS files into minified CSS.
|
|
281
|
+
<br>[Install](https://github.com/adamlui/scss-to-css/#-installation) /
|
|
282
|
+
[Readme](https://github.com/adamlui/scss-to-css/#readme) /
|
|
283
|
+
[CLI usage](https://github.com/adamlui/scss-to-css/#-command-line-usage) /
|
|
284
|
+
[API usage](https://github.com/adamlui/scss-to-css/#-api-usage) /
|
|
285
|
+
[Discuss](https://github.com/adamlui/scss-to-css/discussions)
|
|
286
|
+
|
|
287
|
+
<br>
|
|
288
|
+
|
|
289
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
290
|
+
|
|
267
291
|
<picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/white/icon32x27.png"><img height=13 src="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/dark-gray/icon32x27.png"></picture> <a href="https://js-utils.com">**More JavaScript utilities**</a> /
|
|
268
|
-
<a href="https://js
|
|
292
|
+
<a href="https://github.minify-js.org/discussions">Discuss</a> /
|
|
269
293
|
<a href="#-minifyjs">Back to top ↑</a>
|
package/docs/SECURITY.md
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
<a href="bn/SECURITY.md">বাংলা</a> |
|
|
12
12
|
<a href="mr/SECURITY.md">मराठी</a> |
|
|
13
13
|
<a href="pa/SECURITY.md">ਪੰਜਾਬੀ</a> |
|
|
14
|
-
<a href="de/SECURITY.md">Deutsch</a>
|
|
14
|
+
<a href="de/SECURITY.md">Deutsch</a> |
|
|
15
|
+
<a href="es/SECURITY.md">Español</a> |
|
|
16
|
+
<a href="fr/SECURITY.md">Français</a>
|
|
15
17
|
</h6>
|
|
16
18
|
</div>
|
|
17
19
|
|