Socket
Socket
Sign inDemoInstall

is-resolvable

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

18

index.js

@@ -6,12 +6,12 @@ 'use strict';

module.exports = function isResolvable(moduleId) {
if (typeof moduleId !== 'string') {
throw new TypeError(inspect(moduleId) + ' is not a string. Expected a valid Node.js module identifier (<string>), for example \'eslint\', \'./index.js\', \'./lib\'.');
}
if (typeof moduleId !== 'string') {
throw new TypeError(inspect(moduleId) + ' is not a string. Expected a valid Node.js module identifier (<string>), for example \'eslint\', \'./index.js\', \'./lib\'.');
}
try {
require.resolve(moduleId);
return true;
} catch (err) {
return false;
}
try {
require.resolve(moduleId);
return true;
} catch (err) {
return false;
}
};
{
"name": "is-resolvable",
"version": "1.0.1",
"description": "Check if a module ID is resolvable with require()",
"repository": "shinnn/is-resolvable",
"author": "Shinnosuke Watanabe (https://github.com/shinnn)",
"scripts": {
"pretest": "eslint --fix --format=codeframe index.js test.js",
"test": "node --throw-deprecation --track-heap-objects test.js",
"coverage": "istanbul cover --print=both test.js"
},
"license": "MIT",
"files": [
"index.js"
],
"keywords": [
"file",
"path",
"resolve",
"resolvable",
"check",
"module"
],
"devDependencies": {
"@shinnn/eslint-config-node": "^4.0.2",
"eslint": "^4.11.0",
"istanbul": "^0.4.5",
"tape": "^4.8.0"
},
"eslintConfig": {
"extends": "@shinnn/node",
"rules": {
"no-var": "off"
}
}
"name": "is-resolvable",
"version": "1.0.2",
"description": "Check if a module ID is resolvable with require()",
"repository": "shinnn/is-resolvable",
"author": "Shinnosuke Watanabe (https://github.com/shinnn)",
"scripts": {
"pretest": "eslint --fix --format=codeframe index.js test.js",
"test": "node --throw-deprecation --track-heap-objects test.js",
"coverage": "istanbul cover --print=both test.js"
},
"license": "ISC",
"files": [
"index.js"
],
"keywords": [
"file",
"path",
"resolve",
"resolvable",
"check",
"module"
],
"devDependencies": {
"@shinnn/eslint-config-node": "^5.0.0",
"eslint": "^4.16.0",
"istanbul": "^0.4.5",
"tape": "^4.8.0"
},
"eslintConfig": {
"extends": "@shinnn/node",
"rules": {
"no-var": "off",
"prefer-template": "off"
}
}
}
# is-resolvable
[![NPM version](https://img.shields.io/npm/v/is-resolvable.svg)](https://www.npmjs.com/package/is-resolvable)
[![npm version](https://img.shields.io/npm/v/is-resolvable.svg)](https://www.npmjs.com/package/is-resolvable)
[![Build Status](https://travis-ci.org/shinnn/is-resolvable.svg?branch=master)](https://travis-ci.org/shinnn/is-resolvable)
[![Build status](https://ci.appveyor.com/api/projects/status/ww1cdpignehlasbs?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/is-resolvable)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/is-resolvable.svg)](https://coveralls.io/r/shinnn/is-resolvable)
[![Dependency Status](https://david-dm.org/shinnn/is-resolvable.svg)](https://david-dm.org/shinnn/is-resolvable)
[![devDependency Status](https://david-dm.org/shinnn/is-resolvable/dev-status.svg)](https://david-dm.org/shinnn/is-resolvable#info=devDependencies)
A [Node](https://nodejs.org/) module to check if a module ID is resolvable with [`require()`](https://nodejs.org/api/globals.html#globals_require)
A [Node.js](https://nodejs.org/) module to check if a given module ID is resolvable with [`require()`](https://nodejs.org/api/globals.html#globals_require)

@@ -26,3 +24,3 @@ ```javascript

[Use npm.](https://docs.npmjs.com/cli/install)
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).

@@ -41,4 +39,4 @@ ```

*moduleId*: `String` (module ID)
Return: `Boolean`
*moduleId*: `string` (module ID)
Return: `boolean`

@@ -56,10 +54,9 @@ It returns `true` if `require()` can load a file form a given module ID, otherwise `false`.

// When `eslint` module is installed but `jshint` isn't
isResolvable('eslint'); //=> true
isResolvable('jshint'); //=> false
// When `lodash` module is installed but `underscore` isn't
isResolvable('lodash'); //=> true
isResolvable('underscore'); //=> false
// When `readable-stream` module is installed
isResolvable('readable-stream/readable'); //=> true
isResolvable('readable-stream/writable'); //=> true
// When `lodash` module is installed
isResolvable('lodash/isObject'); //=> true
isResolvable('lodash/fp/reject.js'); //=> true
```

@@ -69,4 +66,2 @@

Copyright (c) 2014 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc