@gplane/cue

中文文档
0.2.0发布于 2024/01/14MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 25.4万

Library for processing Cue Sheet.

原始使用文档
文档目录5 节
  1. Usage
  2. Parsing
  3. Dumping
  4. References
  5. License

cue

Library for processing Cue Sheet, with tolerant parser.

Usage

Parsing

import { parse } from '@gplane/cue'

const { sheet, errors } = parse('')

You can get parsed Cue Sheet via sheet.

By default, parser is tolerant for syntax. If there're syntax errors, you can get errors via errors, while you still can get parsed result in sheet.

fatal option

Error will be thrown instead of being collected in errors if fatal option is set to true.

import { parse } from '@gplane/cue'

const { sheet, errors } = parse('', { fatal: true })

checkAtLeastOneTrack option

It will require at least one track in the sheet if checkAtLeastOneTrack option is set to true.

import { parse } from '@gplane/cue'

const { sheet, errors } = parse('', { checkAtLeastOneTrack: true })

strictFileCommandPosition option

Position of FILE command will be checked if strictFileCommandPosition option is set to true.

import { parse } from '@gplane/cue'

const { sheet, errors } = parse('', { strictFileCommandPosition: true })

strictPerformerLength option

Performer string with more that 80 characters will be treated as an error if strictPerformerLength option is set to true.

import { parse } from '@gplane/cue'

const { sheet, errors } = parse('', { strictPerformerLength: true })

strictSongWriterLength option

Song writer string with more that 80 characters will be treated as an error if strictSongWriterLength option is set to true.

import { parse } from '@gplane/cue'

const { sheet, errors } = parse('', { strictSongWriterLength: true })

strictTitleLength option

Title string with more that 80 characters will be treated as an error if strictTitleLength option is set to true.

import { parse } from '@gplane/cue'

const { sheet, errors } = parse('', { strictTitleLength: true })

Dumping

import { dump } from '@gplane/cue'

const sheet = {
  /* ... */
}
const text = dump(sheet)

You can pass Cue Sheet object (for example, the sheet value returned from parse function) to it.

There're some limitations:

  • Dumping comments by using REM command is not supported.
  • It won't validate the Cue Sheet. For example, if file name of FILE command is an empty string, it will still be dumped without checking.

lineBreak option

Only '\n' or '\r\n' is allowed. Default value is '\n'.

import { dump } from '@gplane/cue'

const sheet = {
  /* ... */
}
const text = dump(sheet, { lineBreak: '\r\n' })

indentKind option

Only '\t' or ' ' is allowed. Default value is ' '.

import { dump } from '@gplane/cue'

const sheet = {
  /* ... */
}
const text = dump(sheet, { indentKind: '\t' })
// or
const text = dump(sheet, { indentKind: ' ' })

indentSize option

Only positive integer is allowed. Default value is 2.

import { dump } from '@gplane/cue'

const sheet = {
  /* ... */
}
const text = dump(sheet, { indentSize: 4 })

References

License

MIT License

Copyright (c) 2021-present Pig Fang

版本与发布记录

@gplane/cue 共发布 3 个版本,首次发布于 2023/04/01;过去 12 个月发布了 0 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.0latest2024/01/142 年前
0.1.12023/04/243 年前
0.1.02023/04/013 年前

关于 @gplane/cue 的常见问题

@gplane/cue 是什么?

Library for processing Cue Sheet.

如何安装 @gplane/cue?

在项目目录运行 npm install @gplane/cue,或使用 pnpm add / yarn add / bun add。

@gplane/cue 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gplane/cue 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@gplane/cue 可以商用吗?

@gplane/cue 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gplane/cue 的下载量有多少?

根据 npm 官方下载统计,@gplane/cue 在 2026/10/17 – 2026/11/15 这 30 天内被下载 254,279 次,日均约 8,476 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gplane/cue 还在维护吗?

最新版本 0.2.0 发布于 2024/01/14(2 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/04/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。