]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove unused helpers (#7039)
authorBen McCann <322311+benmccann@users.noreply.github.com>
Fri, 31 Jan 2020 00:23:40 +0000 (16:23 -0800)
committerGitHub <noreply@github.com>
Fri, 31 Jan 2020 00:23:40 +0000 (19:23 -0500)
docs/getting-started/v3-migration.md
src/helpers/index.js
test/specs/core.helpers.tests.js

index 76d8a53d092b4353419e46afc2d71430e5e02a1e..a7e8345a0afce0af33158e86bdfb26f2b0d143b9 100644 (file)
@@ -91,6 +91,9 @@ Animation system was completely rewritten in Chart.js v3. Each property can now
 * `helpers.addEvent`
 * `helpers.aliasPixel`
 * `helpers.configMerge`
+* `helpers.findIndex`
+* `helpers.findNextWhere`
+* `helpers.findPreviousWhere`
 * `helpers.indexOf`
 * `helpers.lineTo`
 * `helpers.longestText` was moved to the `helpers.canvas` namespace and made private
index df5d4fbd0ce356ffe0ad77a471e97ec25465cf62..8e28efcdc19d4b07228f878575e326944029a2b8 100644 (file)
@@ -36,43 +36,6 @@ export default {
        math,
        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
        niceNum: function(range, round) {
                var exponent = Math.floor(math.log10(range));
index 308438e04614cdb4bfc44a91c7ed779ab35935c1..d7fc8e30df6bd3d56d9c1fb92a7d9a58d5eb9910 100644 (file)
@@ -6,19 +6,6 @@ describe('Core helper tests', function() {
                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() {
                var uid = helpers.uid();
                expect(uid).toEqual(jasmine.any(Number));