mirror of
https://github.com/lovell/sharp.git
synced 2026-02-09 16:16:16 +01:00
Update tests to meet semistandard code standards
Switch to const/let instead of var
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user