Excerpt type definition seems wrong #125

Open
opened 2021-06-08 21:53:10 +00:00 by wkirby · 1 comment
wkirby commented 2021-06-08 21:53:10 +00:00 (Migrated from github.com)

The type for excerpt is declared as:

type Input = string | Buffer

interface GrayMatterOption<
    I extends Input,
    O extends GrayMatterOption<I, O>
  > {
    parser?: () => void
    eval?: boolean
    excerpt?: boolean | ((input: I, options: O) => string)
    excerpt_separator?: string
    engines?: {
      [index: string]:
        | ((input: string) => object)
        | { parse: (input: string) => object; stringify?: (data: object) => string }
    }
    language?: string
    delimiters?: string | [string, string]
  }

But the example function usage in the README is:

function firstFourLines(file, options) {
  file.excerpt = file.content.split('\n').slice(0, 4).join(' ');
}

This example function does not take a string or a Buffer — it takes a GrayMatterFile and doesn't appear to return anything.

The type, I think, should be redeclared as:

excerpt?: boolean | ((file: GrayMatterFile, options: O) => void)
The type for `excerpt` is declared as: ``` type Input = string | Buffer interface GrayMatterOption< I extends Input, O extends GrayMatterOption<I, O> > { parser?: () => void eval?: boolean excerpt?: boolean | ((input: I, options: O) => string) excerpt_separator?: string engines?: { [index: string]: | ((input: string) => object) | { parse: (input: string) => object; stringify?: (data: object) => string } } language?: string delimiters?: string | [string, string] } ``` But the example function usage in the README is: ``` function firstFourLines(file, options) { file.excerpt = file.content.split('\n').slice(0, 4).join(' '); } ``` This example function does not take a string or a Buffer — it takes a `GrayMatterFile` and doesn't appear to return anything. The type, I think, should be redeclared as: ``` excerpt?: boolean | ((file: GrayMatterFile, options: O) => void) ```
doowb commented 2021-06-09 12:07:59 +00:00 (Migrated from github.com)

@wkirby thanks for the detailed issue. It looks like PR #111 fixes this.

I'll try merge this in and publish a fix this weekend.

@wkirby thanks for the detailed issue. It looks like PR #111 fixes this. I'll try merge this in and publish a fix this weekend.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rtlabs-llm-agents/gms-gray-matter#125
No description provided.