Options
All
  • Public
  • Public/Protected
  • All
Menu

scratchbook

Scratch Book is an annotation library written in Typescript that makes it easy to write documentation in a decentralized fashion

Index

factory Functions

Const compose

  • compose(separator: string): (parts: string[]) => string
  • Compose a key by joining string parts together using a separator. Example:

     compose('/')(['year', 'month'])
    

    Parameters

    • separator: string

    Returns (parts: string[]) => string

      • (parts: string[]): string
      • Parameters

        • parts: string[]

        Returns string

Const createScratchNote

  • createScratchNote(id: string, text: string, url?: string): ScratchNote
  • Create a scratch note Example:

     createScratchNote('year/month', '2021/07')
    

    Or with a link:

     createScratchNote('prog/language', 'TypeScript', 'https://en.wikipedia.org/wiki/TypeScript')
    

    Parameters

    • id: string
    • text: string
    • Optional url: string

    Returns ScratchNote

Const newScratchNote

  • newScratchNote(composer: IdComposer): (idParts: string[], text: string, url?: string) => ScratchNote
  • Create a scratch note using a composer Example:

     const slash = compose('/');
     newScratchNote(slash)(['year', 'month'], '2021/07');
    

    Or with a link:

     newScratchNote(slash)(['prog', 'language'], 'TypeScript', 'https://en.wikipedia.org/wiki/TypeScript')
    

    Parameters

    • composer: IdComposer

    Returns (idParts: string[], text: string, url?: string) => ScratchNote

      • (idParts: string[], text: string, url?: string): ScratchNote
      • Parameters

        • idParts: string[]
        • text: string
        • Optional url: string

        Returns ScratchNote

matcher Functions

Const and

  • and(matchers: IdMatcher[]): (id: string) => boolean
  • Logical AND on two or more matchers Example:

     const query = and([withPrefix('year'), withSuffix('day')]);
    

    Parameters

    • matchers: IdMatcher[]

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const not

  • not(matcher: IdMatcher): (id: string) => boolean
  • Logical NOT on a matcher Example:

     const query = not(withPrefix('fish'));
    

    Parameters

    • matcher: IdMatcher

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const or

  • or(matchers: IdMatcher[]): (id: string) => boolean
  • Logical OR on two or more matchers Example:

     const query = or([withPrefix('fish'), withPrefix('bird')]);
    

    Parameters

    • matchers: IdMatcher[]

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const withAnyExactly

  • withAnyExactly(textList: string[]): (id: string) => boolean
  • Matcher for an id that matches exactly at least one of several text fragments Example:

     const query = withAnyExactly(['year/month', 'year/week']);
    

    Parameters

    • textList: string[]

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const withAnyPrefix

  • withAnyPrefix(prefixList: string[]): (id: string) => boolean
  • Matcher for an id that starts with at least one of several prefixes Example:

     const query = withAnyPrefix(['year/month', 'year/week']);
    

    Parameters

    • prefixList: string[]

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const withAnySuffix

  • withAnySuffix(suffixList: string[]): (id: string) => boolean
  • Matcher for an id that ends with at least one of several suffixes Example:

     const query = withAnySuffix(['/available', '/cheap']);
    

    Parameters

    • suffixList: string[]

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const withAnyText

  • withAnyText(textList: string[]): (id: string) => boolean
  • Matcher for an id that includes at least one of several text fragments Example:

     const query = withAnyText(['_blue', '_red']);
    

    Parameters

    • textList: string[]

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const withExactly

  • withExactly(text: string): (id: string) => boolean
  • Matcher for an id that matches exactly a given text Example:

     const query = withExactly('year/month/day');
    

    Parameters

    • text: string

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const withPrefix

  • withPrefix(prefix: string): (id: string) => boolean
  • Matcher for an id that starts with a prefix Example:

     const query = withPrefix('year/month');
    

    Parameters

    • prefix: string

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const withSuffix

  • withSuffix(suffix: string): (id: string) => boolean
  • Matcher for an id that ends with a suffix Example:

     const query = withSuffix('/day');
    

    Parameters

    • suffix: string

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

Const withText

  • withText(text: string): (id: string) => boolean
  • Matcher for an id that includes a given text Example:

     const query = withText('_name');
    

    Parameters

    • text: string

    Returns (id: string) => boolean

      • (id: string): boolean
      • Parameters

        • id: string

        Returns boolean

transform Functions

Const filterScratchBook

  • Filter a scratch book based on a composable matcher Example:

     const query = and([withPrefix('year'), withSuffix('day')]);
     const specificScratchBook = filterScratchBook(query)(mainScratchBook)
    

    Parameters

    • matcher: IdMatcher

    Returns (scratchBook: ScratchBook) => ScratchBook

Const mergeScratchBooks

  • Merge several scratch books into one. The notes will be sorted by id and unique. Example:

     const globalScratchBook = mergeScratchBooks([fishScratchBook, birdScratchBook])
    

    Parameters

    Returns ScratchBook

Const sortScratchBook

  • Search the notes of by their id and remove duplicate notes. Two notes are a duplicate if all their fields (id, text, url) are the same. Example:

     const orderedScratchBook = sortScratchBook(messyScratchBook)
    

    Parameters

    Returns { notes: ScratchNote[] }

Generated using TypeDoc