no-comma is a javascript library for dealing with inputted numbers that include commas

Overview

no-comma

no-comma is a javascript library for dealing with inputted numbers that include commas. Nocomma will allow you to check if the number contains commas, and remove them. You can also add commas.

Installation

npm i no-comma

Usage

const noComma = require('no-comma')

const isComma = noComma.isComma // check if input contains commas
const removeComma = noComma.removeComma // remove commas from string/number
const addComma = noComma.addComma // use commas to seperate number


const number = '5,000,000'
const noNumber = '5000000'


isComma(noNumber) // returns false
isComma(number) // returns true

removeComma(number) // returns 5000000
addComma(noNumber) // returns 5,000,000

Examples

const noComma = require('no-comma')

const isComma = noComma.isComma
const removeComma = noComma.removeComma
const addComma = noComma.addComma


// req.body.salary = 4,000,000

const salaryNoComma = removeComma(req.body.salary) // returns 4000000

//Adding the returned number with regular number
const salaryAdding = (salaryNoComma + 12) // returns 4000012

console.log(addComma(salaryAdding)) // returns 4,000,012

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

You might also like...

Use real-time computing technology and web technology to build a big data Kanban l to solve the problem. Among them, practical technologies include MySQL, Kafka, Flink, Redis, Flask and Echarts

Use real-time computing technology and web technology to build a big data Kanban l to solve the problem. Among them, practical technologies include MySQL, Kafka, Flink, Redis, Flask and Echarts

实时计算(English Version) 运用实时计算技术、Web 技术构建一个大数据看板来解决问题。其中实用技术包括Mysql、Kafka、Flink、Redis、Flask和Echarts 目录 1.问题需求 2.方案分析 3.安装环境 4.环境启动命令和运行代码的方法 5.代码目录结构说明

Jan 8, 2022

Trusted timestamps that you can physically include in photos, videos and live streams using QR codes and audible data signals.

Trusted timestamps that you can physically include in photos, videos and live streams using QR codes and audible data signals.

QR Date This is the reference implementation for the first version of QR Date, a signed timestamp inside a QR code that you can use to verify the date

Oct 5, 2022

Multi-chain sniper bot to buy and sell tokens on ETH compatible chains. Features include instant or mempool sniping, rug protection, and sell management.

Multi-chain sniper bot to buy and sell tokens on ETH compatible chains. Features include instant or mempool sniping, rug protection, and sell management.

An open-source defi sniper. defi-sniper is free to download. NEW Community telegram group: https://t.me/+aBLUmP1UnypiNTVh Premium Services Now Availab

May 3, 2022

An easy-to-use library to make your life easier when working with random numbers or random choices in javascript.

vrandom An easy-to-use library to make your life easier when working with random numbers or random choices in javascript. Table of contents Installati

Aug 16, 2022

front.phone is a Javascript library that identifies, validates and formats phone numbers.

front.phone front.phone is a Javascript library that identifies, validates and formats phone numbers. Demo The main goal of this project is to create

Oct 27, 2022

A small JavaScript library to generate YouTube-like ids from numbers.

A small JavaScript library to generate YouTube-like ids from numbers.

Hashids is small JavaScript library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user: htt

Dec 30, 2022

An unreliable and overall unusable sorting library for numbers with a global cache on the edge.

unsort An unreliable and overall unusable sorting library for numbers with a global cache on the edge. the algorithm This library implements a number

May 19, 2022

A jQuery-free general purpose library for building credit card forms, validating inputs and formatting numbers.

A jQuery-free general purpose library for building credit card forms, validating inputs and formatting numbers.

Dec 30, 2022

A JavaScript plugin for entering and validating international telephone numbers

A JavaScript plugin for entering and validating international telephone numbers

International Telephone Input A JavaScript plugin for entering and validating international telephone numbers. It adds a flag dropdown to any input, d

Dec 30, 2022
Owner
Fatty
Fatty
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A web app demonstrating how the Fourier series can be used to approximate user-inputted line drawing

Fourier Series Animation An interactive React web app that demonstrates how an arbitrary user-inputted line drawing can be approximated using the Four

Jason Wang 31 Dec 22, 2022
A simple javascript utility library to include partial html (iframe alternate) without a framework or jQuery.

alt-iframe A simple javascript utility library to include partial html (iframe alternate) without a framework or jQuery. <!doctype html> <html lang="e

FrontEndNeo 17 Dec 30, 2022
Replacement for comma.ai backend and useradmin dashboard

Replacement for comma.ai backend and useradmin dashboard. Bundled with a modified version of comma's cabana to allow viewing & analyzing drives.

null 15 Jan 1, 2023
A monorepo for comma.ai web interfaces and packages

comma webapps This mono-repository contains the web applications and packages for the web UIs of comma.ai Contributing Just pick something and work on

null 5 Sep 27, 2022
🦆 The repository for dealing with all the ducks created and managed by the Fairfield Programming Association.

Download Since the Fairfield Programming Association's duck generator is built on top of node.js and npm, you need to have both of those installed as

Fairfield Programming Association 15 Feb 4, 2022
A peroidic-table api built with Nodejs & Mongodb to help make frontend requests dealing with chemistry...

A peroidic-table api for frontend apps Usage Example (GET all elements) // GET /api/elements const ajio = require("ajio") ajio.baseUrl("https://apis-

John Daniels 3 May 24, 2022
Well-tested utility functions dealing with async iterables

aitertools This library provides a well-tested collection of small utility functions dealing with async iterables. You can think of it as LINQ or aite

Hong Minhee (洪 民憙) 11 Aug 15, 2022