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

@nguyenduclong/rdbtools

v1.0.2

Published

Bộ công cụ CLI nhỏ cho các tác vụ thường gặp:

Readme

rdbtools

Bộ công cụ CLI nhỏ cho các tác vụ thường gặp:

  • fix-sort-imports: sắp xếp thứ tự import cho JS/TS.
  • docx-to-md: chuyển file .docx sang Markdown, tách ảnh ra file riêng.
  • md-extract: tách ảnh nhúng dạng data:image/...;base64 trong Markdown thành file ảnh.
  • rdb-mock: chạy mock server có route tùy biến và proxy các route còn lại lên upstream.

Cài đặt

Dùng trực tiếp trong repo

npm install

Dùng như package CLI

npm install -g @nguyenduclong/rdbtools

Hoặc chạy qua npx:

npx @nguyenduclong/rdbtools <command>

1) fix-sort-imports

Sắp xếp nhóm import theo cú pháp member (none, all, multiple, single), đồng thời sort tên trong { ... }.

Cách dùng

fix-sort-imports <file-or-dir> [...more] [--write=false]

Ví dụ:

fix-sort-imports src
fix-sort-imports src/a.ts src/b.ts
fix-sort-imports src --write=false

Ghi chú:

  • Mặc định --write=true (ghi đè file).
  • Bỏ qua các thư mục phổ biến như node_modules, .git, dist, build, coverage, .next, .turbo, .yarn, out.

2) docx-to-md

Chuyển .docx thành Markdown, xuất ảnh thành file riêng trong thư mục output.

Cách dùng

docx-to-md <input-docx-file>

Ví dụ:

docx-to-md ./docs/spec.docx

Kết quả:

  • Tạo thư mục cùng tên file đầu vào (không gồm đuôi .docx), ví dụ docs/spec/.
  • File markdown output: docs/spec/spec.md.
  • Ảnh được xuất vào cùng thư mục output.

3) md-extract

Tách ảnh nhúng base64 trong file Markdown thành file ảnh riêng và rewrite lại link ảnh trong Markdown.

Cách dùng

md-extract <input-markdown-file>

Ví dụ:

md-extract ./notes/report.md

Kết quả:

  • Tạo thư mục output theo tên file markdown, ví dụ notes/report/.
  • File markdown đã rewrite: notes/report/report.md.
  • Ảnh được xuất vào cùng thư mục output.

4) rdb-mock

Mock server dựa trên Express:

  • Route khớp trong mockRoutes sẽ dùng handler mock.
  • Route còn lại sẽ proxy sang sourceUrl.

Cách dùng

rdb-mock <path-to-mock-routes-file>

Ví dụ file config (mock.config.cjs):

module.exports = {
  sourceUrl: 'http://localhost:8000',
  host: '127.0.0.1', // optional, mặc định lấy từ MOCK_HOST hoặc 127.0.0.1
  port: 8001,
  mockRoutes: [
    {
      path: '/tenant/pats/',
      method: 'GET',
      handle: (req, res) => res.status(200).json({ results: [] }),
    },
  ],
  // optional
  middlewares: [],
};

Chạy:

rdb-mock ./mock.config.cjs

Health check:

curl http://127.0.0.1:8001/__mock/health

Scripts npm

npm run extract-md-images -- <input-md-file>
npm run docx-to-md -- <input-docx-file>
npm run rdb-mock -- <path-to-config>

License

ISC