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

dooy-js-tool

v0.1.8

Published

Dooy的小工具 想用拿走

Downloads

15

Readme

dooy-js-tool 小工具

安装

npm i dooy-js-tool

const dooy = require("dooy-js-tool");

浏览器引入

<script src="dist/dooy-js-tool.min.js"></script>

工具 方法使用

在线运行

console.log( dooy.tool.dateFormat("yyyy-MM-dd hh:mm:ss" ) );
console.log( dooy.tool.dateFormat("yyyy-MM-dd hh:mm:ss",new Date()) );
console.log( dooy.tool.dateFormat("yyyy-MM-dd hh:mm:ss",'2022-09-10') );
console.log( dooy.tool.dateFormat("yyyy-MM-dd hh:mm:ss",1664400496) );

console.log( dooy.tool.now( 1664400496));
console.log( dooy.tool.now( "2022-10-01 05:28:16"));
console.log( dooy.tool.now( new Date("2022-10-01 05:28:16")));

console.log( dooy.tool.getQueryStr("abc")); // ?abc=123 仅支持 浏览器模式

腾讯COS

需要腾讯COS库支持 引入腾讯COS

<script src="https://cdn.jsdelivr.net/npm/cos-js-sdk-v5/dist/cos-js-sdk-v5.min.js"></script>
#或者
let COS = require('cos-js-sdk-v5');

调用

<input type="file"   onchange="upload">
<script>
    /**
     * init(opt) 
     * opt 参数
     * @param COS 腾讯云COS js
     * @param {function} callback
     * @param {String} stsMyServer 验证码服务器地址
     * @param cosCdn 存放cos CDN 远程域名
     * @param Bucket 存储桶
     * @param Region 腾讯云园区
     */
    let opt={
        COS
        ,stsMyServer:'/pigai?c=mpad&a=cos&do=1' //批改网验证服务器
        ,callback: res=>{
            console.log("返回>>",res);
        }
    }
function upload(e){
        const file = e.target.files && e.target.files[0];

        dooy.cos.init(opt).upload(file
            ,{onProgress: info=>{
                    let percent = Math.floor(info.percent * 10000) / 100;
                    let speed = Math.floor(info.speed / 1024 / 1024 * 100) / 100;
                    console.log('进度:' + percent + '%; 速度:' + speed + 'Mb/s;');
                }
        });

    }
</script>

ES

需要 axios支持

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>

使用

 let es= dooy.es.init({axios});
 //新建一个buckets
 let ts = es.createBuckets(res.data.aggregations.ts.buckets);
 //获取bucket中 key 为 1的值
 let t2 = ts.getObjectByKey('1');

//获取bucket 中的日志 带 key doc_cnt 和file.value 
 let rz=ts.getValue();

批改ES

需要 lodash axios支持

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>

调用

getPigaiEs(){
    let opt={
        school:'',//学校 支持多学校[’北京大学‘,'南京大学']
        stime:'2010-01-01',//开始日期
        etime:'2022-10-01',//截止日期
        rank:'y',//排序方式 y 年,m 月,w 周,d 日
        where:{},//其他条件 比如地域 where.city=['北京市',’北京‘]
    }
    let es= dooy.es.init({axios});
    let pigaiEs = new dooy.pigaiEs(es,_, opt);
    return pigaiEs;
}
//获取概况统计 分别获取
loadInit(){
    this.getPigaiEs().getMember().then(res=>{
        this.smain= _.extend(this.smain ,res[0].data);
        //console.log('main>>', this.smain);
    });
    this.getPigaiEs().getRequest().then(res=>{
        this.st.request = true;
        this.request= _.extend(this.request ,res[0].data);
        //console.log('request>>', res[0]);
    });
    this.getPigaiEs().getEssay({all:1}).then(res=>{
        this.st.essay = true;
        this.essay= _.extend(this.essay ,res[0].data);
        //console.log('essay>>', res[0]);
    });
}

//获取按年、月、周、日统计 多次请求等等回来 像 jquery.wehn,axios.all
this.getPigaiEs().rankRequest().rankEssay().rankMember().then( res=>{
    let request= res[0].data;
    let essay= res[1].data;
    let member= res[2].data;
});

批改网登录登出

初始化

let pigaiLogin=  dooy.pigaiLogin.init({axios})

获取登录信息

let u = pigaiLogin.getJsPigaiInfo();
#未登录为 null
#有登录为 返回
{
    "userName": "用户名",
    "userId": "123",
    "isLogin": true,
    "nickName": "显示名字",
    "lang": "cn",
    "isV": 1,
    "ts": 2,
    "school": "学校",
    "info":{ ##原始数据 批改网是什么这就是什么
        "i": "21",
            "u": "student",
            "u2": "张宇2",
            "k": "af498d7fe57cbc84df6ae085340de151",
            "img": "20211012/21",
            "ts": 2,
            "s": "昆明理工大学",
            "iv": 1,
            "st": "0",
            "no": "123132131232121",
            "cl": "2019安工化工A班"
    }
}

登录

pigaiLogin.login(this.form.name,this.form.psw).then(res=>{
                    console.log('dddd',res);
                    if(res.error==0){
                        userInfo=res.data;
                    }
                });

登出

pigaiLogin.logout();