Skip to content

Commit

Permalink
Merge pull request #6945 from elastic/jasper/backport/6936/4.x
Browse files Browse the repository at this point in the history
[backport] PR #6936 to 4.x
  • Loading branch information
epixa committed Apr 15, 2016
2 parents d654a7c + bec02dc commit 63e3776
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 43 deletions.
16 changes: 8 additions & 8 deletions src/ui/public/utils/lodash-mixins/__tests__/_move.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
describe('_.move', function () {
let _ = require('lodash');
let expect = require('expect.js');
const _ = require('lodash');
const expect = require('expect.js');

it('accepts previous from->to syntax', function () {
let list = [
const list = [
1,
1,
1,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand Down
14 changes: 7 additions & 7 deletions src/ui/public/utils/lodash-mixins/__tests__/_organize_by.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
describe('_.organize', function () {
let _ = require('lodash');
let expect = require('expect.js');
const _ = require('lodash');
const expect = require('expect.js');

it('it works', function () {
let col = [
const col = [
{
name: 'one',
roles: ['user', 'admin', 'owner']
Expand All @@ -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);

Expand All @@ -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);
});
});
10 changes: 5 additions & 5 deletions src/ui/public/utils/lodash-mixins/__tests__/_push_all.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
describe('_.pushAll', function () {
let _ = require('lodash');
let expect = require('expect.js');
const _ = require('lodash');
const expect = require('expect.js');

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]);
Expand Down
22 changes: 11 additions & 11 deletions src/ui/public/utils/lodash-mixins/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define(function (require) {
* @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)) {
Expand All @@ -28,11 +28,11 @@ define(function (require) {
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);
Expand All @@ -59,23 +59,23 @@ define(function (require) {
* @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] = [];
buckets[key].push(obj);
}

_.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);
}
Expand Down Expand Up @@ -109,14 +109,14 @@ define(function (require) {
* @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;
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/utils/lodash-mixins/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ define(function (require) {
* @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 () {
Expand All @@ -34,8 +34,8 @@ define(function (require) {
});

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);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/utils/lodash-mixins/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ define(function (require) {
* @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) {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/utils/lodash-mixins/oop.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ define(function (require) {
};
}

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)
});
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/utils/lodash-mixins/string.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function (require) {
return function (_) {

var DOT_PREFIX_RE = /(.).+?\./g;
const DOT_PREFIX_RE = /(.).+?\./g;

_.mixin({

Expand Down Expand Up @@ -40,10 +40,10 @@ define(function (require) {
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);
}

Expand Down

0 comments on commit 63e3776

Please sign in to comment.