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

Require the first found package from an array.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Require One NPM version

Build Status NPM downloads Dependency Status

Load the first package found from the given array.

Install

MethodInstallation
npmnpm install require-one --save
componentcomponent install robloach/require-one
Composercomposer require require-one
Bowerbower install require-one

Usage

This works across CommonJS/node, AMD and with global variables for the browser.

CommonJS

This is an example of loading either jQuery, Zepto, or Cheerio with a CommonJS module loader, like Node.js.

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

AMD

This is an example of loading either jQuery, Zepto, or Cheerio with an AMD module loader, like Require.js.

require(['require-one'], function(requireOne) {

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

  // ...
});

Globals

This is an example of loading either jQuery, Zepto, or Cheerio without a module loader, i.e. with the browser's global variables.

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="path/to/require-one.js"></script>
    <script>
      var $ = requireOne('jquery', 'jQuery', 'zepto', 'Zepto', 'cheerio');
      // => jQuery, Zepto or Cheerio, depending on which one is available.
    </script>
  </head>
  <body>
    <h1>My Sample Project</h1>
  </body>
</html>

License

MIT

Keywords

FAQs

Package last updated on 24 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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