looks-like-number

1.0.7 • Public • Published

npm version Build Status Coverage Status

looks-like-number.js

General utility function to verify its argument looks like a number

Usage

var looksLikeNumb = require("looks-like-number")
var allowLeftRightSpaces = true;

looksLikeNumb(0) // true
looksLikeNumb('0') // true
looksLikeNumb('-1.2') // true
looksLikeNumb(Number.MAX_VALUE) // true
looksLikeNumb('1e15') // true
looksLikeNumb('1,5') // true

looksLikeNumb([]) // false
looksLikeNumb(new Date(1,1,2021)) // false
looksLikeNumb(undefined) // false
looksLikeNumb(null) // false
looksLikeNumb({a: '-9'}) // false
looksLikeNumb(/\d+/g) // false
looksLikeNumb(function(){ ... }) // false
looksLikeNumb(Symbol()) // false
looksLikeNumb('') // false

looksLikeNumb(' 44') // false
looksLikeNumb('15 ') // false
looksLikeNumb(' 5 ') // false
looksLikeNumb(' 44', allowLeftRightSpaces) // true
looksLikeNumb('15 ', allowLeftRightSpaces) // true
looksLikeNumb(' 5 ', allowLeftRightSpaces) // true
looksLikeNumb(' ', allowLeftRightSpaces) // false
looksLikeNumb(' 1 9 ', allowLeftRightSpaces) // false

Package Sidebar

Install

npm i looks-like-number

Weekly Downloads

2

Version

1.0.7

License

ISC

Unpacked Size

4.99 kB

Total Files

4

Last publish

Collaborators

  • kgkoutis