Ruby modules in TypeScript

TypeScript implementations of 44 Ruby standard library functions across 3 modules. Each function is individually importable and tree-shakeable.

Array Math String

We have 44 Ruby functions so far - help us add more

Got a rainy Sunday afternoon and a taste for a porting puzzle?

  • Get inspiration from the Ruby core documentation.
  • Click "New file" in the appropriate folder on GitHub. This will fork the project to your account, directly add the file to it, and send a Pull Request to us.

We will then review it. If it's useful to the project and in line with our contributing guidelines your work will become part of Locutus and you'll be automatically credited in the authors section accordingly.

Upstream Surface Inventory 44/290 shipped • 217 next 15%

Locutus tracks the upstream Ruby catalog and sorts it into what is already shipped, what we still want, what we intentionally keep, and what still needs a decision.

15% catalog shipped
Shipped Next Explicit non-goals
Shipped 44/290
Next to port 217
Explicit non-goals 29

44 of 290 upstream entries are already shipped; 217 are explicitly on the shortlist; 29 are explicit non-goals.

Array instance methods

Ruby 3.3 Catalog source: live runtime snapshot ruby:3.3

10% shipped
14/134 shipped 109 next 11 explicit non-goals

14 shipped • 109 next • 11 explicit non-goals.

Next

  • - Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • [] Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • []= Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • * Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • & Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • + Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • << Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • | Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • all? Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • any? Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • append Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • assoc Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • at Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • chunk Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • chunk_while Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • clear Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • collect Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • collect_concat Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • collect! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • combination Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • compact! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • concat Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • count Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • cycle Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • deconstruct Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • delete Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • delete_at Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • delete_if Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • detect Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • difference Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • dig Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • drop Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • drop_while Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • empty? Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • entries Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • fetch Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • fill Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • filter Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • filter! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • find Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • find_all Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • find_index Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • flat_map Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • flatten! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • grep Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • grep_v Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • include? Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • index Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • inject Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • insert Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • intersect? Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • intersection Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • join Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • keep_if Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • length Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • map Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • map! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • max Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • max_by Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • member? Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • min Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • min_by Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • minmax Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • minmax_by Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • none? Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • one? Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • partition Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • pop Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • prepend Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • product Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • push Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • rassoc Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • reduce Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • reject Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • reject! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • repeated_combination Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • repeated_permutation Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • replace Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • reverse Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • reverse_each Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • reverse! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • rindex Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • rotate Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • rotate! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • select Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • select! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • shift Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • shuffle Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • shuffle! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • size Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • slice Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • slice_after Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • slice_before Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • slice! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • sort Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • sort_by Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • sort_by! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • sort! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • sum Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • take Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • take_while Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • to_a Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • to_ary Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • to_h Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • transpose Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • union Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • uniq! Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • unshift Most Ruby Array methods map naturally onto JS arrays and plain objects.
  • values_at Most Ruby Array methods map naturally onto JS arrays and plain objects.
Explicit non-goals (11)
  • chain Skip Lazy enumerator chaining is not a stable plain-value target.
  • each Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_cons Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_entry Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_index Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_slice Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_with_index Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_with_object Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • lazy Skip Lazy enumerators do not fit Locutus' plain-value model.
  • pack Skip Binary packing semantics do not map cleanly to JS plain values.
  • to_set Skip Ruby Set values are not a stable plain-value target for Locutus.

Math module methods

Ruby 3.3 Catalog source: live runtime snapshot ruby:3.3

58% shipped
15/26 shipped 11 next

15 shipped • 11 next.

Next

  • acosh Ruby Math helpers map cleanly to JS numbers.
  • asinh Ruby Math helpers map cleanly to JS numbers.
  • atan2 Ruby Math helpers map cleanly to JS numbers.
  • atanh Ruby Math helpers map cleanly to JS numbers.
  • erf Ruby Math helpers map cleanly to JS numbers.
  • erfc Ruby Math helpers map cleanly to JS numbers.
  • frexp Ruby Math helpers map cleanly to JS numbers.
  • gamma Ruby Math helpers map cleanly to JS numbers.
  • hypot Ruby Math helpers map cleanly to JS numbers.
  • ldexp Ruby Math helpers map cleanly to JS numbers.
  • lgamma Ruby Math helpers map cleanly to JS numbers.

String instance methods

Ruby 3.3 Catalog source: live runtime snapshot ruby:3.3

12% shipped
15/130 shipped 97 next 18 explicit non-goals

15 shipped • 97 next • 18 explicit non-goals.

Next

  • -@ Most Ruby String methods are strong plain-value portability targets.
  • [] Most Ruby String methods are strong plain-value portability targets.
  • []= Most Ruby String methods are strong plain-value portability targets.
  • * Most Ruby String methods are strong plain-value portability targets.
  • % Most Ruby String methods are strong plain-value portability targets.
  • + Most Ruby String methods are strong plain-value portability targets.
  • +@ Most Ruby String methods are strong plain-value portability targets.
  • < Most Ruby String methods are strong plain-value portability targets.
  • << Most Ruby String methods are strong plain-value portability targets.
  • <= Most Ruby String methods are strong plain-value portability targets.
  • =~ Most Ruby String methods are strong plain-value portability targets.
  • > Most Ruby String methods are strong plain-value portability targets.
  • >= Most Ruby String methods are strong plain-value portability targets.
  • ascii_only? Most Ruby String methods are strong plain-value portability targets.
  • between? Most Ruby String methods are strong plain-value portability targets.
  • capitalize! Most Ruby String methods are strong plain-value portability targets.
  • casecmp Most Ruby String methods are strong plain-value portability targets.
  • casecmp? Most Ruby String methods are strong plain-value portability targets.
  • center Most Ruby String methods are strong plain-value portability targets.
  • chars Most Ruby String methods are strong plain-value portability targets.
  • chomp! Most Ruby String methods are strong plain-value portability targets.
  • chop! Most Ruby String methods are strong plain-value portability targets.
  • chr Most Ruby String methods are strong plain-value portability targets.
  • clamp Most Ruby String methods are strong plain-value portability targets.
  • clear Most Ruby String methods are strong plain-value portability targets.
  • codepoints Most Ruby String methods are strong plain-value portability targets.
  • concat Most Ruby String methods are strong plain-value portability targets.
  • count Most Ruby String methods are strong plain-value portability targets.
  • dedup Most Ruby String methods are strong plain-value portability targets.
  • delete Most Ruby String methods are strong plain-value portability targets.
  • delete_prefix! Most Ruby String methods are strong plain-value portability targets.
  • delete_suffix! Most Ruby String methods are strong plain-value portability targets.
  • delete! Most Ruby String methods are strong plain-value portability targets.
  • downcase! Most Ruby String methods are strong plain-value portability targets.
  • dump Most Ruby String methods are strong plain-value portability targets.
  • empty? Most Ruby String methods are strong plain-value portability targets.
  • getbyte Most Ruby String methods are strong plain-value portability targets.
  • grapheme_clusters Most Ruby String methods are strong plain-value portability targets.
  • gsub! Most Ruby String methods are strong plain-value portability targets.
  • hex Most Ruby String methods are strong plain-value portability targets.
  • index Most Ruby String methods are strong plain-value portability targets.
  • insert Most Ruby String methods are strong plain-value portability targets.
  • lines Most Ruby String methods are strong plain-value portability targets.
  • ljust Most Ruby String methods are strong plain-value portability targets.
  • lstrip Most Ruby String methods are strong plain-value portability targets.
  • lstrip! Most Ruby String methods are strong plain-value portability targets.
  • match Most Ruby String methods are strong plain-value portability targets.
  • match? Most Ruby String methods are strong plain-value portability targets.
  • next Most Ruby String methods are strong plain-value portability targets.
  • next! Most Ruby String methods are strong plain-value portability targets.
  • oct Most Ruby String methods are strong plain-value portability targets.
  • ord Most Ruby String methods are strong plain-value portability targets.
  • partition Most Ruby String methods are strong plain-value portability targets.
  • prepend Most Ruby String methods are strong plain-value portability targets.
  • replace Most Ruby String methods are strong plain-value portability targets.
  • reverse! Most Ruby String methods are strong plain-value portability targets.
  • rindex Most Ruby String methods are strong plain-value portability targets.
  • rjust Most Ruby String methods are strong plain-value portability targets.
  • rpartition Most Ruby String methods are strong plain-value portability targets.
  • rstrip Most Ruby String methods are strong plain-value portability targets.
  • rstrip! Most Ruby String methods are strong plain-value portability targets.
  • scan Most Ruby String methods are strong plain-value portability targets.
  • scrub Most Ruby String methods are strong plain-value portability targets.
  • scrub! Most Ruby String methods are strong plain-value portability targets.
  • setbyte Most Ruby String methods are strong plain-value portability targets.
  • size Most Ruby String methods are strong plain-value portability targets.
  • slice Most Ruby String methods are strong plain-value portability targets.
  • slice! Most Ruby String methods are strong plain-value portability targets.
  • split Most Ruby String methods are strong plain-value portability targets.
  • squeeze Most Ruby String methods are strong plain-value portability targets.
  • squeeze! Most Ruby String methods are strong plain-value portability targets.
  • strip! Most Ruby String methods are strong plain-value portability targets.
  • sub Most Ruby String methods are strong plain-value portability targets.
  • sub! Most Ruby String methods are strong plain-value portability targets.
  • succ Most Ruby String methods are strong plain-value portability targets.
  • succ! Most Ruby String methods are strong plain-value portability targets.
  • sum Most Ruby String methods are strong plain-value portability targets.
  • swapcase Most Ruby String methods are strong plain-value portability targets.
  • swapcase! Most Ruby String methods are strong plain-value portability targets.
  • to_c Most Ruby String methods are strong plain-value portability targets.
  • to_f Most Ruby String methods are strong plain-value portability targets.
  • to_i Most Ruby String methods are strong plain-value portability targets.
  • to_r Most Ruby String methods are strong plain-value portability targets.
  • to_str Most Ruby String methods are strong plain-value portability targets.
  • to_sym Most Ruby String methods are strong plain-value portability targets.
  • tr_s Most Ruby String methods are strong plain-value portability targets.
  • tr_s! Most Ruby String methods are strong plain-value portability targets.
  • tr! Most Ruby String methods are strong plain-value portability targets.
  • undump Most Ruby String methods are strong plain-value portability targets.
  • unicode_normalize Most Ruby String methods are strong plain-value portability targets.
  • unicode_normalize! Most Ruby String methods are strong plain-value portability targets.
  • unicode_normalized? Most Ruby String methods are strong plain-value portability targets.
  • unpack Most Ruby String methods are strong plain-value portability targets.
  • unpack1 Most Ruby String methods are strong plain-value portability targets.
  • upcase! Most Ruby String methods are strong plain-value portability targets.
  • upto Most Ruby String methods are strong plain-value portability targets.
  • valid_encoding? Most Ruby String methods are strong plain-value portability targets.
Explicit non-goals (18)
  • b Skip Ruby's binary-string clone helper adds little value in JS.
  • byteindex Skip Byte-oriented string APIs do not fit Locutus' current plain-value model.
  • byterindex Skip Byte-oriented string APIs do not fit Locutus' current plain-value model.
  • bytes Skip Byte-oriented string APIs do not fit Locutus' current plain-value model.
  • bytesize Skip Byte-oriented string APIs do not fit Locutus' current plain-value model.
  • byteslice Skip Byte-oriented string APIs do not fit Locutus' current plain-value model.
  • bytesplice Skip Byte-oriented string APIs do not fit Locutus' current plain-value model.
  • crypt Skip Password-hash wrappers are security-sensitive and not a good Locutus target.
  • each_byte Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_char Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_codepoint Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_grapheme_cluster Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • each_line Skip Enumerator-driven iteration APIs are better expressed directly in JS.
  • encode Skip Encoding-object semantics do not fit Locutus' plain-value model.
  • encode! Skip Encoding-object semantics do not fit Locutus' plain-value model.
  • encoding Skip Encoding objects are not a stable plain-value target.
  • force_encoding Skip Encoding mutation does not fit Locutus' plain-value model.
  • intern Skip Symbol-table interning does not fit Locutus' plain-value model.