New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dedent-tabs

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dedent-tabs

An ES6 string tag that strips indentation from multi-line strings

0.10.3
latest
Source
npm
Version published
Weekly downloads
1.2K
7.42%
Maintainers
1
Weekly downloads
 
Created
Source

Dedent-Tabs

npm npm bundle size monthly downloads

CI Code Coverage Codacy Badge Dependabot Status Dependency Status Dependency Status

It's basicly dedent, but with support for tabs and still maintained.

An ES6 string tag that strips indentation from multi-line strings.

Usage

import dedent from "dedent-tabs";

function usageExample() {
  const first = dedent`A string that gets so long you need to break it over
                       multiple lines. Luckily dedent is here to keep it
                       readable without lots of spaces ending up in the string
                       itself.`;

  const second = dedent`
    Leading and trailing lines will be trimmed, so you can write something like
    this and have it work as you expect:

      * how convenient it is
      * that I can use an indented list
         - and still have it do the right thing

    That's all.
  `;

  const third = dedent(`
    Wait! I lied. Dedent can also be used as a function.
  `);

  return first + "\n\n" + second + "\n\n" + third;
}
> console.log(usageExample());
A string that gets so long you need to break it over
multiple lines. Luckily dedent is here to keep it
readable without lots of spaces ending up in the string
itself.

Leading and trailing lines will be trimmed, so you can write something like
this and have it work as you expect:

  * how convenient it is
  * that I can use an indented list
    - and still have it do the right thing

That's all.

Wait! I lied. Dedent can also be used as a function.

Escape characters in template strings

When using the template string tag syntax, for example:

dedent`
  Hi there I am
  a multi line
  string
`

dedent will not support all the escape sequences that a standard ES6 template string supports and will return them literally.

For example:

console.log(dedent`
  \xA9
`)
// Logs "\xA9"

The currently supported escape sequences are:

The reason these escape characters are not fully supported is due to having to bypass the native escape character handling (using the raw property) in order to be able to handle newlines correctly.

There are plans to correct this in the future (see Issue #109).

All escape characters are supported when calling dedent-tabs as a function.

License

MIT

Release new version

  • npm ci - for a clean environment
  • npm version patch|minor|major - Bump version https://docs.npmjs.com/cli/v6/commands/npm-version
  • npm run lint - to ensure a consistent code style
  • npm run test - to make sure everything is working
  • Bump version
  • npm run build - to create the bundle to release
  • git commit -m "update bundle" - to make sure the latest bundle is in the dist directory
  • npm publish

Keywords

dedent

FAQs

Package last updated on 23 Mar 2023

Did you know?

Socket

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.

Install

Related posts