JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 623
  • Score
    100M100P100Q99451F
  • License MIT

Validates and formats ORCID numbers

Package Exports

  • orcid-utils

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (orcid-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ORCID Utils

Build Status

Library to manipulate ORCID identifiers. Allows validation of identifiers based on their check-digit, and to format a provided identifier into a number of potentially useful formats.

Designed to be used as either a require-able module, or as a standalone object that can be imported into a normal HTML page.

Node Installation

npm install orcid-utils --save

Example Node Usage

const ORCID = require('orcid-utils');
const orcidNumber = '0000-0000-0000-0001';

if (ORCID.isValid(orcidNumber)) {

    console.log(ORCID.toDashFormat(orcidNumber));
    // 0000-0000-0000-0001
    
    console.log(ORCID.toNoDashFormat(orcidNumber));
    // 0000000000000001
    
    console.log(ORCID.toUriWithoutProtocol(orcidNumber));
    // orcid.org/0000-0000-0000-0001
    
    console.log(ORCID.toUriWithProtocol(orcidNumber));
    // https://orcid.org/0000-0000-0000-0001
    
    // toUriWithProtocol also takes a boolean parameter that
    // specifies whether the URI should use https or not.
    
    console.log(ORCID.toUriWithProtocol(orcidNumber, true));
    // https://orcid.org/0000-0000-0000-0001    
    console.log(ORCID.toUriWithProtocol(orcidNumber, false));
    // http://orcid.org/0000-0000-0000-0001

}

Node Testing

Testing is performed using the nodetest package, and is aliased to the test script.

npm test

Example Browser Usage

<html>
<head>
<script src="src/orcid.js"></script>
</head>

<body>
<input type="text" id="orcidTextInput">
<input type="button" onClick="validateAndLog();">

    <script>
      var validateAndLog = function validateAndLog() {
        var orcidNumber = document.getElementById('orcidTextInput').value;

        if (ORCID.isValid(orcidNumber)) {
          console.log(ORCID.toDashFormat(orcidNumber));
          // 0000-0000-0000-0001
          
          // All the other examples from above work here too!
        } else {
          console.log('Not Valid');
        }

      };
    </script>

</body>
</html>

How to Contribution

Please do report any issues you have with this to the project's GitHub Issue Tracker.

If you wish to make any modifications or amendments, I'm happy to review pull requests :).