@stdlib/assert-instance-of
Advanced tools
+3
-3
@@ -1,5 +0,5 @@ | ||
| "use strict";var a=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=a(function(o,n){ | ||
| var i=require('@stdlib/error-tools-fmtprodmsg/dist');function u(r,e){if(typeof e!="function")throw new TypeError(i('03v3E',e));return r instanceof e}n.exports=u | ||
| });var s=t();module.exports=s; | ||
| "use strict";var t=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var n=t(function(m,r){ | ||
| var i=require('@stdlib/assert-has-has-instance-symbol-support/dist'),s=require('@stdlib/symbol-has-instance/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist'),f=i();function o(a,e){if(typeof e!="function"&&!(f&&typeof e=="object"&&typeof e[s]=="function"))throw new TypeError(u('03v3E',e));return a instanceof e}r.exports=o | ||
| });var p=n();module.exports=p; | ||
| /** @license Apache-2.0 */ | ||
| //# sourceMappingURL=index.js.map |
| { | ||
| "version": 3, | ||
| "sources": ["../lib/main.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// MODULES //\n\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Tests whether a value has in its prototype chain a specified constructor as a prototype property.\n*\n* @param {*} value - value to test\n* @param {Function} constructor - constructor to test against\n* @throws {TypeError} constructor must be callable\n* @returns {boolean} boolean indicating whether a value is an instance of a provided constructor\n*\n* @example\n* var bool = instanceOf( [], Array );\n* // returns true\n*\n* @example\n* var bool = instanceOf( {}, Object ); // exception\n* // returns true\n*\n* @example\n* var bool = instanceOf( 'beep', String );\n* // returns false\n*\n* @example\n* var bool = instanceOf( null, Object );\n* // returns false\n*\n* @example\n* var bool = instanceOf( 5, Object );\n* // returns false\n*/\nfunction instanceOf( value, constructor ) {\n\t// TODO: replace with `isCallable` check\n\tif ( typeof constructor !== 'function' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be callable. Value: `%s`.', constructor ) );\n\t}\n\treturn ( value instanceof constructor );\n}\n\n\n// EXPORTS //\n\nmodule.exports = instanceOf;\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 whether a value has in its prototype chain a specified constructor as a prototype property.\n*\n* @module @stdlib/assert-instance-of\n*\n* @example\n* var instanceOf = require( '@stdlib/assert-instance-of' );\n*\n* var bool = instanceOf( [], Array );\n* // returns true\n*\n* bool = instanceOf( {}, Object ); // exception\n* // returns true\n*\n* bool = instanceOf( 'beep', String );\n* // returns false\n*\n* bool = instanceOf( null, Object );\n* // returns false\n*\n* bool = instanceOf( 5, Object );\n* // returns false\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], | ||
| "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,uBAAwB,EAiC9C,SAASC,EAAYC,EAAOC,EAAc,CAEzC,GAAK,OAAOA,GAAgB,WAC3B,MAAM,IAAI,UAAWH,EAAQ,mEAAoEG,CAAY,CAAE,EAEhH,OAASD,aAAiBC,CAC3B,CAKAJ,EAAO,QAAUE,ICpBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", | ||
| "names": ["require_main", "__commonJSMin", "exports", "module", "format", "instanceOf", "value", "constructor", "main"] | ||
| "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// MODULES //\n\nvar hasHasInstanceSymbolSupport = require( '@stdlib/assert-has-has-instance-symbol-support' ); // eslint-disable-line id-length\nvar HasInstanceSymbol = require( '@stdlib/symbol-has-instance' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar hasSupport = hasHasInstanceSymbolSupport();\n\n\n// MAIN //\n\n/**\n* Tests whether a value has in its prototype chain a specified constructor as a prototype property.\n*\n* @param {*} value - value to test\n* @param {Function} constructor - constructor to test against\n* @throws {TypeError} constructor must be callable\n* @returns {boolean} boolean indicating whether a value is an instance of a provided constructor\n*\n* @example\n* var bool = instanceOf( [], Array );\n* // returns true\n*\n* @example\n* var bool = instanceOf( {}, Object ); // exception\n* // returns true\n*\n* @example\n* var bool = instanceOf( 'beep', String );\n* // returns false\n*\n* @example\n* var bool = instanceOf( null, Object );\n* // returns false\n*\n* @example\n* var bool = instanceOf( 5, Object );\n* // returns false\n*/\nfunction instanceOf( value, constructor ) {\n\t// TODO: replace with `isCallable` check\n\tif (\n\t\ttypeof constructor !== 'function' &&\n\t\t!(\n\t\t\thasSupport &&\n\t\t\ttypeof constructor === 'object' &&\n\t\t\ttypeof constructor[ HasInstanceSymbol ] === 'function'\n\t\t)\n\t) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be callable. Value: `%s`.', constructor ) );\n\t}\n\treturn ( value instanceof constructor );\n}\n\n\n// EXPORTS //\n\nmodule.exports = instanceOf;\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 whether a value has in its prototype chain a specified constructor as a prototype property.\n*\n* @module @stdlib/assert-instance-of\n*\n* @example\n* var instanceOf = require( '@stdlib/assert-instance-of' );\n*\n* var bool = instanceOf( [], Array );\n* // returns true\n*\n* bool = instanceOf( {}, Object ); // exception\n* // returns true\n*\n* bool = instanceOf( 'beep', String );\n* // returns false\n*\n* bool = instanceOf( null, Object );\n* // returns false\n*\n* bool = instanceOf( 5, Object );\n* // returns false\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], | ||
| "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAA8B,QAAS,gDAAiD,EACxFC,EAAoB,QAAS,6BAA8B,EAC3DC,EAAS,QAAS,uBAAwB,EAK1CC,EAAaH,EAA4B,EAiC7C,SAASI,EAAYC,EAAOC,EAAc,CAEzC,GACC,OAAOA,GAAgB,YACvB,EACCH,GACA,OAAOG,GAAgB,UACvB,OAAOA,EAAaL,CAAkB,GAAM,YAG7C,MAAM,IAAI,UAAWC,EAAQ,mEAAoEI,CAAY,CAAE,EAEhH,OAASD,aAAiBC,CAC3B,CAKAP,EAAO,QAAUK,IClCjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", | ||
| "names": ["require_main", "__commonJSMin", "exports", "module", "hasHasInstanceSymbolSupport", "HasInstanceSymbol", "format", "hasSupport", "instanceOf", "value", "constructor", "main"] | ||
| } |
+15
-1
@@ -23,5 +23,12 @@ /** | ||
| var hasHasInstanceSymbolSupport = require( '@stdlib/assert-has-has-instance-symbol-support' ); // eslint-disable-line id-length | ||
| var HasInstanceSymbol = require( '@stdlib/symbol-has-instance' ); | ||
| var format = require( '@stdlib/string-format' ); | ||
| // VARIABLES // | ||
| var hasSupport = hasHasInstanceSymbolSupport(); | ||
| // MAIN // | ||
@@ -59,3 +66,10 @@ | ||
| // TODO: replace with `isCallable` check | ||
| if ( typeof constructor !== 'function' ) { | ||
| if ( | ||
| typeof constructor !== 'function' && | ||
| !( | ||
| hasSupport && | ||
| typeof constructor === 'object' && | ||
| typeof constructor[ HasInstanceSymbol ] === 'function' | ||
| ) | ||
| ) { | ||
| throw new TypeError( format( 'invalid argument. Second argument must be callable. Value: `%s`.', constructor ) ); | ||
@@ -62,0 +76,0 @@ } |
+1
-1
@@ -1,1 +0,1 @@ | ||
| Copyright (c) 2016-2024 The Stdlib Authors. | ||
| Copyright (c) 2016-2026 The Stdlib Authors. |
+3
-1
| { | ||
| "name": "@stdlib/assert-instance-of", | ||
| "version": "0.2.2", | ||
| "version": "0.3.0", | ||
| "description": "Test whether a value has in its prototype chain a specified constructor as a prototype property.", | ||
@@ -33,3 +33,5 @@ "license": "Apache-2.0", | ||
| "dependencies": { | ||
| "@stdlib/assert-has-has-instance-symbol-support": "github:stdlib-js/assert-has-has-instance-symbol-support#main", | ||
| "@stdlib/string-format": "^0.2.2", | ||
| "@stdlib/symbol-has-instance": "github:stdlib-js/symbol-has-instance#main", | ||
| "@stdlib/error-tools-fmtprodmsg": "^0.2.2" | ||
@@ -36,0 +38,0 @@ }, |
+5
-5
@@ -219,3 +219,3 @@ <!-- | ||
| Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. | ||
| Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. | ||
@@ -233,4 +233,4 @@ </section> | ||
| [test-image]: https://github.com/stdlib-js/assert-instance-of/actions/workflows/test.yml/badge.svg?branch=v0.2.2 | ||
| [test-url]: https://github.com/stdlib-js/assert-instance-of/actions/workflows/test.yml?query=branch:v0.2.2 | ||
| [test-image]: https://github.com/stdlib-js/assert-instance-of/actions/workflows/test.yml/badge.svg?branch=v0.3.0 | ||
| [test-url]: https://github.com/stdlib-js/assert-instance-of/actions/workflows/test.yml?query=branch:v0.3.0 | ||
@@ -247,4 +247,4 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert-instance-of/main.svg | ||
| [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg | ||
| [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im | ||
| [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg | ||
| [chat-url]: https://stdlib.zulipchat.com | ||
@@ -251,0 +251,0 @@ [stdlib]: https://github.com/stdlib-js/stdlib |
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 2 instances in 1 package
30811
4.56%171
7.55%4
100%2
Infinity%