Ruby's String module in TypeScript


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 15/149 shipped • 116 next 10%

Namespace-level inventory for Ruby 3.3: what we already ship, what we may still want, and what we intentionally skip or keep.

String

Ruby 3.3 · Catalog source: version-pinned source manifest ruby:3.3:String

11% shipped
15/131 shipped 116 next 18 explicit non-goals
Shipped (15)

Next

Most Ruby String methods are strong plain-value portability targets.

  • -@
  • []
  • []=
  • *
  • %
  • +
  • +@
  • <
  • <<
  • <=
  • =~
  • >
  • >=
  • ascii_only?
  • between?
  • capitalize!
  • casecmp
  • casecmp?
  • center
  • chars
  • chomp!
  • chop!
  • chr
  • clamp
  • clear
  • codepoints
  • concat
  • count
  • dedup
  • delete
  • delete_prefix!
  • delete_suffix!
  • delete!
  • downcase!
  • dump
  • empty?
  • getbyte
  • grapheme_clusters
  • gsub!
  • hex
  • index
  • insert
  • iseuc
  • isjis
  • issjis
  • isutf8
  • kconv
  • lines
  • ljust
  • lstrip
  • lstrip!
  • match
  • match?
  • new
  • next
  • next!
  • oct
  • ord
  • parse_csv
  • partition
  • prepend
  • replace
  • reverse!
  • rindex
  • rjust
  • rpartition
  • rstrip
  • rstrip!
  • scan
  • scrub
  • scrub!
  • setbyte
  • shellescape
  • shellsplit
  • size
  • slice
  • slice!
  • split
  • squeeze
  • squeeze!
  • strip!
  • sub
  • sub!
  • succ
  • succ!
  • sum
  • swapcase
  • swapcase!
  • to_c
  • to_f
  • to_i
  • to_json_raw
  • to_json_raw_object
  • to_r
  • to_str
  • to_sym
  • toeuc
  • tojis
  • tolocale
  • tosjis
  • toutf16
  • toutf32
  • toutf8
  • tr_s
  • tr_s!
  • tr!
  • try_convert
  • undump
  • unicode_normalize
  • unicode_normalize!
  • unicode_normalized?
  • unpack
  • unpack1
  • upcase!
  • upto
  • valid_encoding?
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.

« More Ruby functions