Sha256: dbb150665211cd006b33e47fc207fa80b9d90dcad14308fe9d1fa0f512b35552

Contents?: true

Size: 324 Bytes

Versions: 6

Compression:

Stored size: 324 Bytes

Contents

# frozen_string_literal: true

# Polyfill for String#byteindex, which didn't exist until Ruby 3.2.
if !("".respond_to?(:byteindex))
  String.include(
    Module.new {
      def byteindex(needle, offset = 0)
        charindex = index(needle, offset)
        slice(0...charindex).bytesize if charindex
      end
    }
  )
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
prism-1.3.0 lib/prism/polyfill/byteindex.rb
prism-1.2.0 lib/prism/polyfill/byteindex.rb
prism-1.1.0 lib/prism/polyfill/byteindex.rb
prism-1.0.0 lib/prism/polyfill/byteindex.rb
prism-0.30.0 lib/prism/polyfill/byteindex.rb
prism-0.28.0 lib/prism/polyfill/byteindex.rb