Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

empty-utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

empty-utils

two utils to check the given value is empty or not

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

empty-utils

Two utils to check the given value is empty or not.

Downloads install size

Install

$ npm install empty-utils

Usage

import { isEmpty, isNotEmpty } from 'empty-utils'

// will return "true"
isEmpty(null)
isEmpty(undefined)
isEmpty('')
isEmpty([])
isEmpty({})
isEmpty(Object.create(null))
isEmpty({ [Symbol('foo')]: 'bar' })
isEmpty(new Map())
isEmpty(new Set())
isEmpty(new RegExp())

// will return "false"
isEmpty(0)
isEmpty(5)
isEmpty(0.0)
isEmpty(0.1)
isEmpty(BigInt(0))
isEmpty(3n)
isEmpty(true)
isEmpty(false)
isEmpty(' ')
isEmpty('😸')
isEmpty([1])
isEmpty([{}])
isEmpty(['hello'])
isEmpty(new WeakMap())
isEmpty(new WeakSet())
isEmpty(function () {})
isEmpty(Number.NaN)
isEmpty(Infinity)
isEmpty(Symbol('bar'))
isEmpty(new Date())
isEmpty(/kurdish/)

Strict mode?

Once the strict mode is enabled 0 (zero) as Number or BigInt and Strings filled with spaces will be evaluated as empty. However the objects only contains Symbol(s) will be evaluated as not empty.

// strict mode
isEmpty(0, true)    // true
isEmpty(0n, true)   // true
isEmpty(' ', true)  // true

isEmpty({ [Symbol('foo')]: 'bar' }, true)  // false

Available utils

NameDescription
isEmptyA function who checks if the given value is empty.
isNotEmptyA function who checks if the given value is not empty.

Options

NameTypeDefaultDescription
valueany-The thing to be checked.
strictbooleanfalseStrict mode

Keywords

FAQs

Package last updated on 08 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc