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 🙏

© 2024 – Pkg Stats / Ryan Hefner

retry-script

v1.0.2

Published

重试script

Downloads

7

Readme

retry-script

retry-script插件是一款能够使我们的项目、在加载js静态资源失败的时候、进行重新尝试加载(或者换域名重新加载)

特色功能:

  • 使用简单、支持自定义配置
  • 支持cdn的方式引入

快速开始

引入script (注意: 一定要在项目的最顶部引入)

<script src="http://xxx.xxx.xxx/retry-script.js"></script>
<script>
new RetryScript([
    'http://local/1',
    'http://local/2',
    'http://local/3'
 ])
</script>

注意: 一定要在项目的最顶部引入

配置项

支持两种方式配置

  • 1、仅配置hosts时, 可以简化为

    new RetryScript([
        'http://local/1',
        'http://local/2',
        'http://local/3'
     ])
  • 2、当多个配置时,看下面示例

    new RetryScript({
        hosts: [
            'http://local/1',
            'http://local/2',
            'http://local/3'
        ],
        handler (config) {
            return config.join('http://www.xxx.cn', config.source)
        }
    })

| 名称 | 类型 | 默认值 | 必传 | 说明 | | ------------------- | ----------------- | ------ | ---- | ------------------------------------------------------------ | | hosts | string[] | 无 | 是 | 重试的host数组列表, 当js加载失败时、默认会依次从hosts数组中按照顺序取出对应的域名来尝试加载js | | handler | function | 无 | 否 | 处理函数, 接收**config对象**, 返回值作为下次重试的src 地址; 如果返回值是字符串,则作为下次重试的src地址; 返回值如果是其他类型,则使用默认规则生成下次重试地址 |

config对象说明

| 名称 | 类型 | 说明 | | ------------------- | ----------------- | ------------------------------------------------------------ | | currentIndex | number | 重试的hosts的index索引 | | source | string | 解析出来的资源名 | | oldSrc | string | 上一次加载失败的src路径 | | hosts | string[] | 传入的配置项hosts | | join | function | 路径拼接函数、用法同nodepath模块的join方法 |

方法

| 方法名 | 返回值 | 示例 | 描述 | | ------------- | ------ | ----------------------- | ---------------------- | | destory | 无 | captcha.destory() | 销毁控件 |