blockly
Version:
Blockly is a library for building visual programming editors.
35 lines (30 loc) • 700 B
JavaScript
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Utility methods related to arrays.
*/
;
/**
* @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;