time-to-botec

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

is_object.js (1592B)


      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 * Tests if a value is an object; e.g., `{}`.
     25 *
     26 * @private
     27 * @param {*} value - value to test
     28 * @returns {boolean} boolean indicating whether value is an object
     29 *
     30 * @example
     31 * var bool = isObject( {} );
     32 * // returns true
     33 *
     34 * @example
     35 * var bool = isObject( null );
     36 * // returns false
     37 */
     38 function isObject( value ) {
     39 	return (
     40 		typeof value === 'object' &&
     41 		value !== null &&
     42 		!Array.isArray( value )	// NOTE: we inline the `isObject` function from `@stdlib/assert/is-object` and use the built-in `isArray` method in this particular package in order to avoid circular dependencies. This should not be problematic as (1) this package is unlikely to be used outside of Node.js and, thus, in environments lacking support for the built-in APIs, and (2) most of the historical bugs for the respective APIs were in environments such as IE and not the versions of V8 included in Node.js >= v0.10.x.
     43 	);
     44 }
     45 
     46 
     47 // EXPORTS //
     48 
     49 module.exports = isObject;