New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

require-one-of

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-one-of - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Change Log

<a name="1.0.2"></a>
## [1.0.2](https://github.com/Kikobeats/require-one-of/compare/v1.0.1...v1.0.2) (2019-01-14)
### Bug Fixes
* ensure to resolve starting from cwd ([9b0a877](https://github.com/Kikobeats/require-one-of/commit/9b0a877))
* use minus name ([610ac28](https://github.com/Kikobeats/require-one-of/commit/610ac28))
<a name="1.0.1"></a>

@@ -7,0 +18,0 @@ ## [1.0.1](https://github.com/Kikobeats/require-one-of/compare/v1.0.0...v1.0.1) (2019-01-14)

5

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://documentup.com/Kikobeats/require-one-of",
"version": "1.0.1",
"version": "1.0.2",
"main": "src/index.js",

@@ -26,2 +26,5 @@ "author": {

],
"dependencies": {
"import-from": "~2.1.0"
},
"devDependencies": {

@@ -28,0 +31,0 @@ "@commitlint/cli": "latest",

23

src/index.js
'use strict'
const resolveFrom = require('resolve-from')
const assert = require('assert')
const CACHE = {}
const resolveCwd = resolveFrom.silent.bind(resolveFrom, process.cwd())
const load = module => {
try {
return require(module)
} catch (e) {
return null
}
}
const cache = {}

@@ -24,4 +19,8 @@ const createError = modules =>

assert(Array.isArray(modules), 'Need to provide a collection')
const module = modules.find(load)
if (module) return module
for (const module of modules) {
const modulePath = resolveCwd(module)
if (modulePath) return require(modulePath)
}
throw error(modules)

@@ -32,5 +31,5 @@ }

const key = modules.join(',')
return CACHE[key] || (CACHE[key] = find(modules, fn))
return cache[key] || (cache[key] = find(modules, fn))
}
module.exports.CACHE = CACHE
module.exports.cache = cache
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc