# endent

> ➡️ An ES6 string tag that makes indentation right

Latest version **2.1.0** (published 2021-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install endent
pnpm add endent
yarn add endent
bun add endent
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2021-06-21 |
| First published | 2017-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 11.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | zhouhancheng |
| Maintainers | zhouhancheng |
| Keywords | dedent, tag, multi-line string |

## Links

- npm: https://www.npmjs.com/package/endent
- Repository: https://github.com/ZhouHansen/endent
- Homepage: https://github.com/ZhouHansen/endent#readme
- Issues: https://github.com/ZhouHansen/endent/issues
- npm.io page: https://npm.io/package/endent

## Dependencies (3)

- [dedent](https://npm.io/package/dedent.md) ^0.7.0
- [objectorarray](https://npm.io/package/objectorarray.md) ^1.0.5
- [fast-json-parse](https://npm.io/package/fast-json-parse.md) ^1.0.3

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 2.1.0 (latest) — 2021-06-21
- 2.0.1 — 2020-04-13
- 2.0.0 — 2020-04-11
- 1.4.1 — 2020-02-20
- 1.4.0 — 2020-01-23
- 1.3.0 — 2019-02-26
- 1.2.0 — 2018-09-02
- 1.1.2 — 2018-07-02
- 1.1.1 — 2017-12-30
- 1.0.9 — 2017-12-11
- 1.0.8 — 2017-12-10
- 1.0.7 — 2017-12-10
- 1.0.6 — 2017-12-10
- 1.0.5 — 2017-12-09
- 1.0.4 — 2017-12-08
- … 4 more at https://npm.io/package/endent/versions

## README

# Endent [![stability][stability-image]][stability-index]

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![dm][dm-image]][npm-url]
[![js-standard-style][code-style]][standard]

[stability-image]: https://img.shields.io/badge/stability-stable-green.svg
[stability-index]: https://nodejs.org/api/documentation.html#documentation_stability_index
[npm-image]: https://img.shields.io/npm/v/endent.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/endent
[travis-image]: https://img.shields.io/travis/indentjs/endent.svg?style=flat-square
[travis-url]: https://travis-ci.org/indentjs/endent
[dm-image]: http://img.shields.io/npm/dm/endent.svg?style=flat-square
[code-style]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard]: https://github.com/feross/standard

An ES6 string tag that makes indentation right, adds some key features to [dedent](https://github.com/dmnd/dedent).

## Feature

### Pretty object

```ts
import dedent from "dedent";
import endent from "endent";

var someobj = {
  contact: {
    jack: 123456,
    tom: 654321,
  },
  color: "blue",
};

var somejson = '["bear", "fish", "dog", "cat"]';

var awfulTmpl = dedent`
  function store (state, emitter) {
    state["someobj"] = ${JSON.stringify(someobj, null, 2)}
    state["somejson"] = ${JSON.stringify(JSON.parse(somejson), null, 2)}
  }
`;
// use endent.pretty(value) when value is object or array.
var prettyTmpl = endent`
  function store (state, emitter) {
    state["someobj"] = ${endent.pretty(someobj)}
    state["somejson"] = ${somejson}
  }
`;

console.log(awfulTmpl + "\n\n" + prettyTmpl);
```

```ts
// awfulTmpl
function store(state, emitter) {
  state["someobj"] = {
contact: {
  jack: 123456,
  tom: 654321,
},
color: "blue",
}
  state["somejson"] = [
"bear", 
"fish", 
"dog",
"cat"
]
}

// prettyTmpl
function store(state, emitter) {
  state["someobj"] = {
    contact: {
      jack: 123456,
      tom: 654321,
    },
    color: "blue",
  }
  state["somejson"] = [
    "bear", 
    "fish", 
    "dog", 
    "cat"
  ]
}
```

### Endows suitable indentation for multiline interpolation

```ts
var dependencies = ["jquery", "underscore", "bootstrap"];
var dependencyTmpl = ``;
dependencies.forEach((d, i) => {
  dependencyTmpl += `var ${d} = require("${d}")\n`;
});

var awfulTmpl = dedent`
  ;(function () {
    ${dependencyTmpl}
  })()
`;

var prettyTmpl = endent`
  ;(function () {
    ${dependencyTmpl}
  })()
`;

console.log(awfulTmpl + "\n\n" + prettyTmpl);
```

```js
// awfulTmpl
(function () {
  var jquery = require("jquery");
var underscore = require("underscore");
var bootstrap = require("bootstrap");
})();

// prettyTmpl
(function () {
  var jquery = require("jquery");
  var underscore = require("underscore");
  var bootstrap = require("bootstrap");
})();
```

## License

MIT

---
_Source: https://npm.io/package/endent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
