🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

has-values

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
h

has-values

Returns true if any values exist, false if empty. Works for booleans, functions, numbers, strings, nulls, objects and arrays.

2.0.1
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

76

Maintenance

100

License

Version published
Weekly downloads
21M
-16.91%
Maintainers
1
Weekly downloads
 
Created
Issues
3

What is has-values?

The has-values npm package is a utility that checks if a value exists and is not empty. It can be used to validate objects, arrays, strings, and other data types to ensure they contain meaningful data.

What are has-values's main functionalities?

Check if a string has a value

This feature allows you to check if a string is non-empty. It returns true if the string has a value and false if it is empty.

const hasValues = require('has-values');
console.log(hasValues('hello')); // true
console.log(hasValues('')); // false

Check if an array has values

This feature checks if an array contains any elements. It returns true if the array has elements and false if it is empty.

const hasValues = require('has-values');
console.log(hasValues([1, 2, 3])); // true
console.log(hasValues([])); // false

Check if an object has values

This feature checks if an object has any properties. It returns true if the object has properties and false if it is empty.

const hasValues = require('has-values');
console.log(hasValues({a: 1, b: 2})); // true
console.log(hasValues({})); // false

Check if a nested object has values

This feature checks if a nested object contains any values. It returns true if the nested object has values and false if it is empty.

const hasValues = require('has-values');
console.log(hasValues({a: {b: 2}})); // true
console.log(hasValues({a: {}})); // false

Other packages similar to has-values

FAQs

Package last updated on 31 Jan 2018

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