Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

prefix-ns

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prefix-ns

Easy access to prefixes and namespaces of prefix.cc.

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
1.2K
144.67%
Maintainers
1
Weekly downloads
 
Created
Source

prefix-ns

This npm module gives easy access to the prefixes and namespaces of prefix.cc. Upon installation of this module, the latest dump is downloaded from prefix.cc and stored locally. The dump is only updated when the module is re-installed. A default dump (data.json) is available if the download of the dump fails.

Usage

import * as prefixns from 'prefix-ns';

//The following method returns an array of all prefixes.
const allPrefixes = prefixns.getPrefixes();
console.log(allPrefixes);

// --> ['rdf', 'foaf', ...]

//The following method returns the namespace of a given prefix.
//null is returned when the prefix is not found.
const namespace = prefixns.getNamespaceViaPrefix('foaf');
console.log(namespace);

// --> http://xmlns.com/foaf/0.1/

//The following method returns the prefix of a given namespace.
//null is returned when the namespace is not found.
const prefix = prefixns.getPrefixViaNamespace('http://xmlns.com/foaf/0.1/');
console.log(prefix);

// --> foaf

//The following method returns a map where the prefixes are the keys and the namesapces are the values.
const map = prefixns.asMap();
console.log(map.foaf);

// --> http://xmlns.com/foaf/0.1/

If you want to use require, you do

const prefixns = require('prefix-ns/index.cjs');

License

MIT

Keywords

prefix

FAQs

Package last updated on 25 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts