Package detail

oneline

rexxars721.9kMIT2.0.0

Write nice template literals with newlines, but format as a single-line string

template-literal, template-string, tagged, string

readme

oneline

Write nice template literals with newlines, but format as a single-line string. Trims leading/trailing whitespace and replaces all newlines and subsequent whitespace with a single space.

npm versionnpm bundle sizenpm weekly downloads

Installing

npm install --save oneline

Basic usage

import {oneline} from 'oneline'

const url = 'https://docs.npmjs.com/'
const message = oneline`
  It's a fine day to write a long, verbose string.
  It could contain all sorts of expressions, let's for instance
  inject a URL, say to the NPM docs: ${url}. In the end, this will
  all result in a single line of text.
`

console.log(message)
// It's a fine day to write a long, verbose string. It could contain all sorts of expressions, let's for instance inject a URL, say to the NPM docs: https://docs.npmjs.com/. In the end, this will all result in a single line of text.

Thanks to...

Thanks Hal Henke for donating the package name! <3

License

MIT © Espen Hovlandsdal

changelog

📓 Changelog

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.0.0 (2025-03-16)

⚠ BREAKING CHANGES

  • Named export now used instead of default export.
  • ESM/CommonJS dual bundle, theoretically could break some bundlers.

Features

  • make compatible with bun, deno (57fd683)
  • named export, dual ESM/CommonJS (4fd1264)

Bug Fixes

  • incorrect version number (bab7328)