rdfjs/data-model-spec

Static Term property for duck typing?

Closed this issue · 3 comments

Libraries can choose to have API functions that accept RDFJS Terms as well as some other types of objects. For these cases, it may be useful to define a static property on Term to distinguish Term objects from others.

While testing for a truthy .termType might seem sufficient, it is arguably not semantically robust enough. Perhaps defining a static boolean .isRDFJSTerm property on Term would enable universal duck typing?

It's definitely good to have this discussion: the spec should define a test whether something is a Term.

I think that we can manage with existing properties though, such as indeed termType. (If termType doesn't do the trick, than the odds are that .isRDFJSTerm also won't do.)

@blake-regalia do you still see a need for something like .isRDFJSTerm you originally proposed?

This issue could relate to #137

Let's close it due to lack of activity, please just reopen if needed.