1.0.2 • Published 6 years ago

ev-test v1.0.2

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Some basic DIY functions

Install

  • npm install ev-test

Usage

  • import util from 'ev-test'

Functions

  • Get the value of name in querystring:

    		query(name, querystring)
    	
    		// query('hello', '?hello=js') => 'js'
  • Serilize data:

      serialize(data)
    
      // serialize({hello: 'js', hi: 'test'}) => 'hello=js&hi=test'
  • Search DOM with selector:

    		$(selector)
    	
  • Remove the node from DOM:

    		removeNode(node)
    	
  • Insert node after target as a sibling in DOM:

    		insertAfter(node, target)
    			
  • Add className, which could be an array or a string, to the class list of target

    		addClass(node, className)
  • Remove className, which could be an array or a string, from the class list of target

    		removeClass(node, className)
  • Get the absolute URL of a relative URL in current page

    		getAbsoluteUrl(url)
    
      // getAbsoluteUrl('/abc') => 'https://www.npmjs.com/abc'
  • Debouce, to avoid shaking of the window

    		debounce(callback, time)
  • Remove the element of index from arr

    		removeItemByIndex(index, arr) 
    
      // removeItemByIndex(1, [1,2,3]) => [1, 3]