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

@croz/hrk2eur

v1.3.1

Published

Simple script that tracks HRK amounts on the page and switches them with EUR equivalent.

Downloads

1,302

Readme

HRK 2 EUR Converter

By joining the European Union in 2013 Croatia also accepted an obligation to adopt Euro as the official national currency replacing Kuna. The current national plan is to replace Kuna with Euro at midnight 01.01.2023.

A rough timetable is as follows:

  1. ~ 06.2022 fixed exchange rate at which conversion will be made is defined
  2. 01.07.2022 - 31.12.2022 - all documents (price lists etc.) should include values converted to EUR alongside HRK values
  3. 01.01.2023. - switchover of all currency to EUR
  4. 01.01.2023 - 31.12.2023 - all documents (price lists etc.) should include values converted to HRK alongside EUR values

The same is true for websites, shops and other web applications. Trying to find a simple solution to the challenge that many web admins and developers will have to resolve, CROZ's team came up with an idea and developed a software solution in line with this vision:

  • FOR web app and website owners and developers
  • WHO WILL, due to the Croatian transition from Croatian kuna to EUR, have to display all amounts in both currencies on their websites
  • OUR "Very Smart Currency Converter (smile)"
  • IS a simple JavaScript script
  • THAT automatically finds all amounts in HRK (and in the second phase of the transition in EUR) on web pages, calculate and display the counter-values in other currency.
  • INSTEAD OF going through the entire development cycle of existing web applications and pages
  • OUR PRODUCT IS easy to install, simple to configure, and it is capable to change the mode of operation depending on the legal deadlines without compromising the look & feel of the website.

Usage

This script can be used as an @croz/hrk2eur package npm or as a <script> tag from CDN.

To use it in your npm project, type npm install @croz/hrk2eur, and add

import {watchPrices} from @croz/hrk2eur

watchPrices();

to your main script.

For a CDN usage add the following snippet at the end of your html file:

<script src="https://unpkg.com/@croz/[email protected]/dist/umd/main.js"></script>
<script>hrk2eur.watchPrices()</script>

If you want to have EUR as a primary value, as it's recommended, use:

import {watchPrices} from @croz/hrk2eur

watchPrices({ isEurPrimary: true });

for npm or:

<script src="https://unpkg.com/@croz/[email protected]/dist/umd/main.js"></script>
<script>hrk2eur.watchPrices({ isEurPrimary: true })</script>

for CDN usage.

NEW

New feature in the script is conversion from EUR to HRK intended for usage after 1.1.2023. when EURO is introduced. You can set it manually, using convertEurToHrk flag, or set it to switch automatically with autoSwitchOnEurIntroduction. In this mode script uses eurPriceRegexList instead of priceRegexList. Note that in this mode script expects that your page is fully migrated to EUR currency, and serves only for showing informational purposes.

import {watchPrices} from @croz/hrk2eur

watchPrices({ autoSwitchOnEurIntroduction: true });

for npm or:

<script src="https://unpkg.com/@croz/[email protected]/dist/umd/main.js"></script>
<script>hrk2eur.watchPrices({ autoSwitchOnEurIntroduction: true })</script>

for CDN usage.

Options

isEurPrimary

Type: boolean

Default: false

Usage: Whether to show amount in EUR before amount in HRK. Relevant only if script is in HRK -> EUR mode

convertEurToHrk - NEW

Type: boolean

Default: false

Usage: Use it to switch conversion to EUR -> HRK manually

autoSwitchOnEurIntroduction - NEW

Type: boolean

Default: false

Usage: Used to make the script automatically switch from HRK -> EUR to EUR -> HRK on EURO introduction date.

textNodesToCheck

Type: Array

Default: ['span', 'b', 'p', 'strong', 'form', 'div', 'li', 'a', 'option']

Usage: List of strings representing which text only html tags to check.

otherNodesToCheck

Type: Array

Default: ['div', 'dd', 'td', 'ul', 'span', 'p', 's']

Usage: List of strings representing which container html tags to check.

eurFactor

Type: Number

Default: 7.53450

Usage: Middle rate of the HRK to EUR, used for calculating equivalent.

eurIntroductionDate

Type: Date

Default: 2023-01-01

Usage: Date of the introduction of EURO in Croatia. Available for changing for easier testing of autoSwitchOnEurIntroduction flag.

priceRegexList

Type: Array

Default:

[
    { regex: /((KN|kn|Kn|hrk|HRK)\s*([0-9.]+,[0-9]{2}))/, priceIndex: 3, decimalSeparator: ',', thousandSeparator: '.' },  // HRK 2.000,00
    { regex: /((KN|kn|Kn|hrk|HRK)\s*([0-9,]+\.[0-9]{2}))/, priceIndex: 3, decimalSeparator: '.', thousandSeparator: ',' }, // HRK 2,000.00
    { regex: /((KN|kn|Kn|hrk|HRK)\s*([0-9][0-9.]*))/, priceIndex: 3, thousandSeparator: '.' }, // HRK 1.000
    { regex: /((KN|kn|Kn|hrk|HRK)\s*([0-9][0-9,]*))/, priceIndex: 3, thousandSeparator: ',' }, // HRK 20,000
    { regex: /(([0-9.]+,[0-9]{2})\s*(KN|kn|Kn|hrk|HRK))/, priceIndex: 2, decimalSeparator: ',', thousandSeparator: '.' }, // 2.000,00 HRK
    { regex: /(([0-9,]+\.[0-9]{2})\s*(KN|kn|Kn|hrk|HRK))/, priceIndex: 2, decimalSeparator: '.', thousandSeparator: ',' }, // 2,000.00 HRK
    { regex: /(([0-9][0-9.]*)\s*(KN|kn|Kn|hrk|HRK))/, priceIndex: 2, thousandSeparator: '.' }, // 20.000 kn
    { regex: /(([0-9][0-9,]*)\s*(KN|kn|Kn|hrk|HRK))/, priceIndex: 2, thousandSeparator: ',' }, // 20,000 kn
]

Usage: List of objects which include regexes to check the prices for HRK -> EUR conversion.

Pass an array of objects, object options:

regex - regex for matching text, must include a group for currency and amount

priceIndex - index of the group for the amount

decimalSeparator - character used for decimal separation

thousandSeparator - character user for separating thousands

eurPriceRegexList

Type: Array

Default:

[
    { regex: /((€|EUR|Eur|eur)\s*([0-9.]+,[0-9]{2}))/, priceIndex: 3, decimalSeparator: ',', thousandSeparator: '.' },  // € 2.000,00
    { regex: /((€|EUR|Eur|eur)\s*([0-9,]+\.[0-9]{2}))/, priceIndex: 3, decimalSeparator: '.', thousandSeparator: ',' }, // € 2,000.00
    { regex: /((€|EUR|Eur|eur)\s*([0-9][0-9.]*))/, priceIndex: 3, thousandSeparator: '.' }, // € 1.000
    { regex: /((€|EUR|Eur|eur)\s*([0-9][0-9,]*))/, priceIndex: 3, thousandSeparator: ',' }, // € 20,000
    { regex: /(([-|+]?[0-9.]+,[0-9]{2})\s*(€|EUR|Eur|eur))/, priceIndex: 2, decimalSeparator: ',', thousandSeparator: '.' }, // 2.000,00 €
    { regex: /(([-|+]?[0-9,]+\.[0-9]{2})\s*(€|EUR|Eur|eur))/, priceIndex: 2, decimalSeparator: '.', thousandSeparator: ',' }, // 2,000.00 €
    { regex: /(([-|+]?[0-9][0-9.]*)\s*(€|EUR|Eur|eur))/, priceIndex: 2, thousandSeparator: '.' }, // 20.000 €
    { regex: /(([-|+]?[0-9][0-9,]*)\s*(€|EUR|Eur|eur))/, priceIndex: 2, thousandSeparator: ',' }, // 20,000 €
]

Usage: List of objects which include regexes to check the prices for EUR -> HRK conversion.

Logic is the same as priceRegexList. Ignored if eurPriceRegexList and autoSwitchOnEurIntroduction are false.

observerOptions

Type: Object

Default: { childList: true, subtree: true }

Usage: Object of options sent to the MutationObserver.