UNPKG

660 BJavaScriptView Raw
1/*!
2 * has-any <https://github.com/jonschlinkert/has-any>
3 *
4 * Copyright (c) 2014-2015, Jon Schlinkert.
5 * Licensed under the MIT License.
6 */
7
8'use strict';
9
10/**
11 * Does the given `obj` have any of the specified `keys`?
12 *
13 * @param {Object} `obj`
14 * @param {Array} `keys`
15 * @return {Boolean} Returns true if any of the keys match.
16 */
17
18module.exports = function hasAny(o, keys) {
19 if (typeof o !== 'object') {
20 return false;
21 }
22
23 keys = !Array.isArray(keys) ? [keys] : keys;
24 var len = keys.length;
25 var has = false;
26
27 for (var i = 0; i < len; ++i) {
28 if (o.hasOwnProperty(keys[i])) {
29 has = true;
30 break;
31 }
32 }
33 return has;
34};
\No newline at end of file