JSPM

round-price

1.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q18324F
    • License MIT

    Utility functions for applying custom rounding rules to prices, where decimal parts are rounded to either .5 or the next whole number.

    Package Exports

    • round-price
    • round-price/src/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (round-price) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    round-price

    🔢 Egyszerű, de szabály-alapú kerekítési segédfüggvények árakhoz.
    Támogatja a speciális logikát, ahol .5-re vagy egészre történik a kerekítés az ár tört része alapján.

    ✨ Funkciók

    • roundPrice(price) – alkalmazza a szabályokat, és visszaadja a kerekített értéket.
    • shouldRound(price) – logikailag eldönti, hogy adott árra szükséges-e kerekítés.

    📦 Telepítés

    Publikus NPM-ről:

    npm install round-price

    Lokálisan (ha saját repo vagy fájlrendszerből):

    npm install ../round-price

    ✅ Használat

    const { roundPrice, shouldRound } = require('round-price');
    
    const price = 12.3;
    
    if (shouldRound(price)) {
      const rounded = roundPrice(price);
      console.log(`Kerekített ár: ${rounded}`); // 12.5
    }

    🔍 Kerekítési szabály

    1. Ha az ár egész szám vagy .5-re végződik → nem történik módosítás.
    2. Ha a tört rész 0 < x < 0.5.5-re kerekít.
    3. Ha a tört rész x > 0.5 → felfelé egész számra kerekít.
    4. Negatív számokra a fenti logika tükörképe alkalmazandó.

    Példák:

    Bemenet Eredmény
    12 12
    12.3 12.5
    12.99 13
    12.5 12.5
    -4.2 -4.5
    -4.8 -5

    🧪 Tesztelés

    Ha fejlesztőként használod, a csomaghoz tartozik Jest-alapú tesztelés is:

    npm install
    npm test

    📝 Licenc

    MIT © 2025