<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans">
	<id>https://notblog.vudrux.site/wiki/%E7%94%A8%E6%88%B7:DGCK81LNN/cosmokit?action=history&amp;feed=atom</id>
	<title>用户:DGCK81LNN/cosmokit - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://notblog.vudrux.site/wiki/%E7%94%A8%E6%88%B7:DGCK81LNN/cosmokit?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://notblog.vudrux.site/wiki/%E7%94%A8%E6%88%B7:DGCK81LNN/cosmokit?action=history"/>
	<updated>2026-06-17T08:34:24Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://notblog.vudrux.site/index.php?title=%E7%94%A8%E6%88%B7:DGCK81LNN/cosmokit&amp;diff=3002&amp;oldid=prev</id>
		<title>2026年5月12日 (二) 15:39 DGCK81LNN</title>
		<link rel="alternate" type="text/html" href="https://notblog.vudrux.site/index.php?title=%E7%94%A8%E6%88%B7:DGCK81LNN/cosmokit&amp;diff=3002&amp;oldid=prev"/>
		<updated>2026-05-12T15:39:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月12日 (二) 23:39的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;第1行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第1行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{info|color=red|此文档由 AI 生成并人工修正表述，完整 API 以源码为准：&amp;lt;br/&amp;gt;https://github.com/shigma/cosmokit}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{info|color=red|此文档由 AI 生成并人工修正表述，完整 API 以源码为准：&amp;lt;br/&amp;gt;https://github.com/shigma/cosmokit}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{DISPLAYTITLE:Cosmokit 中文文档}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{DISPLAYTITLE:Cosmokit 中文文档}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Cosmokit 是主要由 Shigma 开发的一组灵活的 JavaScript/TypeScript 通用工具库，涵盖常用对象、数组、字符串、二进制和时间操作。&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Cosmokit 是主要由 Shigma 开发的一组灵活的 JavaScript/TypeScript 通用工具库，涵盖常用对象、数组、字符串、二进制和时间操作。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>DGCK81LNN</name></author>
	</entry>
	<entry>
		<id>https://notblog.vudrux.site/index.php?title=%E7%94%A8%E6%88%B7:DGCK81LNN/cosmokit&amp;diff=3001&amp;oldid=prev</id>
		<title>DGCK81LNN：​创建页面，内容为“{{info|color=red|此文档由 AI 生成并人工修正表述，完整 API 以源码为准：&lt;br/&gt;https://github.com/shigma/cosmokit}}  {{DISPLAYTITLE:Cosmokit 中文文档}}  Cosmokit 是主要由 Shigma 开发的一组灵活的 JavaScript/TypeScript 通用工具库，涵盖常用对象、数组、字符串、二进制和时间操作。  == 安装 == &lt;syntaxhighlight lang=&quot;shell&quot;&gt; npm install cosmokit # 或者 yarn add cosmokit &lt;/syntaxhighlight&gt;  &lt;syntaxhighli…”</title>
		<link rel="alternate" type="text/html" href="https://notblog.vudrux.site/index.php?title=%E7%94%A8%E6%88%B7:DGCK81LNN/cosmokit&amp;diff=3001&amp;oldid=prev"/>
		<updated>2026-05-12T15:38:12Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“{{info|color=red|此文档由 AI 生成并人工修正表述，完整 API 以源码为准：&amp;lt;br/&amp;gt;https://github.com/shigma/cosmokit}}  {{DISPLAYTITLE:Cosmokit 中文文档}}  Cosmokit 是主要由 Shigma 开发的一组灵活的 JavaScript/TypeScript 通用工具库，涵盖常用对象、数组、字符串、二进制和时间操作。  == 安装 == &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt; npm install cosmokit # 或者 yarn add cosmokit &amp;lt;/syntaxhighlight&amp;gt;  &amp;lt;syntaxhighli…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{info|color=red|此文档由 AI 生成并人工修正表述，完整 API 以源码为准：&amp;lt;br/&amp;gt;https://github.com/shigma/cosmokit}}&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:Cosmokit 中文文档}}&lt;br /&gt;
&lt;br /&gt;
Cosmokit 是主要由 Shigma 开发的一组灵活的 JavaScript/TypeScript 通用工具库，涵盖常用对象、数组、字符串、二进制和时间操作。&lt;br /&gt;
&lt;br /&gt;
== 安装 ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;&lt;br /&gt;
npm install cosmokit&lt;br /&gt;
# 或者&lt;br /&gt;
yarn add cosmokit&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
import { contain, camelCase, Time } from &amp;#039;cosmokit&amp;#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 数组工具 ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;contain(array1, array2)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;判断 array2 的所有元素是否都包含在 array1 内。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;intersection(array1, array2)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;计算两数组的交集。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;difference(array1, array2)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;计算两数组的差集。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;union(array1, array2)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;计算两数组的并集。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;deduplicate(array)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;数组去重。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;remove(list, item)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;从数组里移除某元素，返回是否成功。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;makeArray(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;将 null/undefined/单个值/数组标准化为数组。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
import { deduplicate, union } from &amp;#039;cosmokit&amp;#039;&lt;br /&gt;
deduplicate([1, 2, 2, 3]) // [1, 2, 3]&lt;br /&gt;
union([1, 2], [2, 3]) // [1, 2, 3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 对象通用工具 ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;noop()&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;空函数，什么都不做。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;isNullable(value)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;判断是否为 null/undefined/void。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;isNonNullable(value)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;判断是否不是 null/undefined/void。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;isPlainObject(data)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;判断是否为普通对象（非数组）。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;filterKeys(object, fn)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;对对象的键值进行筛选。回调函数接收键、值，保留结果为真的键值并组成新的对象。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;mapValues(object, fn)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;对对象的键值进行映射。回调函数接收值、键，返回新值并保留原键不变组成新的对象。&amp;lt;br/&amp;gt;别名：&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;valueMap&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;pick(source, keys, forced)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;从对象上选出指定的键，返回对应键值组成的新对象。&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;forced&amp;lt;/syntaxhighlight&amp;gt; 为真时不存在的键会被强制添加，值为 undefined。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;omit(source, keys)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;排除对象上指定的键，返回其余键值组成的新对象。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;defineProperty(object, key, value)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;在对象上定义不可枚举属性。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
import { isNullable, pick, omit } from &amp;#039;cosmokit&amp;#039;&lt;br /&gt;
pick({ a:1, b:2 }, [&amp;#039;a&amp;#039;]) // { a: 1 }&lt;br /&gt;
omit({ a:1, b:2 }, [&amp;#039;b&amp;#039;]) // { a: 1 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 类型与二进制数据工具 ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;is(type, value)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;判断变量是否为指定全局类型。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Binary.is(value)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;判断是否为 ArrayBuffer/SharedArrayBuffer。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Binary.isSource(value)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;判断是否为二进制源（(Shared)ArrayBuffer/ArrayBufferView）。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Binary.fromSource(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;获取二进制源的 ArrayBuffer。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Binary.toBase64(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;转 base64 字符串。&amp;lt;br/&amp;gt;全局别名：&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;arrayBufferToBase64&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Binary.fromBase64(str)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;base64 转 ArrayBuffer。&amp;lt;br/&amp;gt;全局别名：&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;base64ToArrayBuffer&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Binary.toHex(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;转十六进制字符串。&amp;lt;br/&amp;gt;全局别名：&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;arrayBufferToHex&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Binary.fromHex(str)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;十六进制转 ArrayBuffer。&amp;lt;br/&amp;gt;全局别名：&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;hexToArrayBuffer&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;clone(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;深拷贝对象，支持 Date。&lt;br /&gt;
&lt;br /&gt;
== 字符串工具 ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;camelCase(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;连字符/下划线转小驼峰。&amp;lt;br/&amp;gt;别名：&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;camelize&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;paramCase(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;转 param-case。&amp;lt;br/&amp;gt;别名：&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;hyphenate&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;snakeCase(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;转 snake_case。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;formatProperty(key)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;格式化属性键：输入字符串或 Symbol 键，输出 &amp;lt;code&amp;gt;.key&amp;lt;/code&amp;gt; 或 &amp;lt;code&amp;gt;[value]&amp;lt;/code&amp;gt; 格式的字符串。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;trimSlash(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;去除末尾斜杠。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;sanitize(source)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;开头保留斜杠，并去除末尾斜杠。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
import { camelCase, paramCase } from &amp;#039;cosmokit&amp;#039;&lt;br /&gt;
camelCase(&amp;#039;foo_bar&amp;#039;) // &amp;#039;fooBar&amp;#039;&lt;br /&gt;
paramCase(&amp;#039;fooBar&amp;#039;) // &amp;#039;foo-bar&amp;#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 时间工具 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time&amp;lt;/syntaxhighlight&amp;gt; 命名空间导出一系列时间相关常量与工具方法。&lt;br /&gt;
&lt;br /&gt;
* 毫秒单位的时间常量：&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.millisecond&amp;lt;/syntaxhighlight&amp;gt;、&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.second&amp;lt;/syntaxhighlight&amp;gt;、&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.minute&amp;lt;/syntaxhighlight&amp;gt;、&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.hour&amp;lt;/syntaxhighlight&amp;gt;、&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.day&amp;lt;/syntaxhighlight&amp;gt;、&amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.week&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.setTimezoneOffset(num)&amp;lt;/syntaxhighlight&amp;gt; / &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.getTimezoneOffset()&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;设置/获取默认时区偏移（本地时间转 UTC 时间需要加上的分钟数，与 &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Date.prototype.getTimezoneOffset()&amp;lt;/syntaxhighlight&amp;gt; 一致）。该默认值会被 Time.getDateNumber 和 Time.fromDateNumber 使用，初始为系统当前时区偏移。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.getDateNumber(date, offset)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;获取本地日期编号。date 为 Date 对象或毫秒时间戳。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.fromDateNumber(val, offset)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;日期编号转 Date 对象。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.parseTime(str)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;解析形如“1d2h5m3s”的时间字符串到毫秒数。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.parseDate(str)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;解析日期字符串到 Date 对象。除了 Date 原生支持的格式外还支持下列格式：&lt;br /&gt;
** 同 &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.parseTime(str)&amp;lt;/syntaxhighlight&amp;gt; 的格式，表示当前时间的指定间隔之后。&lt;br /&gt;
** &amp;lt;code&amp;gt;年-月-日-时:分:秒&amp;lt;/code&amp;gt;（分、秒可省略），可省略年、月、日（使用当前日期）或只省略年（使用当前年份）。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.format(ms)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;将毫秒数格式化为人类可读的大致值，如 3h。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.toDigits(num, length=2)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;数字左补零到指定长度。&lt;br /&gt;
* &amp;lt;syntaxhighlight inline lang=&amp;quot;javascript&amp;quot;&amp;gt;Time.template(template, time)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br/&amp;gt;格式化时间戳为指定模板字符串。模板字符串支持以下占位符：yyyy（四位年）、yy（两位年）、MM（两位月）、dd（两位日）、hh（两位小时）、mm（两位分钟）、ss（两位秒）、SSS（三位毫秒）。例如 &amp;lt;code&amp;gt;Time.template(&amp;#039;yyyy-MM-dd hh:mm:ss&amp;#039;, new Date())&amp;lt;/code&amp;gt;。time 必须为 Date 对象，默认取当前时间。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
import { Time } from &amp;#039;cosmokit&amp;#039;&lt;br /&gt;
Time.parseTime(&amp;#039;2h5m&amp;#039;) // 7500000&lt;br /&gt;
Time.format(60000) // &amp;#039;1m&amp;#039;&lt;br /&gt;
Time.template(&amp;quot;yyyy-MM-dd hh:mm:ss&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>DGCK81LNN</name></author>
	</entry>
</feed>