Update tests to meet semistandard code standards

Switch to const/let instead of var
This commit is contained in:
Lovell Fuller
2016-10-26 11:52:45 +01:00
parent 36e636dca1
commit cbdbbe535a
38 changed files with 1378 additions and 1405 deletions

View File

@@ -1,5 +1,4 @@
'use strict';
/*jshint esversion: 6 */
const fs = require('fs');
const request = require('request');
@@ -10,7 +9,7 @@ const client = tumblr.createClient({
consumer_secret: '***'
});
const fetchImages = function(offset) {
const fetchImages = function (offset) {
console.log(`Fetching offset ${offset}`);
client.posts('humanae', {
type: 'photo',
@@ -21,8 +20,7 @@ const fetchImages = function(offset) {
response.posts.forEach((post) => {
const url = post.photos[0].alt_sizes
.filter((image) => image.width === 100)
.map((image) => image.url)
[0];
.map((image) => image.url)[0];
const filename = `./images/${post.id}.jpg`;
try {
fs.statSync(filename);

View File

@@ -1,8 +1,7 @@
'use strict';
/*jshint esversion: 6 */
const fs = require('fs');
const child_process = require('child_process');
const childProcess = require('child_process');
const a = [];
const b = [];
@@ -12,7 +11,7 @@ fs.readdirSync('./images')
.forEach((file) => {
// Extract one pixel, avoiding first DCT block, and return value of A and B channels
const command = `convert ./images/${file}[1x1+8+8] -colorspace lab -format "%[fx:u.g] %[fx:u.b]" info:`;
const result = child_process.execSync(command, { encoding: 'utf8' });
const result = childProcess.execSync(command, { encoding: 'utf8' });
const ab = result.split(' ');
a.push(ab[0]);
b.push(ab[1]);
@@ -22,7 +21,7 @@ a.sort((v1, v2) => v1 - v2);
b.sort((v1, v2) => v1 - v2);
// Convert from 0..1 to -128..128
const convert = function(v) {
const convert = function (v) {
return Math.round(256 * (v - 0.5));
};