code-trimmer
Trim source code into the beauty if needed for node, and autocomplete-me.
code-trimmer will indent a given chunk of source code, started with unnecessarily added whitespaces or tabs, by trimming the tabs and white-spaces in a consistent way, scanning through line by line as following :
const trimmer = const source = "\t\t\t\t\t\t\t(async () => {\n\t\t\t\t\t\t\t\tconst result = await fire(\n\t\t\t\t\t\t\t\t\t'trimmed!',\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})()" const res = trimmer console
origin source =>
/* (async () => { const result = await Swal.fire( 'Success', 'Your code is saved!', 'success' ) if (result) { window.location = `${BASE_URL}/main` } })()*/
into =>
/* (async () => { const result = await Swal.fire( 'Success', 'Your code is saved!', 'success' ) if (result) { window.location = `${BASE_URL}/main` }})()*/
Installation for Node.js
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
If this is a brand new project, make sure to create a package.json
first with
the npm init
command.
Installation is done using the
npm install
command:
$ npm install code-trimmer
Installation for Web Browser
CDN
<script src="https://cdn.jsdelivr.net/npm/code-trimmer@0.0.5/code-trimmer.js"></script>
<script>
const trimmer = require("./code-trimmer")
const source = "\t\t\t\t\t\t\t(async () => {\n\t\t\t\t\t\t\t\tconst result = await fire(\n\t\t\t\t\t\t\t\t\t'trimmed!',\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})()"
const res = trimmer.trim(source)
console.log(res)
</script>
Features
* Do one thing well
* Simple to use