- function package from pppig
- npm-url https://www.npmjs.com/package/pppig
- git-url http://git.imweb.io/pppig/adam
You can install with npm:
$ npm i pppig
$ import tools from 'pppig'
- Function for gets the value of the specified name in the specified querystring
tools.query('name', '?name=js') //return 'js'
- Function for turn the object into a url string
tools.serialize({hello: 'js'}) //return '?hello=js'
- Function for simulating jQuery
tools.$(selector) //return {DOM|null}
- Function for Deleting DOM node
tools.removeNode(node) //return {DOM}
- Function for inserting the node node after the target node
tools.insertAfter(node, target) //no return
- Function for add class name
tools.addClass(node, className) //no return
- Function for remove class name
tools.removeClass(node, className) //no return
- Function for get absolute url
tools.getAbsoluteUrl('/jerojiang') //return 'http://imweb.io/jerojiang'
- Function for avoiding shake
- example
test('debounce', (done) => { // 使用jest模拟异步调用
let total = 0 // 声明总调用次数为 0 次
tools.debounce(() => { // 调用 function debounce
expect(total).toBe(10)
done()
}, 300) // 设定延迟调用时间
for (let i = 0; i < 10; i++) { //统计总调用次数为 10 次
total++
}
})
- Function for remove item by index
tools.removeItemByIndex(1, [1, 2, 3]) //return [1, 3]