@gosavetool/text

中文文档
1.0.0发布于 2026/11/01MITTypeScriptCommonJS零依赖

Word count, reading time, social media character limits, Title Case, slugs (with Turkish and accented letters) and whitespace cleanup. Zero dependencies.

原始使用文档
文档目录6 节
  1. Install
  2. Counts and reading time
  3. Social media and SEO limits
  4. Case and slugs
  5. Related
  6. License

@gosavetool/text

Small text helpers with no dependencies: word and character counts, reading time, social media character limits, case changes, URL slugs and whitespace cleanup.

Made by GoSaveTool. Need it without code? Try the Character Counter.

Install

npm install @gosavetool/text

Counts and reading time

const { stats } = require('@gosavetool/text');

stats('Hello world. It’s 2026!');
// { words: 4, chars: 23, charsNoSpaces: 20, lines: 1, sentences: 2, readSeconds: 1 }

Reading time uses 238 words a minute, the average silent reading speed for non-fiction.

Social media and SEO limits

const { limits } = require('@gosavetool/text');

limits(caption, ['x-post', 'instagram-caption']);
// { 'x-post': { limit: 280, used: 312, left: -32, fits: false }, 'instagram-caption': { … fits: true } }
NameLimit
x-post280
instagram-caption2,200
tiktok-caption4,000
youtube-title100
youtube-description5,000
linkedin-post3,000
pinterest-description500
seo-title60
meta-description160

Case and slugs

const t = require('@gosavetool/text');

t.title('the lord of the rings: return of the king'); // 'The Lord of the Rings: Return of the King'
t.sentence('HELLO WORLD. how ARE you?');               // 'Hello world. How are you?'
t.slug('Ölçü Birimi & Çeviri!');                       // 'olcu-birimi-ceviri'
t.camel('best posting time');                          // 'bestPostingTime'
t.snake('bestPostingTime');                            // 'best_posting_time'
t.kebab('Best Posting_Time');                          // 'best-posting-time'
t.clean('a   b  \n\n\n\nc');                            // 'a b\n\nc'

slug() turns Turkish (ı, ş, ğ, ç, ö, ü), German (ß) and accented letters into plain ASCII.

TypeScript types are included.

License

MIT

版本与发布记录

@gosavetool/text 共发布 2 个版本,首次发布于 2026/11/01;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.0.0latest2026/11/012 天前
0.0.0-stage2026/11/012 天前

关于 @gosavetool/text 的常见问题

@gosavetool/text 是什么?

字数,阅读时间,社交媒体字符限制,标题大小写,鼻涕虫(土耳其语和重音字母)和空白清理。零依赖关系。

如何安装 @gosavetool/text?

在项目目录运行 npm install @gosavetool/text,或使用 pnpm add / yarn add / bun add。

@gosavetool/text 支持 TypeScript 吗?

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

@gosavetool/text 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@gosavetool/text 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@gosavetool/text 可以商用吗?

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

@gosavetool/text 还在维护吗?

最新版本 1.0.0 发布于 2026/11/01(2 天前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/11/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。