Front end of the Slack clone application.

copy.js 570B

1234567891011121314151617181920
  1. "use strict";
  2. var aFrom = require("../array/from")
  3. , assign = require("./assign")
  4. , value = require("./valid-value");
  5. module.exports = function (obj/*, propertyNames, options*/) {
  6. var copy = Object(value(obj)), propertyNames = arguments[1], options = Object(arguments[2]);
  7. if (copy !== obj && !propertyNames) return copy;
  8. var result = {};
  9. if (propertyNames) {
  10. aFrom(propertyNames, function (propertyName) {
  11. if (options.ensure || propertyName in obj) result[propertyName] = obj[propertyName];
  12. });
  13. } else {
  14. assign(result, obj);
  15. }
  16. return result;
  17. };