union.js 457 B

1234567891011121314151617181920
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  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. module.exports = function(arrays) {
  8. const result = new Set(arrays[0]);
  9. let i,j, array;
  10. for (i = 1; i < arrays.length; i++) {
  11. array = arrays[i];
  12. for (j = 0; j < array.length; j++) {
  13. result.add(array[j]);
  14. }
  15. }
  16. return Array.from(result);
  17. };