Modul:Func: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
StadtbahnBI>ExE Boss (Copied from mw:Module:Func) |
Tt (Diskussion | Beiträge) K (1 Version importiert) |
(kein Unterschied)
|
Aktuelle Version vom 9. Oktober 2021, 15:25 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Func/Doku erstellt werden
-------------------------------------------------------------------------------- -- This module provies helper functions for manipulating Lua functions. -- -- @module func -- @alias p -- @author ExE Boss -- @require [[Module:No globals]] -------------------------------------------------------------------------------- require("Module:No globals"); local checkTypeMulti = require("libraryUtil").checkTypeMulti; local p = {}; -------------------------------------------------------------------------------- -- Creates a bound function that calls `func` with the varargs passed to `bind` -- preceding the varargs passed to the newly created bound function. -- -- @param {function} func -- @param {any} ... -- @return {function} -- @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind -------------------------------------------------------------------------------- function p.bind(func, ...) checkTypeMulti("bind", 1, func, { "table", "function" }); local len = select("#", ...); local args = {...}; return function(...) return func(unpack(args, 1, len), ...); end end return p;