Skip to content

k.utils

KScript Toolset: Helper API by submodule

Overview

k.utils aggregates commonly used tool methods and sub-objects in site scripts. Except for the root methods listed below, each submodule has its own documentation page.

Root Methods

methodillustrate
sleep(ms)Blocks the current thread for specified milliseconds
bytesToString(bytes, encoding)Convert byte array to string according to encoding
stringToBytes(content, encoding)Convert string to byte array according to encoding
ParameterTypeRequiredDescription
msnumberYesSleep duration in milliseconds
bytesnumber[]YesByte array to convert
contentstringYesText to convert
encodingstringYesCharacter encoding, such as utf-8
MethodReturn
sleep(ms)void
bytesToString(bytes, encoding)string
stringToBytes(content, encoding)number[]
ts
k.utils.sleep(100)

Encoding conversion is useful when you work with downloaded files, ZIP entries, or text stored as bytes:

ts
const bytes = k.utils.stringToBytes("Hello Kooboo", "utf-8")
k.file.writeBinary("exports/hello.txt", bytes)

const saved = k.file.readBinary("exports/hello.txt")
const text = k.utils.bytesToString(saved, "utf-8")

return { text }

Submodules

submoduledocument
CDNcdn
clientJSclientJS
communitycommunity
compressioncompression
converterconverter
CRMcrm
datedate
domdom
imageimage
inlineHtmlinlineHtml
mimemime
ninjibleninjible
officeoffice
puppeteerpuppeteer
screenShotscreenShot
sitemapsitemap
smssms
stringstring
templatetemplate
uriuri
xmlxml
  • k.net — IP, Ping, SSH, SFTP, and Telnet
  • k.google — PageSpeed/Lighthouse and Firebase
  • k.file — site file reading and writing