Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/rest op #860

Merged
merged 3 commits into from Nov 5, 2021
Merged

Refactor/rest op #860

merged 3 commits into from Nov 5, 2021

Conversation

dskiba
Copy link
Contributor

@dskiba dskiba commented Oct 28, 2021

Motivation

  1. Better performance. No needs to do 2 interactions over arr (filter, reduce)
  2. Add typings for restOp (using Omit version https://stackoverflow.com/a/53968837/12853087)
  3. Add tests for restOp

Summary

Improved performance, by reducing interactions (ON)
Add typing for restOp (see TS playground)

Added test for it

Test plan

it('can get rest keys from object', () => {
  const obj = { one: 1, two: 2, three: 3 };
  const rest = restOp(obj, ['two']);
  // eslint-disable-next-line no-unused-vars
  const { two, ...expectedRest } = obj;
  expect(rest).toEqual(expectedRest);
});

added works well, but pre-commit hooks failed

 FAIL  __tests__/detect-core-js.test.js
   Ensures that package do not include core-js dependency after build

    expect(received).not.toContain(expected) // indexOf

    Expected substring: not "The corejs3 polyfill added the following polyfills"
    Received string:        "@babel/preset-env: `DEBUG` option
    
    Using targets:
    {
      \"android\": \"90\",
...

As I see some tests failed, If you know how to fix them, let me know, please. Since I did not touch that files or tests.

@Anber
Copy link
Collaborator

Anber commented Nov 5, 2021

Hi @dskiba!
detect-core-js fails because your changes introduce some syntax that requires core-js. In that specific case, you use includes:

    The corejs3 polyfill added the following polyfills:
      es.array.includes { \"android\":\"90\", \"chrome\":\"90\", \"edge\":\"90\", \"firefox\":\"88\", \"ie\":\"11\", \"ios\":\"14\", \"opera\":\"75\", \"safari\":\"14\", \"samsung\":\"13\" }
      es.string.includes { \"android\":\"90\", \"chrome\":\"90\", \"edge\":\"90\", \"firefox\":\"88\", \"ie\":\"11\", \"ios\":\"14\", \"opera\":\"75\", \"safari\":\"14\", \"samsung\":\"13\" }

@dskiba
Copy link
Contributor Author

dskiba commented Nov 5, 2021

Hi @dskiba! detect-core-js fails because your changes introduce some syntax that requires core-js. In that specific case, you use includes:

    The corejs3 polyfill added the following polyfills:
      es.array.includes { \"android\":\"90\", \"chrome\":\"90\", \"edge\":\"90\", \"firefox\":\"88\", \"ie\":\"11\", \"ios\":\"14\", \"opera\":\"75\", \"safari\":\"14\", \"samsung\":\"13\" }
      es.string.includes { \"android\":\"90\", \"chrome\":\"90\", \"edge\":\"90\", \"firefox\":\"88\", \"ie\":\"11\", \"ios\":\"14\", \"opera\":\"75\", \"safari\":\"14\", \"samsung\":\"13\" }

Oh, okay thank you. I'll change it to the 'indexOf' method

@callstack-bot
Copy link

Hey @dskiba, thank you for your pull request 🤗.
The coverage report for this branch can be viewed here.

@dskiba
Copy link
Contributor Author

dskiba commented Nov 5, 2021

@Anber
✅ All tests passed now, thanks to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants