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

js-gtts

v1.1.1

Published

内置基础网络请求和提供渲染原生和自定义音频样式的组件

Downloads

5

Readme

为了能让本工具能运行在 javascript 的所有环境中以及使用 node 的后端服务中正常使用,规范采用 UMD 前后端跨平台的解决方案

实现

  1. 先判断是否支持Node.js模块格式(exports是否存在),存在则使用Node.js模块格式
  2. 再判断是否支持AMD(define是否存在),存在则使用AMD方式加载模块
  3. 前两个都不存在,则将模块公开到全局(window或global)

使用

作为TTS的中间件,支持接口自定义和请求数据的发送和响应数据的接收。

  1. js
  • 文件引入
  • 调用 GTTS.post 入参为当前的页面地址 url 和 要语音的文本内容 content
  • 回调成功后 GTTS.insertVoiceFileById('can', rd.returnObject, type)
    • (rd === res.data, can为插入的元素id节点)
    • type指的是音频相对于容器的位置仅支持标准DOM接口, 比如 insertBefore

约定

  • 请求
    • 仅对入参非空进行校验
    • 不做超时处理
    • 异常捕获请用户自行操作
  • 音频dom插入
    • 使用浏览器原生的 audio 标签 仅保留 播放/暂停 时间显示 播放进度
      • mac chrome: Version 74.0.3729.169
      • mac Safari: Version 13.1.2 (15609.3.5.1.3)
      • mac Microsoft Edge Version 84.0.522.63 (Official build)
      • mac Firefox 81.0.2 会保留音量操作
    • 对同一个插入的节点仅渲染一次,目前不做容器和音频文件的缓存;如果想更新,请刷新页面,重新获取

入参

  1. config
  • headers
  1. data
  • 当前页面地址 curUrl
  • 文本 content

相关参考

  1. umdjs/umd