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

finnish-bank-utils

v1.3.3

Published

A micro Javascript library for validating, creating and formatting Finnish IBAN bank account numbers and reference numbers. Can parse payment details from Finnish virtual barcodes.

Downloads

2,068

Readme

Build Status 0 deps Downloads License

  • A micro Javascript library for validating, creating and formatting Finnish IBAN bank account numbers and reference numbers
  • Lightweight, 5.2kB
  • No dependencies
  • Vanilla JS (ES6) + Babel for browser compatibility

Installation

# NPM
npm install finnish-bank-utils

# Bower
bower install finnish-bank-utils
<!-- From unpkg.com -->
<script src="https://unpkg.com/finnish-bank-utils/finnish-bank-utils.min.js"></script>

Usage

Node.js

const FinnishBankUtils = require('finnish-bank-utils')
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')

Browser: Writes FinnishBankUtils into global namespace.

<script src="finnish-bank-utils.min.js"></script>
<script>
  FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
</script>

Examples

# Valid IBAN returns true, allows whitespace
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
FinnishBankUtils.isValidFinnishIBAN('FI 90 800026 2776 1348')
# Valid reference number returns true, allows whitespace
# !! Reference number type must be a string !!
FinnishBankUtils.isValidFinnishRefNumber('1511890656')
FinnishBankUtils.isValidFinnishRefNumber('15118 90656')

# Allow international format for local reference number
FinnishBankUtils.isValidFinnishRefNumber('RF34 1234 561')
# Valid IBAN returns formatted version, allows whitespace
FinnishBankUtils.formatFinnishIBAN('FI9080002627761348')
// 'FI90 8000 2627 7613 48'
# Valid reference number returns formatted version, allows whitespace
FinnishBankUtils.formatFinnishRefNumber('1511890656')
// '15118 90656'
FinnishBankUtils.formatFinnishRefNumber('RF341234561')
// 'RF34 1234 561'
# Format Finnish virtual bar code (virtuaaliviidakoodi, pankkiviivakoodi)
# Supports versions 4 and 5
FinnishBankUtils.formatFinnishVirtualBarCode({iban: 'FI58 1017 1000 0001 22', sum: 482.99, reference: '55958 22432 94671', date: '31.1.2012'})
// '458101710000001220004829900000000559582243294671120131'
FinnishBankUtils.formatFinnishVirtualBarCode({iban: 'FI02 5000 4640 0013 02', sum: 693.8, reference: 'RF61 6987 5672 0839', date: '24.7.2011'})
// '502500046400013020006938061000000000698756720839110724'
# Parse Finnish virtual bar code (virtuaaliviidakoodi, pankkiviivakoodi)
# Supports versions 4 and 5
FinnishBankUtils.parseFinnishVirtualBarCode('458101710000001220004829900000000559582243294671120131')
// {iban: 'FI58 1017 1000 0001 22', sum: 482.99, reference: '55958 22432 94671', date: '31.1.2012'}
FinnishBankUtils.parseFinnishVirtualBarCode('502500046400013020006938061000000000698756720839110724')
// {iban: 'FI02 5000 4640 0013 02', sum: 693.8, reference: 'RF61 6987 5672 0839', date: '24.7.2011'}
# Generate a Finnish reference number
FinnishBankUtils.generateFinnishRefNumber()
// '6173672848'

FinnishBankUtils.generateFinnishRefNumber('617367284')
// '6173672848'
# Generate a Finnish IBAN
FinnishBankUtils.generateFinnishRefIBAN()
// 'FI9080002627761348'

Functions

isValidFinnishRefNumber(referenceNumber) : string --> boolean
  • Validates parameter given reference number
isValidFinnishIBAN(ibanNumber) : string --> boolean
  • Validates parameter given Finnish IBAN number
formatFinnishRefNumber(referenceNumber) : string --> string
  • Formats parameter given reference number
formatFinnishIBAN(ibanNumber) : string --> string
  • Formats parameter given Finnish IBAN number
formatFinnishVirtualBarCode({iban : string, sum : number, reference : string, date : string}) : object --> string
  • Formats parameters to Finnish virtual bar code
parseFinnishVirtualBarCode(barCode) : string --> object
  • Parses parameter given Finnish virtual bar code
generateFinnishRefNumber(initial) : string|void --> string
  • Generates a (possibly random 10 char long) Finnish reference number.
generateFinnishIBAN() : void --> string
  • Generates a random Finnish IBAN number

Building

# Build a distributable, minified UMD library compatible with browsers and Node
npm run dist

# Run tests
npm run test

License

MIT License