# @dword-design/endent 中文文档

规范地址：https://npmcn.com/package/%40dword-design/endent/

版本：1\.4\.7
npm 元数据更新时间：2025-07-17T15:14:32.323Z
中文译文更新时间：2026-11-13T01:30:30.886Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40dword-design/endent
原文对照：https://npmcn.com/package/%40dword-design/endent/?lang=original
项目主页：https://github.com/ZhouHansen/endent#readme
源码仓库：https://github.com/ZhouHansen/endent

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：11.7 kB，10 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：3 个
- 首次发布：2021-12-22T15:36:32.060Z
- 最新版本发布：2025-07-17T15:14:32.170Z
- 近 30 天下载量：397508（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：10（近 12 个月 0 个）

## 中文简介

右缩进的ES6字符串标签

## 安装

```sh
npm install @dword-design/endent
```

也可以使用：`pnpm add @dword-design/endent`、`yarn add @dword-design/endent`、`bun add @dword-design/endent`

## README

# 最终 [![stability](https://img.shields.io/badge/stability-stable-green.svg)](https://nodejs.org/api/documentation.html#documentation_stability_index)

[![npm](https://img.shields.io/npm/v/endent.svg?style=flat-square)](https://www.npmjs.com/package/endent) [![travis](https://img.shields.io/travis/indentjs/endent.svg?style=flat-square)](https://travis-ci.org/indentjs/endent) [![dm](http://img.shields.io/npm/dm/endent.svg?style=flat-square)](https://www.npmjs.com/package/endent) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

一个让缩进右侧的 ES6 字符串标记, 添加一些关键特性到 [缩写](https://github.com/dmnd/dedent)。 。 。 .

## 迁移

因为我失去了我的2因子真品 这个项目已经转移到了 [https://github.com/zhouhanseng/endendent (中文(简体) )](https://github.com/zhouhanseng/endent)

## 特性

### 漂亮对象

```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 缩进

```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");
})();
```

## 许可证

麻省理工学院

## 常见问题

### @dword-design/endent 是什么？

右缩进的ES6字符串标签

### 如何安装 @dword-design/endent？

在项目目录运行 npm install @dword-design/endent，或使用 pnpm add / yarn add / bun add。

### @dword-design/endent 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @dword-design/endent 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @dword-design/endent 可以商用吗？

@dword-design/endent 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @dword-design/endent 的下载量有多少？

根据 npm 官方下载统计，@dword-design/endent 在 2026/10/13 – 2026/11/11 这 30 天内被下载 397,508 次，日均约 13,250 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @dword-design/endent 还在维护吗？

最新版本 1\.4\.7 发布于 2025/07/17（1\.3 年前）；至今共发布 10 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/12/22。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

