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 🙏

© 2024 – Pkg Stats / Ryan Hefner

doi-utils-pmb

v0.1.0

Published

Validate and normalize a Digital Object Identifier (DOI).

Downloads

21

Readme

doi-utils-pmb

Validate and normalize a Digital Object Identifier (DOI).

Similar projects

Other projects I found that claim to be able to validate DOIs, normalize them, and format them as URI:

  • identifiers-doi: Readme says it's only for ancient node versions. Also its only interface (as of v0.2.1) is .extract(), no obvious way to validate and build a URI.
  • doi-utils: Seems rather battle-proven, has lots more tests, and can detect a much wider range of DOI-containing URIs.
    • Unfortunately, in versions ≥ 2.x, the author's ESM-only crusade got to levels where my eslint is no longer able to verify that the dependency can be resolved. So I tried using the latest CJS version, but its export is wrapped in a default property and eslint says I cannot use destructuring in import statements. Thus, effectively, I would need almost as much code just for importing his package (either as ESM or CJS) as I had needed for the crappy draft implementation I made before I went searching for a pre-existing module.

API

This module exports an object that holds these properties and methods:

.doiNsBaseUri

A string with the author's latest recommended prefix for constructing a URI from a bare DOI. Currently, in violation of the DOI handbook, it is: https://doi.org/

.whyNotBareDoi(input)

If input is a string with a bare DOI (10.xxx/xxx), return false. Otherwise, return an Error object describing a failed expectation.

.expectBareDoi(input)

If .whyNotBareDoi(input) has a complaint, throw it. Otherwise, return input.

.toBare(input)

Remove known namespace identifier prefixes from a DOI URI, and validate (.expectBareDoi) the remaining text.

.toUri(doi)

Convert any understood representation of a DOI to the recommended URI for that DOI.

Usage

see test/usage.mjs.

Known issues

  • Needs more/better tests and docs.

 

License

MIT