Merge pull request #6936 from epixa/uiletconst11

[internal] Replace var with const/let in ui/public/utils/lodash-mixins
This commit is contained in:
Court Ewing 2016-04-15 14:25:00 -04:00
commit 176d271a20
8 changed files with 37 additions and 37 deletions

View file

@ -3,7 +3,7 @@ import expect from 'expect.js';
describe('_.move', function () {
it('accepts previous from->to syntax', function () {
let list = [
const list = [
1,
1,
1,
@ -27,7 +27,7 @@ describe('_.move', function () {
});
it('moves an object up based on a function callback', function () {
let list = [
const list = [
1,
1,
1,
@ -55,7 +55,7 @@ describe('_.move', function () {
});
it('moves an object down based on a function callback', function () {
let list = [
const list = [
1,
1,
1,
@ -83,7 +83,7 @@ describe('_.move', function () {
});
it('moves an object up based on a where callback', function () {
let list = [
const list = [
{ v: 1 },
{ v: 1 },
{ v: 1 },
@ -110,7 +110,7 @@ describe('_.move', function () {
it('moves an object up based on a where callback', function () {
let list = [
const list = [
{ v: 1 },
{ v: 1 },
{ v: 1 },
@ -136,7 +136,7 @@ describe('_.move', function () {
});
it('moves an object down based on a pluck callback', function () {
let list = [
const list = [
{ id: 0, normal: true },
{ id: 1, normal: true },
{ id: 2, normal: true },

View file

@ -3,7 +3,7 @@ import expect from 'expect.js';
describe('_.organize', function () {
it('it works', function () {
let col = [
const col = [
{
name: 'one',
roles: ['user', 'admin', 'owner']
@ -22,7 +22,7 @@ describe('_.organize', function () {
}
];
let resp = _.organizeBy(col, 'roles');
const resp = _.organizeBy(col, 'roles');
expect(resp).to.have.property('user');
expect(resp.user).to.have.length(4);
@ -34,15 +34,15 @@ describe('_.organize', function () {
});
it('behaves just like groupBy in normal scenarios', function () {
let col = [
const col = [
{ name: 'one' },
{ name: 'two' },
{ name: 'three' },
{ name: 'four' }
];
let orgs = _.organizeBy(col, 'name');
let groups = _.groupBy(col, 'name');
const orgs = _.organizeBy(col, 'name');
const groups = _.groupBy(col, 'name');
expect(orgs).to.eql(groups);
});
});

View file

@ -3,10 +3,10 @@ import expect from 'expect.js';
describe('_.pushAll', function () {
it('pushes an entire array into another', function () {
let a = [1, 2, 3, 4];
let b = [5, 6, 7, 8];
const a = [1, 2, 3, 4];
const b = [5, 6, 7, 8];
let output = _.pushAll(b, a);
const output = _.pushAll(b, a);
expect(output).to.be(a);
expect(a).to.eql([1, 2, 3, 4, 5, 6, 7, 8]);
expect(b).to.eql([5, 6, 7, 8]);

View file

@ -15,7 +15,7 @@ export default function (_) {
* @return {array} - the objs argument
*/
move: function (objs, obj, below, qualifier) {
var origI = _.isNumber(obj) ? obj : objs.indexOf(obj);
const origI = _.isNumber(obj) ? obj : objs.indexOf(obj);
if (origI === -1) return objs;
if (_.isNumber(below)) {
@ -27,11 +27,11 @@ export default function (_) {
below = !!below;
qualifier = _.callback(qualifier);
var above = !below;
var finder = below ? _.findIndex : _.findLastIndex;
const above = !below;
const finder = below ? _.findIndex : _.findLastIndex;
// find the index of the next/previous obj that meets the qualifications
var targetI = finder(objs, function (otherAgg, otherI) {
const targetI = finder(objs, function (otherAgg, otherI) {
if (below && otherI <= origI) return;
if (above && otherI >= origI) return;
return !!qualifier(otherAgg, otherI);
@ -58,8 +58,8 @@ export default function (_) {
* @return {object}
*/
organizeBy: function (collection, callback) {
var buckets = {};
var prop = typeof callback === 'function' ? false : callback;
const buckets = {};
const prop = typeof callback === 'function' ? false : callback;
function add(key, obj) {
if (!buckets[key]) buckets[key] = [];
@ -67,14 +67,14 @@ export default function (_) {
}
_.each(collection, function (obj) {
var keys = prop === false ? callback(obj) : obj[prop];
const keys = prop === false ? callback(obj) : obj[prop];
if (!_.isArray(keys)) {
add(keys, obj);
return;
}
var length = keys.length;
let length = keys.length;
while (length-- > 0) {
add(keys[length], obj);
}
@ -108,14 +108,14 @@ export default function (_) {
* @return {Array} dest
*/
pushAll: function (source, dest) {
var start = dest.length;
var adding = source.length;
const start = dest.length;
const adding = source.length;
// allocate - http://goo.gl/e2i0S0
dest.length = start + adding;
// fill sparse positions
var i = -1;
let i = -1;
while (++i < adding) dest[start + i] = source[i];
return dest;

View file

@ -13,11 +13,11 @@ export default function (_) {
* @return {Function} - the wrapper method
*/
onceWithCb: function (fn) {
var callbacks = [];
const callbacks = [];
// on initial flush, call the init function, but ensure
// that it only happens once
var flush = _.once(function (cntx, args) {
let flush = _.once(function (cntx, args) {
args.push(function finishedOnce() {
// override flush to simply schedule an asynchronous clear
flush = function () {
@ -33,8 +33,8 @@ export default function (_) {
});
return function runOnceWithCb() {
var args = [].slice.call(arguments, 0);
var cb = args[args.length - 1];
let args = [].slice.call(arguments, 0);
const cb = args[args.length - 1];
if (typeof cb === 'function') {
callbacks.push(cb);

View file

@ -18,8 +18,8 @@ export default function (_) {
* @return {object}
*/
flattenWith: function (dot, nestedObj, flattenArrays) {
var stack = []; // track key stack
var flatObj = {};
const stack = []; // track key stack
const flatObj = {};
(function flattenObj(obj) {
_.keys(obj).forEach(function (key) {

View file

@ -11,10 +11,10 @@ export default function (_) {
};
}
var props = {
const props = {
inherits: describeConst(function (SuperClass) {
var prototype = Object.create(SuperClass.prototype, {
const prototype = Object.create(SuperClass.prototype, {
constructor: describeConst(this),
superConstructor: describeConst(SuperClass)
});

View file

@ -1,6 +1,6 @@
export default function (_) {
var DOT_PREFIX_RE = /(.).+?\./g;
const DOT_PREFIX_RE = /(.).+?\./g;
_.mixin({
@ -39,10 +39,10 @@ export default function (_) {
commaSeperatedList: function (input) {
if (_.isArray(input)) return input;
var source = String(input || '').split(',');
var list = [];
const source = String(input || '').split(',');
const list = [];
while (source.length) {
var item = source.shift().trim();
const item = source.shift().trim();
if (item) list.push(item);
}