Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend sink map to handle sink factory method #10

Closed
wants to merge 1 commit into from

Conversation

tpluscode
Copy link

@tpluscode tpluscode commented Apr 23, 2020

Extends the sink map to accept a Sink instance as well a lazy factory method so that dynamic importing is possible

// this is a breaking change, as the export is now an ES module
// in node would be
// const { SinkMap } = require('@rdfjs/sink-map')
import { SinkMap } from '@rdfjs/sink-map'

const parsers = new SinkMap()

parsers.set('application/ld+json', async () => {
  const JsonLdParser = await import('@rdfjs/parser-jsonld')
  return new JsonLdParser()
})

Above is how I populate the map in @rdfjs/formats-common

The parser module will only be loaded when sink.import('application/ld+json', stream) for the first time

@bergos bergos closed this Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants