Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

12345678910111213141516171819202122232425
  1. import { map } from './map';
  2. export function pluck(...properties) {
  3. const length = properties.length;
  4. if (length === 0) {
  5. throw new Error('list of properties cannot be empty.');
  6. }
  7. return (source) => map(plucker(properties, length))(source);
  8. }
  9. function plucker(props, length) {
  10. const mapper = (x) => {
  11. let currentProp = x;
  12. for (let i = 0; i < length; i++) {
  13. const p = currentProp != null ? currentProp[props[i]] : undefined;
  14. if (p !== void 0) {
  15. currentProp = p;
  16. }
  17. else {
  18. return undefined;
  19. }
  20. }
  21. return currentProp;
  22. };
  23. return mapper;
  24. }
  25. //# sourceMappingURL=pluck.js.map