Модуль:SummaryII/dependencies

Материал из свободной русской энциклопедии «Традиция»
Перейти к навигации Перейти к поиску

Для документации этого модуля может быть создана страница Модуль:SummaryII/dependencies/doc

--[[
	Dependencies:
--]]
local type	= type

local str	= mw.ustring	or string
local array = require 'Module:Array' or {}

local function clone (tbl)	
	local cloned
  	if type (tbl) == 'table' then
  		cloned = {}
  		setmetatable (cloned, getmetatable (tbl))
  		for key, value in pairs (tbl) do
  			cloned [key] = clone (value)
  		end
  	else
  		cloned = tbl
  	end
	return cloned
end	-- local function clone (tbl)
  				
return {
	wrap	= coroutine.wrap
  , yield	= coroutine.yield
  
  , sort	= table.sort
  , join	= table.concat
  , clone	= mw.clone or clone
  , merge	= array.table_merge or function (...)
		local type = type
		local merged = {}
		for _, tbl in ipairs {...} do
			for key, value in pairs (type (tbl) == 'table' and tbl or {tbl}) do
				merged [key] = value
			end
		end
		return merged
	end	-- merge	= array.table_merge or function (...)
  , merge_to_first	= array.table_merge_to_first or function (first, ...)
  		local type = type
		for _, tbl in ipairs {...} do
			for key, value in pairs (type (tbl) == 'table' and tbl or {tbl}) do
				first [key] = value
			end
		end
	return first
	end	-- table_merge_to_first	= array.table_merge or function (first, ...)
  , keys	= array.table_keys or function (tbl)
		local keys = {}
		for key, _ in pairs (tbl) do
			keys [#keys + 1] = key
		end
		return keys
	end	-- keys	= array.table_keys or function (tbl)
  
  , lc		= str.lower
  , sub		= str.sub
  , gsub	= str.gsub
  , find	= str.find
  , gmatch	= str.gmatch
  , len		= str.len
  , trim	= mw.text.trim	or function (s)
		return s:gsub ('^%s*(.-)%s*$', '%1')
	end
  , split	= mw.text.split	or function (s, sep)
		sep = sep or '%s'
		local t = {}
		for str in str.gmatch (s, '([^' .. sep .. ']+)') do
			table.insert (t, str)
		end
		return t
	end	-- function (s, sep)

  , regex	= (rex_pcre () or require 'lrexlib.so').new
  ,	lpeg	= lpeg or require 'lualpeg.so'
  , re		= (require 'Module:Re' or require 're.lua').compile
  
  , ask		= mw.smw.ask
}	-- return {...}