Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Doc Chomp chomps on your document literals
Doc Chomp is useful for keeping nice indentation outside ES6 template literals, while making them internally clean and consistent.
The simplest way to use Doc Chomp is to tag a string!
const DocChomp = require('doc-chomp');
let chompedString = DocChomp`
This string will be trimmed such that all indentation matches this line
* Extra indentation is supported just fine
* No problem! 👌🏼
The line after the DocChomp call shouldn't be used, or Doc Chomp will complain!
`
function compareStrings() {
if (chompedString) {
return chompedString === DocChomp`
This string will be trimmed such that all indentation matches this line
* Extra indentation is supported just fine
* No problem! 👌🏼
The line after the DocChomp call shouldn't be used, or Doc Chomp will complain!
`;
}
}
compareStrings(); // true!
In this example, chompedString
will have two space characters trimmed from each line, and the other one will have six removed from each line.
With this usage, the first blank line (adjacent to DocChomp
) is removed, and no text may be added on that line as DocChomp. If text was accepted here, Doc Chomp couldn't make a good choice about spacing! If you need to put text on that line, you can use the manual modes below!
In both of these modes, note that if the line DocChomp
is on is blank, it will be omitted from the output, and line numbers begin at the next line.
If passed a number, Doc Chomp will detect the indentation from that line of the input.
function mcGuffin() {
if (this.glazed) {
return chompedString === DocChomp(2)`This string will have six space characters removed from the start of each line
* Because this line is defined as line 2, and used for indentation detection
* 👌🏼
`;
} else {
return chompedString === DocChomp(2)`
This is the "first" line (line 0), according to Doc Chomp, because the above line is blank.
* Which means this is line 2, and used for indentation detection
* No problem! 👌🏼
`;
}
}
If passed a string, Doc Chomp will remove exactly that indentation from each line.
function mcGuffin() {
if (this.glazed) {
return chompedString === DocChomp(' ')`This string will have six space characters removed from the start of each line
* Extra indentation is supported just fine
* No problem! 👌🏼
`;
} else {
return chompedString === DocChomp('\t\t\t')`This string will have three tab characters removed from the start of each line
* Extra indentation is supported just fine
* No problem! 👌🏼
`;
}
}
FAQs
Doc Chomp chomps on your document literals
The npm package doc-chomp receives a total of 260 weekly downloads. As such, doc-chomp popularity was classified as not popular.
We found that doc-chomp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.