@stdlib/utils
Version:
Standard utilities.
52 lines (46 loc) • 1.78 kB
TypeScript
/*
* @license Apache-2.0
*
* Copyright (c) 2019 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// TypeScript Version: 4.1
/**
* Returns a string value indicating a specification defined classification (via the internal property `[[Class]]`) of an object.
*
* ## Notes
*
* - The function is *not* robust for ES2015+ environments. In ES2015+, `Symbol.toStringTag` allows overriding the default description of an object. While measures are taken to uncover the default description, such measures can be thwarted. While this function remains useful for type-checking, be aware that value impersonation is possible. Where possible, prefer functions tailored to checking for particular value types, as specialized functions are better equipped to address `Symbol.toStringTag`.
*
* @param v - input value
* @returns string value indicating a specification defined classification of the input value
*
* @example
* var str = nativeClass( 'a' );
* // returns '[object String]'
*
* @example
* var str = nativeClass( 5 );
* // returns '[object Number]'
*
* @example
* function Beep() {
* return this;
* }
* var str = nativeClass( new Beep() );
* // returns '[object Object]'
*/
declare function nativeClass( v: any ): string;
// EXPORTS //
export = nativeClass;