Socket
Socket
Sign inDemoInstall

angular-dynamic-number

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-dynamic-number - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

2

bower.json
{
"name": "angular-dynamic-number",
"version": "1.5.1",
"version": "1.5.2",
"homepage": "https://github.com/uhlryk/angular-dynamic-number",

@@ -5,0 +5,0 @@ "authors": [

{
"name": "angular-dynamic-number",
"version": "1.5.1",
"version": "1.5.2",
"description": "Highly customizable angular directive for numbers",

@@ -5,0 +5,0 @@ "keywords": [

@@ -103,3 +103,8 @@ /*jslint node: true */

function removeLeadingZero(value){
return String(value).replace(/^0+/g, "").replace(/^-00+/g, "-0").replace(/-0+\[\.,]/, "-0$&").replace(/^[\.,]/g, "0$&");
// return String(value).replace(/^0+/g, "").replace(/^-00+/g, "-0").replace(/-0+\[\.,]/, "-0$&").replace(/^[\.,]/g, "0$&");
return String(value)
.replace(/^0+/g, "")//change 00000 to ''
.replace(/^-0(\d+)/g, "-$1")//change -013212 to -0
.replace(/^-([\.,])/, "-0$1")//change -. to -0.
.replace(/^[\.,]/g, "0$&");//change . to 0.
}

@@ -106,0 +111,0 @@ function removeThousandSeparators(value, thousandSeparator){

@@ -1,1 +0,1 @@

!function(n,e,t){"use strict";function r(n,e){return","===e?String(n).replace(".",","):String(n)}function u(n,e){return","===e?String(n).replace(/\./g,"").replace(",","."):String(n).replace(/,/g,"")}function i(n,e){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return e}function a(n,e){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return e}function o(n,e){return","===n?",":"."===n?".":e}function c(n,e){return"false"===n?!1:"true"===n?!0:e}function f(n,e){return"false"===n?!1:"true"===n?!0:e}function l(n,e){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:e}function s(n,e){return"false"===n?!1:"true"===n?!0:e}function g(n,e){return"false"===n?!1:"true"===n?!0:e}function m(n,e,t,r,u){var i="-?";r===!1&&u===!0?i="-":r===!0&&u===!1&&(i="");var a="[0-9]{0,"+n+"}";0===n&&(a="0");var o="(\\"+t+"([0-9]){0,"+e+"})";return 0===e&&(o=""),new RegExp("^"+i+a+o+"?$")}function d(n){return String(n).replace(/^0+/g,"").replace(/^-00+/g,"-0").replace(/-0+\[\.,]/,"-0$&").replace(/^[\.,]/g,"0$&")}function v(n,e){return"."===e?String(n).replace(/\./g,""):String(n).replace(/,/g,"")}function p(n,e){return String(n).replace(/\B(?=(\d{3})+(?!\d))/g,e)}function h(n,e){n.$setViewValue(e),n.$render()}function S(n,e,t,u,i,a){if(n=Number(n),!isNaN(n)&&isFinite(n)){var o=Math.pow(10,e);return n=i?r((u(n*o)/o).toFixed(e),t):r(String(u(n*o)/o),t),a&&(n=p(n,"."===t?",":".")),n}return i?0..toFixed(e):"0"}function w(n){var e=0;if(document.selection){n.focus();var t=document.selection.createRange();t.moveStart("character",-n.value.length),e=t.text.length}else(n.selectionStart||"0"==n.selectionStart)&&(e=n.selectionStart);return e}function N(n,e){if(null!==n)if(n.createTextRange){var t=n.createTextRange();t.move("character",e),t.select()}else n.selectionStart?(n.focus(),n.setSelectionRange(e,e)):n.focus()}function y(n,e,t){for(var r=0,u=0,i=0;i<n.length;i++)if(n[i]!==e){if(r++,r>=t)break}else u++;return u}function b(n){return{restrict:"A",require:"?ngModel",scope:{awnum:"@",numInt:"@",numFract:"@",numSep:"@",numPos:"@",numNeg:"@",numRound:"@",numThousand:"@"},link:function(n,e,s,b){if(!e[0]||"INPUT"!==e[0].tagName||"text"!==e[0].type)return void console.warn("Directive angular-dynamic-number works only for 'input' tag with type = 'text'");if(!b)return void console.warn("Directive angular-dynamic-number need ngModel attribute");var $=i(n.numInt,6),x=a(n.numFract,2),M=o(n.numSep,"."),F=c(n.numPos,!0),R=f(n.numNeg,!0),I=l(n.numRound,Math.round),T=g(n.numThousand,!1);if(F===!1&&R===!1)throw new Error("Number is set to not be positive and not be negative. Change num_pos attr or/and num_neg attr to true");var V=m($,x,M,F,R);b.$parsers.unshift(function(n){var i=String(n),a=w(e[0]),o=i.slice(0,a),c=o.length;if(o=v(o,"."===M?",":"."),i=v(i,"."===M?",":"."),o=d(o),i=d(i),""===i&&"0"===String(n).charAt(0))return h(b,0),0;if(i===t||""===i)return 0;if("-"===i)return h(b,"-"),0;if(V.test(i)===!1){var f=r(b.$modelValue,M);return T&&(f=p(f,"."===M?",":".")),h(b,f),N(e[0],a-1),b.$modelValue}var l=0,s=a-c+o.length;return T&&(i=p(i,"."===M?",":"."),l=y(i,"."===M?",":".",s)),h(b,i),N(e[0],s+l),u(i,M)}),b.$formatters.push(function(n){return S(n,x,M,I,!1,T)})}}}e.module("dynamicNumber",[]).provider("dynamicNumberStrategy",function(){var n={};this.addStrategy=function(e,t){n[e]=t},this.getStrategy=function(e){return n[e]},this.$get=function(){return{getStrategy:function(e){return n[e]}}}}).filter("awnum",function(){return function(n,e,t,r,u,i){var c=a(e,2),f=o(t,"."),m=l(r,Math.round),d=s(u,!1),v=g(i,!1);return S(n,c,f,m,d,v)}}).directive("awnum",["dynamicNumberStrategy",b])}(window,window.angular);
!function(n,e,t){"use strict";function r(n,e){return","===e?String(n).replace(".",","):String(n)}function u(n,e){return","===e?String(n).replace(/\./g,"").replace(",","."):String(n).replace(/,/g,"")}function i(n,e){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return e}function a(n,e){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return e}function o(n,e){return","===n?",":"."===n?".":e}function c(n,e){return"false"===n?!1:"true"===n?!0:e}function f(n,e){return"false"===n?!1:"true"===n?!0:e}function l(n,e){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:e}function s(n,e){return"false"===n?!1:"true"===n?!0:e}function g(n,e){return"false"===n?!1:"true"===n?!0:e}function m(n,e,t,r,u){var i="-?";r===!1&&u===!0?i="-":r===!0&&u===!1&&(i="");var a="[0-9]{0,"+n+"}";0===n&&(a="0");var o="(\\"+t+"([0-9]){0,"+e+"})";return 0===e&&(o=""),new RegExp("^"+i+a+o+"?$")}function d(n){return String(n).replace(/^0+/g,"").replace(/^-0(\d+)/g,"-$1").replace(/^-([\.,])/,"-0$1").replace(/^[\.,]/g,"0$&")}function v(n,e){return"."===e?String(n).replace(/\./g,""):String(n).replace(/,/g,"")}function p(n,e){return String(n).replace(/\B(?=(\d{3})+(?!\d))/g,e)}function h(n,e){n.$setViewValue(e),n.$render()}function S(n,e,t,u,i,a){if(n=Number(n),!isNaN(n)&&isFinite(n)){var o=Math.pow(10,e);return n=i?r((u(n*o)/o).toFixed(e),t):r(String(u(n*o)/o),t),a&&(n=p(n,"."===t?",":".")),n}return i?0..toFixed(e):"0"}function w(n){var e=0;if(document.selection){n.focus();var t=document.selection.createRange();t.moveStart("character",-n.value.length),e=t.text.length}else(n.selectionStart||"0"==n.selectionStart)&&(e=n.selectionStart);return e}function N(n,e){if(null!==n)if(n.createTextRange){var t=n.createTextRange();t.move("character",e),t.select()}else n.selectionStart?(n.focus(),n.setSelectionRange(e,e)):n.focus()}function y(n,e,t){for(var r=0,u=0,i=0;i<n.length;i++)if(n[i]!==e){if(r++,r>=t)break}else u++;return u}function b(n){return{restrict:"A",require:"?ngModel",scope:{awnum:"@",numInt:"@",numFract:"@",numSep:"@",numPos:"@",numNeg:"@",numRound:"@",numThousand:"@"},link:function(n,e,s,b){if(!e[0]||"INPUT"!==e[0].tagName||"text"!==e[0].type)return void console.warn("Directive angular-dynamic-number works only for 'input' tag with type = 'text'");if(!b)return void console.warn("Directive angular-dynamic-number need ngModel attribute");var $=i(n.numInt,6),x=a(n.numFract,2),M=o(n.numSep,"."),F=c(n.numPos,!0),R=f(n.numNeg,!0),I=l(n.numRound,Math.round),T=g(n.numThousand,!1);if(F===!1&&R===!1)throw new Error("Number is set to not be positive and not be negative. Change num_pos attr or/and num_neg attr to true");var V=m($,x,M,F,R);b.$parsers.unshift(function(n){var i=String(n),a=w(e[0]),o=i.slice(0,a),c=o.length;if(o=v(o,"."===M?",":"."),i=v(i,"."===M?",":"."),o=d(o),i=d(i),""===i&&"0"===String(n).charAt(0))return h(b,0),0;if(i===t||""===i)return 0;if("-"===i)return h(b,"-"),0;if(V.test(i)===!1){var f=r(b.$modelValue,M);return T&&(f=p(f,"."===M?",":".")),h(b,f),N(e[0],a-1),b.$modelValue}var l=0,s=a-c+o.length;return T&&(i=p(i,"."===M?",":"."),l=y(i,"."===M?",":".",s)),h(b,i),N(e[0],s+l),u(i,M)}),b.$formatters.push(function(n){return S(n,x,M,I,!1,T)})}}}e.module("dynamicNumber",[]).provider("dynamicNumberStrategy",function(){var n={};this.addStrategy=function(e,t){n[e]=t},this.getStrategy=function(e){return n[e]},this.$get=function(){return{getStrategy:function(e){return n[e]}}}}).filter("awnum",function(){return function(n,e,t,r,u,i){var c=a(e,2),f=o(t,"."),m=l(r,Math.round),d=s(u,!1),v=g(i,!1);return S(n,c,f,m,d,v)}}).directive("awnum",["dynamicNumberStrategy",b])}(window,window.angular);
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