GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MediaWiki Frontend API
  • Home
  • Modules
  • jquery.confirmable
  • jquery.highlightText
  • jquery.lengthLimit
  • jquery.makeCollapsible
  • jquery.spinner
  • jquery.suggestions
  • jquery.tablesorter
  • jquery.textSelection
  • mediawiki.DateFormatter
  • mediawiki.ForeignApi
  • mediawiki.String

This view

  • Original page
  • New address

GeezerVison is showing doc.wikimedia.org — Module: mediawiki.String, MediaWiki Frontend API, JSDoc

Module providing string utility functions.

Source:
  • mediawiki.String.js, line 235

Methods

byteLength(str) → {number}static #

Calculate the byte length of a string (accounting for UTF-8).

Parameters:

Name Type Description
str string

Returns:

Type
number
Author:
  • Jan Paul Posma, 2011
  • Timo Tijhof, 2012
  • David Chan, 2013
Source:
  • mediawiki.String.js, line 12
Calculate the byte length of a string (accounting for UTF-8).

charAt(string, offset, [backwards]) → {string}static #

Like String.charAt(), but return the pair of UTF-16 surrogates for characters outside of BMP.

Parameters:

Name Type Attributes Description
string string
offset number

Offset to extract the character

backwards boolean optional

Use backwards direction to detect UTF-16 surrogates, defaults to false

Returns:

Type
string
Source:
  • mediawiki.String.js, line 58

Like String.charAt(), but return the pair of UTF-16 surrogates for characters outside of BMP.

codePointLength(str) → {number}static #

Calculate the character length of a string (accounting for UTF-16 surrogates).

Parameters:

Name Type Description
str string

Returns:

Type
number
Source:
  • mediawiki.String.js, line 40
Calculate the character length of a string (accounting for UTF-16 surrogates).

lcFirst(string) → {string}static #

Lowercase the first character. Support UTF-16 surrogates for characters outside of BMP.

Parameters:

Name Type Description
string string

Returns:

Type
string
Source:
  • mediawiki.String.js, line 78
Lowercase the first character.

trimByteLength(safeVal, newVal, byteLimit, [filterFunction]) → {module:mediawiki.String~StringTrimmed}static #

Utility function to trim down a string, based on byteLimit and given a safe start position. It supports insertion anywhere in the string, so "foo" to "fobaro" if limit is 4 will result in "fobo", not "foba". Basically emulating the native maxlength by reconstructing where the insertion occurred.

Parameters:

Name Type Attributes Description
safeVal string

Known value that was previously returned by this function, if none, pass empty string.

newVal string

New value that may have to be trimmed down.

byteLimit number

Number of bytes the value may be in size.

filterFunction function optional

Function to call on the string before assessing the length.

Returns:

Type
module:mediawiki.String~StringTrimmed
Source:
  • mediawiki.String.js, line 189

Utility function to trim down a string, based on byteLimit and given a safe start position.

trimCodePointLength(safeVal, newVal, codePointLimit, [filterFunction]) → {module:mediawiki.String~StringTrimmed}static #

Utility function to trim down a string, based on codePointLimit and given a safe start position. It supports insertion anywhere in the string, so "foo" to "fobaro" if limit is 4 will result in "fobo", not "foba". Basically emulating the native maxlength by reconstructing where the insertion occurred.

Parameters:

Name Type Attributes Description
safeVal string

Known value that was previously returned by this function, if none, pass empty string.

newVal string

New value that may have to be trimmed down.

codePointLimit number

Number of characters the value may be in size.

filterFunction function optional

Function to call on the string before assessing the length.

Returns:

Type
module:mediawiki.String~StringTrimmed
Source:
  • mediawiki.String.js, line 217

Utility function to trim down a string, based on codePointLimit and given a safe start position.

ucFirst(string) → {string}static #

Uppercase the first character. Support UTF-16 surrogates for characters outside of BMP.

Parameters:

Name Type Description
string string

Returns:

Type
string
Source:
  • mediawiki.String.js, line 90
Uppercase the first character.

Type Definitions

StringTrimmed #

Type:

  • Object

Properties:

Name Type Description
newVal string

a trimmed version of the string

trimmed boolean

whether the string is different from the original version.

Source:
  • mediawiki.String.js, line 168
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.