Gathering detailed insights and metrics for @stdlib/utils-native-class
Gathering detailed insights and metrics for @stdlib/utils-native-class
Gathering detailed insights and metrics for @stdlib/utils-native-class
Gathering detailed insights and metrics for @stdlib/utils-native-class
Determine the specification defined classification of an object.
npm install @stdlib/utils-native-class
99.6
Supply Chain
97.5
Quality
83
Maintenance
100
Vulnerability
84.7
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Stars
67 Commits
3 Watching
5 Branches
10 Contributors
Updated on 01 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-13.2%
75,873
Compared to previous day
Last week
-2.3%
432,749
Compared to previous week
Last month
-2%
1,879,732
Compared to previous month
Last year
13.7%
34,741,265
Compared to previous year
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Determine the specification defined classification of an object.
1npm install @stdlib/utils-native-class
Alternatively,
script
tag without installation and bundlers, use the ES Module available on the esm
branch (see README).deno
branch (see README for usage intructions).umd
branch (see README).The branches.md file summarizes the available branches and displays a diagram illustrating their relationships.
To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
1var nativeClass = require( '@stdlib/utils-native-class' );
Returns a string
value indicating a specification defined classification of an object
.
1var str = nativeClass( 'a' ); 2// returns '[object String]' 3 4str = nativeClass( 5 ); 5// returns '[object Number]' 6 7function Beep() { 8 return this; 9} 10str = nativeClass( new Beep() ); 11// returns '[object Object]'
The function is not robust for ES2015+ environments. In ES2015+, Symbol.toStringTag
allows overriding the default description of an object.
1var toStr = Object.prototype.toString; 2 3var str = toStr.call( false ); 4// returns '[object Boolean]' 5 6var o = {}; 7str = toStr.call( o ); 8// returns '[object Object]' 9 10// Mask the default description: 11o[ Symbol.toStringTag ] = 'Boolean'; 12 13str = toStr.call( o ); 14// returns '[object Boolean]'
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. Prefer functions tailored to checking for particular value types, as specialized functions are better equipped to address Symbol.toStringTag
.
1var Float32Array = require( '@stdlib/array-float32' ); 2var Float64Array = require( '@stdlib/array-float64' ); 3var Int8Array = require( '@stdlib/array-int8' ); 4var Int16Array = require( '@stdlib/array-int16' ); 5var Int32Array = require( '@stdlib/array-int32' ); 6var Uint8Array = require( '@stdlib/array-uint8' ); 7var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); 8var Uint16Array = require( '@stdlib/array-uint16' ); 9var Uint32Array = require( '@stdlib/array-uint32' ); 10var ArrayBuffer = require( '@stdlib/array-buffer' ); 11var Symbol = require( '@stdlib/symbol-ctor' ); 12var nativeClass = require( '@stdlib/utils-native-class' ); 13 14var str = nativeClass( 'a' ); 15// returns '[object String]' 16 17str = nativeClass( 5 ); 18// returns '[object Number]' 19 20str = nativeClass( NaN ); 21// returns '[object Number]' 22 23str = nativeClass( null ); 24// returns '[object Null]' 25 26str = nativeClass( void 0 ); 27// returns '[object Undefined]' 28 29str = nativeClass( true ); 30// returns '[object Boolean]' 31 32str = nativeClass( false ); 33// returns '[object Boolean]' 34 35str = nativeClass( {} ); 36// returns '[object Object]' 37 38str = nativeClass( [] ); 39// returns '[object Array]' 40 41str = nativeClass( function noop() {} ); 42// returns '[object Function]' 43 44str = nativeClass( /./ ); 45// returns '[object RegExp]' 46 47str = nativeClass( new Date() ); 48// returns '[object Date]' 49 50str = nativeClass( new Map() ); 51// returns '[object Map]' 52 53str = nativeClass( new WeakMap() ); 54// returns '[object WeakMap]' 55 56str = nativeClass( new Set() ); 57// returns '[object Set]' 58 59str = nativeClass( new WeakSet() ); 60// returns '[object WeakSet]' 61 62str = nativeClass( Symbol( 'beep' ) ); 63// returns '[object Symbol]' 64 65str = nativeClass( new Error() ); 66// returns '[object Error]' 67 68str = nativeClass( new TypeError() ); 69// returns '[object Error]' 70 71str = nativeClass( new SyntaxError() ); 72// returns '[object Error]' 73 74str = nativeClass( new URIError() ); 75// returns '[object Error]' 76 77str = nativeClass( new RangeError() ); 78// returns '[object Error]' 79 80str = nativeClass( new ReferenceError() ); 81// returns '[object Error]' 82 83str = nativeClass( new EvalError() ); 84// returns '[object Error]' 85 86str = nativeClass( new Int8Array() ); 87// returns '[object Int8Array]' 88 89str = nativeClass( new Uint8Array() ); 90// returns '[object Uint8Array]' 91 92str = nativeClass( new Uint8ClampedArray() ); 93// returns '[object Uint8ClampedArray]' 94 95str = nativeClass( new Int16Array() ); 96// returns '[object Int16Array]' 97 98str = nativeClass( new Uint16Array() ); 99// returns '[object Uint16Array]' 100 101str = nativeClass( new Int32Array() ); 102// returns '[object Int32Array]' 103 104str = nativeClass( new Uint32Array() ); 105// returns '[object Uint32Array]' 106 107str = nativeClass( new Float32Array() ); 108// returns '[object Float32Array]' 109 110str = nativeClass( new Float64Array() ); 111// returns '[object Float64Array]' 112 113str = nativeClass( new ArrayBuffer() ); 114// returns '[object ArrayBuffer]' 115 116str = nativeClass( Math ); 117// returns '[object Math]' 118 119str = nativeClass( JSON ); 120// returns '[object JSON]' 121 122function Person() { 123 return this; 124} 125str = nativeClass( new Person() ); 126// returns '[object Object]'
@stdlib/utils-constructor-name
: determine the name of a value's constructor.@stdlib/utils-type-of
: determine a value's type.This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
no SAST tool detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More