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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jtxt

v0.1.8

Published

A CLI tool like awk but using js grammar instead

Readme

Rust CI

$ jtxt 'var it = l.split("]")[2]; console.log(it)' gc.log

Quick Start

Download from the release, run the binary executable file or npm i -g jtxt

从release中下载二进制文件直接运行即可,或者使用npm i -g jtxt

Usage

注意logic/end/begin部分,在windows下需要用"而不能用'

$ jtxt -h
Usage: jtxt [options] <logic> [filename]

Arguments:
  logic               处理逻辑的 JavaScript 代码
  filename            要读取的文件名 (default: null)

Options:
  -V, --version       output the version number
  -b, --begin <code>  初始化的逻辑代码
  -e, --end <code>    结束后的逻辑代码
  -h, --help          display help for command

Example with 1.txt

# 1 filter the lines that only contains numbers from 1.txt
# 1 从1.txt中过滤全是数字的行
$ jtxt 'if (l.match(/^\d+$/)) console.log(l)' 1.txt
200
404
200

# 2 compute the character number of 1.txt (exclude the [\r]\n)
# 2 计算1.txt中的字符个数(除了换行符[\r]\n)
$ jtxt -b 'ctx.s=0' 'ctx.s += l.length' -e 'console.log(ctx.s)' 1.txt
168

# 3 filter the lines that contains `Request`, and process the time text, then analyze the distribution of quantity per hour
# 3 过滤含有Request的行,并将时间部分进行处理,分析每个小时的请求数量分布
$ jtxt 'if(l.indexOf("Request")>=0) console.log(l)' 1.txt \
    | jtxt -b 'ctx.m={}' 'var k = "h" + new Date(l.substring(0,19)).getHours(); if(!ctx.m[k]) ctx.m[k]=0; ctx.m[k]++' -e 'console.log(ctx.m)' 1.txt
{ h13: 2, h0: 3, h14: 1, hNaN: 1 }

Well, to simplify the command, you can also use the preset variable: var ctx = { n1:0, n2:0, n3:0, s:'', arr:[]}

你也可以用内置的变量ctx来简化指令,var ctx = { n1:0, n2:0, n3:0, s:'', arr:[]}

Async & Shell

The logic is an async function, so you can use await in it directly, and the lines are processed sequentially one by one. Besides, exec/execSync are injected to run shell commands. They return the stdout as a string (trailing newline trimmed), and throw an error on non-zero exit.

logic 是一个 async 函数,可以直接使用 await,各行严格按顺序串行处理。另外注入了 exec/execSync 用于执行 shell 命令,返回 stdout 字符串(去掉末尾换行),命令非零退出时会抛错。

# 1 call an HTTP API for each line
# 1 对每一行调用 HTTP 接口
$ jtxt 'const r = await fetch("https://api.example.com/u/" + l); console.log(l, r.status)' ids.txt

# 2 run a shell command for each line
# 2 对每一行执行 shell 命令
$ jtxt 'console.log(l, await exec("wc -c < " + l))' filelist.txt

# 3 execSync is also available, e.g. get the git version once in begin
# 3 也可以使用同步的 execSync,例如在 begin 中获取一次 git 版本
$ jtxt -b 'ctx.s = execSync("git rev-parse --short HEAD")' 'ctx.n1++' -e 'console.log(ctx.s, ctx.n1)' 1.txt

Note: exec spawns a subprocess for every call, so it is recommended to use it with filtered lines or in begin/end, rather than on every line of a huge file.

注意:exec 每次调用都会启动一个子进程,建议配合过滤后的行或在 begin/end 中使用,而不是对大文件的每一行调用。

Agent Skill

This repository ships an agent skill (skills/jtxt) that teaches AI coding agents (Claude Code, OpenCode, Cursor, Codex, etc.) when and how to use jtxt. Install it with the skills CLI:

本仓库附带一个 agent skill(skills/jtxt),用于教会 AI coding agent(Claude Code、OpenCode、Cursor、Codex 等)何时以及如何使用 jtxt。可通过 skills CLI 安装:

# interactive: pick the skill and the target agents
# 交互式:选择 skill 和目标 agent
$ npx skills add sunwu51/jtxt

# non-interactive: install this skill directly
# 非交互式:直接安装本 skill
$ npx skills add sunwu51/jtxt --skill jtxt --yes

# install for specific agents only
# 只为指定的 agent 安装
$ npx skills add sunwu51/jtxt --skill jtxt --agent claude-code --agent opencode

Performance

Environment: macOS (Apple Silicon), Node.js v26, ripgrep 15.1.0, macOS built-in awk. The test file is a 500MB / 3,268,000 lines random log generated by bench_gen.js. Each command runs 3 times and the best result is taken. Run bash bench_tools.sh to reproduce.

测试环境:macOS(Apple Silicon),Node.js v26,ripgrep 15.1.0,macOS 自带 awk。测试文件为由 bench_gen.js 生成的 500MB / 3,268,000 行随机日志。每条命令运行 3 次取最优,可通过 bash bench_tools.sh 复现。

| 场景 scenario | jtxt (node) | awk | rg | wc | |---|---|---|---|---| | 行计数 count lines | 509ms | 7147ms | 139ms | 442ms | | 子串过滤计数 count lines containing abc | 652ms | 7523ms | 62ms | - | | 词数统计 count words | 934ms | 7107ms | 1894ms | 655ms | | 正则匹配计数 count lines matching [0-9]{5}$ | 536ms | 9008ms | 1393ms | - |

- means the tool cannot complete the scenario alone / - 表示该工具无法独立完成此场景

  • For pure searching (counting lines, literal filtering), rg has an order of magnitude advantage (SIMD + mmap + multi-threading). It is not jtxt's goal to replace it.
  • 对于纯搜索场景(行计数、子串过滤),rg 有数量级优势(SIMD + mmap + 多线程),jtxt 并不以取代它为目标。
  • For computing-heavy scenarios (word counting with split, complex regex), jtxt (V8) is even faster than rg's default regex engine, and in the same order of magnitude as wc which is implemented in C.
  • 对于计算较重的场景(split 词数统计、复杂正则),jtxt (V8) 甚至快于 rg 的默认正则引擎,与 C 实现的 wc 处于同一量级。
  • Compared with awk which has a similar positioning, jtxt is more than 10x faster in all scenarios (note: the built-in awk on macOS is quite old).
  • 与定位相近的 awk 相比,jtxt 在所有场景都快 10 倍以上(注:macOS 自带的 awk 版本较老)。
  • The core value of jtxt is the arbitrary processing that dedicated tools cannot do: aggregation, transformation, fetch, exec, etc.
  • jtxt 的核心价值在于专用工具做不到的任意处理:聚合、转换、fetchexec 等。