blob: 46b283093abd48178b4e21ae822de4360f234746 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
'use strict';
module.exports = function array_keys(input, searchValue, argStrict) {
// eslint-disable-line camelcase
// discuss at: http://locutus.io/php/array_keys/
// original by: Kevin van Zonneveld (http://kvz.io)
// input by: Brett Zamir (http://brett-zamir.me)
// input by: P
// bugfixed by: Kevin van Zonneveld (http://kvz.io)
// bugfixed by: Brett Zamir (http://brett-zamir.me)
// improved by: jd
// improved by: Brett Zamir (http://brett-zamir.me)
// example 1: array_keys( {firstname: 'Kevin', surname: 'van Zonneveld'} )
// returns 1: [ 'firstname', 'surname' ]
var search = typeof searchValue !== 'undefined';
var tmpArr = [];
var strict = !!argStrict;
var include = true;
var key = '';
for (key in input) {
if (input.hasOwnProperty(key)) {
include = true;
if (search) {
if (strict && input[key] !== searchValue) {
include = false;
} else if (input[key] !== searchValue) {
include = false;
}
}
if (include) {
tmpArr[tmpArr.length] = key;
}
}
}
return tmpArr;
};
//# sourceMappingURL=array_keys.js.map
|