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

@kitions/http

v1.0.1

Published

1. 必须能同时在C/S 端使用 2. 能明确的错误分层 1. 能区分获取值是否存在 空`null` 2. 能区分是否是错误 3. 方便使用

Downloads

5

Readme

Introduction

目标

  1. 必须能同时在C/S 端使用
  2. 能明确的错误分层
    1. 能区分获取值是否存在 空null
    2. 能区分是否是错误
  3. 方便使用

设计

  1. axios 基础上进行封装 满足多端使用
  2. Option Result 分别表示 值是否存在 以及结果是否错误
  3. 以方便为主,所以封装写死很多配置降低灵活度。但是要提供尽量多的option参数
  Http.get(url)
  Http.get(url,options)

  let option = new Options(
        header,   // 头部信息
        body  // 需要传输的数据
  )

缓存使用

  Http.get(url, options)
  Http.post(url, data, options)

需要缓存的话,下面三个参数传在options中

option?: AxiosRequestConfig & IStoreKey<T>

  1. 开启缓存isCache字段,bool类型
  2. isProtoOK: (data: T) => boolean 针对特殊协议回调。不传使用默认协议 code msg data,code===0 时进行sessionStorage缓存
  3. storageKey sessionStorage的key,可选参数,不传默认key为url.
interface IStoreKey<T> {
  isCache?: boolean; // 是否缓存
  isProtoOK?: (res: T) => boolean; // 回调参数返回请求成功对象,传回bool类型,判断使用默认协议,可选参数
  storageKey?: string; // sessionStorage的key,可选参数,不传默认key为url
}