time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

main.js (1201B)


      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 // MAIN //
     22 
     23 /**
     24 * Returns an array of an object's own and inherited enumerable property names.
     25 *
     26 * @param {ObjectLike} obj - input object
     27 * @returns {Array} key array
     28 *
     29 * @example
     30 * function Foo() {
     31 *     this.beep = 'boop';
     32 *     return this;
     33 * }
     34 *
     35 * Foo.prototype.foo = 'bar';
     36 *
     37 * var obj = new Foo();
     38 *
     39 * var keys = keysIn( obj );
     40 * // e.g., returns [ 'beep', 'foo' ]
     41 */
     42 function keysIn( obj ) {
     43 	var out;
     44 	var key;
     45 
     46 	out = [];
     47 	for ( key in obj ) { // eslint-disable-line guard-for-in
     48 		out.push( key );
     49 	}
     50 	return out;
     51 }
     52 
     53 
     54 // EXPORTS //
     55 
     56 module.exports = keysIn;