main.js (1486B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 // MODULES // 22 23 var keys = require( './../../keys' ); 24 var propertySymbols = require( './../../property-symbols' ); 25 var isEnumerable = require( '@stdlib/assert/is-enumerable-property' ); 26 27 28 // MAIN // 29 30 /** 31 * Returns an array of an object's own enumerable property names and symbols. 32 * 33 * @param {*} value - input object 34 * @returns {Array} a list of own property enumerable names and symbols 35 * 36 * @example 37 * var obj = { 38 * 'beep': 'boop', 39 * 'foo': 3.14 40 * }; 41 * 42 * var props = enumerableProperties( obj ); 43 * // e.g., returns [ 'beep', 'foo' ] 44 */ 45 function enumerableProperties( value ) { 46 var out; 47 var tmp; 48 var i; 49 50 out = keys( value ); 51 tmp = propertySymbols( value ); 52 for ( i = 0; i < tmp.length; i++ ) { 53 if ( isEnumerable( value, tmp[ i ] ) ) { 54 out.push( tmp[ i ] ); 55 } 56 } 57 return out; 58 } 59 60 61 // EXPORTS // 62 63 module.exports = enumerableProperties;