🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@stdlib/assert-is-symbol

Package Overview
Dependencies
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/assert-is-symbol - npm Package Compare versions

Comparing version
0.0.9
to
0.1.0
CITATION.cff

Sorry, the diff of this file is not supported yet

+3
/// <reference path="../docs/types/index.d.ts" />
import isSymbol from '../docs/types/index';
export = isSymbol;
"use strict";var e=function(r,t){return function(){return t||r((t={exports:{}}).exports,t),t.exports}};var i=e(function(L,n){
function R(r){return typeof r=="symbol"}n.exports=R
});var v=e(function(M,l){
function d(r){return Symbol.prototype.toString.call(r)}l.exports=d
});var b=e(function(N,y){
var h=v(),g=/^Symbol\(.*\)$/;function C(r){try{return typeof r.valueOf()=="symbol"&&g.test(h(r))}catch(t){return!1}}y.exports=C
});var s=e(function(Q,m){
var E=require('@stdlib/utils-native-class/dist'),F=b();function $(r){return typeof r=="object"&&E(r)==="[object Symbol]"&&F(r)}m.exports=$
});var p=e(function(T,f){
var k=i(),w=s();function z(r){return k(r)||w(r)}f.exports=z
});var x=e(function(U,S){
var q=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),o=p(),A=i(),B=s();q(o,"isPrimitive",A);q(o,"isObject",B);S.exports=o
});var P=e(function(V,j){
var O=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),u=require('@stdlib/utils-constant-function/dist'),a=u(!1),D=u(!1),G=u(!1);O(a,"isPrimitive",D);O(a,"isObject",G);j.exports=a
});var H=require('@stdlib/assert-has-symbol-support/dist'),I=x(),J=P(),c;H()?c=I:c=J;module.exports=c;
/** @license Apache-2.0 */
//# sourceMappingURL=index.js.map
{
"version": 3,
"sources": ["../lib/primitive.js", "../lib/tostring.js", "../lib/try2tostring.js", "../lib/object.js", "../lib/generic.js", "../lib/main.js", "../lib/polyfill.js", "../lib/index.js"],
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Tests if a value is a symbol primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a symbol primitive\n*/\nfunction isSymbol( value ) {\n\treturn ( typeof value === 'symbol' );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isSymbol;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* Note: we wrap `toString` to allow loading this file in non-ES2015 environments.\n*/\n\n// MAIN //\n\n/**\n* Attempts to serialize a value as a symbol.\n*\n* @private\n* @param {*} value - value to serialize\n* @returns {string} serialized value\n*/\nfunction toStr( value ) {\n\t// Non-generic:\n\treturn Symbol.prototype.toString.call( value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = toStr;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar toStr = require( './tostring.js' );\n\n\n// VARIABLES //\n\nvar RE = /^Symbol\\(.*\\)$/;\n\n\n// MAIN //\n\n/**\n* Attempts to call a `Symbol` method.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if able to call a `Symbol` method\n*/\nfunction test( value ) {\n\ttry {\n\t\treturn (\n\t\t\t// Objects created via `Object.create( null )` have no `valueOf()` method:\n\t\t\ttypeof value.valueOf() === 'symbol' &&\n\n\t\t\t// Test output of a non-generic method:\n\t\t\tRE.test( toStr( value ) )\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = test;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar nativeClass = require( '@stdlib/utils-native-class' );\nvar test = require( './try2tostring.js' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is a symbol object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a symbol object\n*/\nfunction isSymbol( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tnativeClass( value ) === '[object Symbol]' &&\n\t\ttest( value )\n\t);\n}\n\n\n// EXPORTS //\n\nmodule.exports = isSymbol;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPrimitive = require( './primitive.js' );\nvar isObject = require( './object.js' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is a symbol.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a symbol\n*/\nfunction isSymbol( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = isSymbol;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar isSymbol = require( './generic.js' );\nvar isPrimitive = require( './primitive.js' );\nvar isObject = require( './object.js' );\n\n\n// MAIN //\n\nsetReadOnly( isSymbol, 'isPrimitive', isPrimitive );\nsetReadOnly( isSymbol, 'isObject', isObject );\n\n\n// EXPORTS //\n\nmodule.exports = isSymbol;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar constantFunction = require( '@stdlib/utils-constant-function' );\n\n\n// MAIN //\n\nvar isSymbol = constantFunction( false );\nvar isPrimitive = constantFunction( false );\nvar isObject = constantFunction( false );\n\nsetReadOnly( isSymbol, 'isPrimitive', isPrimitive );\nsetReadOnly( isSymbol, 'isObject', isObject );\n\n\n// EXPORTS //\n\nmodule.exports = isSymbol;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is a symbol.\n*\n* @module @stdlib/assert-is-symbol\n*\n* @example\n* var Symbol = require( '@stdlib/symbol-ctor' );\n* var isSymbol = require( '@stdlib/assert-is-symbol' );\n*\n* var bool = isSymbol( Symbol( 'beep' ) );\n* // returns true\n*\n* bool = isSymbol( Object( Symbol( 'beep' ) ) );\n* // returns true\n*\n* bool = isSymbol( {} );\n* // returns false\n*\n* @example\n* var Symbol = require( '@stdlib/symbol-ctor' );\n* var isSymbol = require( '@stdlib/assert-is-symbol' ).isPrimitive;\n*\n* var bool = isSymbol( Symbol( 'beep' ) );\n* // returns true\n*\n* bool = isSymbol( Object( Symbol( 'beep' ) ) );\n* // returns false\n*\n* bool = isSymbol( {} );\n* // returns false\n*\n* @example\n* var Symbol = require( '@stdlib/symbol-ctor' );\n* var isSymbolObject = require( '@stdlib/assert-is-symbol' ).isObject;\n*\n* var bool = isSymbolObject( Symbol( 'beep' ) );\n* // returns false\n*\n* bool = isSymbolObject( Object( Symbol( 'beep' ) ) );\n* // returns true\n*\n* bool = isSymbolObject( {} );\n* // returns false\n*/\n\n// MODULES //\n\nvar hasSymbols = require( '@stdlib/assert-has-symbol-support' );\nvar main = require( './main.js' );\nvar polyfill = require( './polyfill.js' );\n\n\n// MAIN //\n\nvar isSymbol;\nif ( hasSymbols() ) {\n\tisSymbol = main;\n} else {\n\tisSymbol = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isSymbol;\n\n// exports: { \"isPrimitive\": \"isSymbol.isPrimitive\", \"isObject\": \"isSymbol.isObject\" }\n"],
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA0BA,SAASC,EAAUC,EAAQ,CAC1B,OAAS,OAAOA,GAAU,QAC3B,CAKAF,EAAO,QAAUC,ICjCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAQ,CAEvB,OAAO,OAAO,UAAU,SAAS,KAAMA,CAAM,CAC9C,CAKAF,EAAO,QAAUC,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,IAKRC,EAAK,iBAYT,SAASC,EAAMC,EAAQ,CACtB,GAAI,CACH,OAEC,OAAOA,EAAM,QAAQ,GAAM,UAG3BF,EAAG,KAAMD,EAAOG,CAAM,CAAE,CAE1B,OAAUC,EAAM,CACf,MAAO,EACR,CACD,CAKAL,EAAO,QAAUG,ICxDjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,4BAA6B,EACpDC,EAAO,IAWX,SAASC,EAAUC,EAAQ,CAC1B,OACC,OAAOA,GAAU,UACjBH,EAAaG,CAAM,IAAM,mBACzBF,EAAME,CAAM,CAEd,CAKAJ,EAAO,QAAUG,IC7CjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,IACdC,EAAW,IAWf,SAASC,EAAUC,EAAQ,CAC1B,OAASH,EAAaG,CAAM,GAAKF,EAAUE,CAAM,CAClD,CAKAJ,EAAO,QAAUG,ICzCjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,IACXC,EAAc,IACdC,EAAW,IAKfH,EAAaC,EAAU,cAAeC,CAAY,EAClDF,EAAaC,EAAU,WAAYE,CAAS,EAK5CJ,EAAO,QAAUE,ICpCjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAmB,QAAS,iCAAkC,EAK9DC,EAAWD,EAAkB,EAAM,EACnCE,EAAcF,EAAkB,EAAM,EACtCG,EAAWH,EAAkB,EAAM,EAEvCD,EAAaE,EAAU,cAAeC,CAAY,EAClDH,EAAaE,EAAU,WAAYE,CAAS,EAK5CL,EAAO,QAAUG,IC6BjB,IAAIG,EAAa,QAAS,mCAAoC,EAC1DC,EAAO,IACPC,EAAW,IAKXC,EACCH,EAAW,EACfG,EAAWF,EAEXE,EAAWD,EAMZ,OAAO,QAAUC",
"names": ["require_primitive", "__commonJSMin", "exports", "module", "isSymbol", "value", "require_tostring", "__commonJSMin", "exports", "module", "toStr", "value", "require_try2tostring", "__commonJSMin", "exports", "module", "toStr", "RE", "test", "value", "err", "require_object", "__commonJSMin", "exports", "module", "nativeClass", "test", "isSymbol", "value", "require_generic", "__commonJSMin", "exports", "module", "isPrimitive", "isObject", "isSymbol", "value", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "isSymbol", "isPrimitive", "isObject", "require_polyfill", "__commonJSMin", "exports", "module", "setReadOnly", "constantFunction", "isSymbol", "isPrimitive", "isObject", "hasSymbols", "main", "polyfill", "isSymbol"]
}
+4
-4

@@ -19,3 +19,3 @@ /*

// TypeScript Version: 2.0
// TypeScript Version: 4.1

@@ -48,3 +48,3 @@ /**

*/
( value: any ): boolean;
( value: any ): value is symbol | Symbol;

@@ -73,3 +73,3 @@ /**

*/
isPrimitive( value: any ): boolean;
isPrimitive( value: any ): value is symbol;

@@ -98,3 +98,3 @@ /**

*/
isObject( value: any ): boolean;
isObject( value: any ): value is Symbol;
}

@@ -101,0 +101,0 @@

+1
-1

@@ -1,1 +0,1 @@

Copyright (c) 2016-2022 The Stdlib Authors.
Copyright (c) 2016-2023 The Stdlib Authors.
{
"name": "@stdlib/assert-is-symbol",
"version": "0.0.9",
"version": "0.1.0",
"description": "Test if a value is a symbol.",

@@ -40,15 +40,16 @@ "license": "Apache-2.0",

"dependencies": {
"@stdlib/assert-has-symbol-support": "^0.0.x",
"@stdlib/utils-constant-function": "^0.0.x",
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x",
"@stdlib/utils-native-class": "^0.0.x"
"@stdlib/assert-has-symbol-support": "^0.1.0",
"@stdlib/utils-constant-function": "^0.1.0",
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0",
"@stdlib/utils-native-class": "^0.1.0"
},
"devDependencies": {
"@stdlib/assert-is-boolean": "^0.0.x",
"@stdlib/bench": "^0.0.x",
"@stdlib/symbol-ctor": "^0.0.x",
"@stdlib/assert-is-boolean": "^0.0.8",
"@stdlib/bench": "^0.0.12",
"@stdlib/object-ctor": "^0.1.0",
"@stdlib/symbol-ctor": "^0.1.0",
"proxyquire": "^2.0.0",
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
"istanbul": "^0.4.1",
"tap-spec": "5.x.x"
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
},

@@ -95,5 +96,5 @@ "engines": {

"funding": {
"type": "patreon",
"url": "https://www.patreon.com/athan"
"type": "opencollective",
"url": "https://opencollective.com/stdlib"
}
}

@@ -21,2 +21,13 @@ <!--

<details>
<summary>
About stdlib...
</summary>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
</details>
# isSymbol

@@ -172,3 +183,3 @@

Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].

@@ -186,4 +197,4 @@ </section>

[test-image]: https://github.com/stdlib-js/assert-is-symbol/actions/workflows/test.yml/badge.svg?branch=v0.0.9
[test-url]: https://github.com/stdlib-js/assert-is-symbol/actions/workflows/test.yml?query=branch:v0.0.9
[test-image]: https://github.com/stdlib-js/assert-is-symbol/actions/workflows/test.yml/badge.svg?branch=v0.1.0
[test-url]: https://github.com/stdlib-js/assert-is-symbol/actions/workflows/test.yml?query=branch:v0.1.0

@@ -201,3 +212,3 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert-is-symbol/main.svg

[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
[chat-url]: https://gitter.im/stdlib-js/stdlib/
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im

@@ -204,0 +215,0 @@ [stdlib]: https://github.com/stdlib-js/stdlib

{{alias}}( value )
Tests if a value is a symbol.
Parameters
----------
value: any
Value to test.
Returns
-------
bool: boolean
Boolean indicating whether a value is a symbol.
Examples
--------
> var bool = {{alias}}( {{alias:@stdlib/symbol/ctor}}( 'beep' ) )
true
> bool = {{alias}}( Object( {{alias:@stdlib/symbol/ctor}}( 'beep' ) ) )
true
> bool = {{alias}}( {} )
false
> bool = {{alias}}( null )
false
> bool = {{alias}}( true )
false
See Also
--------
/*
* @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.
*/
import isSymbol = require( './index' );
// TESTS //
// The function returns a boolean...
{
isSymbol( Symbol( 'beep' ) ); // $ExpectType boolean
isSymbol( 'abc' ); // $ExpectType boolean
}
// The compiler throws an error if the function is provided an unsupported number of arguments...
{
isSymbol(); // $ExpectError
isSymbol( Symbol( 'beep' ), 123 ); // $ExpectError
}
// Attached to main export is an `isPrimitive` method which returns a boolean...
{
isSymbol.isPrimitive( Symbol( 'beep' ) ); // $ExpectType boolean
isSymbol.isPrimitive( Object( Symbol( 'beep' ) ) ); // $ExpectType boolean
}
// The compiler throws an error if the `isPrimitive` method is provided an unsupported number of arguments...
{
isSymbol.isPrimitive(); // $ExpectError
isSymbol.isPrimitive( Symbol( 'beep' ), 123 ); // $ExpectError
}
// Attached to main export is an `isObject` method which returns a boolean...
{
isSymbol.isObject( Symbol( 'beep' ) ); // $ExpectType boolean
isSymbol.isObject( Object( Symbol( 'beep' ) ) ); // $ExpectType boolean
}
// The compiler throws an error if the `isObject` method is provided an unsupported number of arguments...
{
isSymbol.isObject(); // $ExpectError
isSymbol.isObject( Symbol( 'beep' ), 123 ); // $ExpectError
}