Remove unused helpers (#7039)

This commit is contained in:
Ben McCann 2020-01-30 16:23:40 -08:00 committed by GitHub
parent eec71bfb22
commit d449bbc83a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 50 deletions

View File

@ -91,6 +91,9 @@ Animation system was completely rewritten in Chart.js v3. Each property can now
* `helpers.addEvent` * `helpers.addEvent`
* `helpers.aliasPixel` * `helpers.aliasPixel`
* `helpers.configMerge` * `helpers.configMerge`
* `helpers.findIndex`
* `helpers.findNextWhere`
* `helpers.findPreviousWhere`
* `helpers.indexOf` * `helpers.indexOf`
* `helpers.lineTo` * `helpers.lineTo`
* `helpers.longestText` was moved to the `helpers.canvas` namespace and made private * `helpers.longestText` was moved to the `helpers.canvas` namespace and made private

View File

@ -36,43 +36,6 @@ export default {
math, math,
rtl, rtl,
findIndex: Array.prototype.findIndex ?
function(array, callback, scope) {
return array.findIndex(callback, scope);
} :
function(array, callback, scope) {
scope = scope === undefined ? array : scope;
for (var i = 0, ilen = array.length; i < ilen; ++i) {
if (callback.call(scope, array[i], i, array)) {
return i;
}
}
return -1;
},
findNextWhere: function(arrayToSearch, filterCallback, startIndex) {
// Default to start of the array
if (coreHelpers.isNullOrUndef(startIndex)) {
startIndex = -1;
}
for (var i = startIndex + 1; i < arrayToSearch.length; i++) {
var currentItem = arrayToSearch[i];
if (filterCallback(currentItem)) {
return currentItem;
}
}
},
findPreviousWhere: function(arrayToSearch, filterCallback, startIndex) {
// Default to end of the array
if (coreHelpers.isNullOrUndef(startIndex)) {
startIndex = arrayToSearch.length;
}
for (var i = startIndex - 1; i >= 0; i--) {
var currentItem = arrayToSearch[i];
if (filterCallback(currentItem)) {
return currentItem;
}
}
},
// Implementation of the nice number algorithm used in determining where axis labels will go // Implementation of the nice number algorithm used in determining where axis labels will go
niceNum: function(range, round) { niceNum: function(range, round) {
var exponent = Math.floor(math.log10(range)); var exponent = Math.floor(math.log10(range));

View File

@ -6,19 +6,6 @@ describe('Core helper tests', function() {
helpers = window.Chart.helpers; helpers = window.Chart.helpers;
}); });
it('should filter an array', function() {
var data = [-10, 0, 6, 0, 7];
var callback = function(item) {
return item > 2;
};
expect(helpers.findNextWhere(data, callback)).toEqual(6);
expect(helpers.findNextWhere(data, callback, 2)).toBe(7);
expect(helpers.findNextWhere(data, callback, 4)).toBe(undefined);
expect(helpers.findPreviousWhere(data, callback)).toBe(7);
expect(helpers.findPreviousWhere(data, callback, 3)).toBe(6);
expect(helpers.findPreviousWhere(data, callback, 0)).toBe(undefined);
});
it('should generate integer ids', function() { it('should generate integer ids', function() {
var uid = helpers.uid(); var uid = helpers.uid();
expect(uid).toEqual(jasmine.any(Number)); expect(uid).toEqual(jasmine.any(Number));