Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stdlib/utils-try-require

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/utils-try-require - npm Package Compare versions

Comparing version
0.2.2
to
0.2.3
+1
-1
dist/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 isError = require( '@stdlib/assert-is-error' );\n\n\n// MAIN //\n\n/**\n* Wraps `require` in a try/catch block.\n*\n* @param {string} id - module id\n* @returns {*|Error} `module.exports` of the resolved module or an error\n*\n* @example\n* var out = tryRequire( 'beepboop' );\n*\n* if ( out instanceof Error ) {\n* console.error( out.message );\n* }\n*/\nfunction tryRequire( id ) {\n\ttry {\n\t\treturn require( id ); // eslint-disable-line stdlib/no-dynamic-require\n\t} catch ( error ) {\n\t\tif ( isError( error ) ) {\n\t\t\treturn error;\n\t\t}\n\t\t// Handle case where a literal is thrown...\n\t\tif ( typeof error === 'object' ) {\n\t\t\treturn new Error( JSON.stringify( error ) );\n\t\t}\n\t\treturn new Error( error.toString() );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = tryRequire;\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* Wrap `require` in a try/catch block.\n*\n* @module @stdlib/utils-try-require\n*\n* @example\n* var tryRequire = require( '@stdlib/utils-try-require' );\n*\n* var out = tryRequire( 'beepboop' );\n*\n* if ( out instanceof Error ) {\n* console.log( out.message );\n* }\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
"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 isError = require( '@stdlib/assert-is-error' );\n\n\n// MAIN //\n\n/**\n* Wraps `require` in a try/catch block.\n*\n* @param {string} id - module id\n* @returns {(*|Error)} `module.exports` of the resolved module or an error\n*\n* @example\n* var out = tryRequire( 'beepboop' );\n*\n* if ( out instanceof Error ) {\n* console.error( out.message );\n* }\n*/\nfunction tryRequire( id ) {\n\ttry {\n\t\treturn require( id ); // eslint-disable-line stdlib/no-dynamic-require\n\t} catch ( error ) {\n\t\tif ( isError( error ) ) {\n\t\t\treturn error;\n\t\t}\n\t\t// Handle case where a literal is thrown...\n\t\tif ( typeof error === 'object' ) {\n\t\t\treturn new Error( JSON.stringify( error ) );\n\t\t}\n\t\treturn new Error( error.toString() );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = tryRequire;\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* Wrap `require` in a try/catch block.\n*\n* @module @stdlib/utils-try-require\n*\n* @example\n* var tryRequire = require( '@stdlib/utils-try-require' );\n*\n* var out = tryRequire( 'beepboop' );\n*\n* if ( out instanceof Error ) {\n* console.log( out.message );\n* }\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,EAAU,QAAS,yBAA0B,EAkBjD,SAASC,EAAYC,EAAK,CACzB,GAAI,CACH,OAAO,QAASA,CAAG,CACpB,OAAUC,EAAQ,CACjB,OAAKH,EAASG,CAAM,EACZA,EAGH,OAAOA,GAAU,SACd,IAAI,MAAO,KAAK,UAAWA,CAAM,CAAE,EAEpC,IAAI,MAAOA,EAAM,SAAS,CAAE,CACpC,CACD,CAKAJ,EAAO,QAAUE,ICrBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
"names": ["require_main", "__commonJSMin", "exports", "module", "isError", "tryRequire", "id", "error", "main"]
}

@@ -32,3 +32,3 @@ /**

* @param {string} id - module id
* @returns {*|Error} `module.exports` of the resolved module or an error
* @returns {(*|Error)} `module.exports` of the resolved module or an error
*

@@ -35,0 +35,0 @@ * @example

+1
-1

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

Copyright (c) 2016-2024 The Stdlib Authors.
Copyright (c) 2016-2026 The Stdlib Authors.
{
"name": "@stdlib/utils-try-require",
"version": "0.2.2",
"version": "0.2.3",
"description": "Wrap `require` in a try/catch block.",

@@ -33,3 +33,3 @@ "license": "Apache-2.0",

"dependencies": {
"@stdlib/assert-is-error": "^0.2.1"
"@stdlib/assert-is-error": "^0.2.2"
},

@@ -36,0 +36,0 @@ "devDependencies": {},

@@ -174,3 +174,3 @@ <!--

Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].

@@ -188,4 +188,4 @@ </section>

[test-image]: https://github.com/stdlib-js/utils-try-require/actions/workflows/test.yml/badge.svg?branch=v0.2.2
[test-url]: https://github.com/stdlib-js/utils-try-require/actions/workflows/test.yml?query=branch:v0.2.2
[test-image]: https://github.com/stdlib-js/utils-try-require/actions/workflows/test.yml/badge.svg?branch=v0.2.3
[test-url]: https://github.com/stdlib-js/utils-try-require/actions/workflows/test.yml?query=branch:v0.2.3

@@ -202,4 +202,4 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-try-require/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

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