Closed RubenVerborgh closed 5 years ago
For consistency, we may also want add a similar method for converting Quad
objects.
I could make PR for DataFactory#clone()
(Term or Quad) clone((Term or Quad) other)
I think in this case we don't allow undefined
or null
@elf-pavlik I would propose creating separate methods for cloning terms and quads (cloneTerm
, cloneQuad
). Implementations may otherwise become too complicated for determining the argument type.
fromTerm/fromQuad?
👎 for .clone()
, as this could be interpreted as a clone function of the factory itself. It doesn't make sense now, but maybe in the future we have an additional spec (Prefix + CURIE support which turns the DataFactory into an environment) were having multiple instance of the DataFactory makes more sense.
I favor fromTerm
and fromQuad
a little bit over cloneTerm
and cloneQuad
. from*
indicates much stronger that new instances by the DataFactory are created and not that somehow the constructor of the given Term/Quad is used.
fromTerm
& fromQuad
SGTM, if no one else makes PR today/tomorrow I'll submit one on Wednesday
PR #158
Sorry I just noticed this, but I'm curious... Why not pass a plain object to the Term or Quad functions directly?
As I replied on https://gitter.im/rdfjs/public?at=5cb48398c55bd14d35ebcf88 single factory object makes it much easier to pass it around. Spec only defines methods on the factory and doesn't define any constructors for specific terms.
We want to consider adding a method to
DataFactory
that takes aTerm
-shaped object (from any library) as input, and outputs aTerm
(from the library of theDataFactory
) thatequals
it.This can be used to convert a
Term
from one RDF/JS implementation to another.