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

pida

v1.0.16

Published

tiny library like jQuery without any dependencies 一个很小的jquery类似的库,用了jquery类似的查询语法,没有依赖

Downloads

7

Readme

Pida

Terribly small javascript library ,up to 5k (gziped)

  • Chrome or other supported:( no IE )
  • Browser side only,not for node.js

Installation:

yarn add pida

or

npm install --save pida

Example of document query

import  pida from  'pida'
pida.onDomReady(()=>{
    console.dir(pida.$("a").length)
     pida.addListener(pida.$("a"),"click",(evt)=>{
         console.log(evt.target);
     })
    pida.each(pida.$("a"),(item)=>{
        console.log(item);
    })
    console.dir(pida)
})

vite demo project:https://github.com/gotapi/pida-demo

ajax get request

pida.get("https://ip4.dev/myip?format=json",{
    "on":{
        "load":(progress)=>{
            console.log("onload")
        },
        "loaded":(progress)=>{
            console.log("onloaded")    
        }
    }
}).then((data)=>{
    console.log(data);
}).catch((err)=>{
    console.log("got error")
    console.log(err);
});

ajax post request

let data = new FormData()
data.append("title","hello")
pida.post("https://example.org/",{
    headers:{
        "secret":"this is secret"
    }
    },
    data
).then((resp)=>{
    console.log("got resp:")
    console.log(resp)
}).catch((err)=>{
    console.log("got error")
    console.log(err)
});

example for post x-www-form-urlencoded data:

let formSend = "type=json&url=" + encodeURIComponent(location.href) + "&content=" + encodeURIComponent("Hellobaby");

pida.post("https://gotapi.net/v3/api/text2pic", {
    "timeout": 15000,
    "headers": {
        "secret": secret,
        "Content-Type": "application/x-www-form-urlencoded"
   }
},
formSend).then((data) => {});

hide/show/toggle

pida.$("a[href]").toggle()

html/val/text

pida.$("p").html("same text")

attr

//when you try to getAttributes,return the first
pida.$("input").attr("value")
pida.$("href").attr("link","/index")

addClass/removeClass

pida.$("p").addClass("bigger")
pida.$("p").removeClass("blue-text")

usage of event binding

    pida.$("a[href]").on("click", (evt) => {
        evt.preventDefault();
        console.log(evt.target.getAttribute("href"));
    });

chainable

pida.$("a[href]").on("click",(evt)=>{ console.log(evt);}).addClass("blue").addClass("bigger")

other helpers

pida.each(iter,(element)=>{

})
pida.isArray()
pida.isObject()
pida.isString()
console.log(pida.os) //Windows or iOS  or Android etc.
console.log(pida.browser) //Chrome or  Opera or Microsoft Edge or Firefox etc

change log

1.0.16

在提交get/post等ajax请求时,把xhr作为参数传进去了。

1.0.15

  1. 一些bug修复. some bugfixs
  2. 文档更新.document updated;
  3. 优化代码,以让pida在sonarqube上的等级变为A级。code optimized to pass sonar-scanner.

1.0.14

修复在addClass时的bug

1.0.13

The behavior of html/val/attr/text is unified. When there are multiple hit objects, only the first html/val/attr/text attribute is returned. 统一了html/val/attr/text的行为,当命中对象有多个时,只返回第一个的html/val/attr/text属性。