Jump to content

User:Gurch/Snuggle documentation

From Wikipedia, the free encyclopedia

General

[edit]

apply

[edit]

(function, object, ...) → object

Evaluates the specified function with remaining parameters as arguments.

assign (:=)

[edit]

(string, object) → object

Assigns a value to an identifier. Returns the value that was assigned.

boolean

[edit]

object → boolean

Returns boolean representation of argument.

function

[edit]

(args:object, ..., expression:object) → function

Returns a function. expression is expression to be evaluated, args are identifiers appearing in expression, which are substituted for argument values when the function is called.

if

[edit]

(boolean, object, object) → object

(boolean, object) → object

If first argument is true, evaluates and returns second argument, otherwise evaluates and returns third argument, or false if no third argument is provided. Does not evaluate the argument that is not returned.

is

[edit]

(object, string) → boolean

Returns true if argument 1 is of type given by argument 2, otherwise false.

number

[edit]

object → number

Returns numeric representation of argument.

sequence (;)

[edit]

(object, ...) → object

Evaluates arguments in order, returns value of last one.

string

[edit]

object → string

Returns string representation of argument.

switch

[edit]

(value:object, {test:object, expression:object}...) → object

Conditionally evaluates one or more expressions based on value. Arguments following first are in pairs; for each pair, if test is equal to value, expression is evaluated. Last expression evaluated is returned. test can be a list, in which case expression will be evaluated if any item in test is equal to value.

type

[edit]

object → string

Returns type of argument.

wikitext

[edit]

object → string

Return wikitext representation of argument.

Logical

[edit]

not (!)

[edit]

boolean → boolean

Logical 'not' operator.

and (&)

[edit]

(boolean, boolean) → boolean

Logical 'and' operator. Short-circuiting: evaluates from left to right, arguments following a false value not evaluated.

or (|)

[edit]

(boolean, boolean) → boolean

Logical 'or' operator. Short-circuiting: evaluates from left to right, arguments following a true value not evaluated.

xor

[edit]

(boolean, boolean) → boolean

Logical 'exclusive-or' operator.


Comparison

[edit]

=

[edit]

(object, object) → boolean

Returns true if string representations of objects are equal, otherwise false.

!=

[edit]

(object, object) → boolean

Returns false if string representations of objects are equal, otherwise true.

>

[edit]

(number, number) → boolean

Returns true if first argument greater than second, otherwise false.

<

[edit]

(number, number) → boolean

Returns true if first argument less than second, otherwise false.

>=

[edit]

(number, number) → boolean

Returns true if first argument greater than or equal to second, otherwise false.

<=

[edit]

(number, number) → boolean

Returns true if first argument less than or equal to second, otherwise false.


Math

[edit]

+=

[edit]

(string, number) → number

Increments value of specified identifier by specified number and returns result.

-=

[edit]

(string, number) → number

Decrements value of specified identifier by specified number and returns result.

sum (+)

[edit]

(number, ...) → number

Returns sum of arguments.

sub (-)

[edit]

(number, number) → number

Subtracts second argument from first.

*

[edit]

(number, number) → number

Multiplies arguments.

/

[edit]

(number, number) → number

Divides first argument by second.

div (\)

[edit]

(number, number) → number

Divides first argument by second, returns integer part of result.

mod (%)

[edit]

(number, number) → number

Divides first argument by second, returns integer remainder.

pow (^)

[edit]

(number, number) → number

Returns first argument raised to power of second argument.

abs

[edit]

number → number

Returns absolute value of argument.

sign

[edit]

number → number

Returns sign of argument.

sqrt

[edit]

number → number

Returns square root of argument.

max

[edit]

(number, ...) → number

Returns maximum of arguments.

min

[edit]

(number, ...) → number

Returns minimum of arguments.

log

[edit]

number → number

Returns logarithm to base 10 of argument.

ln

[edit]

number → number

Returns natural logarithm of argument.

classify

[edit]

(number, number) → string

Accepts value and interval size; returns string representation of interval of that size to which value belongs.

Strings

[edit]

+

[edit]

(string, string) → string

Concatenates two strings.

&=

[edit]

(string, string) → string

Concatenates the value of identifier in first argument with second argument, assigns result to identifier and returns result.

contains

[edit]

(string, string) → boolean

Returns true if first argument contains second, otherwise false.

lower

[edit]

string → string

Returns argument transformed to lowercase.

upper

[edit]

string → string

Returns argument transformed to uppercase.

lowerfirst

[edit]

string → string

Returns argument with first character transformed to lowercase.

upperfirst

[edit]

string → string

Returns argument with first character transformed to uppercase.

length

[edit]

string → number

Returns length of argument.

empty

[edit]

string → boolean

Returns true if argument is of length zero, otherwise false.

startswith

[edit]

(string, string) → boolean

Returns true if first argument starts with second argument, otherwise false.

endswith

[edit]

(string, string) → boolean

Returns true if first argument ends with second argument, otherwise false.

replace

[edit]

(string, string, string) → string

Returns first argument with all instances of second argument replaced by third argument.


Regex

[edit]

like

[edit]

(string, string) → boolean

Returns true if regex pattern given by second argument matches whole of first argument, otherwise false.

match

[edit]

(string, string) → string

(string, string, number) → string

With two arguments, returns first occurence of regex pattern given by second argument in first argument, or empty string if no match. With three arguments, occurence specified by third argument is returned, or empty string if there are insufficient matches.

replacepattern

[edit]

(string, string, string) → string

Returns first argument with regex search pattern and replace pattern in second and third arguments applied.


Dates

[edit]

date

[edit]

object → date

Returns date representation of argument.

dayname

[edit]

date → string

Returns name of day of week.

dayofmonth

[edit]

date → number

Returns day of month.

dayofweek

[edit]

date → number

Returns day of week.

dayofyear

[edit]

date → number

Returns day of year.

fullday

[edit]

date → string

Returns day, month name and year.

fullmonth

[edit]

date → string

Returns month name and year.

fullweek

[edit]

date → string

Returns week number and year.

hour

[edit]

date → number

Returns hour component of argument.

minute

[edit]

date → number

Returns minute component of argument.

month

[edit]

date → number

Returns month number.

monthname

[edit]

date → string

Returns name of month.

second

[edit]

date → number

Returns second component of argument.

week

[edit]

date → number

Returns week number.

year

[edit]

date → number

Returns year number.


Lists

[edit]

list

[edit]

(object, ...) → list

Returns list constructed from arguments.

count

[edit]

list → number

Returns number of items in list.

sort

[edit]

list → list

Sorts argument, contents must all be of same type.

unique

[edit]

list → list

Returns argument with any duplicate values removed.

group

[edit]

list → table(object, number)

Returns a table listing each unique value in argument and the number of occurences.

groupby

[edit]

(list, expression) → table(object, number)

Applies expression to each value in list, then applies group to results.

exclude

[edit]

(list, list) → list

Returns first argument with any values that occur in second argument removed.

union

[edit]

(list, list) → list

Returns list containing values from both arguments, including duplicates.

merge

[edit]

(list, object) → list

Appends object in second argument to list given by first argument.

first

[edit]

list → object

Returns first value in argument.

rest

[edit]

list → list

Returns argument with first value removed.

last

[edit]

list → object

Returns last value in argument.

item

[edit]

(list, number) → object

Returns value in first argument at zero-based index given by second argument

limit

[edit]

(list, number) → list

Returns number of items given by second argument from first argument, or entire list if shorter.

range

[edit]

(list, number, number) → list

Returns subset of items from argument 1, of size given by argument 3 and beginning at index given by argument 2.

reverse

[edit]

list → list

Returns argument with items reversed.

filter

[edit]

(list, expression) → list

Evaluates expression in the context of each item in the list, returns list of items for which expression evaluates to true.

map (->)

[edit]

(list, expression) → list

Evaluates expression in the context of each item in the list, returns list of results.

fold

[edit]

(list, string) → object

(list, string, object) → object

Starts with third argument or default value as result and iteratively applies function given by string to next item in list. See fold (higher-order function).

movingavg

[edit]

(list:list, size:number) → list

Returns list of averages of each set of size consecutive values in list. Length of resulting list is list count(list) - size + 1.


Tables

[edit]

table

[edit]

(list, expression, ...) → table

Evaluates each expression given in the context of each item in list and constructs a table of resulting values. Table contains one row for each item in list and one column for each expression. Parameter names given for expressions will be used as column names.

count

[edit]

table → number

Returns number of rows in argument.

column

[edit]

(table, number) → list

(table, string) → list

Returns list of values in table column given by column index or name.

columncount

[edit]

table → number

Returns number of columns in argument.

sortby

[edit]

(table, number) → table

(table, string) → table

Sorts table by column index or name.

Categories

[edit]

category

[edit]

string → category

Returns category with name given by argument.

hidden

[edit]

category → boolean

Returns true if category is hidden, otherwise false.

count

[edit]

category → number

Returns number of items in category.

subcatcount

[edit]

category → number

Returns number of subcategories in category.


Pages

[edit]

page

[edit]

string → page

Returns page with name given by argument.

::

[edit]

(page:page, param:string) → string

Infobox lookup. Returns value of parameter param in infobox on page, with reference to parameter normalization table. Returns <no infobox> if page has no infobox, <no param> if page has an infobox but it does not contain parameter param.

assessment

[edit]

page → string

Returns assessment level of page.

basename

[edit]

page → string

Returns page name without namespace prefix.

categories

[edit]

page → list

Returns list of categories that current version of page is in.

creator

[edit]

page → user

Returns creator of page.

firstedit

[edit]

page → revision

Returns first revision of page.

hasinfobox

[edit]

page → boolean

Returns true if current version of page has an infobox, otherwise false.

infobox

[edit]

page → templateinstance

Returns infobox on current version of page, if any.

isarticle

[edit]

page → boolean

Returns true if page is article, otherwise false.

isarticletalkpage

[edit]

page → boolean

Returns true if page is article talk page, otherwise false.

isredirect

[edit]

page → boolean

Returns true if current version of page is a redirect, otherwise false.

isrootpage

[edit]

page → boolean

Returns true if page is not a subpage, otherwise false.

issubjectpage

[edit]

page → boolean

Returns true if page is not a talk page, otherwise false.

issubpage

[edit]

page → boolean

Returns true if page is a subpage, otherwise false.

istalkpage

[edit]

page → booleam

Returns true if page is a talk page, otherwise false.

lastedit

[edit]

page → revision

Returns most recent revision of page.

namespace

[edit]

page → namespace

Returns page's namespace.

subjectpage

[edit]

page → page

If page is talk page, returns equivalent subject page, otherwise returns page.

talkpage

[edit]

page → page

If page is not talk page, returns equivalent talk page, otherwise returns page.

target

[edit]

page → page

If page is a redirect, returns redirect target.

text

[edit]

page → string

Returns text of current revision to page.

title

[edit]

page → string

Returns page title.


Revisions

[edit]

revision

[edit]

number → revision

Returns revision with id given by argument.

author

[edit]

revision → user

Returns author of revision.

change

[edit]

revision → number

Returns difference in size between revision and previous revision to page.

issection

[edit]

revision → boolean

Returns true if revision is section edit, otherwise false.

minor

[edit]

revision → boolean

Returns true if revision is marked as minor, otherwise false.

new

[edit]

revision → boolean

Returns true if revision is first revision to page, otherwise false.

page

[edit]

revision → page

Returns page to which revision was made.

section

[edit]

revision → string

Returns section that was edited, if any.

size

[edit]

revision → number

Returns size of revision.

summary

[edit]

revision → string

Returns edit summary for revision.

time

[edit]

revision → date

Returns revision date/time.

tool

[edit]

revision → string

Returns tool used for revision, if identifiable from summary.


Users

[edit]

user

[edit]

string → user

Returns user with name given by argument.

anonymous

[edit]

user → boolean

Returns true if user is anonymous, otherwise false.

created

[edit]

user → date

Returns date/time of account creation.

editcount

[edit]

user → number

Returns number of edits user has made.

ignored

[edit]

user → boolean

Returns true if user is on ignored users list, otherwise false.

name

[edit]

user → string

Returns user's name.

talkpage

[edit]

user → page

Returns user's talk page.

userpage

[edit]

user → page

Returns user's user page.


Namespaces

[edit]

namespace

[edit]

number → namespace

Returns namespace with specified number.

issubjectspace

[edit]

namespace → boolean

Returns true if namespace is not a talk namespace, otherwise false.

istalkspace

[edit]

namespace → boolean

Returns true if namespace is a talk namespace, otherwise false.

name

[edit]

namespace → string

Returns namespace name.

number

[edit]

namespace → number

Returns namespace number.

subpages

[edit]

namespace → boolean

Returns true if subpages are enabled in namespace, otherwise false.


List requests

[edit]

Optional parameters common to all requests:

  • cache (boolean): Set to false to ignore any cached results.
  • limit (number): Maximum number of results to return. Default 1000.
  • namespaces (number): For requests that return pages or revisions, limit results to specified namespaces.
  • type (string): For requests that return pages, specify "revisions" to return info on last revision to each page, and "content" to return full text of last revision to each page.

allpages

[edit]

void → list

Returns all pages.

[edit]

page → list

Returns pages that link to specified page.

category

[edit]

category → list

Returns contents of specified category.

contribs

[edit]

user → list

Returns user's contributions.

deletedcontribs

[edit]

user → list

Returns user's deleted contributions.

externallinkusage

[edit]

string → list

Returns pages containing specified external link.

history

[edit]

page → list

Returns revisions of specified page.

images

[edit]

page → list

Returns images on specified page.

imageusage

[edit]

page → list

Returns pages that use specified image.

[edit]

page → list

Returns all internal links on specified page.

prefix

[edit]

string → list

Returns pages with titles that begin with specified prefix.

subcats

[edit]

category → list

Returns subcategories of specified category.

[edit]

string → list

Returns pages that appear in search results for specified search term.

templates

[edit]

page → list

Returns templates used on specified page.

transclusions

[edit]

page → list

Returns pages on which specified template is used.


Statistics

[edit]

pagecount

[edit]

void → number

Returns total number of pages.

articlecount

[edit]

void → number

Returns total number of articles.

usercount

[edit]

void → number

Returns total number of user accounts.

activeusercount

[edit]

void → number

Returns total number of active user accounts.

filecount

[edit]

void → number

Returns total number of files.

editscount

[edit]

void → number

Returns total number of revisions.


Wikitext

[edit]

expand

[edit]

string → string

Returns argument treated as wiki markup with any templates expanded.

strip

[edit]

string → string

Returns argument with wiki links, tags and formatting removed.

paramnorm

[edit]

string → string

Returns argument normalized according to parameter normalization table.

getparam

[edit]

(wikitext:string, template:string, param:string) → string

Returns value of parameter param in first occurence of template in wikitext.

setparam

[edit]

(wikitext:string, template:string, param:string, value:string) → boolean

Returns wikitext with parameter param in first occurence of template set to value. Treats any template that redirects to template as an instance of such. Replaces parameter value if it already exists, otherwise adds it. Does nothing if no instance of template is found. Returns true if parameter was set, otherwise false.

addcategory

[edit]

(wikitext:string, category:string) → string

Returns wikitext with category added. Does not add category if already present.

removecategory

[edit]

(wikitext:string, category:string) → string

Returns wikitext with category removed, or no change if category not present.

replacecategory

[edit]

(wikitext:string, category:string, replacement:string) → string

Returns wikitext with category replaced with replacement, or no change if not present.

removetemplate

[edit]

(wikitext:string, template:string) → string

Returns wikitext with first occurence of template removed, or no change if no instance of template present. Treats any template that redirects to template as an instance of such.

Actions

[edit]

edit

[edit]

(page:page, wikitext:string, summary:string) → string

Edits page specified by page, using wikitext as text and summary as edit summary.

Optional arguments:

  • section - string. Edit this section. Should be number or "new".
  • minor - boolean. Whether to mark as minor edit. Defaults to true.
  • bot - boolean. Whether to mark as bot edit. Defaults to true if account is in bot group, has no effect if not.
  • create - boolean. Whether to create page if it does not exist. Defaults to true.
  • conflict - string. Behaviour in event of edit conflict. One of the following values. Default is ignore.
    • abort - Give up and move on.
    • retry - Try again. When adding section or prepending/appending text, applies changes on top of conflicted edit. Will overwrite conflicted edit in other cases.
    • prompt - Ask whether to save anyway.
    • ignore - Don't bother checking for conflicts in the first place.