1.0.2 • Published 6 years ago
adam_lightning v1.0.2
adam_lightning
- a library that contains some frequently used js functions
- npm-url:https://www.npmjs.com/package/adam_lightning
- git-url:http://git.imweb.io/liaotl/adam
Installation
You can install with npm:
$ npm install adam_lightning
Usage
import adam from 'adam_lightning'
Function
1. query(name, querystring)
- Function for gets the value of the specified name in the specified querystring
adam.query('hello', '?hello=js') //return 'js'
2. serialize(data)
- Function for turn the object into a url string
adam.serialize({hello: 'js'}) //return '?hello=js'
3. $(selector)
- Function for selecting DOM given a CSS selector
adam.$(selector) //return {DOM|undefined}
4. removeNode(node)
- Function for Deleting DOM node
adam.removeNode(node) //return {DOM}
5. getLastChild(node)
- Function to get the last child of target DOM (not blank node)
adam.getLastChild(node) //return {DOM|null}
6. insertAfter(node, target)
- Function for inserting the node after the target node
adam.insertAfter(node, target)
7. hasClass(node, className)
- Function for checking if the node has the class name
adam.hasClass(node, className) //return true or false
8. addClass(node, className)
- Function for adding a new class name to the node
adam.addClass(node, className) //return true or false
9. removeClass(node, className)
- Function for removing a class name from the node
adam.removeClass(node, className) //return true or false
10. getAbsoluteUrl(url)
- Function for get absolute url
adam.getAbsoluteUrl('/hhh') //return 'https://github.com/hhh'
11. debounce(callback, time)
- Function for avoiding shake
window.addEventListener('scroll', () => {
console.log('default')
})
window.addEventListener('scroll', adam.debounce)
12. removeItemByIndex(index, arr)
- Function for removing item by index
adam.removeItemByIndex(1, [1, 2, 3]) //return [1, 3]