npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jyostudio/text

v0.1.9

Published

text

Readme

@jyostudio/text

提供了强大的文本处理能力,包括 StringBuilder 和多种字符编码支持(ASCII, UTF-8, UTF-16, UTF-32)。

安装

Node.js

npm install @jyostudio/text

浏览器 (ES Modules)

<script type="importmap">
  {
    "imports": {
      "@jyostudio/text": "https://unpkg.com/@jyostudio/text/dist/index.js"
    }
  }
</script>

完整用法 (推荐)

直接引用主入口文件,包含所有功能。

import { StringBuilder, Encoding } from "@jyostudio/text";

// 使用 StringBuilder
const sb = new StringBuilder("Hello");
sb.append(" World");
console.log(sb.toString()); // "Hello World"

// 使用 Encoding
const utf8 = Encoding.utf8;
const bytes = utf8.getBytes("你好");
console.log(bytes);

按需引用 (独立模块)

为了减小体积,您可以只引用需要的功能模块。构建产物位于 dist/ 目录下。

1. 单独使用 StringBuilder

StringBuilder 是完全独立的模块。

import StringBuilder from "@jyostudio/text/dist/string-builder.js";

const sb = new StringBuilder();
sb.appendLine("Line 1");

2. 单独使用 Encoding

Encoding 系统采用注册机制。您需要引入基础的 Encoding 类,然后引入您需要的具体编码实现(如 ascii-encoding.js)。具体编码文件被引入时会自动注册到 Encoding 系统中。

注意ascii-encoding.js 等文件依赖于 encoding.jsencoding-info.js。在使用模块加载器(如 Webpack 或原生 ES Modules)时,这些依赖会自动处理。

// 1. 引入基础 Encoding 类
import Encoding from "@jyostudio/text/dist/encoding.js";

// 2. 引入需要的编码实现 (副作用导入,用于注册编码)
import "@jyostudio/text/dist/ascii-encoding.js";
import "@jyostudio/text/dist/utf8-encoding.js";

// 3. 使用
const ascii = Encoding.getEncoding("ascii");
const bytes = ascii.getBytes("Hello");

浏览器中使用独立模块

如果您直接在浏览器中使用独立文件,请确保正确配置 importmap 以解析模块间的依赖关系。

<script type="importmap">
  {
    "imports": {
      "@jyostudio/text/dist/": "https://unpkg.com/@jyostudio/text/dist/"
    }
  }
</script>

<script type="module">
  import StringBuilder from "@jyostudio/text/dist/string-builder.js";
  import Encoding from "@jyostudio/text/dist/encoding.js";
  import "@jyostudio/text/dist/utf8-encoding.js";

  const sb = new StringBuilder("Test");
  const utf8 = Encoding.getEncoding("utf-8");
</script>

许可证

MIT License

Copyright (c) 2025 nivk

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.