0.2.0 • Published 4 months ago

@gplane/cue v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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

0.2.0

4 months ago

0.1.1

1 year ago

0.1.0

1 year ago