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

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 2.1.0 to 2.1.1

2

package.json
{
"name": "angular-dynamic-number",
"version": "2.1.0",
"version": "2.1.1",
"description": "Highly customizable angular directive for numbers",

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

@@ -644,3 +644,3 @@ /*jslint node: true */

})
.filter('awnum', function(dynamicNumberStrategy) {
.filter('awnum', ['dynamicNumberStrategy', function(dynamicNumberStrategy) {
return function(value, numFract, numSep, numRound, numFixed, numThousand, numThousandSep, numPrepend, numAppend) {

@@ -667,3 +667,3 @@ var strategy = {};

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

@@ -670,0 +670,0 @@

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

!function(n,e){"use strict";if("function"==typeof define&&define.amd)define(["angular"],e);else{if("undefined"==typeof module||"object"!=typeof module.exports)return e(n.angular);module.exports=e(require("angular"))}}(window,function(n){"use strict";function e(n,e,t,u){if(void 0===n||null===n||""===n)return 0;var a="";return a=","===e?String(n).replace(".",","):String(n),r(a,t,u)}function t(n,e,t){return","===e?String(n).replace(/['\.\s]/g,"").replace(",","."):"."===e?String(n).replace(/[',\s]/g,""):void 0}function r(n,e,t){var r=n;return t&&(r+=t),e&&(r=/^\-.+/.test(r)?r.replace("-","-"+e):/^\-/.test(r)?r:e+r),r}function u(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 i(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function c(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function d(n,e){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:e}function m(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function p(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function s(n,e,t){if(!n)return t;var r;return r="."===e?new RegExp("^[',\\s]$"):new RegExp("^['\\.\\s]$"),r.test(n)?n:t}function f(n){var e=new RegExp("[^\\d,\\.\\s\\-]{1}");return e.test(n)?n:null}function l(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 g(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 S(n,e){return"."===e?String(n).replace(/\./g,""):","===e?String(n).replace(/,/g,""):String(n).replace(new RegExp("['\\s]","g"),"")}function h(n,e,t){return n=String(n).split(e),n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,t),n.join(e)}function w(n,e,t,u,a,o){o&&(a.enable=!1),n.$setViewValue(r(String(e),t,u)),n.$render()}function $(n,t,r,u,a,o,i,c,d){if(""===n||void 0===n||null===n)return"";if(n=Number(n),!isNaN(n)&&isFinite(n)){var m=Math.pow(10,t);return n=a?e((u(n*m)/m).toFixed(t),r,c,d):e(String(u(n*m)/m),r,c,d),o&&(n=h(n,r,i)),n}return a?0..toFixed(t):"0"}function N(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 T(n){return Number(n)}function P(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,t,r,m){var g={};n.awnum&&(g=m.getStrategy(n.awnum));var v=u(void 0!==n.numInt?n.numInt:g.numInt,6),S=a(void 0!==n.numFract?n.numFract:g.numFract,2),h=o(void 0!==n.numSep?n.numSep:g.numSep,"."),w=i(void 0!==n.numPos?n.numPos:g.numPos,!0),$=c(void 0!==n.numNeg?n.numNeg:g.numNeg,!0),N=d(void 0!==n.numRound?n.numRound:g.numRound,Math.round),R=p(void 0!==n.numThousand?n.numThousand:g.numThousand,!1),x=s(void 0!==n.numThousandSep?n.numThousandSep:g.numThousandSep,h,"."===h?",":"."),T=f(void 0!==n.numPrepend?n.numPrepend:g.numPrepend),P=f(void 0!==n.numAppend?n.numAppend:g.numAppend);if(w===!1&&$===!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=l(v,S,h,w,$);return{element:e,attrs:t,ngModelController:r,viewRegexTest:b,integerPart:v,fractionPart:S,fractionSeparator:h,isPositiveNumber:w,isNegativeNumber:$,roundFunction:N,isThousandSeparator:R,thousandSeparator:x,prepend:T,append:P}}function y(n,r,u){var a=r.element,o=(r.attrs,r.ngModelController),i=r.viewRegexTest,c=(r.integerPart,r.fractionPart),d=r.fractionSeparator,m=r.isPositiveNumber,p=r.isNegativeNumber,s=(r.roundFunction,r.isThousandSeparator),f=r.thousandSeparator,l=r.prepend,$=r.append,T=String(n);if(I){I=!1;var P=new RegExp("[^"+(p?"-":"")+d+f+"0-9]+","g");T=T.replace(P,""),P=new RegExp("^["+d+f+"]"),T=T.replace(P,""),P=new RegExp("["+d+f+"]([0-9]{"+c+"})$"),T=T.replace(P,d+"$1")}if(T=v(T,l,$),new RegExp("^[.,"+f+"]{2,}").test(T))return w(o,0,l,$,u),0;var b=N(a[0]);l&&b--;var y=T.slice(0,b);y=S(y,f),T=S(T,f),y=g(y);var F=T;if(T=g(T),T==="0"+d&&F===d&&m)return c?(w(o,"0"+d,l,$,u,!0),R(a[0],2),0):(w(o,"",l,$,u),0);if(""===T&&"0"===String(n).charAt(0))return w(o,0,l,$),0;if(void 0===T||""===T)return 0;if("-"===T)return m&&!p?w(o,"",l,$,u):w(o,"-",l,$,u),0;if(i.test(T)===!1){var E=e(o.$modelValue,d,l,$);return s&&(E=h(E,d,f)),w(o,E,l,$,u),R(a[0],b-1),o.$modelValue}var A=0,M=y.length;return s&&(T=h(T,d,f),A=x(T,f,M)),l&&(A++,new RegExp("^(\\-\\d)$").test(T)&&(A+=2),new RegExp("^(\\d)$").test(T)&&A++),w(o,T,l,$,u),R(a[0],M+A),t(T,d,f)}function F(n,e){n.$setViewValue(""),n.$render(),n.$setViewValue(e),n.$render()}function E(n,e){var t=$(n.$modelValue,e.fractionPart,e.fractionSeparator,e.roundFunction,!1,e.isThousandSeparator,e.thousandSeparator,e.prepend,e.append);F(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(P(e),t,r,u,n);t.on("paste",function(){I=!0}),e.$watch("numInt",function(o,i){i!==o&&(a=b(P(e,"numInt",o),t,r,u,n),E(u,a))}),e.$watch("numFract",function(o,i){i!==o&&(a=b(P(e,"numFract",o),t,r,u,n),E(u,a))}),e.$watch("numSep",function(o,i){i!==o&&(a=b(P(e,"numSep",o),t,r,u,n),E(u,a))}),e.$watch("numPos",function(o,i){i!==o&&(a=b(P(e,"numPos",o),t,r,u,n),E(u,a))}),e.$watch("numNeg",function(o,i){i!==o&&(a=b(P(e,"numNeg",o),t,r,u,n),E(u,a))}),e.$watch("numThousand",function(o,i){i!==o&&(a=b(P(e,"numThousand",o),t,r,u,n),E(u,a))}),e.$watch("numThousandSep",function(o,i){i!==o&&(a=b(P(e,"numThousandSep",o),t,r,u,n),E(u,a))}),e.$watch("numAppend",function(o,i){i!==o&&(a=b(P(e,"numAppend",o),t,r,u,n),E(u,a))}),e.$watch("numPrepend",function(o,i){i!==o&&(a=b(P(e,"numPrepend",o),t,r,u,n),E(u,a))});var o={enable:!0,count:0};u.$parsers.unshift(function(n){return o.enable?(o.count++,T(y(n,a,o))):(o.enable=!0,n)}),u.$formatters.push(function(n){return $(n,a.fractionPart,a.fractionSeparator,a.roundFunction,!1,a.isThousandSeparator,a.thousandSeparator,a.prepend,a.append)})}}}var I=!1,M="dynamicNumber";return n.module(M,[]).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(e){return function(t,r,u,i,c,l,g,v,S){var h,w={};n.isString(r)&&(w=e.getStrategy(r),r=w.numFract);var h=a(r,2),N=o(void 0!==u?u:w.numSep,"."),R=d(void 0!==i?i:w.numRound,Math.round),x=m(void 0!==c?c:w.numFixed,!1),T=p(void 0!==l?l:w.numThousand,!1),P=s(void 0!==g?g:w.numThousandSep,N,"."===N?",":"."),b=f(void 0!==v?v:w.numPrepend),y=f(void 0!==S?S:w.numAppend),F=$(t,h,N,R,x,T,P,b,y);return""===F?"0":F}}).directive("awnum",["dynamicNumberStrategy",A]),M});
!function(n,e){"use strict";if("function"==typeof define&&define.amd)define(["angular"],e);else{if("undefined"==typeof module||"object"!=typeof module.exports)return e(n.angular);module.exports=e(require("angular"))}}(window,function(n){"use strict";function e(n,e,t,u){if(void 0===n||null===n||""===n)return 0;var a="";return a=","===e?String(n).replace(".",","):String(n),r(a,t,u)}function t(n,e,t){return","===e?String(n).replace(/['\.\s]/g,"").replace(",","."):"."===e?String(n).replace(/[',\s]/g,""):void 0}function r(n,e,t){var r=n;return t&&(r+=t),e&&(r=/^\-.+/.test(r)?r.replace("-","-"+e):/^\-/.test(r)?r:e+r),r}function u(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 i(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function c(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function d(n,e){return"floor"===n?Math.floor:"ceil"===n?Math.ceil:"round"===n?Math.round:e}function m(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function p(n,e){return"false"===n||n===!1?!1:"true"===n||n===!0?!0:e}function s(n,e,t){if(!n)return t;var r;return r="."===e?new RegExp("^[',\\s]$"):new RegExp("^['\\.\\s]$"),r.test(n)?n:t}function f(n){var e=new RegExp("[^\\d,\\.\\s\\-]{1}");return e.test(n)?n:null}function l(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 g(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 S(n,e){return"."===e?String(n).replace(/\./g,""):","===e?String(n).replace(/,/g,""):String(n).replace(new RegExp("['\\s]","g"),"")}function h(n,e,t){return n=String(n).split(e),n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,t),n.join(e)}function w(n,e,t,u,a,o){o&&(a.enable=!1),n.$setViewValue(r(String(e),t,u)),n.$render()}function $(n,t,r,u,a,o,i,c,d){if(""===n||void 0===n||null===n)return"";if(n=Number(n),!isNaN(n)&&isFinite(n)){var m=Math.pow(10,t);return n=a?e((u(n*m)/m).toFixed(t),r,c,d):e(String(u(n*m)/m),r,c,d),o&&(n=h(n,r,i)),n}return a?0..toFixed(t):"0"}function N(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 T(n){return Number(n)}function P(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,t,r,m){var g={};n.awnum&&(g=m.getStrategy(n.awnum));var v=u(void 0!==n.numInt?n.numInt:g.numInt,6),S=a(void 0!==n.numFract?n.numFract:g.numFract,2),h=o(void 0!==n.numSep?n.numSep:g.numSep,"."),w=i(void 0!==n.numPos?n.numPos:g.numPos,!0),$=c(void 0!==n.numNeg?n.numNeg:g.numNeg,!0),N=d(void 0!==n.numRound?n.numRound:g.numRound,Math.round),R=p(void 0!==n.numThousand?n.numThousand:g.numThousand,!1),x=s(void 0!==n.numThousandSep?n.numThousandSep:g.numThousandSep,h,"."===h?",":"."),T=f(void 0!==n.numPrepend?n.numPrepend:g.numPrepend),P=f(void 0!==n.numAppend?n.numAppend:g.numAppend);if(w===!1&&$===!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=l(v,S,h,w,$);return{element:e,attrs:t,ngModelController:r,viewRegexTest:b,integerPart:v,fractionPart:S,fractionSeparator:h,isPositiveNumber:w,isNegativeNumber:$,roundFunction:N,isThousandSeparator:R,thousandSeparator:x,prepend:T,append:P}}function y(n,r,u){var a=r.element,o=(r.attrs,r.ngModelController),i=r.viewRegexTest,c=(r.integerPart,r.fractionPart),d=r.fractionSeparator,m=r.isPositiveNumber,p=r.isNegativeNumber,s=(r.roundFunction,r.isThousandSeparator),f=r.thousandSeparator,l=r.prepend,$=r.append,T=String(n);if(I){I=!1;var P=new RegExp("[^"+(p?"-":"")+d+f+"0-9]+","g");T=T.replace(P,""),P=new RegExp("^["+d+f+"]"),T=T.replace(P,""),P=new RegExp("["+d+f+"]([0-9]{"+c+"})$"),T=T.replace(P,d+"$1")}if(T=v(T,l,$),new RegExp("^[.,"+f+"]{2,}").test(T))return w(o,0,l,$,u),0;var b=N(a[0]);l&&b--;var y=T.slice(0,b);y=S(y,f),T=S(T,f),y=g(y);var F=T;if(T=g(T),T==="0"+d&&F===d&&m)return c?(w(o,"0"+d,l,$,u,!0),R(a[0],2),0):(w(o,"",l,$,u),0);if(""===T&&"0"===String(n).charAt(0))return w(o,0,l,$),0;if(void 0===T||""===T)return 0;if("-"===T)return m&&!p?w(o,"",l,$,u):w(o,"-",l,$,u),0;if(i.test(T)===!1){var E=e(o.$modelValue,d,l,$);return s&&(E=h(E,d,f)),w(o,E,l,$,u),R(a[0],b-1),o.$modelValue}var A=0,M=y.length;return s&&(T=h(T,d,f),A=x(T,f,M)),l&&(A++,new RegExp("^(\\-\\d)$").test(T)&&(A+=2),new RegExp("^(\\d)$").test(T)&&A++),w(o,T,l,$,u),R(a[0],M+A),t(T,d,f)}function F(n,e){n.$setViewValue(""),n.$render(),n.$setViewValue(e),n.$render()}function E(n,e){var t=$(n.$modelValue,e.fractionPart,e.fractionSeparator,e.roundFunction,!1,e.isThousandSeparator,e.thousandSeparator,e.prepend,e.append);F(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(P(e),t,r,u,n);t.on("paste",function(){I=!0}),e.$watch("numInt",function(o,i){i!==o&&(a=b(P(e,"numInt",o),t,r,u,n),E(u,a))}),e.$watch("numFract",function(o,i){i!==o&&(a=b(P(e,"numFract",o),t,r,u,n),E(u,a))}),e.$watch("numSep",function(o,i){i!==o&&(a=b(P(e,"numSep",o),t,r,u,n),E(u,a))}),e.$watch("numPos",function(o,i){i!==o&&(a=b(P(e,"numPos",o),t,r,u,n),E(u,a))}),e.$watch("numNeg",function(o,i){i!==o&&(a=b(P(e,"numNeg",o),t,r,u,n),E(u,a))}),e.$watch("numThousand",function(o,i){i!==o&&(a=b(P(e,"numThousand",o),t,r,u,n),E(u,a))}),e.$watch("numThousandSep",function(o,i){i!==o&&(a=b(P(e,"numThousandSep",o),t,r,u,n),E(u,a))}),e.$watch("numAppend",function(o,i){i!==o&&(a=b(P(e,"numAppend",o),t,r,u,n),E(u,a))}),e.$watch("numPrepend",function(o,i){i!==o&&(a=b(P(e,"numPrepend",o),t,r,u,n),E(u,a))});var o={enable:!0,count:0};u.$parsers.unshift(function(n){return o.enable?(o.count++,T(y(n,a,o))):(o.enable=!0,n)}),u.$formatters.push(function(n){return $(n,a.fractionPart,a.fractionSeparator,a.roundFunction,!1,a.isThousandSeparator,a.thousandSeparator,a.prepend,a.append)})}}}var I=!1,M="dynamicNumber";return n.module(M,[]).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",["dynamicNumberStrategy",function(e){return function(t,r,u,i,c,l,g,v,S){var h,w={};n.isString(r)&&(w=e.getStrategy(r),r=w.numFract);var h=a(r,2),N=o(void 0!==u?u:w.numSep,"."),R=d(void 0!==i?i:w.numRound,Math.round),x=m(void 0!==c?c:w.numFixed,!1),T=p(void 0!==l?l:w.numThousand,!1),P=s(void 0!==g?g:w.numThousandSep,N,"."===N?",":"."),b=f(void 0!==v?v:w.numPrepend),y=f(void 0!==S?S:w.numAppend),F=$(t,h,N,R,x,T,P,b,y);return""===F?"0":F}}]).directive("awnum",["dynamicNumberStrategy",A]),M});

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