Other modules
In addition to providing many custom elements, DuoyunUI has some basic class with certain features, also includes some common modules that are somewhat being used in custom elements of DuoyunUI, some of which are independent.
Color
Color space conversion; brightness, contrast calculation.
| Name | Description |
|---|---|
rgbToRgbColor |
|
rgbToHslColor |
|
rgbToHexColor |
|
randomColor |
|
parseHexColor |
|
luminance |
Note: ignore alpha |
contrast |
Note: ignore alpha |
rgbToHsl |
Note: ignore alpha |
hslToRgb |
|
rgbToHsv |
|
hsvToRgb |
|
hslToHsv |
|
hsvToHsl |
Encode
hash, base64 etc encode/decode.
| Name | Description |
|---|---|
b64ToUtf8 |
|
base64ToArrayBuffer |
|
utf8ToB64 |
Converted string to Base64, isSafe indicates URL safe |
arrayBufferToBase64 |
|
hash |
Must be async |
fnv1a |
Simple hash, output int |
HotKeys
Lightweight version of hotkeys.
| Name | Description |
|---|---|
normalizeKey |
|
getDisplayKey |
Get the platform button |
setKeys |
Custom key map |
matchHotKey |
Detect whether the current keyboard event matches the specified button |
unlock |
Release the lock state of the continuous button, see hotkeys |
hotkeys |
Must have non-control character; Not case sensitive; Support a-b, press a, hotkeys be locked, wait next keydown event, allow call unlock |
Image
Compressed image; generate SVG.
| Name | Description |
|---|---|
createCanvas |
|
createDataURLFromSVG |
|
createSVGFromText |
Create SVG according to the text |
createBitmapFromSvg |
|
createDataURLFromBlob |
|
compressionImage |
Compression HTMLImageElement/File to DataURL/File |
Number
Format numbers, range adjustments.
| Name | Description |
|---|---|
splitInt |
Use a comma to separate numbers |
formatNumber |
Format number, generator object Need to be combined as a strings on after |
formatBandwidth |
|
formatTraffic |
|
formatDecimal |
|
formatCurrency |
|
formatPercentage |
|
formatToPrecision |
|
clamp |
Similar CSS clamp |
middle |
|
adjustRange |
Calculate the friendly range based on the maximum and minimum value, e.g: [0, 100], [0,500] |
pseudoRandom |
Generate a pseudo -random function |
normalizeNumber |
Random large integer normalization, output 0-1 |
Time
Lightweight version of the date time process library.
| Name | Description |
|---|---|
parseDate |
Parse Date/number to object |
parseNarrowTimeRange |
|
parseNarrowRelativeTime |
|
Time |
Provide some convenient operation methods for Date/Time |
parseDuration |
Parse timestamp to Duration object |
parseDurationToParts |
|
formatDuration |
Timer
Some timer functions.
| Name | Description |
|---|---|
forever |
Until the callback function resolve |
polling |
Polling calls until cancel |
sleep |
|
nextFrame |
|
throttle |
|
debounce |
|
invoke |
Invoke the function by condition |
once |
Only invoke first |
omitOnce |
Ignore the first invoke |
Utils
Some common functions.
| Name | Description |
|---|---|
convertToMap |
Similar lodash.keyBy |
getCascaderDeep |
Get Cascader/Tree max deep |
getCascaderBubbleWeakMap |
Get the value from the bottom layer, compare the new value of the upper layer to choose a new value, bubbling to the top layer |
proxyObject |
Simple proxy object, use prop name as a fallback when reading prop |
readProp |
Deep read prop |
OrderlyPromisePool |
Only let the last add Promise take effect, don’t care about the order of Resolve |
comparer |
Serialize comparer |
getStringFromTemplate |
Serialized TemplateResult return text content |
splitString |
Segmentation search word |
isIncludesString |
Search |
createCacheStore |
Create auto cache(localStorage) Store |
isRemoteIcon |
|
DyPromise |
Pass additional fields not support async function |
Other
animations: Use Web Animations API implement simple animationcache: Provide a simple LRU cacheicons: Build-in icons,see locale: Switch, modify the language,see styles: Some styles that can be shared globallytheme: Build-in theme,see types: Convenient TypeScript type infer help function
