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

hs-public

v0.0.3

Published

npm install hs-public

Downloads

7

Readme

HsPublic

npm install hs-public

##notice:

1.重写了错误处理逻辑 2.抽离对jquery ajax的依赖。成为一个独立的sdk 3.增加了对轮询的支持 4.代码上的优化 5.可能更多的功能,比如是否是开盘时间的判断等

##how to use

基本保证了api的兼容性,之前的代码基本不需要改动

但是tokenUrl变成配置项,使用前必须提供。不提供的话,运行不起来。一般会报错:Cannot read property 'isTokenValid' of null

HsDataFactoryList.configTokenServer({
    tokenUrl:'http://your-token-url'
})

基本使用:

var client = HsDataFactoryList[clientType](
    reqData,//参考恒生api
    extraOptions // {loop:true,timeSpan:5000} 对轮询的支持 
                 // loop:true 开启轮询
                 // timeSpan:5000//轮询的时间间隔,为最少时间间隔,如果不到,会等到5s,然后在请求。
).onDataReady(function(e){
    //这里数据已经请求回来
}).onError(function(e){
    //处理错误,一般使用者不需要处理。
    //Token过期的错误,已经自动处理
}).on('tokenInvalid',function(){
    //token过期时,触发,这时可以加快轮询时间等
    client.timeSpan = 2000;
    //正常后,轮询时间变正常
    client.once('dataReady',function(){
        client.timeSpan= 5000
    })
}).init() //调用init后,请求才开始

client.stop()//停止轮询,已停止的化,没有作用

client.resume()//回复轮询,已经在轮询的,没有作用

目前支持的clientType

    wizard:'http://open.hs.net/quote/v1/wizard',
    kline:'http://open.hs.net/quote/v1/kline',
    real:'http://open.hs.net/quote/v1/real',
    trend:'http://open.hs.net/quote/v1/trend',
    holiday:'http://open.hs.net/quote/v1/market/holiday',
    sort:'http://open.hs.net/quote/v1/sort',
    trend5day:'http://open.hs.net/quote/v1/trend5day
    
如果要添加,作为开发者可以去改代码(src/index.js里的apiUrlMap)

临时添加,可以使用(实验性功能)
   
    HsDataFactoryList._apiUrlMap[newOne]='http://newOneApiUrl'
    HsDataFactoryList._initApiUrl()

2.增加了对轮询的支持

var trend = HsDataFactoryList['trend'](
            { 
                prod_code:'600570.SS',
                fields:'last_px,avg_px,business_amount'
            },
            {
                loop:true,//开启轮询
                timeSpan:5000//轮询的时间间隔,为最少时间间隔,如果不到,会等到5s后在请求。
            }
        ).onDataReady(function(e){console.log(e)})
           .init();
           
           

##how to develop

if you have not installed gulp,babel at global env,first

npm i -g gulp
npm i -g babel
  1. npm i

  2. gulp dev-server

  3. open http://localhost:8080/dev-demo/newApi.html

... to be continued