- 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
You can install with npm:
$ npm install adam_lightning
import adam from 'adam_lightning'
- Function for gets the value of the specified name in the specified querystring
adam.query('hello', '?hello=js') //return 'js'
- Function for turn the object into a url string
adam.serialize({hello: 'js'}) //return '?hello=js'
- Function for selecting DOM given a CSS selector
adam.$(selector) //return {DOM|undefined}
- Function for Deleting DOM node
adam.removeNode(node) //return {DOM}
- Function to get the last child of target DOM (not blank node)
adam.getLastChild(node) //return {DOM|null}
- Function for inserting the node after the target node
adam.insertAfter(node, target)
- Function for checking if the node has the class name
adam.hasClass(node, className) //return true or false
- Function for adding a new class name to the node
adam.addClass(node, className) //return true or false
- Function for removing a class name from the node
adam.removeClass(node, className) //return true or false
- Function for get absolute url
adam.getAbsoluteUrl('/hhh') //return 'https://github.com/hhh'
- Function for avoiding shake
window.addEventListener('scroll', () => {
console.log('default')
})
window.addEventListener('scroll', adam.debounce)
- Function for removing item by index
adam.removeItemByIndex(1, [1, 2, 3]) //return [1, 3]