
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A TypeScript heredoc implementation with smart indentation handling and interpolation support.
npm install heredoc-ts
import { heredoc } from "heredoc-ts"
const message = heredoc`
Hello, world!
This is a multiline string
with proper indentation handling.
`
console.log(message)
// "Hello, world!\nThis is a multiline string\nwith proper indentation handling."
The heredoc function automatically detects and removes the common leading
indentation from all lines:
const code = heredoc`
function example() {
console.log("Hello world")
}
`
// `function example() {\n console.log("Hello world")\n}`
Supports template literal interpolation with intelligent handling of multiline values. This automatically handles the leading spacing (i.e., each newline in the template value has the leading spacing prepended).
const items = ["apple", "banana", "orange"]
const list = heredoc`
Shopping list:
${items.map((item) => `- ${item}`).join("\n")}
`
// "Shopping list:\n- apple\n- banana\n- orange"
You can nest heredoc calls for complex formatting. This will process the indentation of the nested value first, allowing for indented code for readability while maintaining consistent outputs without excessive leading spaces.
const nested = heredoc`
Outer content
${heredoc`
Inner content
with its own
indentation
`}
Back to outer
`
// "Outer content\nInner content\nwith its own\nindentation\nBack to outer"
Fully typed with TypeScript, supporting string, number, boolean, null, and undefined interpolations.
heredoc(strings: TemplateStringsArray, ...values: Stringish[]): stringA template tag function that processes multiline strings:
const text = heredoc`
This text starts with proper indentation.
It maintains relative indentation.
Like this indented line.
`
const name = "Alice"
const greeting = heredoc`
Hello, ${name}!
Welcome to our application.
`
const data = ["one", "two", "three"]
const html = heredoc`
<ul>
${data.map((item) => `<li>${item}</li>`).join("\n")}
</ul>
`
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build the package
pnpm build
# Run linting
pnpm lint
# Type checking
pnpm typecheck
Copyright © 2025 Corey Ward. Available under the MIT license.
This package was originally based on the now-archived package
theredoc by Justin Searls. This
package began as a TypeScript port, and has had several additions. Thank you,
Justin!
FAQs
A heredoc implementation in TypeScript with support for nested heredocs.
We found that heredoc-ts demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.