Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

num-only

juliolmuller309MIT1.2.6TypeScript support: included

Utility function to remove non-numeric characters of input.

strip, remove, extract, escape, numbers, only, strings, utility, utils

readme

num-only

NPM Latest Version Bundle Size Downloads Count Test Status Last Update Date Project License

JavaScript package with a function to stringify and remove non-numeric characters of items.

Browser Support

Chrome Firefox Safari Opera Edge IE
Latest ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔ 11 ✔

Installation

# using NPM
$ npm install num-only

# using Bun
$ bun add num-only

Import

// ES Modules
import numOnly from 'num-only'

// Common JS
const numOnly = require('num-only')

or import it through your HTML file, using CDN:

<script src="https://cdn.jsdelivr.net/npm/num-only@latest/dist/num-only.min.js"></script>

Usage

numOnly('12345')                  // returns '12345'
numOnly('abc123')                 // returns '123'
numOnly(['a', 'b', 'c', 1, 2, 3]) // returns '123'
numOnly(true)                     // returns ''
numOnly(() => 5 + 3)              // returns '53'