@stdlib/assert-instance-of 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +5 -5
- package/dist/index.js +3 -3
- package/dist/index.js.map +3 -3
- package/lib/main.js +15 -1
- package/package.json +3 -1
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -216,7 +216,7 @@ See [LICENSE][stdlib-license].
|
|
|
216
216
|
|
|
217
217
|
## Copyright
|
|
218
218
|
|
|
219
|
-
Copyright © 2016-
|
|
219
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
220
220
|
|
|
221
221
|
</section>
|
|
222
222
|
|
|
@@ -229,8 +229,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
229
229
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/assert-instance-of.svg
|
|
230
230
|
[npm-url]: https://npmjs.org/package/@stdlib/assert-instance-of
|
|
231
231
|
|
|
232
|
-
[test-image]: https://github.com/stdlib-js/assert-instance-of/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
233
|
-
[test-url]: https://github.com/stdlib-js/assert-instance-of/actions/workflows/test.yml?query=branch:v0.
|
|
232
|
+
[test-image]: https://github.com/stdlib-js/assert-instance-of/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
233
|
+
[test-url]: https://github.com/stdlib-js/assert-instance-of/actions/workflows/test.yml?query=branch:v0.3.0
|
|
234
234
|
|
|
235
235
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert-instance-of/main.svg
|
|
236
236
|
[coverage-url]: https://codecov.io/github/stdlib-js/assert-instance-of?branch=main
|
|
@@ -242,8 +242,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
242
242
|
|
|
243
243
|
-->
|
|
244
244
|
|
|
245
|
-
[chat-image]: https://img.shields.io/
|
|
246
|
-
[chat-url]: https://
|
|
245
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
246
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
247
247
|
|
|
248
248
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
249
249
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
var i=require('@stdlib/error-tools-fmtprodmsg/dist');function
|
|
3
|
-
});var
|
|
1
|
+
"use strict";var t=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var n=t(function(m,r){
|
|
2
|
+
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
|
|
3
|
+
});var p=n();module.exports=p;
|
|
4
4
|
/** @license Apache-2.0 */
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
-
"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 (
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,uBAAwB,
|
|
6
|
-
"names": ["require_main", "__commonJSMin", "exports", "module", "format", "instanceOf", "value", "constructor", "main"]
|
|
4
|
+
"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"],
|
|
5
|
+
"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",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "hasHasInstanceSymbolSupport", "HasInstanceSymbol", "format", "hasSupport", "instanceOf", "value", "constructor", "main"]
|
|
7
7
|
}
|
package/lib/main.js
CHANGED
|
@@ -20,9 +20,16 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
+
var hasHasInstanceSymbolSupport = require( '@stdlib/assert-has-has-instance-symbol-support' ); // eslint-disable-line id-length
|
|
24
|
+
var HasInstanceSymbol = require( '@stdlib/symbol-has-instance' );
|
|
23
25
|
var format = require( '@stdlib/string-format' );
|
|
24
26
|
|
|
25
27
|
|
|
28
|
+
// VARIABLES //
|
|
29
|
+
|
|
30
|
+
var hasSupport = hasHasInstanceSymbolSupport();
|
|
31
|
+
|
|
32
|
+
|
|
26
33
|
// MAIN //
|
|
27
34
|
|
|
28
35
|
/**
|
|
@@ -55,7 +62,14 @@ var format = require( '@stdlib/string-format' );
|
|
|
55
62
|
*/
|
|
56
63
|
function instanceOf( value, constructor ) {
|
|
57
64
|
// TODO: replace with `isCallable` check
|
|
58
|
-
if (
|
|
65
|
+
if (
|
|
66
|
+
typeof constructor !== 'function' &&
|
|
67
|
+
!(
|
|
68
|
+
hasSupport &&
|
|
69
|
+
typeof constructor === 'object' &&
|
|
70
|
+
typeof constructor[ HasInstanceSymbol ] === 'function'
|
|
71
|
+
)
|
|
72
|
+
) {
|
|
59
73
|
throw new TypeError( format( 'invalid argument. Second argument must be callable. Value: `%s`.', constructor ) );
|
|
60
74
|
}
|
|
61
75
|
return ( value instanceof constructor );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/assert-instance-of",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Test whether a value has in its prototype chain a specified constructor as a prototype property.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@stdlib/assert-has-has-instance-symbol-support": "github:stdlib-js/assert-has-has-instance-symbol-support#main",
|
|
33
34
|
"@stdlib/string-format": "^0.2.2",
|
|
35
|
+
"@stdlib/symbol-has-instance": "github:stdlib-js/symbol-has-instance#main",
|
|
34
36
|
"@stdlib/error-tools-fmtprodmsg": "^0.2.2"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {},
|