mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
* chore: move arrayRemove to a new utils.array namespace * chore: move getBlockTypeCounts out of utils.js * chore: remove last functions from utils.js * chore: reorder imports * chore: add re-export for runAfterPageLoad
35 lines
700 B
JavaScript
35 lines
700 B
JavaScript
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Utility methods related to arrays.
|
|
*/
|
|
'use strict';
|
|
|
|
/**
|
|
* @namespace Blockly.utils.array
|
|
*/
|
|
goog.module('Blockly.utils.array');
|
|
|
|
|
|
/**
|
|
* Removes the first occurrence of a particular value from an array.
|
|
* @param {!Array} arr Array from which to remove value.
|
|
* @param {*} value Value to remove.
|
|
* @return {boolean} True if an element was removed.
|
|
* @alias Blockly.array.removeElem
|
|
* @package
|
|
*/
|
|
const removeElem = function(arr, value) {
|
|
const i = arr.indexOf(value);
|
|
if (i === -1) {
|
|
return false;
|
|
}
|
|
arr.splice(i, 1);
|
|
return true;
|
|
};
|
|
exports.removeElem = removeElem;
|