Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

require-one

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-one - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

HISTORY.md

7

composer.json

@@ -18,3 +18,10 @@ {

}
},
"archive": {
"exclude": [
"example",
"test",
".*"
]
}
}

8

package.json
{
"name": "require-one",
"version": "0.2.0",
"version": "1.0.0",
"description": "Require the first found package from an array.",

@@ -25,3 +25,9 @@ "main": "require-one.js",

"testit": "^2.0.2"
},
"browser": "./require-one.js",
"browserPackage": {
"files": [
"require-one.js"
]
}
}

22

README.md

@@ -9,3 +9,2 @@ # Require One [![NPM version](https://img.shields.io/npm/v/require-one.svg)](https://npmjs.org/package/require-one "View this project on NPM")

## Install

@@ -19,3 +18,2 @@

## Usage

@@ -25,7 +23,9 @@

### CommonJS/Node
### CommonJS
This is an example of loading either [jQuery](http://jquery.com), [Zepto](http://zeptojs.com), or [Cheerio](http://cheeriojs.github.io/cheerio) with a CommonJS module loader, like [Node.js](http://nodejs.org).
``` javascript
var $ = requireOne('jquery', 'zepto', 'cheerio');
// => jQuery or Cheerio, depending on which one is loaded first.
// => jQuery, Zepto or Cheerio, depending on which one is available.
```

@@ -35,2 +35,4 @@

This is an example of loading either [jQuery](http://jquery.com), [Zepto](http://zeptojs.com), or [Cheerio](http://cheeriojs.github.io/cheerio) with an AMD module loader, like [Require.js](http://requirejs.org).
``` javascript

@@ -40,4 +42,4 @@ require(['require-one'], function(requireOne) {

// Retrieve the first package that is available.
var $ = requireOne('jquery', 'cheerio');
// => jQuery or Cheerio, depending on which one is loaded first.
var $ = requireOne('jquery', 'zepto', 'cheerio');
// => jQuery, Zepto or Cheerio, depending on which one is available.

@@ -50,2 +52,4 @@ // ...

This is an example of loading either [jQuery](http://jquery.com), [Zepto](http://zeptojs.com), or [Cheerio](http://cheeriojs.github.io/cheerio) without a module loader, like with browser globals.
``` html

@@ -56,3 +60,3 @@ <!DOCTYPE html>

<title>My Sample Project</title>
<script type="text/javascript" src="../require-one.js"></script>
<script type="text/javascript" src="path/to/require-one.js"></script>
<script>

@@ -67,1 +71,5 @@ var con = requireOne('nope', 'nopers', 'nopes', 'console');

</html>
## License
[MIT](LICENSE.md)

@@ -15,3 +15,5 @@ /*!

if (typeof define === 'function' && define.amd) {
// AMD
/**
* AMD
*/
define(function (require) {

@@ -23,9 +25,11 @@ // Use AMD's require() wrapper.

} else if (typeof exports === 'object') {
// CommonJS
/**
* CommonJS
*/
module.exports = factory(require)
} else {
/**
* Our own require function for the global scope.
* Global scope
*/
function globalRequire (packageName) {
root.requireOne = factory(function (packageName) {
if (root[packageName]) {

@@ -35,4 +39,3 @@ return root[packageName]

throw new Error('Package ' + packageName + 'not found')
}
root.requireOne = factory(globalRequire)
})
}

@@ -43,6 +46,10 @@ }(this, function (requireFunction) {

*
* @arg {(...string|string[])} packages - An array of strings representing
* which packages to load, or an argument list of strings to load.
* @param {(...string|string[])} packages - An array or argument list of
* strings representing which packages to load.
*
* @returns The first loaded package from the packages parameter.
* @returns The first available package. Throws an error otherwise.
*
* @throws Throws an Error when none of the packages could be loaded.
*
* @global
*/

@@ -49,0 +56,0 @@ return function requireFromArray (packages) {

Sorry, the diff of this file is not supported yet

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