.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / unset-value / node_modules / has-values / README.md
1 # has-values [![NPM version](https://img.shields.io/npm/v/has-values.svg?style=flat)](https://www.npmjs.com/package/has-values) [![NPM downloads](https://img.shields.io/npm/dm/has-values.svg?style=flat)](https://npmjs.org/package/has-values) [![Build Status](https://img.shields.io/travis/jonschlinkert/has-values.svg?style=flat)](https://travis-ci.org/jonschlinkert/has-values)
2
3 > Returns true if any values exist, false if empty. Works for booleans, functions, numbers, strings, nulls, objects and arrays.
4
5 ## Install
6
7 Install with [npm](https://www.npmjs.com/):
8
9 ```sh
10 $ npm install has-values --save
11 ```
12
13 ## Usage
14
15 ```js
16 var hasValue = require('has-values');
17
18 hasValue('a');
19 //=> true
20
21 hasValue('');
22 //=> false
23
24 hasValue(1);
25 //=> true
26
27 hasValue(0);
28 //=> false
29
30 hasValue(0, true); // treat zero as a value
31 //=> true
32
33 hasValue({a: 'a'}});
34 //=> true
35
36 hasValue({}});
37 //=> false
38
39 hasValue(['a']);
40 //=> true
41
42 hasValue([]);
43 //=> false
44
45 hasValue(function(foo) {}); // function length/arity
46 //=> true
47
48 hasValue(function() {});
49 //=> false
50
51 hasValue(true);
52 hasValue(false);
53 //=> true
54 ```
55
56 ## isEmpty
57
58 To test for empty values, do:
59
60 ```js
61 function isEmpty(o, isZero) {
62   return !hasValue(o, isZero);
63 }
64 ```
65
66 ## Related projects
67
68 You might also be interested in these projects:
69
70 * [has-value](https://www.npmjs.com/package/has-value): Returns true if a value exists, false if empty. Works with deeply nested values using… [more](https://www.npmjs.com/package/has-value) | [homepage](https://github.com/jonschlinkert/has-value)
71 * [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object)
72 * [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject)
73
74 ## Contributing
75
76 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/has-values/issues/new).
77
78 ## Building docs
79
80 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
81
82 ```sh
83 $ npm install verb && npm run docs
84 ```
85
86 Or, if [verb](https://github.com/verbose/verb) is installed globally:
87
88 ```sh
89 $ verb
90 ```
91
92 ## Running tests
93
94 Install dev dependencies:
95
96 ```sh
97 $ npm install -d && npm test
98 ```
99
100 ## Author
101
102 **Jon Schlinkert**
103
104 * [github/jonschlinkert](https://github.com/jonschlinkert)
105 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
106
107 ## License
108
109 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
110 Released under the [MIT license](https://github.com/jonschlinkert/has-values/blob/master/LICENSE).
111
112 ***
113
114 _This file was generated by [verb](https://github.com/verbose/verb), v, on March 27, 2016._