Files
blockly/core/utils/array.js
Rachel Fenichel 075385c87c chore: move remaining functions out of utils.js (#5714)
* 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
2021-11-15 18:12:45 -08:00

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;