Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/string/index.ts>dedent

A JavaScript extension package for building strong and modern applications.
Latest
function dedent
import { dedent } from "https://deno.land/x/ayonli_jsext@v0.9.72/string/index.ts";

Removes extra indentation from the string.

NOTE: This function also removes leading and trailing newlines.

Examples

Example 1

import { dedent } from "@ayonli/jsext/string";

class MyClass {
    print() {
        console.log(dedent(`
            create table student(
                id int primary key,
                name text
            )
       `));
    }
}

new MyClass().print();
// Output:
// create table student(
//     id int primary key,
//     name text
// )

Parameters

str: string

Returns

string

This function can also be used as a template literal tag.

Parameters

str: TemplateStringsArray
...values: any[]

Returns

string