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

ng-utilities

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-utilities - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

src/numbers/range.js

8

bower.json
{
"name": "ng-utilities",
"version": "1.0.2",
"version": "1.0.3",
"ignore": [

@@ -18,4 +18,4 @@ "**/.*",

"dependencies": {
"angular": "~1.3",
"angular-messages": "~1.3",
"angular": "^1.3",
"angular-messages": "^1.3",
"moment": "~2.9.0",

@@ -25,5 +25,5 @@ "moment-timezone": "~0.3.0"

"devDependencies": {
"angular-mocks": "~1.3",
"angular-mocks": "^1.3",
"jquery": "~2.1.3"
}
}

@@ -274,2 +274,36 @@ 'use strict';

angular.module('ngUtilities.numbers')
/**
* Defines a filter to generate a range of values.
* Write as : [5] | nguRange or [1,5] | nguRange
*/
.filter('nguRange', function() {
return function(input) {
if (!input || !angular.isArray(input)) {
return undefined;
}
var lowBound, highBound;
switch (input.length) {
case 1:
lowBound = 0;
highBound = parseInt(input[0]) - 1;
break;
case 2:
lowBound = parseInt(input[0]);
highBound = parseInt(input[1]);
break;
default:
return undefined;
}
var result = [];
for (var i = lowBound; i <= highBound; i++) {
result.push(i);
}
return result;
};
});
'use strict';
angular.module('ngUtilities.strings')

@@ -276,0 +310,0 @@ /**

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

"use strict";angular.module("ngUtilities.arrays",[]),angular.module("ngUtilities.dates",[]),angular.module("ngUtilities.forms",[]),angular.module("ngUtilities.numbers",[]),angular.module("ngUtilities.strings",[]),angular.module("ngUtilities.validators",["ngUtilities.strings","ngUtilities.arrays","ngUtilities.numbers"]),angular.module("ngUtilities.arrays").filter("nguSize",function(){return function(a){return angular.isArray(a)?a.length:0}}).filter("nguRemainingSize",["$filter",function(a){return function(b,c){var d=parseInt(c);return isNaN(d)?void 0:(d-=a("nguSize")(b),0>d&&(d=0),d)}}]).filter("nguInArray",function(){return function(a,b){return angular.isArray(b)?b.indexOf(a)>=0:!1}}),angular.module("ngUtilities.dates").provider("nguDateTimeFormat",function(){this.dateFormat="DD-MMM-YYYY",this.timeFormat="HH:mm",this.timeZone="UTC",this.$get=function(){return{dateFormat:this.dateFormat,timeFormat:this.timeFormat,timeZone:this.timeZone}}}).filter("nguDate",["nguDateTimeFormat",function(a){return function(b){if(b){var c=moment(b).tz(a.timeZone).format(a.dateFormat);return"Invalid date"===c?"":c}return""}}]).filter("nguTime",["nguDateTimeFormat",function(a){return function(b){if(b){var c=moment(b).tz(a.timeZone).format(a.timeFormat);return"Invalid date"===c?"":c}return""}}]).filter("nguDateTime",["$filter",function(a){return function(b){var c=a("nguDate")(b)||"",d=a("nguTime")(b)||"",e=c;return""!==e&&""!==d&&(e+=" "),e+=d}}]),angular.module("ngUtilities.debug",[]).filter("nguDebugType",function(){return function(a){return typeof a}}),angular.module("ngUtilities.forms").directive("nguEnter",function(){return function(a,b,c){b.bind("keydown keypress",function(b){var d=b.keyCode||b.which;13!==d||b.shiftKey||(b.preventDefault(),a.$apply(c.nguEnter))})}}),angular.module("ngUtilities",["ngUtilities.strings","ngUtilities.arrays","ngUtilities.numbers","ngUtilities.forms","ngUtilities.dates","ngUtilities.validators","ngUtilities.debug"]),angular.module("ngUtilities.numbers").filter("nguFractionalPart",["$filter",function(a){return function(b,c){if(!b)return void 0;var d;d=angular.isUndefined(c)?b+"":a("number")(b,c);var e=d.split("."),f="";return e.length>1&&(f=e[1]),f}}]),angular.module("ngUtilities.numbers").filter("nguDigitsOnly",function(){return function(a){return angular.isString(a)?a.replace(/[^0-9]/g,""):a}}).filter("nguDigitsMinusOnly",function(){return function(a){return angular.isString(a)?a.replace(/[^0-9\-]/g,"").replace(/(?!^)[^0-9]/g,""):a}}).directive("nguInputDigitsOnly",["$filter",function(a){return{require:"ngModel",restrict:"A",link:function(b,c,d,e){e.$parsers.push(function(b){var c=a("nguDigitsOnly")(b);return c!==b&&(e.$setViewValue(c),e.$render()),""!==c?parseInt(c,10):void 0})}}}]).directive("nguInputDigitsMinusOnly",["$filter",function(a){return{require:"ngModel",restrict:"A",link:function(b,c,d,e){e.$parsers.push(function(b){var c=a("nguDigitsMinusOnly")(b);return c!==b&&(e.$setViewValue(c),e.$render()),""!==c&&"-"!==c?parseInt(c,10):void 0})}}}]),angular.module("ngUtilities.strings").filter("nguCapitalize",["$filter",function(a){return function(b){var c=a("nguLength")(b),d="";return c>0&&(d+=a("uppercase")(b.toString().substring(0,1))),c>1&&(d+=a("lowercase")(b.toString().substring(1))),d}}]).filter("nguLength",function(){return function(a){return(""+(a||"")).length}}).filter("nguRemainingLength",["$filter",function(a){return function(b,c){var d=parseInt(c);return isNaN(d)?void 0:(d-=a("nguLength")(b),0>d&&(d=0),d)}}]),angular.module("ngUtilities.strings").filter("nguPadLeft",function(){return function(a,b,c){if(a&&b){for(var d=parseInt(c)-a.toString().length,e=0;d>e;e++)a=b.toString()+a;return a}return void 0}}).filter("nguPadRight",function(){return function(a,b,c){if(a&&b){for(var d=parseInt(c)-a.toString().length,e=0;d>e;e++)a+=b.toString();return a}return void 0}}),angular.module("ngUtilities.validators").directive("nguValIn",["$filter",function(a){return{restrict:"A",require:"ngModel",scope:{haystack:"=nguValIn"},link:function(b,c,d,e){e.$validators.nguValIn=function(c){return a("nguInArray")(c,b.haystack)}}}}]).directive("nguValNotIn",["$filter",function(a){return{restrict:"A",require:"ngModel",scope:{haystack:"=nguValNotIn"},link:function(b,c,d,e){e.$validators.nguValNotIn=function(c){return angular.isArray(b.haystack)&&a("nguInArray")(c,b.haystack)===!1}}}}]),angular.module("ngUtilities.validators").directive("nguValEqualTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValEqualTo"},link:function(a,b,c,d){d.$validators.nguValEqualTo=function(b){return b===a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}).directive("nguValLeTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValLeTo"},link:function(a,b,c,d){d.$validators.nguValLeTo=function(b){return b<=a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}).directive("nguValLtTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValLtTo"},link:function(a,b,c,d){d.$validators.nguValLtTo=function(b){return b<a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}).directive("nguValGeTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValGeTo"},link:function(a,b,c,d){d.$validators.nguValGeTo=function(b){return b>=a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}).directive("nguValGtTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValGtTo"},link:function(a,b,c,d){d.$validators.nguValGtTo=function(b){return b>a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}),angular.module("ngUtilities.validators").directive("nguValFractionalLengthMin",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValFractionalLengthMin=function(b){if(b){var c=parseInt(d.nguValFractionalLengthMin);if(isNaN(c)||isNaN(b))return!1;var e=a("nguFractionalPart")(b);return e.length>=c}return!0}}}}]).directive("nguValFractionalLengthMax",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValFractionalLengthMin=function(b){if(b){var c=parseInt(d.nguValFractionalLengthMax);if(isNaN(c)||isNaN(b))return!1;var e=a("nguFractionalPart")(b);return e.length<=c}return!0}}}}]),angular.module("ngUtilities.validators").directive("nguValIntMin",function(){return{restrict:"A",require:"ngModel",link:function(a,b,c,d){d.$validators.nguValIntMin=function(a){if(a){var b=parseInt(a),d=parseInt(c.nguValIntMin);return isNaN(d)||isNaN(b)?!1:b>=d}return!0}}}}).directive("nguValIntMax",function(){return{restrict:"A",require:"ngModel",link:function(a,b,c,d){d.$validators.nguValIntMax=function(a){if(a){var b=parseInt(a),d=parseInt(c.nguValIntMax);return isNaN(d)||isNaN(b)?!1:d>=b}return!0}}}}),angular.module("ngUtilities.validators").directive("nguValPasswordSecure",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValPasswordSecure=function(b){return a("nguLength")(b)>=8&&/[a-z]/i.test(b)&&/[0-9]/.test(b)&&/[^a-z0-9]/i.test(b)}}}}]),angular.module("ngUtilities.validators").directive("nguValLengthMin",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValLengthMin=function(b){var c=parseInt(d.nguValLengthMin);if(isNaN(c))return!1;b&&b.trim&&(b=b.trim());var e=a("nguLength")(b);return e>=c}}}}]).directive("nguValLengthMax",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValLengthMin=function(b){var c=parseInt(d.nguValLengthMax);if(isNaN(c))return!1;b&&b.trim&&(b=b.trim());var e=a("nguLength")(b);return c>=e}}}}]);
"use strict";angular.module("ngUtilities.arrays",[]),angular.module("ngUtilities.dates",[]),angular.module("ngUtilities.forms",[]),angular.module("ngUtilities.numbers",[]),angular.module("ngUtilities.strings",[]),angular.module("ngUtilities.validators",["ngUtilities.strings","ngUtilities.arrays","ngUtilities.numbers"]),angular.module("ngUtilities.arrays").filter("nguSize",function(){return function(a){return angular.isArray(a)?a.length:0}}).filter("nguRemainingSize",["$filter",function(a){return function(b,c){var d=parseInt(c);return isNaN(d)?void 0:(d-=a("nguSize")(b),0>d&&(d=0),d)}}]).filter("nguInArray",function(){return function(a,b){return angular.isArray(b)?b.indexOf(a)>=0:!1}}),angular.module("ngUtilities.dates").provider("nguDateTimeFormat",function(){this.dateFormat="DD-MMM-YYYY",this.timeFormat="HH:mm",this.timeZone="UTC",this.$get=function(){return{dateFormat:this.dateFormat,timeFormat:this.timeFormat,timeZone:this.timeZone}}}).filter("nguDate",["nguDateTimeFormat",function(a){return function(b){if(b){var c=moment(b).tz(a.timeZone).format(a.dateFormat);return"Invalid date"===c?"":c}return""}}]).filter("nguTime",["nguDateTimeFormat",function(a){return function(b){if(b){var c=moment(b).tz(a.timeZone).format(a.timeFormat);return"Invalid date"===c?"":c}return""}}]).filter("nguDateTime",["$filter",function(a){return function(b){var c=a("nguDate")(b)||"",d=a("nguTime")(b)||"",e=c;return""!==e&&""!==d&&(e+=" "),e+=d}}]),angular.module("ngUtilities.debug",[]).filter("nguDebugType",function(){return function(a){return typeof a}}),angular.module("ngUtilities.forms").directive("nguEnter",function(){return function(a,b,c){b.bind("keydown keypress",function(b){var d=b.keyCode||b.which;13!==d||b.shiftKey||(b.preventDefault(),a.$apply(c.nguEnter))})}}),angular.module("ngUtilities",["ngUtilities.strings","ngUtilities.arrays","ngUtilities.numbers","ngUtilities.forms","ngUtilities.dates","ngUtilities.validators","ngUtilities.debug"]),angular.module("ngUtilities.numbers").filter("nguFractionalPart",["$filter",function(a){return function(b,c){if(!b)return void 0;var d;d=angular.isUndefined(c)?b+"":a("number")(b,c);var e=d.split("."),f="";return e.length>1&&(f=e[1]),f}}]),angular.module("ngUtilities.numbers").filter("nguDigitsOnly",function(){return function(a){return angular.isString(a)?a.replace(/[^0-9]/g,""):a}}).filter("nguDigitsMinusOnly",function(){return function(a){return angular.isString(a)?a.replace(/[^0-9\-]/g,"").replace(/(?!^)[^0-9]/g,""):a}}).directive("nguInputDigitsOnly",["$filter",function(a){return{require:"ngModel",restrict:"A",link:function(b,c,d,e){e.$parsers.push(function(b){var c=a("nguDigitsOnly")(b);return c!==b&&(e.$setViewValue(c),e.$render()),""!==c?parseInt(c,10):void 0})}}}]).directive("nguInputDigitsMinusOnly",["$filter",function(a){return{require:"ngModel",restrict:"A",link:function(b,c,d,e){e.$parsers.push(function(b){var c=a("nguDigitsMinusOnly")(b);return c!==b&&(e.$setViewValue(c),e.$render()),""!==c&&"-"!==c?parseInt(c,10):void 0})}}}]),angular.module("ngUtilities.numbers").filter("nguRange",function(){return function(a){if(!a||!angular.isArray(a))return void 0;var b,c;switch(a.length){case 1:b=0,c=parseInt(a[0])-1;break;case 2:b=parseInt(a[0]),c=parseInt(a[1]);break;default:return void 0}for(var d=[],e=b;c>=e;e++)d.push(e);return d}}),angular.module("ngUtilities.strings").filter("nguCapitalize",["$filter",function(a){return function(b){var c=a("nguLength")(b),d="";return c>0&&(d+=a("uppercase")(b.toString().substring(0,1))),c>1&&(d+=a("lowercase")(b.toString().substring(1))),d}}]).filter("nguLength",function(){return function(a){return(""+(a||"")).length}}).filter("nguRemainingLength",["$filter",function(a){return function(b,c){var d=parseInt(c);return isNaN(d)?void 0:(d-=a("nguLength")(b),0>d&&(d=0),d)}}]),angular.module("ngUtilities.strings").filter("nguPadLeft",function(){return function(a,b,c){if(a&&b){for(var d=parseInt(c)-a.toString().length,e=0;d>e;e++)a=b.toString()+a;return a}return void 0}}).filter("nguPadRight",function(){return function(a,b,c){if(a&&b){for(var d=parseInt(c)-a.toString().length,e=0;d>e;e++)a+=b.toString();return a}return void 0}}),angular.module("ngUtilities.validators").directive("nguValIn",["$filter",function(a){return{restrict:"A",require:"ngModel",scope:{haystack:"=nguValIn"},link:function(b,c,d,e){e.$validators.nguValIn=function(c){return a("nguInArray")(c,b.haystack)}}}}]).directive("nguValNotIn",["$filter",function(a){return{restrict:"A",require:"ngModel",scope:{haystack:"=nguValNotIn"},link:function(b,c,d,e){e.$validators.nguValNotIn=function(c){return angular.isArray(b.haystack)&&a("nguInArray")(c,b.haystack)===!1}}}}]),angular.module("ngUtilities.validators").directive("nguValEqualTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValEqualTo"},link:function(a,b,c,d){d.$validators.nguValEqualTo=function(b){return b===a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}).directive("nguValLeTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValLeTo"},link:function(a,b,c,d){d.$validators.nguValLeTo=function(b){return b<=a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}).directive("nguValLtTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValLtTo"},link:function(a,b,c,d){d.$validators.nguValLtTo=function(b){return b<a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}).directive("nguValGeTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValGeTo"},link:function(a,b,c,d){d.$validators.nguValGeTo=function(b){return b>=a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}).directive("nguValGtTo",function(){return{restrict:"A",require:"ngModel",scope:{otherModelValue:"=nguValGtTo"},link:function(a,b,c,d){d.$validators.nguValGtTo=function(b){return b>a.otherModelValue},a.$watch("otherModelValue",function(){d.$validate()})}}}),angular.module("ngUtilities.validators").directive("nguValFractionalLengthMin",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValFractionalLengthMin=function(b){if(b){var c=parseInt(d.nguValFractionalLengthMin);if(isNaN(c)||isNaN(b))return!1;var e=a("nguFractionalPart")(b);return e.length>=c}return!0}}}}]).directive("nguValFractionalLengthMax",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValFractionalLengthMin=function(b){if(b){var c=parseInt(d.nguValFractionalLengthMax);if(isNaN(c)||isNaN(b))return!1;var e=a("nguFractionalPart")(b);return e.length<=c}return!0}}}}]),angular.module("ngUtilities.validators").directive("nguValIntMin",function(){return{restrict:"A",require:"ngModel",link:function(a,b,c,d){d.$validators.nguValIntMin=function(a){if(a){var b=parseInt(a),d=parseInt(c.nguValIntMin);return isNaN(d)||isNaN(b)?!1:b>=d}return!0}}}}).directive("nguValIntMax",function(){return{restrict:"A",require:"ngModel",link:function(a,b,c,d){d.$validators.nguValIntMax=function(a){if(a){var b=parseInt(a),d=parseInt(c.nguValIntMax);return isNaN(d)||isNaN(b)?!1:d>=b}return!0}}}}),angular.module("ngUtilities.validators").directive("nguValPasswordSecure",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValPasswordSecure=function(b){return a("nguLength")(b)>=8&&/[a-z]/i.test(b)&&/[0-9]/.test(b)&&/[^a-z0-9]/i.test(b)}}}}]),angular.module("ngUtilities.validators").directive("nguValLengthMin",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValLengthMin=function(b){var c=parseInt(d.nguValLengthMin);if(isNaN(c))return!1;b&&b.trim&&(b=b.trim());var e=a("nguLength")(b);return e>=c}}}}]).directive("nguValLengthMax",["$filter",function(a){return{restrict:"A",require:"ngModel",link:function(b,c,d,e){e.$validators.nguValLengthMin=function(b){var c=parseInt(d.nguValLengthMax);if(isNaN(c))return!1;b&&b.trim&&(b=b.trim());var e=a("nguLength")(b);return c>=e}}}}]);
{
"name": "ng-utilities",
"version": "1.0.2",
"version": "1.0.3",
"description": "Angular utilities for validation, filters...",

@@ -5,0 +5,0 @@ "scripts": {

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