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

node-iso11649

v3.0.0

Published

ISO 11649:2009 creditor reference library for node

Downloads

4,379

Readme

node-iso11649

CircleCI Known Vulnerabilities

ISO 11649:2009 RF creditor reference library for node

  • No dependencies
  • 4 KB (1.2 KB gzipped)

Installation

with NPM

npm install node-iso11649 --save

with Yarn

yarn add node-iso11649

Usage

Generating RF creditor reference

RF creditor reference can be generated from existing reference.

Existing reference characteristics:

  • Contain only numbers 0-9 and/or characters A-Z (example AB2G5 => RF68AB2G5).
  • Max length 21 characters.
  • Not case sensitive (example aB2g5 => RF68AB2G5).
  • Can be string with spaces (example '12345 12345' => RF451234512345).
import { generate } from 'node-iso11649'

console.log(generate('12345 12345'))
// => RF451234512345

RF creditor reference can be generated also without existing reference. In that case epoch timestamp increased with random number and finnish checksum at the end is used.

NOTE: While this provides some level of randomness, uniqueness is not guaranteed. In production, it is best to use cryptographically secure random numbers at least as a part of the reference.

Example result:

import { generate } from 'node-iso11649'

console.log(generate())
// => RF4714508655422864

As creditor references are commonly displayed in groups of 4 characters you can use the optional pretty flag to format the returned value.

import { generate } from 'node-iso11649'

console.log(generate('12345 12345', {pretty: true}))
// => RF45 1234 5123 45

Validating RF creditor reference

Valid RF creditor reference characteristics:

  • Must start with characters RF.
  • Must contain two checksum numbers in indexes 3 and 4.
  • Reference part must follow rules described in 'Existing reference characteristics' section.
import { validate } from 'node-iso11649'

console.log(validate('RF4714508655422864'))
// => true
import { validate } from 'node-iso11649'

console.log(validate('RF00TEST'))
// => false

Parsing RF creditor reference

The reference part can be extracted from the RF creditor reference. This validates the entered RF creditor reference according to the 'Validating RF creditor reference'. It returns the reference string if valid and null if invalid.

import { parse } from 'node-iso11649'

console.log(parse('RF47 1450 8655 4228 64'))
// => 14508655422864
import { parse } from 'node-iso11649'

console.log(parse('RF00TEST'))
// => null

Tests

Run ESLint style checker.

npm run lint

Run unit tests

npm test