npm.io
1.0.8 • Published 8 years ago

basic-tools

Licence
ISC
Version
1.0.8
Deps
0
Size
18 kB
Vulns
0
Weekly
0

basic-tools

  • Common utility function packages(常用的实用工具函数包)
  • npm-url:npm
  • github-url:github


Installation

You can install with npm:

$ npm install basic-tools

Usage

import basicTools from 'basic-tools'

Function

query(name, querystring)
  • Function for gets the value of the specified name in the specified querystring
basicTools.query('name', '?name=js') //return 'js'

serialize(data)
  • Function for turn the object into a url string
basicTools.serialize({hello: 'js'}) //return '?hello=js'

$(selector)
  • Function for simulating jQuery
basicTools.$(selector) //return {DOM|undefined}

removeNode(node)
  • Function for Deleting DOM node
basicTools.removeNode(node) //delete {node}

insertAfter(node)
  • Function for inserting the node node after the target node
basicTools.insertAfter(node, target) 

addClass(node, className)
  • Function for add class name
basicTools.addClass(node, className) //add class

removeClass(node, className)
  • Function for remove class name
basicTools.removeClass(node, className) //removeClass

getAbsoluteUrl(url)
  • Function for get absolute url
basicTools.getAbsoluteUrl('/xxxx') //return 'https://github.com/xxxx'

debounce(callback, time)
  • Function for avoiding shake

removeItemByIndex(index, arr)
  • Function for remove item by index
basicTools.removeItemByIndex(1, [1, 2, 3]) //return [1, 3]

Keywords