npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

is-quad

v1.1.0

Published

Checks if a BaseQuad is a valid RDF Quad

Readme

is-quad

This package is used to check if an rdf-js compliant BaseQuad is a valid Quad type.

GitHub license npm version build Dependabot semantic-release

Usage

Checking a BaseQuad is a Quad

import isQuad from 'is-quad';
import { namedNode, blankNode } from '@rdfjs/data-model';
import type { BaseQuad } from '@rdfjs/types';

const goodQuad = quad(namedNode('s'), namedNode('p'), namedNode('o'));
const badQuad = quad<BaseQuad>(namedNode('s'), blankNode('p'), namedNode('o'));

isQuad(goodQuad); // true
isQuad(badQuad);  // false

Safely casting a BaseQuad as a Quad

import isQuad from 'is-quad';
import { namedNode, blankNode } from '@rdfjs/data-model';
import type { BaseQuad } from '@rdfjs/types';

const goodQuad = quad(namedNode('s'), namedNode('p'), namedNode('o'));
const badQuad = quad<BaseQuad>(namedNode('s'), blankNode('p'), namedNode('o'));

isQuad(goodQuad); // true
isQuad(badQuad);  // false

const quad: Quad = asQuad(goodQuad);
asQuad(badQuad) // Error is thrown

Additional APIs

This package also includes functions to check whether a Term is a valid Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph or Quad - and likewise cast from terms to these tpyes

import {
  termIsQuad, isGraph, isQuadSubject, isQuadPredicate, isQuadObject,
  termAsQuad, asGraph, asQuadSubject, asQuadPredicate, asQuadObject,
} from 'is-quad';
import { namedNode, blankNode, defaultGraph } from '@rdfjs/data-model';

const goodQuad = quad(namedNode('s'), namedNode('p'), namedNode('o'));
const badQuad = quad<BaseQuad>(namedNode('s'), blankNode('p'), namedNode('o'));

termIsQuad(goodQuad); // true
termIsQuad(namedNode('s')); // false
termIsQuad(badQuad); // false

termAsQuad(goodQuad); // goodQuad: Quad
termAsQuad(namedNode('s')); // Error
termAsQuad(badQuad); // Error


isGraph(namedNode('s')) // true
isGraph(defaultGraph()) // true
isGraph(goodQuad) // false
isGraph(badQuad) // false
isGraph(literal('s')) // false

asGraph(namedNode('s')) // namedNode('s'): Quad_Graph
asGraph(defaultGraph()) // defaultGraph(): Quad_Graph
asGraph(goodQuad) // Error
asGraph(badQuad) // Error
asGraph(literal('s')) // Error


isQuadSubject(goodQuad); // true
isQuadSubject(namedNode('s')); // true
isQuadSubject(badQuad); // false
isQuadSubject(literal('s')); // false

asQuadSubject(goodQuad); // goodQuad: Quad_Subject
asQuadSubject(namedNode('s')); // namedNode('s'): Quad_Subject
asQuadSubject(badQuad); // Error
asQuadSubject(literal('s')); // Error


isQuadPredicate(goodQuad); // false
isQuadPredicate(namedNode('p')); // true
isQuadPredicate(badQuad); // false
isQuadSubject(literal('p')); // false

asQuadPredicate(goodQuad); // Error
asQuadPredicate(namedNode('p')); // namedNode('p'): Quad_Predicate
asQuadPredicate(badQuad); // Error
asQuadSubject(literal('p')); // Error


isQuadObject(goodQuad); // true
isQuadObject(namedNode('o')); // true
isQuadObject(badQuad); // false
isQuadSubject(literal('o')); // true

asQuadObject(goodQuad); // goodQuad: Quad_Object
asQuadObject(namedNode('o')); // namedNode('o'): Quad_Object
asQuadObject(badQuad); // Error
asQuadSubject(literal('o')); // literal('o'): Quad_Object

License

©2021–present Jesse Wright, MIT License.