Socket
Socket
Sign inDemoInstall

ng-http-rate-limiter

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

.eslintignore

2

bower.json
{
"name": "ng-http-rate-limiter",
"version": "1.0.1",
"version": "1.0.2",
"authors": [

@@ -5,0 +5,0 @@ "Ben Hollis <ben@benhollis.net>"

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

1.0.2
-----
* Removed an accidental global underscore dependency.
1.0.0

@@ -2,0 +7,0 @@ -----

@@ -1,19 +0,18 @@

/*! ng-http-rate-limiter 1.0.0 2016-05-21 - MIT Licensed, see http://github.com/bhollis/ng-http-rate-limiter */
(function (root, factory) {
if (typeof module !== 'undefined' && module.exports) {
// CommonJS
if (typeof angular === 'undefined') {
factory(require('angular'));
} else {
factory(angular);
}
module.exports = 'ngDialog';
} else if (typeof define === 'function' && define.amd) {
// AMD
define(['angular'], factory);
/*! ng-http-rate-limiter 1.0.2 2017-01-18 - MIT Licensed, see http://github.com/bhollis/ng-http-rate-limiter */
(function(root, factory) {
if (typeof module !== 'undefined' && module.exports) {
// CommonJS
if (typeof angular === 'undefined') {
factory(require('angular'));
} else {
// Global Variables
factory(root.angular);
factory(angular);
}
}(this, function (angular) {
} else if (typeof define === 'function' && define.amd) {
// AMD
define(['angular'], factory);
} else {
// Global Variables
factory(root.angular);
}
})(this, function(angular) {
"use strict";

@@ -23,3 +22,2 @@

.factory("ngHttpRateLimiterQueue", ["$timeout", "$window", function rateLimiterQueue($timeout, $window) {
function RateLimiterQueue(pattern, requestLimit, timeLimit) {

@@ -96,3 +94,3 @@ this.pattern = pattern;

return RateLimiterQueueFactory;
}])
}])

@@ -123,3 +121,2 @@ .provider("ngHttpRateLimiterConfig", function rateLimiterConfig() {

}];
})

@@ -130,3 +127,3 @@

request: function(config) {
var limiter = _.find(rateLimiterConfig.getLimiters(), function(l) {
var limiter = rateLimiterConfig.getLimiters().find(function(l) {
return l.matches(config.url);

@@ -144,5 +141,3 @@ });

};
}]);
}));
});

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

/*! ng-http-rate-limiter 1.0.0 2016-05-21 - MIT Licensed, see http://github.com/bhollis/ng-http-rate-limiter */
!function(a,b){"undefined"!=typeof module&&module.exports?(b("undefined"==typeof angular?require("angular"):angular),module.exports="ngDialog"):"function"==typeof define&&define.amd?define(["angular"],b):b(a.angular)}(this,function(a){"use strict";a.module("ngHttpRateLimiter",[]).factory("ngHttpRateLimiterQueue",["$timeout","$window",function(b,c){function d(a,b,d){this.pattern=a,this.requestLimit=b,this.timeLimit=d||1e3,this.queue=[],this.count=0,this.lastRequestTime=c.performance.now(),this.timer=void 0}function e(a,b,c){return new d(a,b,c)}return a.extend(d.prototype,{matches:function(a){return a.match(this.pattern)},add:function(a,b){this.queue.push({config:a,deferred:b}),this.processQueue()},scheduleProcessing:function(){if(!a.isDefined(this.interval)){var d=Math.max(0,this.timeLimit-(c.performance.now()-this.lastRequestTime));this.timer=b(function(){this.timer=void 0,this.processQueue()}.bind(this),d)}},processQueue:function(){for(;this.queue.length;){if(!this.canProcess())return void this.scheduleProcessing();var a=this.queue.shift();a.deferred.resolve(a.config)}},canProcess:function(){var a=c.performance.now(),b=a-this.lastRequestTime;return b>=this.timeLimit&&(this.lastRequestTime=a,this.count=0),this.count<this.requestLimit?(this.count++,!0):!1}}),e}]).provider("ngHttpRateLimiterConfig",function(){var a=[],b=[];this.addLimiter=function(b,c,d){a.push({pattern:b,requestLimit:c,timeLimit:d})},this.$get=["ngHttpRateLimiterQueue",function(c){for(;a.length;){var d=a.shift();b.push(c(d.pattern,d.requestLimit,d.timeLimit))}return{getLimiters:function(){return b}}}]}).factory("ngHttpRateLimiterInterceptor",["$q","ngHttpRateLimiterConfig",function(a,b){return{request:function(c){var d=_.find(b.getLimiters(),function(a){return a.matches(c.url)});if(d){var e=a.defer();return d.add(c,e),e.promise}return c}}}])});
/*! ng-http-rate-limiter 1.0.2 2017-01-18 - MIT Licensed, see http://github.com/bhollis/ng-http-rate-limiter */
!function(a,b){"undefined"!=typeof module&&module.exports?b("undefined"==typeof angular?require("angular"):angular):"function"==typeof define&&define.amd?define(["angular"],b):b(a.angular)}(this,function(a){"use strict";a.module("ngHttpRateLimiter",[]).factory("ngHttpRateLimiterQueue",["$timeout","$window",function(b,c){function d(a,b,d){this.pattern=a,this.requestLimit=b,this.timeLimit=d||1e3,this.queue=[],this.count=0,this.lastRequestTime=c.performance.now(),this.timer=void 0}function e(a,b,c){return new d(a,b,c)}return a.extend(d.prototype,{matches:function(a){return a.match(this.pattern)},add:function(a,b){this.queue.push({config:a,deferred:b}),this.processQueue()},scheduleProcessing:function(){if(!a.isDefined(this.interval)){var d=Math.max(0,this.timeLimit-(c.performance.now()-this.lastRequestTime));this.timer=b(function(){this.timer=void 0,this.processQueue()}.bind(this),d)}},processQueue:function(){for(;this.queue.length;){if(!this.canProcess())return void this.scheduleProcessing();var a=this.queue.shift();a.deferred.resolve(a.config)}},canProcess:function(){var a=c.performance.now(),b=a-this.lastRequestTime;return b>=this.timeLimit&&(this.lastRequestTime=a,this.count=0),this.count<this.requestLimit&&(this.count++,!0)}}),e}]).provider("ngHttpRateLimiterConfig",function(){var a=[],b=[];this.addLimiter=function(b,c,d){a.push({pattern:b,requestLimit:c,timeLimit:d})},this.$get=["ngHttpRateLimiterQueue",function(c){for(;a.length;){var d=a.shift();b.push(c(d.pattern,d.requestLimit,d.timeLimit))}return{getLimiters:function(){return b}}}]}).factory("ngHttpRateLimiterInterceptor",["$q","ngHttpRateLimiterConfig",function(a,b){return{request:function(c){var d=b.getLimiters().find(function(a){return a.matches(c.url)});if(d){var e=a.defer();return d.add(c,e),e.promise}return c}}}])});

@@ -32,12 +32,5 @@ module.exports = function(grunt) {

},
jshint: {
// define the files to lint
files: ['Gruntfile.js', '<%= pkg.name %>.js', 'ng-<%= pkg.name %>.js', 'test/**/*.js'],
// configure JSHint (documented at http://www.jshint.com/docs/)
options: {
// more options here if you want to override JSHint defaults
globals: {
module: true
}
}
eslint: {
src: ["ng-http-rate-limiter.js"]
}

@@ -48,7 +41,7 @@ });

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks("gruntify-eslint");
grunt.loadNpmTasks('grunt-banner');
grunt.registerTask('default', ['jshint', 'copy', 'uglify', 'usebanner']);
grunt.registerTask('test', ['jshint']);
grunt.registerTask('default', ['eslint', 'copy', 'uglify', 'usebanner']);
grunt.registerTask('test', ['eslint']);
};

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

(function (root, factory) {
(function(root, factory) {
if (typeof module !== 'undefined' && module.exports) {

@@ -9,3 +9,2 @@ // CommonJS

}
module.exports = 'ngDialog';
} else if (typeof define === 'function' && define.amd) {

@@ -18,3 +17,3 @@ // AMD

}
}(this, function (angular) {
})(this, function(angular) {
"use strict";

@@ -24,3 +23,2 @@

.factory("ngHttpRateLimiterQueue", ["$timeout", "$window", function rateLimiterQueue($timeout, $window) {
function RateLimiterQueue(pattern, requestLimit, timeLimit) {

@@ -97,3 +95,3 @@ this.pattern = pattern;

return RateLimiterQueueFactory;
}])
}])

@@ -124,3 +122,2 @@ .provider("ngHttpRateLimiterConfig", function rateLimiterConfig() {

}];
})

@@ -131,3 +128,3 @@

request: function(config) {
var limiter = _.find(rateLimiterConfig.getLimiters(), function(l) {
var limiter = rateLimiterConfig.getLimiters().find(function(l) {
return l.matches(config.url);

@@ -145,5 +142,3 @@ });

};
}]);
}));
});
{
"name": "ng-http-rate-limiter",
"version": "1.0.1",
"version": "1.0.2",
"description": "$http rate limiting in Angular",
"main": "ng-http-rate-limiter.js",
"scripts": {
"start": "grunt",
"test": "grunt test"

@@ -22,7 +23,8 @@ },

"grunt": "~1.0.0",
"grunt-contrib-jshint": "~1.0.0",
"grunt-banner": "~0.6.0",
"grunt-cli": "^1.2.0",
"grunt-contrib-copy": "~1.0.0",
"grunt-contrib-uglify": "~1.0.0",
"grunt-contrib-copy": "~1.0.0",
"grunt-banner": "~0.6.0"
"gruntify-eslint": "^3.1.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc