Skip to main content
Module

x/structurae/index.ts>StringView

Data structures for high-performance JavaScript applications.
Latest
class StringView
implements PrimitiveView<string>
extends DataView
import { StringView } from "https://deno.land/x/structurae@4.0.1/index.ts";

Properties

readonly
size

The amount of UTF characters in the StringView.

Methods

characters(): Generator<string, void, unknown>

Iterates over the characters in the StringView.

charAt(index?): string

Returns a new string consisting of the single UTF character located at the specified character index.

get(): string

Returns the string encoded in the StringView.

getCharStart(
index: number,
startCharIndex?,
startIndex?,
): number

Returns the index of the first byte of a character.

includes(searchValue: IndexedCollection, position?: number): boolean

Checks whether the provided encoded sequence is found inside the view.

indexOf(searchValue: IndexedCollection, fromIndex?): number

Returns the index within the StringView of the first occurrence of the specified value, starting the search at start. Returns -1 if the value is not found.

replace(pattern: IndexedCollection, replacement: IndexedCollection): this

Performs an in-place replacement within the StringView of all occurrences of a given pattern with a given replacement.

reverse(): this

Reverses the characters of the StringView in-place.

searchNaive(searchValue: IndexedCollection, start: number): number
searchShiftOr(searchValue: IndexedCollection, start: number): number
set(value: string): void

Encodes a given string into the StringView

substring(indexStart?, indexEnd?): string

Returns a string of characters between the start and end character indexes, or to the end of the string.

swapChar(i: number, j: number): void
toChar(index: number): string
toJSON(): string

Returns a string value of the StringView.

toString(): string

Returns a string value of the StringView.

Returns a StringView without trailing zeros.

Static Properties

decoder: TextDecoder
encoder: TextEncoder
masks
viewLength: number

Static Methods

decode(
view: DataView,
start?,
length?,
): string

Converts a UTF8 byte array into a JS string. Adopted from Google Closure: https://github.com/google/closure-library/blob/master/closure/goog/crypt/crypt.js

encode(
value: string,
view: DataView,
start?,
length?: number,
): number
from(value: string): StringView

Creates a StringView from a string or an array like object.

getLength(string?): number

Returns the size in bytes of a given string.

initialize(): ViewConstructor<string, PrimitiveView<string>>