tw5-typed / modules/utils/utils
Module: modules/utils/utils
Table of contents
References
- copyDirectory
- copyFile
- createDirectory
- createFileDirectories
- deleteDirectory
- deleteEmptyDirectories
- generateTiddlerExtension
- generateTiddlerFileInfo
- generateTiddlerFilepath
- getSubdirectories
- isDirectory
- isDirectoryEmpty
- removeTrailingSeparator
Type Aliases
Variables
Functions
- base64Decode
- base64Encode
- checkDependencies
- count
- deepCopy
- deepFreeze
- encodeURIComponentExtended
- endsWith
- entityDecode
- escape
- escapeRegExp
- extend
- extendDeepCopy
- extractVersionInfo
- findFollowingLineBreak
- findPrecedingLineBreak
- formatDateString
- formatTitleString
- getAmPm
- getAnimationDuration
- getDaySuffix
- getHours12
- getInt
- getRelativeDate
- getSystemInfo
- getWeek
- getYearForWeekNo
- hashString
- hopArray
- htmlEncode
- htmlTextEncode
- hyphenateCss
- isLinkExternal
- isValidFieldName
- jsonStringify
- log
- logTable
- makeCompareFunction
- makeDataUri
- makeTiddlerDictionary
- nextTick
- parseInt
- parseNumber
- parseTextReference
- removeArrayEntries
- repeat
- replaceString
- sign
- slowInSlowOut
- startsWith
- stringEndsWith
- stringify
- stringifyNumber
- tagToCssSelector
- terminalColour
- timer
- toSentenceCase
- toTitleCase
- trim
- trimPrefix
- trimSuffix
- unHyphenateCss
- unescapeLineBreaks
- warning
References
copyDirectory
Re-exports copyDirectory
copyFile
Re-exports copyFile
createDirectory
Re-exports createDirectory
createFileDirectories
Re-exports createFileDirectories
deleteDirectory
Re-exports deleteDirectory
deleteEmptyDirectories
Re-exports deleteEmptyDirectories
generateTiddlerExtension
Re-exports generateTiddlerExtension
generateTiddlerFileInfo
Re-exports generateTiddlerFileInfo
generateTiddlerFilepath
Re-exports generateTiddlerFilepath
getSubdirectories
Re-exports getSubdirectories
isDirectory
Re-exports isDirectory
isDirectoryEmpty
Re-exports isDirectoryEmpty
removeTrailingSeparator
Re-exports removeTrailingSeparator
Type Aliases
TerminalColourName
Ƭ TerminalColourName: "black"
| "red"
| "green"
| "brown/orange"
| "blue"
| "purple"
| "cyan"
| "light gray"
Defined in
src/modules/utils/utils.d.ts:2
Variables
terminalColourLookup
• Const
terminalColourLookup: Record
<TerminalColourName
, string
>
Defined in
src/modules/utils/utils.d.ts:12
Functions
base64Decode
▸ base64Decode(string64
): string
Decodes a base64 string.
Parameters
Name | Type | Description |
---|---|---|
string64 | string | The base64 string to decode. |
Returns
string
The decoded string.
Description
解码 base64 字符串。
Defined in
src/modules/utils/utils.d.ts:489
base64Encode
▸ base64Encode(string64
): string
Encodes a string to base64.
Parameters
Name | Type | Description |
---|---|---|
string64 | string | The string to encode. |
Returns
string
The encoded base64 string.
Description
将字符串编码为 base64。
Defined in
src/modules/utils/utils.d.ts:497
checkDependencies
▸ checkDependencies(dependencies
, changes
): boolean
Checks whether any members of a hashmap are present in another hashmap.
Parameters
Name | Type | Description |
---|---|---|
dependencies | object | The hashmap to check for dependencies. |
changes | object | The hashmap to check for changes. |
Returns
boolean
True if any members of the hashmap are present in another hashmap, false otherwise.
Description
检查哈希映射的任何成员是否存在于另一个哈希映射中。
Defined in
src/modules/utils/utils.d.ts:191
count
▸ count(object
): number
Returns the number of keys in an object.
Parameters
Name | Type | Description |
---|---|---|
object | object | The object to count the keys of. |
Returns
number
The number of keys in the object.
Description
返回对象中键的数量。
Defined in
src/modules/utils/utils.d.ts:164
deepCopy
▸ deepCopy(object
): any
Deep copy an object.
Parameters
Name | Type | Description |
---|---|---|
object | any | The object to copy. |
Returns
any
The copied object.
Description
深拷贝对象。
Defined in
src/modules/utils/utils.d.ts:220
deepFreeze
▸ deepFreeze(object
): void
Recursively freeze an object and its properties.
Parameters
Name | Type | Description |
---|---|---|
object | any | The object to freeze. |
Returns
void
Description
递归地冻结对象及其属性。
Defined in
src/modules/utils/utils.d.ts:236
encodeURIComponentExtended
▸ encodeURIComponentExtended(s
): string
An extended version of encodeURIComponent that encodes additional characters including those that are illegal within filepaths on various platforms including Windows.
Parameters
Name | Type | Description |
---|---|---|
s | string | The string to encode. |
Returns
string
The encoded string.
Description
encodeURIComponent 的扩展版本,可编码包括在各种平台(包括 Windows)的文件路径中非法的其他字符。
Defined in
src/modules/utils/utils.d.ts:390
endsWith
▸ endsWith(string_
, search
): boolean
Checks if a string ends with another string.
Parameters
Name | Type | Description |
---|---|---|
string_ | string | - |
search | string | The string to search for. |
Returns
boolean
True if the string ends with the search string, false otherwise.
Description
检查字符串是否以另一个字符串结尾。
Defined in
src/modules/utils/utils.d.ts:96
entityDecode
▸ entityDecode(s
): string
Converts all HTML entities to their character equivalents.
Parameters
Name | Type | Description |
---|---|---|
s | string | The string to decode. |
Returns
string
The decoded string.
Description
将所有 HTML 实体转换为它们的字符等价物。
Defined in
src/modules/utils/utils.d.ts:340
escape
▸ escape(ch
): string
Returns an escape sequence for given character. Uses \x
for characters <=
0xFF to save space, \u
for the rest.
Parameters
Name | Type | Description |
---|---|---|
ch | string | The character to escape. |
Returns
string
The escaped character.
Description
返回给定字符的转义序列。对于字符 <=
0xFF,使用 \x
以节省空间,对于其余字符使用 \u
。
Defined in
src/modules/utils/utils.d.ts:356
escapeRegExp
▸ escapeRegExp(s
): string
Escapes the RegExp special characters with a preceding backslash.
Parameters
Name | Type | Description |
---|---|---|
s | string | The string to escape. |
Returns
string
The escaped string.
Description
使用反斜杠转义 RegExp 特殊字符。
Defined in
src/modules/utils/utils.d.ts:382
extend
▸ extend(object
, ...source
): object
Extends an object with one or more sources.
Parameters
Name | Type | Description |
---|---|---|
object | object | The object to extend. |
...source | object [] | - |
Returns
object
The extended object.
Description
使用一个或多个源扩展对象。
Defined in
src/modules/utils/utils.d.ts:203
▸ extend(object
, ...source
): any
Extend an object with properties from one or more sources.
Parameters
Name | Type | Description |
---|---|---|
object | any | The object to extend. |
...source | any [] | - |
Returns
any
The extended object.
Description
从一个或多个源中复制属性来扩展对象。
Defined in
src/modules/utils/utils.d.ts:212
extendDeepCopy
▸ extendDeepCopy(object
, extendedProperties
): any
Extend an object with properties from one or more sources, and deep copy the extended properties.
Parameters
Name | Type | Description |
---|---|---|
object | any | The object to extend. |
extendedProperties | any | The properties to extend and deep copy. |
Returns
any
The extended object.
Description
从一个或多个源中复制属性来扩展对象,并深拷贝扩展的属性。
Defined in
src/modules/utils/utils.d.ts:229
extractVersionInfo
▸ extractVersionInfo(): string
| null
Extracts the version number from the meta tag or from the boot file.
Returns
string
| null
The version number.
Description
从 meta 标签或启动文件中提取版本号。
Defined in
src/modules/utils/utils.d.ts:466
findFollowingLineBreak
▸ findFollowingLineBreak(text
, pos
): number
Finds the line break following a given position in a string.
Parameters
Name | Type | Description |
---|---|---|
text | string | The string to search in. |
pos | number | The position to search for. |
Returns
number
The position of the following line break, or the end of the string.
Description
查找字符串中给定位置之后的换行符。
Defined in
src/modules/utils/utils.d.ts:156
findPrecedingLineBreak
▸ findPrecedingLineBreak(text
, pos
): number
Finds the line break preceding a given position in a string.
Parameters
Name | Type | Description |
---|---|---|
text | string | The string to search in. |
pos | number | The position to search for. |
Returns
number
The position immediately after that line break, or the start of the string.
Description
查找字符串中给定位置之前的换行符。
Defined in
src/modules/utils/utils.d.ts:147
formatDateString
▸ formatDateString(date
, template
): string
Format a date string based on a template.
Use "[UTC]YYYY0MM0DD0hh0mm0ss0XXX"
to format a standard tiddlywiki date string.
See document for more formats.
Parameters
Name | Type | Description |
---|---|---|
date | Date | The date object to format. |
template | string | The template string to use for formatting. |
Returns
string
The formatted date string.
Url
https://tiddlywiki.com/#DateFormat
Defined in
src/modules/utils/utils.d.ts:268
formatTitleString
▸ formatTitleString(template
, options
): string
Format a string template with options.
Parameters
Name | Type | Description |
---|---|---|
template | string | The string template to format. |
options | Object | The options to use for formatting. |
options.base? | string | - |
options.counter? | number | - |
options.separator? | string | - |
Returns
string
The formatted string.
Description
使用选项格式化字符串模板。
Defined in
src/modules/utils/utils.d.ts:253
getAmPm
▸ getAmPm(date
): string
Get the AM/PM period of a date.
Parameters
Name | Type | Description |
---|---|---|
date | Date | The date object to get the period from. |
Returns
string
The period string (either "am" or "pm").
Defined in
src/modules/utils/utils.d.ts:275
getAnimationDuration
▸ getAnimationDuration(): number
Gets the animation duration in milliseconds.
Returns
number
The animation duration.
Description
获取动画持续时间(以毫秒为单位)。
Defined in
src/modules/utils/utils.d.ts:473
getDaySuffix
▸ getDaySuffix(date
): string
Get the suffix for the day of a date.
Parameters
Name | Type | Description |
---|---|---|
date | Date | The date object to get the day suffix from. |
Returns
string
The day suffix string.
Defined in
src/modules/utils/utils.d.ts:282
getHours12
▸ getHours12(date
): number
Get the 12-hour format of the hour of a date.
Parameters
Name | Type | Description |
---|---|---|
date | Date | The date object to get the hour from. |
Returns
number
The 12-hour format of the hour.
Defined in
src/modules/utils/utils.d.ts:303
getInt
▸ getInt(string_
, deflt
): number
Return the integer represented by the str (string). Return the dflt (default) parameter if str is not a base-10 number.
Parameters
Name | Type | Description |
---|---|---|
string_ | string | - |
deflt | number | The default value to return if the string is not a base-10 number. |
Returns
number
The integer represented by the string or the default value if the string is not a base-10 number.
Description
返回由 str(字符串)表示的整数。如果 str 不是十进制数字,则返回 dflt(默认)参数。
Defined in
src/modules/utils/utils.d.ts:55
getRelativeDate
▸ getRelativeDate(delta
): Object
Convert a date delta in milliseconds into a string representation of "23 seconds ago", "27 minutes ago" etc.
Parameters
Name | Type | Description |
---|---|---|
delta | number | delta in milliseconds |
Returns
Object
An object with these members:
- description: string describing the delta period
- updatePeriod: time in millisecond until the string will be inaccurate
Name | Type |
---|---|
description | string |
updatePeriod | number |
Description
将以毫秒为单位的日期差转换为“23秒前”、“27分钟前”等字符串表示形式。
Defined in
src/modules/utils/utils.d.ts:313
getSystemInfo
▸ getSystemInfo(): string
Returns system information useful for debugging.
Returns
string
A string with system information.
Description
返回有用于调试的系统信息字符串。
Defined in
src/modules/utils/utils.d.ts:564
getWeek
▸ getWeek(date
): number
Get the week number of a date.
Parameters
Name | Type | Description |
---|---|---|
date | Date | The date object to get the week number from. |
Returns
number
The week number.
Defined in
src/modules/utils/utils.d.ts:289
getYearForWeekNo
▸ getYearForWeekNo(date
): number
Get the year for a week number of a date.
Parameters
Name | Type | Description |
---|---|---|
date | Date | The date object to get the year from. |
Returns
number
The year for the week number.
Defined in
src/modules/utils/utils.d.ts:296
hashString
▸ hashString(string_
): number
Hashes a string to a number. the function behind <<now "format">>
Parameters
Name | Type |
---|---|
string_ | string |
Returns
number
The hashed number.
Description
将字符串哈希为数字。
Defined in
src/modules/utils/utils.d.ts:481
hopArray
▸ hopArray(object
, array
): boolean
Determines whether an array item is an object property.
Parameters
Name | Type | Description |
---|---|---|
object | object | The object to check. |
array | any [] | The array to check. |
Returns
boolean
True if the array item is an object property, false otherwise.
Description
确定数组项是否为对象属性。
Defined in
src/modules/utils/utils.d.ts:173
htmlEncode
▸ htmlEncode(s
): string
Convert & to "&", < to "<", > to ">", " to """
Parameters
Name | Type | Description |
---|---|---|
s | string | The string to encode. |
Returns
string
The encoded string.
Description
将 & 转换为 "&",< 转换为 "<",> 转换为 ">"," 转换为 """。
Defined in
src/modules/utils/utils.d.ts:324
htmlTextEncode
▸ htmlTextEncode(s
): string
Converts like htmlEncode, but forgets the double quote for brevity
Parameters
Name | Type | Description |
---|---|---|
s | string | The string to encode. |
Returns
string
The encoded string.
Description
类似于 htmlEncode,但为了简洁起见忽略了双引号。
Defined in
src/modules/utils/utils.d.ts:332
hyphenateCss
▸ hyphenateCss(propertyName
): string
Converts a camelcase CSS property name into a dashed one ("backgroundColor" --> "background-color").
Parameters
Name | Type |
---|---|
propertyName | string |
Returns
string
The converted CSS property name.
Description
将驼峰式的 CSS 属性名称转换为连字符分隔的。
Defined in
src/modules/utils/utils.d.ts:421
isLinkExternal
▸ isLinkExternal(to
): boolean
Checks whether a link target is external, i.e. not a tiddler title.
Parameters
Name | Type | Description |
---|---|---|
to | string | The link target to check. |
Returns
boolean
True if the link target is external, false otherwise.
Description
检查链接目标是否为外部链接,即不是 tiddler 标题。
Defined in
src/modules/utils/utils.d.ts:398
isValidFieldName
▸ isValidFieldName(name
): boolean
Checks whether a string is a valid field name.
Parameters
Name | Type | Description |
---|---|---|
name | string | The string to check. |
Returns
boolean
True if the string is a valid field name, false otherwise.
Description
检查字符串是否为有效的字段名称。
Defined in
src/modules/utils/utils.d.ts:459
jsonStringify
▸ jsonStringify(s
, rawUnicode?
): string
Turns a string into a legal JSON string.
Parameters
Name | Type | Description |
---|---|---|
s | string | The string to stringify. |
rawUnicode? | boolean | Whether to escape non-ASCII characters. |
Returns
string
The stringified JSON string.
Description
将字符串转换为合法的 JSON 字符串。
Defined in
src/modules/utils/utils.d.ts:374
log
▸ log(text
, colour?
): void
Displays a message, in color if we're on a terminal.
Parameters
Name | Type | Description |
---|---|---|
text | string | The text to display. |
colour? | string | The color to display the text in. |
Returns
void
Description
在终端上显示消息,如果在终端上则以颜色显示。
Defined in
src/modules/utils/utils.d.ts:23
logTable
▸ logTable(data
): void
Log a table of name: value pairs.
Parameters
Name | Type | Description |
---|---|---|
data | object | The data to log. |
Returns
void
Description
记录名称:值对的表格。
Defined in
src/modules/utils/utils.d.ts:45
makeCompareFunction
▸ makeCompareFunction(type
, options?
): (a
: any
, b
: any
) => number
Creates a comparison function for a given type.
Parameters
Name | Type | Description |
---|---|---|
type | string | The type of comparison function to create. |
options? | Object | The options for the comparison function. |
options.defaultType? | string | - |
options.invert? | boolean | - |
options.isCaseSensitive? | boolean | - |
Returns
fn
The comparison function.
▸ (a
, b
): number
Parameters
Name | Type |
---|---|
a | any |
b | any |
Returns
number
Description
创建给定类型的比较函数。
Defined in
src/modules/utils/utils.d.ts:597
makeDataUri
▸ makeDataUri(text
, type?
, _canonical_uri?
): string
Converts text and content type to a data URI.
Parameters
Name | Type | Description |
---|---|---|
text | string | The text to convert. |
type? | string | The content type of the text. |
_canonical_uri? | string | The canonical URI of the text. |
Returns
string
The data URI.
Description
将文本和内容类型转换为数据 URI。
Defined in
src/modules/utils/utils.d.ts:523
makeTiddlerDictionary
▸ makeTiddlerDictionary(data
): string
Converts a hashmap into a tiddler dictionary format sequence of name:value pairs.
Parameters
Name | Type | Description |
---|---|---|
data | Record <string , any > | The hashmap to convert. |
Returns
string
The tiddler dictionary format sequence of name:value pairs.
Description
将 hashmap 转换为 tiddler 字典格式的 name:value 对序列。
Defined in
src/modules/utils/utils.d.ts:505
nextTick
▸ nextTick(function_
): void
Executes a function on the next tick of the event loop.
Parameters
Name | Type |
---|---|
function_ | () => void |
Returns
void
Description
在事件循环的下一个时刻执行函数。
Defined in
src/modules/utils/utils.d.ts:405
parseInt
▸ parseInt(string_
): number
Parses a string into an integer.
Parameters
Name | Type |
---|---|
string_ | string |
Returns
number
The parsed integer or 0 if the string is not a valid integer.
Description
将字符串解析为整数。
Defined in
src/modules/utils/utils.d.ts:580
parseNumber
▸ parseNumber(string_
): number
Parses a string into a number.
Parameters
Name | Type |
---|---|
string_ | string |
Returns
number
The parsed number or 0 if the string is not a valid number.
Description
将字符串解析为数字。
Defined in
src/modules/utils/utils.d.ts:572
parseTextReference
▸ parseTextReference(textReference
): Object
Parses a text reference of one of these forms:
- title
- !!field
- title!!field
- title##index
- etc Returns an object with the following fields, all optional:
- title: tiddler title
- field: tiddler field name
- index: JSON property index
Parameters
Name | Type |
---|---|
textReference | string |
Returns
Object
An object with the parsed fields.
Name | Type |
---|---|
field? | string |
index? | string |
title? | string |
Description
解析文本引用,支持以下格式:
- title
- !!field
- title!!field
- title##index
- 等等 返回一个包含 以下字段的对象,所有字段都是可选的:
- title:tiddler 标题
- field:tiddler 字段名称
- index:JSON 属性索引
Defined in
src/modules/utils/utils.d.ts:447
removeArrayEntries
▸ removeArrayEntries<T
>(array
, value
): T
[]
Removes entries from an array.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
array | T [] | The array to modify. |
value | T | T [] | A single value or an array of values to remove. |
Returns
T
[]
The modified array.
Description
从数组中删除条目。
Defined in
src/modules/utils/utils.d.ts:182
repeat
▸ repeat(string_
, count
): string
Repeats a string.
Parameters
Name | Type | Description |
---|---|---|
string_ | string | - |
count | number | The number of times to repeat the string. |
Returns
string
The repeated string.
Description
重复一个字符串。
Defined in
src/modules/utils/utils.d.ts:78
replaceString
▸ replaceString(text
, search
, replace
): string
Repeatedly replaces a substring within a string. Like String.prototype.replace, but without any of the default special handling of $ sequences in the replace string.
Parameters
Name | Type | Description |
---|---|---|
text | string | The text to search and replace. |
search | string | RegExp | The substring to search for. |
replace | string | The replacement string. |
Returns
string
The modified string.
Description
反复替换字符串中的子字符串。类似于 String.prototype.replace,但不使用替换字符串中的 $ 序列的默认特殊处理。
Defined in
src/modules/utils/utils.d.ts:65
sign
▸ sign(x
): number
Returns the sign of a number.
Parameters
Name | Type | Description |
---|---|---|
x | number | The number to check. |
Returns
number
1 if the number is positive, -1 if it is negative, and 0 if it is zero or NaN.
Description
返回数字的符号。如果数字为正,则返回 1,如果数字为负,则返回 -1,如果数字为零或 NaN,则返回 0。
Defined in
src/modules/utils/utils.d.ts:543
slowInSlowOut
▸ slowInSlowOut(t
): number
A slow-in, slow-out easing function.
Parameters
Name | Type | Description |
---|---|---|
t | number | The time value, between 0 and 1. |
Returns
number
The eased value.
Description
缓入缓出的缓动函数。
Defined in
src/modules/utils/utils.d.ts:244
startsWith
▸ startsWith(string_
, search
): boolean
Checks if a string starts with another string.
Parameters
Name | Type | Description |
---|---|---|
string_ | string | - |
search | string | The string to search for. |
Returns
boolean
True if the string starts with the search string, false otherwise.
Description
检查字符串是否以另一个字符串开头。
Defined in
src/modules/utils/utils.d.ts:87
stringEndsWith
▸ stringEndsWith(string_
, ending
, position?
): boolean
Checks whether a string ends with a given substring.
Parameters
Name | Type | Description |
---|---|---|
string_ | string | - |
ending | string | The substring to check for. |
position? | number | The position to start checking from. |
Returns
boolean
True if the string ends with the substring, false otherwise.
Description
检查字符串是否以给定的子字符串结尾。
Defined in
src/modules/utils/utils.d.ts:553
stringify
▸ stringify(s
, rawUnicode?
): string
Turns a string into a legal JavaScript string.
Parameters
Name | Type | Description |
---|---|---|
s | string | The string to stringify. |
rawUnicode? | boolean | Whether to escape non-ASCII characters. |
Returns
string
The stringified string.
Description
将字符串转换为合法的 JavaScript 字符串。
Defined in
src/modules/utils/utils.d.ts:365
stringifyNumber
▸ stringifyNumber(number_
): string
Converts a number to a string.
Parameters
Name | Type |
---|---|
number_ | number |
Returns
string
The converted string.
Description
将数字转换为字符串。
Defined in
src/modules/utils/utils.d.ts:588
tagToCssSelector
▸ tagToCssSelector(tagName
): string
Converts a tag name to its fully escaped CSS selector equivalent.
Parameters
Name | Type | Description |
---|---|---|
tagName | string | The tag name to convert. |
Returns
string
The fully escaped CSS selector equivalent.
Description
将标签名称转换为其完全转义的 CSS 选择器等效项。
Defined in
src/modules/utils/utils.d.ts:535
terminalColour
▸ terminalColour(colour?
): string
Returns the terminal color code for a given color.
Parameters
Name | Type | Description |
---|---|---|
colour? | string | The color to get the code for. |
Returns
string
The terminal color code for the given color.
Description
返回给定颜色的终端颜色代码。
Defined in
src/modules/utils/utils.d.ts:31
timer
▸ timer(base?
): number
High resolution microsecond timer for profiling.
Parameters
Name | Type | Description |
---|---|---|
base? | number | The base time to subtract from the current time. |
Returns
number
The current time in microseconds.
Description
用于分析的高分辨率微秒计时器。
Defined in
src/modules/utils/utils.d.ts:513
toSentenceCase
▸ toSentenceCase(string_
): string
Converts a string to sentence case (i.e. capitalizes the first letter).
Parameters
Name | Type |
---|---|
string_ | string |
Returns
string
The converted string.
Description
将字符串转换为句子格式(即将第一个字母大写)。
Defined in
src/modules/utils/utils.d.ts:130
toTitleCase
▸ toTitleCase(string_
): string
Converts a string to title case (i.e. capitalizes each initial letter).
Parameters
Name | Type |
---|---|
string_ | string |
Returns
string
The converted string.
Description
将字符串转换为标题格式(即将每个单词的第一个字母大写)。
Defined in
src/modules/utils/utils.d.ts:138
trim
▸ trim(string_
): string
Trims whitespace from the start and end of a string.
Parameters
Name | Type |
---|---|
string_ | string |
Returns
string
The trimmed string.
Description
从字符串的开头和结尾修剪空格。
Defined in
src/modules/utils/utils.d.ts:104
trimPrefix
▸ trimPrefix(string_
, unwanted
): string
Trims a prefix from a string.
Parameters
Name | Type | Description |
---|---|---|
string_ | string | - |
unwanted | string | The prefix to remove. |
Returns
string
The trimmed string.
Description
从字符串中修剪前缀。
Defined in
src/modules/utils/utils.d.ts:113
trimSuffix
▸ trimSuffix(string_
, unwanted
): string
Trims a suffix from a string.
Parameters
Name | Type | Description |
---|---|---|
string_ | string | - |
unwanted | string | The suffix to remove. |
Returns
string
The trimmed string.
Description
从字符串中修剪后缀。
Defined in
src/modules/utils/utils.d.ts:122
unHyphenateCss
▸ unHyphenateCss(propertyName
): string
Converts a hyphenated CSS property name into a camel case one.
Parameters
Name | Type |
---|---|
propertyName | string |
Returns
string
The converted CSS property name.
Description
将连字符分隔的 CSS 属性名称转换为驼峰式。
Defined in
src/modules/utils/utils.d.ts:413
unescapeLineBreaks
▸ unescapeLineBreaks(s
): string
Unescapes line breaks.
Parameters
Name | Type | Description |
---|---|---|
s | string | The string to unescape. |
Returns
string
The unescaped string.
Description
取消转义换行符。
Defined in
src/modules/utils/utils.d.ts:348
warning
▸ warning(text
): void
Display a warning, in colour if we're on a terminal.
Parameters
Name | Type | Description |
---|---|---|
text | string | The text to display. |
Returns
void
Description
在终端上显示警告,如果在终端上则以颜色显示。