Files
Yep_Q 1564396449 feat: 完善会展策划演示系统
详细说明:
- 添加了V2版本的工作流页面和结果页面
- 更新了Serena记忆文件
- 添加了详细实施计划文档
- 优化了Vite配置
- 更新了项目文档CLAUDE.md
- 构建了演示系统的dist版本
- 包含了exhibition-demo的完整依赖
2025-09-08 11:15:23 +08:00

75 lines
1.6 KiB
JavaScript

/**
* @typedef Options
* Configuration for `stringify`.
* @property {boolean} [padLeft=true]
* Whether to pad a space before a token.
* @property {boolean} [padRight=false]
* Whether to pad a space after a token.
*/
/**
* @typedef {Options} StringifyOptions
* Please use `StringifyOptions` instead.
*/
/**
* Parse comma-separated tokens to an array.
*
* @param {string} value
* Comma-separated tokens.
* @returns {Array<string>}
* List of tokens.
*/
export function parse(value) {
/** @type {Array<string>} */
const tokens = []
const input = String(value || '')
let index = input.indexOf(',')
let start = 0
/** @type {boolean} */
let end = false
while (!end) {
if (index === -1) {
index = input.length
end = true
}
const token = input.slice(start, index).trim()
if (token || !end) {
tokens.push(token)
}
start = index + 1
index = input.indexOf(',', start)
}
return tokens
}
/**
* Serialize an array of strings or numbers to comma-separated tokens.
*
* @param {Array<string|number>} values
* List of tokens.
* @param {Options} [options]
* Configuration for `stringify` (optional).
* @returns {string}
* Comma-separated tokens.
*/
export function stringify(values, options) {
const settings = options || {}
// Ensure the last empty entry is seen.
const input = values[values.length - 1] === '' ? [...values, ''] : values
return input
.join(
(settings.padRight ? ' ' : '') +
',' +
(settings.padLeft === false ? '' : ' ')
)
.trim()
}