Skip to content

Commit

Permalink
feat: Added export isEmpty
Browse files Browse the repository at this point in the history
Signed-off-by: Jaid <jaid.jsx@gmail.com>
  • Loading branch information
Jaid committed Jul 4, 2019
1 parent dcece13 commit 7c0d097
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@

import {isNil, isString, isNumber, isFunction, isObject, isBoolean} from "lodash"

/**
* Returns `true` if the passed value is truthy or has any kind of content
* @example
* import hasContent from "has-content"
* const result = hasContent(" ")
* result === false
* @example
* import hasContent from "has-content"
* const result = hasContent("a")
* result === true
* @returns {boolean} `true` if `value` is truthy or has content
*/
export default value => {
const hasContent = value => {
if (value |> isNil) {
return false
}
Expand All @@ -40,4 +28,38 @@ export default value => {
return Object.keys(value).length > 0
}
return false
}
}

/**
* Returns `false` if the given value is truthy or has any kind of content
* @example
* import {isEmpty} from "has-content"
* const result = hasContent(" ")
* result === true
* @example
* import {isEmpty} from "has-content"
* const result = hasContent("a")
* result === false
* @function isEmpty
* @param {*} value
* @returns {boolean} `false` if `value` is truthy or has content, `true` otherwise
*/
export const isEmpty = value => {
return !hasContent(value)
}

/**
* Returns `true` if the given value is truthy or has any kind of content
* @example
* import hasContent from "has-content"
* const result = hasContent(" ")
* result === false
* @example
* import hasContent from "has-content"
* const result = hasContent("a")
* result === true
* @function default
* @param {*} value
* @returns {boolean} `true` if `value` is truthy or has content
*/
export default hasContent

0 comments on commit 7c0d097

Please sign in to comment.