removeFromArray.js.flow 484 B

12345678910111213141516171819202122
  1. /**
  2. * Copyright (c) 2013-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @providesModule removeFromArray
  8. * @typechecks
  9. * @flow
  10. */
  11. /**
  12. * Removes an element from an array.
  13. */
  14. function removeFromArray<T>(array: Array<T>, element: T): void {
  15. var index = array.indexOf(element);
  16. if (index !== -1) {
  17. array.splice(index, 1);
  18. }
  19. }
  20. module.exports = removeFromArray;