davidm/lua-require-any
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
-
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
- Open with GitHub Desktop
- Download ZIP
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
LUA MODULE
requireany v$(_VERSION) - `require` any one of the listed modules.
SYNOPSIS
local bit, name = require 'requireany' ('bit', 'bit32', 'bit.numberlua')
print(bit.band(0x4, 0x1)) --> 5
print(name) --> 'bit32' (for example)
local bit = require 'requireany' ('bitfoo', nil) --> nil
local bit = require 'requireany' ('bitfoo', {band=. . .}) --> {band=. . .}
-- returns last non-string argument if fail to load any listed module.
DESCRIPTION
Sometimes more than one module may have a necessary interface
and you want to load just one of them depending on which are installed
on the user's system.
In the example above, there are three modules that provide some form
of bitwise-AND operator, and it will preferrentially load them from
left-to-right: first attempt to load 'bit' (LuaBitOp), and failing that
attempt to load load 'bit32' (Lua 5.2), and failing that attempt to load
'bit.numberlua' (a slower pure Lua module), and failing that raise
an error. Alternately, if the last value passed to `requireany` is a
non-string, this value will be returned rather than raising an error.
The second return value (`name`) is the name of the module loaded
(or `nil`).
API
require 'requireany' ( [names...] [, fallback] ) --> module, name
See DESCRIPTION above.
`require 'requireany' (...)` is a short-hand for
`require 'requireany' . requireany (...)`.
HOME PAGE
https://github.com/davidm/lua-require-any
DOWNLOAD/INSTALL
To install using LuaRocks:
luarocks install requireany
Otherwise download <https://github.com/davidm/lua-require-any>.
You may just copy requireany.lua into your LUA_PATH.
Otherwise:
make test
make install (or make install-local) -- to install in LuaRocks
make remove (or make remove-local) -- to remove from LuaRocks
DEPENDENCIES
None (other than Lua 5.1 or 5.2).
LICENSE
(c) 2008-2012 David Manura. Licensed under the same terms as Lua (MIT).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
(end license)
About
Like `require` but selects any one of the listed modules.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published