Skip to content

import signature (in practice) incompatible with Sink #67

Description

@RubenVerborgh

The Dataset signature is

Promise<Dataset> import (Stream stream);

In contrast, the Sink signature is

EventEmitter import (Stream stream);

which makes it hard for objects to implement both cleanly.

In theory, we could return Promise<Dataset> & EventEmitter or even be fancy and do Promise<Dataset & EventEmitter> & EventEmitter for full .then compatibility, but this gets messy.

Any chance we could either rename this method or change its return type?

Activity

  1. bergos commented on Mar 29, 2022

    @bergos
    Member

    It would be the same for the match method. I don't think it makes sense to prefix or postfix the methods to distinguish them. The stream and dataset interfaces are for different use cases. The import method of the Dataset is the only method that consumes a Stream and creates a bridge between both worlds. As the Stream is just consumed, using the Dataset interface doesn't require deeper knowledge about the Stream interface. The name import is the best match for this use case. For the rare case where you want to have both interfaces, it's probably better to use different objects for each interface. Like this:

    const dataset = factory.dataset()
    const store = new DatasetStore(dataset) 
    
    // store.dataset implements the Dataset interface
    await store.dataset.import(quadStream)
    
    // store implements the Store interface
    store.match().on('data', quad => console.log(quad))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions