jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

call to DSCacheFactory(...) produces JSHint warning #117

Closed scheffield closed 10 years ago

scheffield commented 10 years ago

A call like

var profileCache = DSCacheFactory('profileCache');

produces a JSHint warning if the option newcap is activated.

Generally, I think there are two possible solutions

  1. Rename the factory to have it beginning with an lowercase letter, or
  2. Introduce a method createCache

IMHO 2. is the right one, because calling a factory directly doesn't look very naturally to me. This would look like the following:

var profileCache = DSCacheFactory.createCache('profileCache');
jmdobry commented 10 years ago

The only reason it works the way it does now it because that's how $cacheFactory works. I can add .createCache in a backwards compatible way though.

scheffield commented 10 years ago

Hi,

that would fix the warning. But to work more like $cacheFactory it would be much better you call it dsCacheFactory.

BTW: why don't you get a jshint warning? You use "newcap": true" in your .jshintrc too.