package updates
sudo apt-get update
sudo apt-get upgrade
before: | |
There are 2 functions in this file. | |
Function with the largest signature take 2 arguments, while the median is 1.5. | |
Largest function has 11 statements in it, while the median is 8. | |
The most complex function has a cyclomatic complexity value of 5 while the median is 4. | |
after: | |
There are 18 functions in this file. |
◆ node file_stats.js after.js ~/Desktop | |
Total lines count => 82 | |
Total token count => 465 | |
Tokens by fruequency: | |
( => 49 | |
) => 49 | |
; => 30 | |
, => 28 |
◆ node file_stats.js before.js ~/Desktop | |
Total lines count => 39 | |
Total token count => 212 | |
Tokens by fruequency: | |
. => 15 | |
= => 15 | |
; => 14 | |
cn => 12 |
function defaultArguments(func, defaults) { | |
return function () { | |
var params = Array.prototype.slice.call(arguments); | |
var args = func | |
.toString() | |
.match(/\((.*)\)/)[1] | |
.split(/\s*,\s*/) | |
.filter(Boolean) | |
.map(function (e, i) { return params[i] || defaults[e]; }); |
'use strict'; | |
var crypto = require('crypto'); | |
exports.generate_signature = function (params, api_secret) { | |
var sorted = []; | |
var pre_sig; | |
Object.keys(params).sort().forEach(function (key) { | |
sorted.push([key, params[key]].join('=')); |
function sum (a) { | |
return function (b) { | |
return a + b; | |
}; | |
} | |
console.log(sum(1)(2)); | |
fs | |
.readdirSync(__dirname) | |
.filter(function (file) { return /\.json$/.test(file); }) | |
.reduce(function (config, file) { return extend(config, require(__dirname + '/' + file)); }, {}); |