Data and storage

Count numbers by type

normalizetype
See how many entries are mobile, fixed-line, toll-free, or invalid.
Try it
  • fixed_line2
  • invalid1
  • ip_phone1
  • mobile2
  • toll_free2
  • unified_number1

How it works

Counting by type shows the make-up of a contact list: for example, how many customers can receive SMS. Invalid entries are counted separately, so you can see how much needs cleaning.

In each language

import { normalize } from "@kurashina-design/japan-phone";

const numbers = [
  "090-1234-5678", "080-1000-0000", "03-5253-8111", "092-513-5612", "050-3818-1250",
  "0120-123-456", "0800-123-4567", "0570-123-456", "03-1234-5678",
];

const counts = {};
for (const input of numbers) {
  const type = normalize(input)?.type ?? "invalid";
  counts[type] = (counts[type] ?? 0) + 1;
}
for (const type of Object.keys(counts).sort()) console.log(type, counts[type]);

Output:

fixed_line 2
invalid 1
ip_phone 1
mobile 2
toll_free 2
unified_number 1