partitionObjectByKey.js.flow 660 B

1234567891011121314151617181920212223
  1. /**
  2. * Copyright 2015-present Facebook. All Rights Reserved.
  3. *
  4. * @providesModule partitionObjectByKey
  5. * @typechecks
  6. * @flow
  7. */
  8. 'use strict';
  9. var partitionObject = require('./partitionObject');
  10. /**
  11. * Partitions the enumerable properties of an object into two objects, given a
  12. * whitelist `Set` for the first object. This is comparable to
  13. * `whitelistObjectKeys`, but eventually keeping all the keys. Returns a tuple
  14. * of objects `[first, second]`.
  15. */
  16. function partitionObjectByKey(source: Object, whitelist: Set<string>): [Object, Object] {
  17. return partitionObject(source, (_, key) => whitelist.has(key));
  18. }
  19. module.exports = partitionObjectByKey;