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.10.0 to 1.10.1

2

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

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

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

@@ -35,2 +35,3 @@ "keywords": [

"gulp-uglify": "^1.4.1",
"jasmine-core": "^2.4.1",
"karma": "^0.13.10",

@@ -37,0 +38,0 @@ "karma-chrome-launcher": "^0.2.1",

@@ -581,12 +581,18 @@ /*jslint node: true */

})
.filter('awnum', function() {
.filter('awnum', function(dynamicNumberStrategy) {
return function(value, numFract, numSep, numRound, numFixed, numThousand, numThousandSep, numPrepend, numAppend) {
var strategy = {};
var fractionPart;
if(angular.isString(numFract)) {
strategy = dynamicNumberStrategy.getStrategy(numFract);
numFract = strategy.numFract;
}
var fractionPart = initFractionPart(numFract, 2);
var fractionSeparator = initSeparator(numSep, '.');
var roundFunction = initRound(numRound, Math.round);
var isFixed = initIsFixed(numFixed, false);
var isThousandSeparator = initIsThousand(numThousand, false);
var thousandSeparator = initThousandSeparator(numThousandSep, fractionSeparator, fractionSeparator==='.'?',':'.');
var prepend = initNumAppendPrepend(numPrepend);
var append = initNumAppendPrepend(numAppend);
var fractionSeparator = initSeparator(numSep !== undefined ? numSep : strategy.numSep, '.');
var roundFunction = initRound(numRound !== undefined ? numRound : strategy.numRound, Math.round);
var isFixed = initIsFixed(numFixed !== undefined ? numFixed : strategy.numFixed, false);
var isThousandSeparator = initIsThousand(numThousand !== undefined ? numThousand : strategy.numThousand, false);
var thousandSeparator = initThousandSeparator(numThousandSep !== undefined ? numThousandSep : strategy.numThousandSep, fractionSeparator, fractionSeparator==='.'?',':'.');
var prepend = initNumAppendPrepend(numPrepend !== undefined ? numPrepend : strategy.numPrepend);
var append = initNumAppendPrepend(numAppend !== undefined ? numAppend : strategy.numAppend);
var filteredValue = filterModelValue(value, fractionPart, fractionSeparator, roundFunction, isFixed, isThousandSeparator, thousandSeparator, prepend, append);

@@ -600,2 +606,2 @@ if(filteredValue === '') {

.directive('awnum', ['dynamicNumberStrategy',dynamicNumberDirective]);
})(window,window.angular);
})(window,window.angular);

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

!function(n,e,t){"use strict";function r(n,e,r,u){if(n===t||null===n||""===n)return 0;var o="";return o=","===e?String(n).replace(".",","):String(n),a(o,r,u)}function u(n,e,t){return","===e?String(n).replace(/[\.\s]/g,"").replace(",","."):"."===e?String(n).replace(/[,\s]/g,""):void 0}function a(n,e,t){var r=n;return t&&(r+=t),e&&(r=/^\-.+/.test(r)?r.replace("-","-"+e):/^\-/.test(r)?r:e+r),r}function o(n,e){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return e}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 c(n,e){return","===n?",":"."===n?".":e}function m(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function s(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function p(n,e){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:e}function d(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function f(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function l(n,e,t){if(!n)return t;var r;return r="."===e?new RegExp("^[,\\s]$"):new RegExp("^[\\.\\s]$"),r.test(n)?n:t}function g(n){var e=new RegExp("[^\\d,\\.\\s\\-]{1}");return e.test(n)?n:null}function h(n,e,t,r,u){var a="-?";r===!1&&u===!0?a="-":r===!0&&u===!1&&(a="");var o="[0-9]{0,"+n+"}";0===n&&(o="0");var i="(\\"+t+"([0-9]){0,"+e+"})";return 0===e&&(i=""),new RegExp("^"+a+o+i+"?$")}function S(n){return String(n).replace(/^0+/g,"").replace(/^-0(\d+)/g,"-$1").replace(new RegExp("^-([\\.,\\s])","g"),"-0$1").replace(new RegExp("^[\\.,\\s]","g"),"0$&")}function v(n,e,t){var r=n;return e&&(r=r.replace(new RegExp("[\\"+e+"]","g"),"")),t&&(r=r.replace(new RegExp("[\\"+t+"]","g"),"")),r}function w(n,e){return"."===e?String(n).replace(/\./g,""):","===e?String(n).replace(/,/g,""):String(n).replace(new RegExp("\\s","g"),"")}function $(n,e,t){return n=String(n).split(e),n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,t),n.join(e)}function N(n,e,t,r){n.$setViewValue(a(e,t,r)),n.$render()}function T(n,e,u,a,o,i,c,m,s){if(""===n||n===t||null===n)return"";if(n=Number(n),!isNaN(n)&&isFinite(n)){var p=Math.pow(10,e);return n=o?r((a(n*p)/p).toFixed(e),u,m,s):r(String(a(n*p)/p),u,m,s),i&&(n=$(n,u,c)),n}return o?0..toFixed(e):"0"}function P(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="backward"==n.selectionDirection?n.selectionStart:n.selectionEnd);return e}function R(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 x(n,e,t){for(var r=0,u=0,a=0;a<n.length;a++)if(n[a]!==e){if(r++,r>=t)break}else u++;return u}function F(n,e,t){var r={awnum:n.awnum,numInt:n.numInt,numFract:n.numFract,numSep:n.numSep,numPos:n.numPos,numNeg:n.numNeg,numRound:n.numRound,numThousand:n.numThousand,numThousandSep:n.numThousandSep,numPrepend:n.numPrepend,numAppend:n.numAppend};return e&&(r[e]=t),r}function b(n,e,r,u,a){var d={};n.awnum&&(d=a.getStrategy(n.awnum));var S=o(n.numInt!==t?n.numInt:d.numInt,6),v=i(n.numFract!==t?n.numFract:d.numFract,2),w=c(n.numSep!==t?n.numSep:d.numSep,"."),$=m(n.numPos!==t?n.numPos:d.numPos,!0),N=s(n.numNeg!==t?n.numNeg:d.numNeg,!0),T=p(n.numRound!==t?n.numRound:d.numRound,Math.round),P=f(n.numThousand!==t?n.numThousand:d.numThousand,!1),R=l(n.numThousandSep!==t?n.numThousandSep:d.numThousandSep,w,"."===w?",":"."),x=g(n.numPrepend!==t?n.numPrepend:d.numPrepend),F=g(n.numAppend!==t?n.numAppend:d.numAppend);if($===!1&&N===!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 b=h(S,v,w,$,N);return{element:e,attrs:r,ngModelController:u,viewRegexTest:b,integerPart:S,fractionPart:v,fractionSeparator:w,isPositiveNumber:$,isNegativeNumber:N,roundFunction:T,isThousandSeparator:P,thousandSeparator:R,prepend:x,append:F}}function y(n,e){var a=e.element,o=(e.attrs,e.ngModelController),i=e.viewRegexTest,c=(e.integerPart,e.fractionPart,e.fractionSeparator),m=(e.isPositiveNumber,e.isNegativeNumber,e.roundFunction,e.isThousandSeparator),s=e.thousandSeparator,p=e.prepend,d=e.append,f=String(n);if(f=v(f,p,d),new RegExp("^[.,"+s+"]{2,}").test(f))return N(o,0,p,d),0;var l=P(a[0]);p&&l--;var g=f.slice(0,l);if(g=w(g,s),f=w(f,s),g=S(g),f=S(f),""===f&&"0"===String(n).charAt(0))return N(o,0,p,d),0;if(f===t||""===f)return 0;if("-"===f)return N(o,"-",p,d),0;if(i.test(f)===!1){var h=r(o.$modelValue,c,p,d);return m&&(h=$(h,c,s)),N(o,h,p,d),R(a[0],l-1),o.$modelValue}var T=0,F=g.length;return m&&(f=$(f,c,s),T=x(f,s,F)),p&&(T++,new RegExp("^(\\-\\d)$").test(f)&&(T+=2),new RegExp("^(\\d)$").test(f)&&T++),N(o,f,p,d),R(a[0],F+T),setTimeout(function(){R(a[0],F+T)},1),u(f,c,s)}function E(n,e){n.$setViewValue(""),n.$render(),n.$setViewValue(e),n.$render()}function I(n,e){var t=T(n.$modelValue,e.fractionPart,e.fractionSeparator,e.roundFunction,!1,e.isThousandSeparator,e.thousandSeparator,e.prepend,e.append);E(n,t)}function A(n){return{restrict:"A",require:"?ngModel",scope:{awnum:"@",numInt:"@",numFract:"@",numSep:"@",numPos:"@",numNeg:"@",numRound:"@",numThousand:"@",numThousandSep:"@",numPrepend:"@",numAppend:"@"},link:function(e,t,r,u){if(!t[0]||"INPUT"!==t[0].tagName||"text"!==t[0].type&&"tel"!==t[0].type)return void console.warn("Directive angular-dynamic-number works only for 'input' tag with type = 'text' or type = 'tel'");if(!u)return void console.warn("Directive angular-dynamic-number need ngModel attribute");var a=b(F(e),t,r,u,n);e.$watch("numInt",function(o,i){i!==o&&(a=b(F(e,"numInt",o),t,r,u,n),I(u,a))}),e.$watch("numFract",function(o,i){i!==o&&(a=b(F(e,"numFract",o),t,r,u,n),I(u,a))}),e.$watch("numSep",function(o,i){i!==o&&(a=b(F(e,"numSep",o),t,r,u,n),I(u,a))}),e.$watch("numPos",function(o,i){i!==o&&(a=b(F(e,"numPos",o),t,r,u,n),I(u,a))}),e.$watch("numNeg",function(o,i){i!==o&&(a=b(F(e,"numNeg",o),t,r,u,n),I(u,a))}),e.$watch("numThousand",function(o,i){i!==o&&(a=b(F(e,"numThousand",o),t,r,u,n),I(u,a))}),e.$watch("numThousandSep",function(o,i){i!==o&&(a=b(F(e,"numThousandSep",o),t,r,u,n),I(u,a))}),e.$watch("numAppend",function(o,i){i!==o&&(a=b(F(e,"numAppend",o),t,r,u,n),I(u,a))}),e.$watch("numPrepend",function(o,i){i!==o&&(a=b(F(e,"numPrepend",o),t,r,u,n),I(u,a))}),u.$parsers.unshift(function(n){return y(n,a)}),u.$formatters.push(function(n){return T(n,a.fractionPart,a.fractionSeparator,a.roundFunction,!1,a.isThousandSeparator,a.thousandSeparator,a.prepend,a.append)})}}}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,a,o,m,s){var h=i(e,2),S=c(t,"."),v=p(r,Math.round),w=d(u,!1),$=f(a,!1),N=l(o,S,"."===S?",":"."),P=g(m),R=g(s),x=T(n,h,S,v,w,$,N,P,R);return""===x?"0":x}}).directive("awnum",["dynamicNumberStrategy",A])}(window,window.angular);
!function(n,e,t){"use strict";function r(n,e,r,u){if(n===t||null===n||""===n)return 0;var o="";return o=","===e?String(n).replace(".",","):String(n),a(o,r,u)}function u(n,e,t){return","===e?String(n).replace(/[\.\s]/g,"").replace(",","."):"."===e?String(n).replace(/[,\s]/g,""):void 0}function a(n,e,t){var r=n;return t&&(r+=t),e&&(r=/^\-.+/.test(r)?r.replace("-","-"+e):/^\-/.test(r)?r:e+r),r}function o(n,e){if(n>=0){var t=parseInt(n,10);if(isNaN(t)===!1&&isFinite(t)&&t>=0)return t}return e}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 c(n,e){return","===n?",":"."===n?".":e}function m(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function s(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function p(n,e){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:e}function d(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function f(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function g(n,e,t){if(!n)return t;var r;return r="."===e?new RegExp("^[,\\s]$"):new RegExp("^[\\.\\s]$"),r.test(n)?n:t}function l(n){var e=new RegExp("[^\\d,\\.\\s\\-]{1}");return e.test(n)?n:null}function h(n,e,t,r,u){var a="-?";r===!1&&u===!0?a="-":r===!0&&u===!1&&(a="");var o="[0-9]{0,"+n+"}";0===n&&(o="0");var i="(\\"+t+"([0-9]){0,"+e+"})";return 0===e&&(i=""),new RegExp("^"+a+o+i+"?$")}function S(n){return String(n).replace(/^0+/g,"").replace(/^-0(\d+)/g,"-$1").replace(new RegExp("^-([\\.,\\s])","g"),"-0$1").replace(new RegExp("^[\\.,\\s]","g"),"0$&")}function v(n,e,t){var r=n;return e&&(r=r.replace(new RegExp("[\\"+e+"]","g"),"")),t&&(r=r.replace(new RegExp("[\\"+t+"]","g"),"")),r}function w(n,e){return"."===e?String(n).replace(/\./g,""):","===e?String(n).replace(/,/g,""):String(n).replace(new RegExp("\\s","g"),"")}function $(n,e,t){return n=String(n).split(e),n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,t),n.join(e)}function T(n,e,t,r){n.$setViewValue(a(e,t,r)),n.$render()}function N(n,e,u,a,o,i,c,m,s){if(""===n||n===t||null===n)return"";if(n=Number(n),!isNaN(n)&&isFinite(n)){var p=Math.pow(10,e);return n=o?r((a(n*p)/p).toFixed(e),u,m,s):r(String(a(n*p)/p),u,m,s),i&&(n=$(n,u,c)),n}return o?0..toFixed(e):"0"}function P(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="backward"==n.selectionDirection?n.selectionStart:n.selectionEnd);return e}function R(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 x(n,e,t){for(var r=0,u=0,a=0;a<n.length;a++)if(n[a]!==e){if(r++,r>=t)break}else u++;return u}function F(n,e,t){var r={awnum:n.awnum,numInt:n.numInt,numFract:n.numFract,numSep:n.numSep,numPos:n.numPos,numNeg:n.numNeg,numRound:n.numRound,numThousand:n.numThousand,numThousandSep:n.numThousandSep,numPrepend:n.numPrepend,numAppend:n.numAppend};return e&&(r[e]=t),r}function y(n,e,r,u,a){var d={};n.awnum&&(d=a.getStrategy(n.awnum));var S=o(n.numInt!==t?n.numInt:d.numInt,6),v=i(n.numFract!==t?n.numFract:d.numFract,2),w=c(n.numSep!==t?n.numSep:d.numSep,"."),$=m(n.numPos!==t?n.numPos:d.numPos,!0),T=s(n.numNeg!==t?n.numNeg:d.numNeg,!0),N=p(n.numRound!==t?n.numRound:d.numRound,Math.round),P=f(n.numThousand!==t?n.numThousand:d.numThousand,!1),R=g(n.numThousandSep!==t?n.numThousandSep:d.numThousandSep,w,"."===w?",":"."),x=l(n.numPrepend!==t?n.numPrepend:d.numPrepend),F=l(n.numAppend!==t?n.numAppend:d.numAppend);if($===!1&&T===!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 y=h(S,v,w,$,T);return{element:e,attrs:r,ngModelController:u,viewRegexTest:y,integerPart:S,fractionPart:v,fractionSeparator:w,isPositiveNumber:$,isNegativeNumber:T,roundFunction:N,isThousandSeparator:P,thousandSeparator:R,prepend:x,append:F}}function b(n,e){var a=e.element,o=(e.attrs,e.ngModelController),i=e.viewRegexTest,c=(e.integerPart,e.fractionPart,e.fractionSeparator),m=(e.isPositiveNumber,e.isNegativeNumber,e.roundFunction,e.isThousandSeparator),s=e.thousandSeparator,p=e.prepend,d=e.append,f=String(n);if(f=v(f,p,d),new RegExp("^[.,"+s+"]{2,}").test(f))return T(o,0,p,d),0;var g=P(a[0]);p&&g--;var l=f.slice(0,g);if(l=w(l,s),f=w(f,s),l=S(l),f=S(f),""===f&&"0"===String(n).charAt(0))return T(o,0,p,d),0;if(f===t||""===f)return 0;if("-"===f)return T(o,"-",p,d),0;if(i.test(f)===!1){var h=r(o.$modelValue,c,p,d);return m&&(h=$(h,c,s)),T(o,h,p,d),R(a[0],g-1),o.$modelValue}var N=0,F=l.length;return m&&(f=$(f,c,s),N=x(f,s,F)),p&&(N++,new RegExp("^(\\-\\d)$").test(f)&&(N+=2),new RegExp("^(\\d)$").test(f)&&N++),T(o,f,p,d),R(a[0],F+N),setTimeout(function(){R(a[0],F+N)},1),u(f,c,s)}function E(n,e){n.$setViewValue(""),n.$render(),n.$setViewValue(e),n.$render()}function A(n,e){var t=N(n.$modelValue,e.fractionPart,e.fractionSeparator,e.roundFunction,!1,e.isThousandSeparator,e.thousandSeparator,e.prepend,e.append);E(n,t)}function I(n){return{restrict:"A",require:"?ngModel",scope:{awnum:"@",numInt:"@",numFract:"@",numSep:"@",numPos:"@",numNeg:"@",numRound:"@",numThousand:"@",numThousandSep:"@",numPrepend:"@",numAppend:"@"},link:function(e,t,r,u){if(!t[0]||"INPUT"!==t[0].tagName||"text"!==t[0].type&&"tel"!==t[0].type)return void console.warn("Directive angular-dynamic-number works only for 'input' tag with type = 'text' or type = 'tel'");if(!u)return void console.warn("Directive angular-dynamic-number need ngModel attribute");var a=y(F(e),t,r,u,n);e.$watch("numInt",function(o,i){i!==o&&(a=y(F(e,"numInt",o),t,r,u,n),A(u,a))}),e.$watch("numFract",function(o,i){i!==o&&(a=y(F(e,"numFract",o),t,r,u,n),A(u,a))}),e.$watch("numSep",function(o,i){i!==o&&(a=y(F(e,"numSep",o),t,r,u,n),A(u,a))}),e.$watch("numPos",function(o,i){i!==o&&(a=y(F(e,"numPos",o),t,r,u,n),A(u,a))}),e.$watch("numNeg",function(o,i){i!==o&&(a=y(F(e,"numNeg",o),t,r,u,n),A(u,a))}),e.$watch("numThousand",function(o,i){i!==o&&(a=y(F(e,"numThousand",o),t,r,u,n),A(u,a))}),e.$watch("numThousandSep",function(o,i){i!==o&&(a=y(F(e,"numThousandSep",o),t,r,u,n),A(u,a))}),e.$watch("numAppend",function(o,i){i!==o&&(a=y(F(e,"numAppend",o),t,r,u,n),A(u,a))}),e.$watch("numPrepend",function(o,i){i!==o&&(a=y(F(e,"numPrepend",o),t,r,u,n),A(u,a))}),u.$parsers.unshift(function(n){return b(n,a)}),u.$formatters.push(function(n){return N(n,a.fractionPart,a.fractionSeparator,a.roundFunction,!1,a.isThousandSeparator,a.thousandSeparator,a.prepend,a.append)})}}}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(n){return function(r,u,a,o,m,s,h,S,v){var w,$={};e.isString(u)&&($=n.getStrategy(u),u=$.numFract);var w=i(u,2),T=c(a!==t?a:$.numSep,"."),P=p(o!==t?o:$.numRound,Math.round),R=d(m!==t?m:$.numFixed,!1),x=f(s!==t?s:$.numThousand,!1),F=g(h!==t?h:$.numThousandSep,T,"."===T?",":"."),y=l(S!==t?S:$.numPrepend),b=l(v!==t?v:$.numAppend),E=N(r,w,T,P,R,x,F,y,b);return""===E?"0":E}}).directive("awnum",["dynamicNumberStrategy",I])}(window,window.angular);

Sorry, the diff of this file is not supported yet

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