Skip to content

Commit

Permalink
Merge pull request #523 from strongloop/no-vars
Browse files Browse the repository at this point in the history
chore: replace var with let and const
  • Loading branch information
Hage Yaapa authored May 24, 2019
2 parents dc0b85f + f864c3e commit c6a9020
Show file tree
Hide file tree
Showing 15 changed files with 305 additions and 303 deletions.
14 changes: 7 additions & 7 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@

'use strict';

var DataSource = require('loopback-datasource-juggler').DataSource;
var connector = require('..');
var Benchmark = require('benchmark');
const DataSource = require('loopback-datasource-juggler').DataSource;
const connector = require('..');
const Benchmark = require('benchmark');

var ds = new DataSource(connector, {
const ds = new DataSource(connector, {
host: process.env.LB_HOST || '127.0.0.1',
port: process.env.LB_PORT || 27017,
database: process.env.LB_DB || 'strongloop',
});
var Todo = ds.define('Todo', {
const Todo = ds.define('Todo', {
content: {type: String},
});

// not critical for MongoDB, but may uncover inefficiencies in SQL connectors
// https://github.com/strongloop/loopback-connector-mongodb/pull/124/files#r28435614
var uniqVal = 0;
let uniqVal = 0;

function resetTestState() {
uniqVal = 0;
Todo.destroyAll();
}

var suite = new Benchmark.Suite();
const suite = new Benchmark.Suite();
suite
.on('start', function() {
console.log('#', new Date());
Expand Down
10 changes: 5 additions & 5 deletions example/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

'use strict';

var g = require('strong-globalize')();
const g = require('strong-globalize')();

var DataSource = require('loopback-datasource-juggler').DataSource;
const DataSource = require('loopback-datasource-juggler').DataSource;

var config = require('rc')('loopback', {dev: {mongodb: {}}}).dev.mongodb;
const config = require('rc')('loopback', {dev: {mongodb: {}}}).dev.mongodb;

var ds = new DataSource(require('../'), config);
const ds = new DataSource(require('../'), config);

var Customer = ds.createModel('customer', {
const Customer = ds.createModel('customer', {
seq: {type: Number, id: true},
name: String,
emails: [{label: String, email: String}],
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

var SG = require('strong-globalize');
const SG = require('strong-globalize');
SG.SetRootDir(__dirname);

module.exports = require('./lib/mongodb');
8 changes: 4 additions & 4 deletions leak-detection/fixtures/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

'use strict';

var DataSource = require('loopback-datasource-juggler').DataSource;
var connector = require('../..');
const DataSource = require('loopback-datasource-juggler').DataSource;
const connector = require('../..');

var db = new DataSource(connector, {
const db = new DataSource(connector, {
host: process.env.LB_HOST || '127.0.0.1',
port: process.env.LB_PORT || 27017,
database: process.env.LB_DB || 'strongloop',
});
var Todo = db.define('Todo', {
const Todo = db.define('Todo', {
content: {type: String},
});

Expand Down
16 changes: 8 additions & 8 deletions leak-detection/leak-detector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

'use strict';

var memwatch;
let memwatch;

try {
memwatch = require('@airbnb/node-memwatch');
} catch (e) {
memwatch = require('memwatch-next');
}
var sinon = require('sinon');
const sinon = require('sinon');

describe('leak detector', function() {
before(function() {
Expand All @@ -21,18 +21,18 @@ describe('leak detector', function() {
});

it('should detect a basic leak', function(done) {
var test = this;
var iterations = 0;
var leaks = [];
var interval = setInterval(function() {
const test = this;
const iterations = 0;
const leaks = [];
const interval = setInterval(function() {
if (test.iterations >= global.ITERATIONS || test.spy.called) {
test.spy.called.should.be.True();
clearInterval(interval);
return done();
}
test.iterations++;
for (var i = 0; i < 1000000; i++) {
var str = 'leaky string';
for (let i = 0; i < 1000000; i++) {
const str = 'leaky string';
leaks.push(str);
}
}, 0);
Expand Down
10 changes: 5 additions & 5 deletions leak-detection/mongodb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

'use strict';

var memwatch = require('memwatch-next');
var sinon = require('sinon');
var Todo = require('./fixtures/todo');
const memwatch = require('memwatch-next');
const sinon = require('sinon');
const Todo = require('./fixtures/todo');

describe('mongodb', function() {
before(function() {
Expand All @@ -26,12 +26,12 @@ describe('mongodb', function() {
}

function execute(ctx, func, options, done) {
var hasOptions = true;
let hasOptions = true;
if (typeof options === 'function') {
done = options;
hasOptions = false;
}
var interval = setInterval(function() {
const interval = setInterval(function() {
if (ctx.iterations >= global.ITERATIONS || ctx.spy.called) {
ctx.spy.called.should.be.False();
clearInterval(interval);
Expand Down
Loading

0 comments on commit c6a9020

Please sign in to comment.