mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
35 lines
700 B
TypeScript
35 lines
700 B
TypeScript
/**
|
|
* @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;
|