distinctArray.js 472 B

12345678910111213141516171819202122
  1. 'use strict';
  2. /**
  3. * Copyright (c) 2013-present, Facebook, Inc.
  4. *
  5. * This source code is licensed under the MIT license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. *
  8. *
  9. */
  10. var Set = require('./Set');
  11. /**
  12. * Returns the distinct elements of an iterable. The result is an array whose
  13. * elements are ordered by first occurrence.
  14. */
  15. function distinctArray(xs) {
  16. return Array.from(new Set(xs).values());
  17. }
  18. module.exports = distinctArray;