lodash APIs
- cloneDeep
- get
- isEqual
- isEmpty
- debounce
- merge
- uniq
- omit
- isString
- isArray
- pick
- sortBy
- groupBy
- flatten
- set
- find
- orderBy
- mapValues
- isObject
- last
- isNil
- isNumber
- range
- chunk
- throttle
- filter
- uniqBy
- difference
- pickBy
- noop
- capitalize
- uniqueId
- has
- isUndefined
- map
- camelCase
- isFunction
- kebabCase
- intersection
- random
- includes
- isPlainObject
- compact
- Dictionary
- findIndex
- keyBy
- forEach
- trim
- clamp
- identity
- remove
- keys
- isNull
- times
- startCase
- first
- values
- mapKeys
- sumBy
- max
- reduce
- some
- zip
- every
- memoize
- clone
- countBy
- concat
- snakeCase
- assign
- isBoolean
- uniqWith
- omitBy
- without
- minBy
- head
- maxBy
- min
- upperFirst
- escapeRegExp
- reverse
- sample
- shuffle
- defaults
- inRange
- flattenDeep
- take
- union
- sum
- mergeWith
- castArray
- replace
- flatMap
- reject
- zipObject
- template
- isNaN
- mean
- size
- findLast
- unset
- partition
- round
- fromPairs
- floor
- toPairs
- indexOf
- toString
- sampleSize
- differenceBy
- update
- chain
- startsWith
- xor
- pull
- DebouncedFunc
- defaultsDeep
- split
- findKey
- unescape
- partial
- toNumber
- invert
- each
- differenceWith
- endsWith
- slice
- isDate
- unionBy
- findLastIndex
- join
- isInteger
- delay
- isObjectLike
- padStart
- result
- isError
- extend
- cloneDeepWith
- upperCase
- trimStart
- constant
- matches
- lowerCase
- forIn
- lowerFirst
- once
- transform
- isMatch
- escape
- isEqualWith
- zipWith
- isRegExp
- entries
- sortedIndexBy
- dropWhile
- takeWhile
- isElement
- forEachRight
- ReplaceFunction
- TemplateExecutor
- keysIn
- IsEqualCustomizer
- isTypedArray
- cond
- stubTrue
- toUpper
- isMap
- isSet
- meanBy
- rangeRight
- repeat
- trimEnd
- now
- nth
- pullAt
- toPath
- eq
- lt
- lte
- gt
- gte
- pullAllBy
- pullAll
- toLower
- fill
- ceil
- flatMapDeep
- CloneDeepWithCustomizer
- negate
- takeRightWhile
- invoke
- tap
- intersectionWith
- truncate
- Collection
- bind
- curry
- partialRight
- sortedUniq
- sortedIndexOf
- Object
- drop
- _
Other Related APIs
lodash#ReplaceFunction TypeScript Examples
The following examples show how to use
lodash#ReplaceFunction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: documentation.ts From ui5-language-assistant with Apache License 2.0 | 5 votes |
function replace(
string: string,
matcher: RegExp,
replacement: string | ReplaceFunction
): string {
// @ts-expect-error - 'replace' is defined with 2 overloads instead of a union type in the definitions file
return string.replace(matcher, replacement);
}
Example #2
Source File: documentation.ts From ui5-language-assistant with Apache License 2.0 | 5 votes |
tagMatcherToReplacement: {
matcher: RegExp;
replacement: Record<ConvertTarget, string | ReplaceFunction>;
}[] = [
// Italics
{
matcher: /<i>(.+?)<\/i>/g,
replacement: { markdown: "*$1*", plaintext: "$1" },
},
// Bold
{
matcher: /<b>(.+?)<\/b>/g,
replacement: { markdown: "**$1**", plaintext: "$1" },
},
{
matcher: /<strong>(.+?)<\/strong>/g,
replacement: { markdown: "**$1**", plaintext: "$1" },
},
// Emphasis
{
matcher: /<em>(.+?)<\/em>/g,
replacement: { markdown: "***$1***", plaintext: "$1" },
},
// Headers
{
matcher: /<h1>(.+?)<\/h1>/g,
replacement: { markdown: "\n# $1\n\n", plaintext: "\n$1\n" },
},
{
matcher: /<h2>(.+?)<\/h2>/g,
replacement: { markdown: "\n## $1\n\n", plaintext: "\n$1\n" },
},
{
matcher: /<h3>(.+?)<\/h3>/g,
replacement: { markdown: "\n### $1\n\n", plaintext: "\n$1\n" },
},
{
matcher: /<h4>(.+?)<\/h4>/g,
replacement: { markdown: "\n#### $1\n\n", plaintext: "\n$1\n" },
},
// Lists
{
matcher: /<li>(.+?)<\/li>/g,
replacement: { markdown: "\n* $1", plaintext: "\n* $1" },
},
{ matcher: /<ul>/g, replacement: { markdown: "", plaintext: "" } },
{ matcher: /<\/ul>/g, replacement: { markdown: "\n\n", plaintext: "\n" } },
// TODO should we handle ordered lists (ol)?
// Code value
{
matcher: /<code>(.+?)<\/code>/g,
replacement: { markdown: "`$1`", plaintext: "$1" },
},
// Code block
{
matcher: /<pre>([^]+?)<\/pre>/g,
replacement: {
markdown: "\n```javascript\n$1```\n",
plaintext: "\n$1\n",
},
},
// Line break
{ matcher: /<br\/>/g, replacement: { markdown: "\n", plaintext: "\n" } },
{ matcher: /<br>/g, replacement: { markdown: "\n", plaintext: "\n" } },
{ matcher: /<\/br>/g, replacement: { markdown: "\n", plaintext: "\n" } },
// HTML Escaping, e.g. "<View" --> "<View"
// Note: this doesn't replace all html-encoded characters, only the most common ones
{
matcher: /.*/gm,
replacement: { markdown: unescape, plaintext: unescape },
},
]