<commit_before># ORCID Utils


[![Build Status](https://travis-ci.org/alexswilliams/orcid-utils.svg?branch=master)](https://travis-ci.org/alexswilliams/orcid-utils)

Library to manipulate [ORCID](https://orcid.org/) 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

```javascript
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
<html>
<head>
<script src="lib/orcid.min.js"></script>
</head>

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

    <script><commit_msg>Update readme to reflect Jest usage<commit_after># ORCID Utils


[![Build Status](https://travis-ci.org/alexswilliams/orcid-utils.svg?branch=master)](https://travis-ci.org/alexswilliams/orcid-utils)

Library to manipulate [ORCID](https://orcid.org/) 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

```javascript
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 `jest` package, and is aliased
to the `test` script.

`npm test`

## Example Browser Usage

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

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

    <script>
{'fraction_non_alphanumeric': 0.1323943661971831, 'fraction_numerical': 0.06309859154929577, 'mean_word_length': 3.918282548476454, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '272441', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1164, 'n_words': 278}