Răsfoiți Sursa

document undocumented functions

jomo 5 ani în urmă
părinte
comite
e0233f2899
6 a modificat fișierele cu 14 adăugiri și 5 ștergeri
  1. 2 2
      README.md
  2. 3 3
      lib/helpers.js
  3. 4 0
      lib/logging.js
  4. 2 0
      lib/networking.js
  5. 1 0
      lib/routes/index.js
  6. 2 0
      lib/server.js

+ 2 - 2
README.md

@@ -1,5 +1,5 @@
-# Crafatar [![travis](https://img.shields.io/travis/crafatar/crafatar/master.svg?style=flat-square)](https://travis-ci.org/crafatar/crafatar/) [![Coverage Status](https://img.shields.io/coveralls/crafatar/crafatar.svg?style=flat-square)](https://coveralls.io/r/crafatar/crafatar) [![Code Climate](https://img.shields.io/codeclimate/github/crafatar/crafatar.svg?style=flat-square)](https://codeclimate.com/github/crafatar/crafatar)
-[![dependency status](https://img.shields.io/david/crafatar/crafatar.svg?style=flat-square)](https://david-dm.org/crafatar/crafatar) [![devDependency status](https://img.shields.io/david/dev/crafatar/crafatar.svg?style=flat-square)](https://david-dm.org/crafatar/crafatar#info=devDependencies) [![docs status](https://inch-ci.org/github/crafatar/crafatar.svg?branch=master&style=flat-square)](https://inch-ci.org/github/crafatar/crafatar)
+# Crafatar
+[![travis](https://img.shields.io/travis/crafatar/crafatar/master.svg?style=flat-square)](https://travis-ci.org/crafatar/crafatar/) [![Coverage Status](https://img.shields.io/coveralls/crafatar/crafatar.svg?style=flat-square)](https://coveralls.io/r/crafatar/crafatar) [![Code Climate](https://img.shields.io/codeclimate/github/crafatar/crafatar.svg?style=flat-square)](https://codeclimate.com/github/crafatar/crafatar) [![dependency status](https://img.shields.io/david/crafatar/crafatar.svg?style=flat-square)](https://david-dm.org/crafatar/crafatar) [![devDependency status](https://img.shields.io/david/dev/crafatar/crafatar.svg?style=flat-square)](https://david-dm.org/crafatar/crafatar#info=devDependencies) [![docs status](https://inch-ci.org/github/crafatar/crafatar.svg?branch=master&style=flat-square)](https://inch-ci.org/github/crafatar/crafatar)
 
 
 <img alt="logo" src="lib/public/logo.png" align="right">

+ 3 - 3
lib/helpers.js

@@ -122,13 +122,14 @@ var requests = {
   cape: {}
 };
 
-function push_request(userId, type, fun) {
+// add a request for +userId+ and +type+ to the queue
+function push_request(userId, type, callback) {
   // avoid special properties (e.g. 'constructor')
   var userId_safe = "!" + userId;
   if (!requests[type][userId_safe]) {
     requests[type][userId_safe] = [];
   }
-  requests[type][userId_safe].push(fun);
+  requests[type][userId_safe].push(callback);
 }
 
 // calls back all queued requests that match userId and type
@@ -162,7 +163,6 @@ function store_images(rid, userId, cache_details, type, callback) {
     logging.debug(rid, "adding to request queue");
     push_request(userId, type, callback);
   } else {
-    // add request to the queue
     push_request(userId, type, callback);
 
     networking.get_profile(rid, userId, function(err, profile) {

+ 4 - 0
lib/logging.js

@@ -23,15 +23,19 @@ function log(level, args, logger) {
   }
 }
 
+// log with INFO level
 exp.log = function() {
   log(" INFO", arguments);
 };
+// log with WARN level
 exp.warn = function() {
   log(" WARN", arguments, console.warn);
 };
+// log with ERROR level
 exp.error = function() {
   log("ERROR", arguments, console.error);
 };
+// log with DEBUG level if debug logging is enabled
 if (config.server.debug_enabled) {
   exp.debug = function() {
     log("DEBUG", arguments);

+ 2 - 0
lib/networking.js

@@ -13,6 +13,7 @@ var session_requests = [];
 
 var exp = {};
 
+// returns the amount of outgoing session requests made in the last 1000ms
 function req_count() {
   var index = session_requests.findIndex((i) => i >= Date.now() - 1000);
   if (index >= 0) {
@@ -22,6 +23,7 @@ function req_count() {
   }
 }
 
+// deletes all entries in session_requests older than a second
 exp.resetCounter = function() {
   var count = req_count();
   if (count) {

+ 1 - 0
lib/routes/index.js

@@ -7,6 +7,7 @@ var ejs = require("ejs");
 var str;
 var index;
 
+// pre-compile the index page
 function compile() {
   logging.log("Compiling index page");
   str = read(path.join(__dirname, "..", "views", "index.html.ejs"), "utf-8");

+ 2 - 0
lib/server.js

@@ -135,6 +135,7 @@ function requestHandler(req, res) {
 
 var exp = {};
 
+// Start the server
 exp.boot = function(callback) {
   var port = config.server.port;
   var bind_ip = config.server.bind;
@@ -163,6 +164,7 @@ exp.boot = function(callback) {
   });
 };
 
+// Close the server
 exp.close = function(callback) {
   server.close(callback);
 };