meddelare-counters
Advanced tools
Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3
@@ -7,3 +7,3 @@ "use strict"; | ||
// The memory-cache is per-process and returns pointers, not copies. | ||
// Using process-scoped keys with a SocialButtonsCounts "namespace", so multiple SocialButtonsCounts instances share cache. | ||
// Using process-scoped keys with a MeddelareCounters "namespace", so multiple MeddelareCounters instances share cache. | ||
// Using cache.clear() will clear all caches, even in other parts of the application. Be careful! | ||
@@ -37,5 +37,5 @@ cache = require("memory-cache"), | ||
function SocialButtonsCounts(options) { | ||
function MeddelareCounters(options) { | ||
options = options || {}; | ||
this._options = copyDeep(SocialButtonsCounts._defaultOptions, options); | ||
this._options = copyDeep(MeddelareCounters._defaultOptions, options); | ||
@@ -57,3 +57,3 @@ // Set logger separately instead of relying on the deep copy. | ||
SocialButtonsCounts.prototype._networkCallbacks = { | ||
MeddelareCounters.prototype._networkCallbacks = { | ||
twitter: function(url, callback) { | ||
@@ -137,7 +137,7 @@ // Twitter is nice and easy | ||
SocialButtonsCounts.prototype.isValidNetwork = function(network) { | ||
MeddelareCounters.prototype.isValidNetwork = function(network) { | ||
return Object.prototype.hasOwnProperty.call(this._networkCallbacks, network); | ||
}; | ||
SocialButtonsCounts.prototype.getInvalidNetworks = function(networks) { | ||
MeddelareCounters.prototype.getInvalidNetworks = function(networks) { | ||
return networks.filter(function(network) { | ||
@@ -148,3 +148,3 @@ return !this.isValidNetwork(network); | ||
SocialButtonsCounts.prototype.retrieveUncachedCount = function(url, network) { | ||
MeddelareCounters.prototype.retrieveUncachedCount = function(url, network) { | ||
if (!this.isValidNetwork(network)) { | ||
@@ -164,5 +164,5 @@ throw new Error("Unknown network: " + network); | ||
SocialButtonsCounts.prototype.getCachedOrRetrieveCount = function(url, network) { | ||
MeddelareCounters.prototype.getCachedOrRetrieveCount = function(url, network) { | ||
var self = this, | ||
cacheKey = SocialButtonsCounts._createCacheKey(url, network); | ||
cacheKey = MeddelareCounters._createCacheKey(url, network); | ||
@@ -201,3 +201,3 @@ return Promise.resolve(cache.get(cacheKey)) | ||
SocialButtonsCounts.prototype.retrieveCounts = function(url, networks) { | ||
MeddelareCounters.prototype.retrieveCounts = function(url, networks) { | ||
// Create an object of callbacks for each of the requested networks It is | ||
@@ -218,4 +218,4 @@ // then passed to the Promise library to executed in parallel All results will | ||
SocialButtonsCounts._createCacheKey = function(url, network) { | ||
return "SocialButtonsCounts " + network + " '" + url + "'"; | ||
MeddelareCounters._createCacheKey = function(url, network) { | ||
return "MeddelareCounters " + network + " '" + url + "'"; | ||
}; | ||
@@ -225,3 +225,3 @@ | ||
SocialButtonsCounts._defaultOptions = { | ||
MeddelareCounters._defaultOptions = { | ||
// Cache results in memory -- but keep good and bad (error thrown) results for different periods of time. | ||
@@ -239,2 +239,2 @@ // (In milliseconds.) | ||
module.exports = SocialButtonsCounts; | ||
module.exports = MeddelareCounters; |
{ | ||
"name": "meddelare-counters", | ||
"version": "1.0.0-alpha.2", | ||
"version": "1.0.0-alpha.3", | ||
"description": "Node.js promise-based, asynchronous, parallel, per-URL social network share count fetcher -- the base of Meddelare.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://meddelare.com/", |
@@ -43,4 +43,4 @@ # [Meddelare](http://meddelare.com/) Social Buttons Share Count Fetcher [meddelare-node-counters](https://github.com/meddelare/meddelare-node-counters) | ||
```javascript | ||
var SocialButtonsCounts = require("meddelare-counters"), | ||
socialButtonsCounts = new SocialButtonsCounts(); | ||
var MeddelareCounters = require("meddelare-counters"), | ||
meddelareCounters = new MeddelareCounters(); | ||
@@ -55,3 +55,3 @@ // Use your own website here, or a specific page url. | ||
socialButtonsCounts.retrieveCounts(url, networks) | ||
meddelareCounters.retrieveCounts(url, networks) | ||
.then(function(results) { | ||
@@ -93,3 +93,3 @@ console.log("Success!", results); | ||
Configure the middleware instance at creation time, for example `new SocialButtonsCounts({ unknownCount: 0 })`. | ||
Configure the middleware instance at creation time, for example `new MeddelareCounters({ unknownCount: 0 })`. | ||
@@ -96,0 +96,0 @@ These are the default values. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18740