Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

input-number

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

input-number - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

.eslintrc.json

21

index.js
/**
* @module input-number
*/
'use strict'

@@ -14,5 +15,5 @@ const caret = require('caret-position2');

module.exports = numerify;
module.exports = inputNumber;
function numerify (input, opts) {
function inputNumber (input, opts) {
opts = opts || {};

@@ -26,3 +27,6 @@ opts.step = opts.step || ((opts.min && opts.max) ? (opts.max - opts.min / 100) : 1);

input.addEventListener('keydown', e => {
input.removeEventListener('keydown', input._inputNumber)
input.addEventListener('keydown', keydown)
function keydown(e) {
let key = keys[e.which];

@@ -54,4 +58,4 @@

let number = parseFloat(numStr);
let fract = /\.([0-9]+)/.exec(numStr);
if (key === 'up') {

@@ -65,2 +69,5 @@ number = clamp((number+opts.step), opts.min, opts.max);

// ensure number format
if (fract) number = number.toFixed(fract[1].length)
let leftStr = str.slice(0, left);

@@ -89,5 +96,7 @@ let rightStr = str.slice(right);

}
});
}
input._inputNumber = keydown
return input;
}
}
{
"name": "input-number",
"version": "1.0.5",
"version": "1.1.0",
"description": "Make input recognize numbers",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc