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

iban-constructor

v1.2.3

Published

library to generate iban

Downloads

8

Readme

Iban Constructor

Generates an IBAN from the country code, bank code and account code. It returns an object with two callback functions, success and error. The success callback is called if the iban-object was successfully created and has three attributes:

iban : The IBAN printed as an electronic text with no space iban_print : The IBAN printed with space on evry 4th character iban_format : The IBAN format based on formats-variable at top of iban.js

If the iban resulted in an error the error callback will be called with an object containing two attributes: type : Type of the error message : The message containing details of what failed

NB! If the bank code is null, the account number is the basis for collecting bank code

Installation

npm install iban-constructor --save

Usage

  var ibanConstructor = require('iban-constructor')
          bankHelpers = require('iban-constructor/lib/bankHelpers')
         generateIban = ibanConstructor.generate;

  var generatedIban = generateIban('FR', '30004', '00001', '00000000001')
    .success(function (iban) {

      console.log(iban);
      /*
      iban = {
        iban: "FR7630004000010000000000136",
        iban_print: "FR76 3000 4000 0100 0000 0000 136",
        iban_format:
        {
          country: 'France',
          code: 'FR',
          bank: [ [ 0, 'c' ], [ 5, 'n' ], [ 5, 'n' ] ],
          bank_code_format: '0  5n 5n',
          account: [ [ 0, 'c' ], [ 11, 'c' ], [ 2, 'n' ] ],
          account_format: '0  11   2n',
          bankLength: 10,
          accountLength: 13,
          totalLength: 27
        }
      };*/

        //...
    })
    .error(function (error) {
      // ...
    });

    // to see all availables banks see `iban-constructor/lib/bankCodes.csv`
    var BankExists = bankHelpers.bankExists('30004');
    var Bic = bankHelpers.findBicFromBankCode('30004');
    var Bank = bankHelpers.findBankCodeFromBic('BLICMCMCXXX');
    var BankCode = bankHelpers.generateBankCode();
    var BankCounter = bankHelpers.generateBankCounter();
    var Account = bankHelpers.generateAccount();

    try {
        var ValidIban = bankHelpers.generateIbanForBank('17515');
    } catch (e) {
        // error...
    }

    console.log('BankExists shoud be true', BankExists);
    console.log('Bic shoud be BNPAFRPPXXX', Bic);
    console.log('Bank shoud be 13488', Bank);
    console.log('BankCode shoud be a string', BankCode);
    console.log('BankCounter shoud be number', BankCounter);
    console.log('Account shoud be number', Account);
    console.log('CodeBank shoud be valid iban', ValidIban);

If you need to validate your iban you can use the iban npm module

var IBAN = require('iban');
IBAN.isValid('hello world'); // false
IBAN.isValid(ValidIban); // true

Tests

npm test

Release History

  • 1.2.0 Add country definition for helpers
  • 1.1.2 Add iban npm module reference in README and few cleaning
  • 1.1.1 Fix checksum forced with a length of 2
  • 1.1.0 Add BankHelpers
  • 1.0.4 Update Readme
  • 1.0.3 Rename
  • 1.0.2 Update doc
  • 1.0.1 Update doc
  • 1.0.0 Initial release

Todo

  • More tests