0.0.2 • Published 2 years ago

swiss-knife-utils v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

swiss-knife-utils

My must-have utils and type guards

Installation

yarn add swiss-knife-utils

or

npm install swiss-knife-utils

Usage

import { isFunction, isNil, isHTMLElement, getWindowFromElement } from 'swiss-knife-utils'

function handleOnClick(cb) {
    return (event) => {
        if (isNil(event)) {
            return
        }

        if (isFunction(cb)) {
            cb(event)
        }
        
        if (isHTMLElement(event.target)) {
          const domWindow = getWindowFromElement(event.target)
        }
    }
}

Utils

Logic

  • isArray
  • isBoolean
  • isEmptyArray
  • isEmptyString
  • isFunction
  • isHTMLElement
  • isNil
  • isNonEmptyArray
  • isNonEmptyString
  • isNumber
  • isString

DOM

  • getWindowFromElement