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