pppig

1.0.0 • Public • Published

pppig

Installation

You can install with npm:

$ npm i pppig

Usage

$ import tools from 'pppig'

Function

query(name, querystring)

  • Function for gets the value of the specified name in the specified querystring

tools.query('name', '?name=js') //return 'js'

serialize(data)

  • Function for turn the object into a url string

tools.serialize({hello: 'js'}) //return '?hello=js'

$(selector)

  • Function for simulating jQuery

tools.$(selector) //return {DOM|null}

removeNode(node)

  • Function for Deleting DOM node

tools.removeNode(node) //return {DOM}

insertAfter(node)

  • Function for inserting the node node after the target node

tools.insertAfter(node, target) //no return

addClass(node, className)

  • Function for add class name

tools.addClass(node, className) //no return

removeClass(node, className)

  • Function for remove class name

tools.removeClass(node, className) //no return

getAbsoluteUrl(url)

  • Function for get absolute url

tools.getAbsoluteUrl('/jerojiang') //return 'http://imweb.io/jerojiang'

debounce(callback, time)

  • 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++
    }
  })

removeItemByIndex(index, arr)

  • Function for remove item by index

tools.removeItemByIndex(1, [1, 2, 3]) //return [1, 3]

Readme

Keywords

none

Package Sidebar

Install

npm i pppig

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

8.54 kB

Total Files

7

Last publish

Collaborators

  • pppig