Skip to content

Fast.Utils 完整导出清单

以下模块不再只列举名称;每个模块均链接到逐方法文档,每个公开函数都包含实际调用示例、输入值、输入类型、输入说明、返回值、返回类型及返回说明。导出对象及返回函数的方法已并入各自所属模块。

模块逐方法文档
Array查看
Async查看
Base64查看
Color查看
Crypto查看
Date查看
DOM查看
Environment查看
Function查看
Identity查看
Logger查看
Number查看
Object查看
Storage查看
String查看
Vue查看

以下清单按 @fast-china/utils 2.1.8 根入口逐模块核对。全部成员均从包根具名导入,不存在公开模块子路径;类型成员使用 import type。具体合同见上表的逐方法文档及运行时契约

ts
import { chunk, sleep, encodeBase64, parseHexColor, addDays, addCssUnit, isBrowser, once, clamp, pick, Local, camelCase } from "@fast-china/utils";

const pages = chunk([1, 2, 3, 4], 2);
await sleep(20);
const encoded = encodeBase64("Fast");
const color = parseHexColor("#409eff");
const tomorrow = addDays(new Date(), 1);
const size = addCssUnit(24);
const browser = isBrowser();
const initialize = once(() => ({ ready: true }));
const progress = clamp(120, 0, 100);
const selected = pick({ id: 1, name: "Fast" }, ["id"] as const);
Local.set("profile", selected);
const className = camelCase("fast-element-plus");

Array

  • 类型:KeySelector
  • 函数:chunkremoveNullishValuesuniqueuniqueBygroupBypartitiondifferenceintersectionsymmetricDifferencehasDuplicatesByallEqualBy

Async

  • 类型:AbortOptionsTimeoutOptionsRetryContextRetryOptionsConcurrentMapOptionsDebouncedFunctionThrottledFunction
  • 函数:sleepwithTimeoutretrymapConcurrentdebouncethrottle

异步 API 保留原始失败原因;取消通过 AbortSignal 传播。debounce 返回的函数公开 cancelflushpendingthrottle 公开 cancelpending,不提供 flush

Base64

  • 类型:DecodedText
  • 函数:encodeBase64BytesdecodeBase64BytesencodeBase64decodeBase64encodeBase64UrlBytesdecodeBase64UrlBytesencodeBase64UrldecodeBase64UrlencodeLatin1Base64decodeLatin1Base64encodeSecureBase64decodeSecureBase64

DecodedText 可作为普通字符串使用;只有显式调用 .parseJson<T>() 才尝试解析 JSON。SecureBase64 是兼容编码,不是加密。

Color

  • 类型:RgbColorRgbaColor
  • 函数:parseHexColorformatHexColormixHexColorsmixHexColorWithBlackmixHexColorWithWhiterelativeLuminancecontrastRatiopickHigherContrastColor

Crypto

  • 类型:AesCipherModeAesPaddingModePemKeyPairEcNamedCurve
  • 随机与比较:GenerateRandomBytesFixedTimeEquals
  • 摘要:MD5EncryptSHA1EncryptSHA256BytesSHA256EncryptSHA384BytesSHA384EncryptSHA512BytesSHA512Encrypt
  • HMAC 与派生:HMACSHA256EncryptHMACSHA384EncryptHMACSHA512EncryptPBKDF2SHA256HashPasswordPBKDF2SHA256VerifyPasswordPBKDF2SHA256HKDFSHA256
  • AES:AESEncryptAESDecryptAESEncryptAuthenticatedAESDecryptAuthenticatedAESEncryptWithPasswordAESDecryptWithPassword
  • RSA:GenerateRSAKeyPairRSAEncryptOAEPRSADecryptOAEPRSASignPSSRSAVerifyPSS
  • EC:GenerateECDSAKeyPairECDSASignECDSAVerifyGenerateECDHKeyPairDeriveECDHSecretDeriveECDHKeySHA256
ts
import { AESDecryptWithPassword, AESEncryptWithPassword, HashPasswordPBKDF2SHA256, VerifyPasswordPBKDF2SHA256 } from "@fast-china/utils";

const payload = await AESEncryptWithPassword("message", "password");
const plaintext = await AESDecryptWithPassword(payload, "password");
const passwordHash = await HashPasswordPBKDF2SHA256("password");
const valid = await VerifyPasswordPBKDF2SHA256("password", passwordHash);

Date

  • 类型:DateInputRelativeTimeOptionsDateShortcutDateRangeShortcut
  • 函数:toDateisValidDatestartOfDayendOfDayaddDaysaddMonthsaddYearsisSameDayisFuturegetLocalDayBoundsisWithinIntervalformatRelativeTimeformatChineseRelativeTimecreateOneMonthRangeFromTodayisDateAfterNowgetLocalTimeGreetingcreateDateRangeShortcutscreateDateShortcutsgetStartOfToday

DOM

  • 类型:StyleValueStyleObjectStyleInput
  • 函数:addCssUnitserializeStyle

Environment

  • 类型:RuntimeKind
  • 函数:isBrowserisWebWorkerisNodeisUniApphasWebCryptodetectRuntimeisMobileUserAgentisTabletUserAgent

检测结果只描述当前能力或 User-Agent,不承诺目标平台支持全部库功能。

Function 与 Identity

  • Function:once
  • Identity 类型:InstallationIdentityConfigurationInstallationIdentity
  • Identity 值:configureInstallationIdentityinstallationIdentitygetOrCreateInstallationId

安装标识只标识当前存储空间中的安装实例,不是认证凭证、硬件标识或秘密。

Logger

  • 类型:LogLevelLoggerSinkLoggerOptionsLogger
  • 值:createLoggerconfigureLoggerlogger

Number

  • 类型:FormatBytesOptions
  • 函数:clampinRangeroundTosumaveragelerpformatBytesrandomInt

Object 与 Query

  • 类型:QueryPrimitiveQueryValueQueryStringOptions
  • 函数:isPlainObjecthasOwncloneDeepisEqualpickomitomitBypickBymapValuesshallowEqualtoQueryString

Storage

  • 类型:StorageCodecStorageConfigurationStorageReadOptionsStorageWriteOptionsStorageArea
  • 值:base64StorageCodecLocalSessionconfigureStorageisStorageConfigured

String

  • 类型:ParsedQueryParametersStringLocale
  • 函数:decodeURIComponentRepeatedlyparseQueryStringisValidJsonsplitWordsupperFirstlowerFirstcamelCasepascalCasekebabCasetruncateGraphemescopyrandomStringgenerateUuidV4isUuidV4escapeHtmlnormalizeWhitespace

Vue

  • 类型:AwaitableFunctionBreakpointsElementSizeEmitHandlersEventTargetSourceResizeObserverTargetUseBreakpointsReturnUseElementSizeReturnUseWindowSizeReturnVueInstallValueInstallableTSXWithInstallTypedSlotsTypedSlotsDeclaration
  • 函数:callOptionalFunctionuseBreakpointsuseElementSizeuseEmitsuseEventListeneruseExposeuseNowuseResizeObserveruseWindowSizedefinePropTypeusePropsuseRendermakeSlotswithDefineTypewithInstallwithNoopInstallwithInstallDirective
ts
import { definePropType, makeSlots, withInstall } from "@fast-china/utils";
import { defineComponent } from "vue";

const slots = makeSlots<{ default: () => unknown }>();
const valueType = definePropType<string>(String);
const component = withInstall(defineComponent({ name: "ExampleComponent", props: { value: valueType }, slots }));

Vue Helper 是组件库作者能力。普通业务应用通常只需要数据、异步、环境和 Storage API。