# prefix-ns

> Easy access to prefixes and namespaces of prefix.cc.

Latest version **1.1.0** (published 2025-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install prefix-ns
pnpm add prefix-ns
yarn add prefix-ns
bun add prefix-ns
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2025-06-25 |
| First published | 2017-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 185.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 0 |
| Author | Pieter Heyvaert |
| Maintainers | pheyvaer |
| Keywords | prefix, namespace, mapping, prefix.cc |

## Links

- npm: https://www.npmjs.com/package/prefix-ns
- Repository: https://github.com/pheyvaer/prefix-ns
- Homepage: https://github.com/pheyvaer/prefix-ns#readme
- Issues: https://github.com/pheyvaer/prefix-ns/issues
- npm.io page: https://npm.io/package/prefix-ns

## Dependencies (1)

- [fs-extra](https://npm.io/package/fs-extra.md) ^11.3.0

## Recent versions

- 1.1.0 (latest) — 2025-06-25
- 1.0.0 — 2025-06-25
- 0.1.2 — 2017-04-27
- 0.1.1 — 2017-04-18
- 0.1.0 — 2017-04-18
- 0.0.1 — 2017-04-18

## README

# prefix-ns

This npm module gives easy access to the prefixes and namespaces of [prefix.cc](https://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

```$JavaScript
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

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

## License
MIT

---
_Source: https://npm.io/package/prefix-ns · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
