Skip to content

Add a few Stdlib helpers #7516

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add a few Stdlib helpers #7516

wants to merge 4 commits into from

Conversation

DZakh
Copy link
Member

@DZakh DZakh commented May 24, 2025

  • String.capitalize
  • String.isEmpty
  • Dict.size
  • Dict.isEmpty
  • Array.isEmpty
  • Map.isEmpty
  • Set.isEmpty

Let me know if I need to cherry-pick some changes.

@DZakh DZakh marked this pull request as draft May 24, 2025 14:14
Copy link

pkg-pr-new bot commented May 24, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7516

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7516

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7516

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7516

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7516

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7516

commit: 9b6e506

@DZakh DZakh marked this pull request as ready for review May 24, 2025 14:26
@zth
Copy link
Collaborator

zth commented Jul 12, 2025

I like these. @cknitt what do you think?

@DZakh could you rebase?

@cknitt
Copy link
Member

cknitt commented Jul 13, 2025

I like these. @cknitt what do you think?

Certainly useful, my only concern is that Dict.size and Dict.empty sort of hide their performance implications (array allocation, O(n)).

Actually they could be implemented without the array allocation:

function size(dict) {
  let count = 0;
  for (let key in dict) {
    if (dict.hasOwnProperty(key)) count++;
  }
  return count;
}

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.

3 participants