Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/easyts/mod.ts>Slice

js library written with ts, use select and chan like golang in js.
Latest
class Slice
implements Iterable<T>
extends ClassForEach<T>
import { Slice } from "https://deno.land/x/easyts@0.1.3/mod.ts";

Constructors

new
private
Slice(
array: Array<T>,
start: number,
end: number,
)

Properties

readonly
capacity: number

return slice capacity

readonly
length: number

return slice length

readonly
reverse: Iterable<T>

Returns an object that implements a js Iterable, but it traverses the data in reverse

Methods

append(...vals: Array<T>): Slice<T>

Add a new element at the end of the slice and return the new slice

copy(src: Iterable<T>): number

Copy data from src to current slice

get(i: number): T

Returns the element at index i in the slice

iterator(reverse?: boolean): Iterator<T>

return js iterator

set(i: number, val: T): void

Sets the element at index i in the slice to val

slice(start?: number, end?: number): Slice<T>

take sub-slices

[Symbol.iterator](): Iterator<T>

implements js Iterable

Static Methods

attach<T>(
a: Array<T>,
start?: number,
end?: number,
): Slice<T>

Creates a slice attached to the incoming array

make<T>(length: number, capacity?: number): Slice<T>

Create a slice