
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
rope-sequence
Advanced tools
This module implements a single data type, RopeSequence
, which is a
persistent sequence type implemented as a loosely-balanced
rope.
It supports appending, prepending, and slicing without doing a full
copy. Random access is somewhat more expensive than in an array
(logarithmic, with some overhead), but should still be relatively
fast.
Licensed under the MIT license.
RopeSequence<T>
static
from
(?union<[T], RopeSequence<T>>) → RopeSequence<T>
Create a rope representing the given array, or return the rope itself if a rope was given.
static
empty
: RopeSequence<T>
The empty rope.
length
: number
The length of the rope.
append
(union<[T], RopeSequence<T>>) → RopeSequence<T>
Append an array or other rope to this one, returning a new rope.
prepend
(union<[T], RopeSequence<T>>) → RopeSequence<T>
Prepend an array or other rope to this one, returning a new rope.
slice
(from: ?number = 0, to: ?number = this.length) → RopeSequence<T>
Create a rope repesenting a sub-sequence of this rope.
get
(index: number) → T
Retrieve the element at the given position from this rope.
forEach
(f: fn(element: T, index: number) → ?bool, from: ?number, to: ?number)
Call the given function for each element between the given indices.
This tends to be more efficient than looping over the indices and
calling get
, because it doesn't have to descend the tree for every
element.
to
may be less then from
, in which case the iteration will happen
in reverse (starting at index from - 1
, down to index to
.
The iteration function may return false
to abort iteration early.
map
(f: fn(element: T, index: number) → U, from: ?number, to: ?number) → [U]
Map the given functions over the elements of the rope, producing a flat array.
flatten
() → [T]
Return the content of this rope as an array.
FAQs
Rope-based persistent sequence type
The npm package rope-sequence receives a total of 2,209,869 weekly downloads. As such, rope-sequence popularity was classified as popular.
We found that rope-sequence demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.