Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

500 B
Raw Blame
/**
 * Create an object composed of the picked object properties
 * @param {Object} object
 * @param {string[]} keys
 * @returns {Object}
 */

type AnyObject = {
  [x: string]: any;
};

const pick = (object: AnyObject, keys: string[]) =>
  keys.reduce((newObject: AnyObject, key) => {
    if (object && Object.prototype.hasOwnProperty.call(object, key)) {
      // eslint-disable-next-line no-param-reassign
      newObject[key] = object[key];
    }
    return newObject;
  }, {});

export { pick };