npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zenenwjaimes/array-stream-traversal

v1.37.0

Published

Traverse arrays with file stream like abilities (seek, read, tell)

Downloads

4

Readme

array-stream-traversal

Adds the ability to traverse an array with file stream like abilities such as seek, read, tell.

Example Usage

import {ArrayStreamT} from 'array-stream-traversal';

const exampleArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

try {
  const ast = ArrayStreamT.load(exampleArray);
  const res = ast.read(4); // res = [0, 1, 2, 3]
  
  ast.seek(1); // pointer should be at idx 1
  
  const res2 = ast.read(1); // [1] and move pointer to idx 2
  
  ast.seek(2, ArrayStreamT.SeekPos.CURR); // Seeks from current position, so it adds on instead of resettting to beginning
  
  console.log(ast.tell()); // 4
  console.log(ast.read()); // 5
}
catch(err) {
  // do error things here
} 

ArrayStreamT

External ArrayStreamT object

ArrayStreamT~SeekPos ⇒ object

Seek whence constant SET: Starts seek from beginning of array CURR: Seek from current position

Kind: inner enum of ArrayStreamT
Properties

| Name | Type | Default | | --- | --- | --- | | SET | integer | 0 | | CURR | integer | 1 |

ArrayStreamT~InvalidLengthException(message) ⇒ Error

Returns custom invalid length exception

Kind: inner method of ArrayStreamT

| Param | Type | Description | | --- | --- | --- | | message | string | exception message |

ArrayStreamT~InvalidPositionException(message) ⇒ Error

Returns custom invalid position exception

Kind: inner method of ArrayStreamT

| Param | Type | Description | | --- | --- | --- | | message | string | exception message |

ArrayStreamT~load(data, makeCopy:, position:, whence:) ⇒ object

ArrayStreamT Object

Kind: inner method of ArrayStreamT
Returns: object - returns array, read/seek/tell methods

| Param | Type | Description | | --- | --- | --- | | data | Array | | | makeCopy: | boolean | Copies the array (recommended), default true | | position: | integer | Starting position, default 0 | | whence: | integer | Where to start seeking from, default SeekPos.SET |

ArrayStreamT~read(len:) ⇒ array

Read x amount of bytes/items

Kind: inner method of ArrayStreamT

| Param | Type | Description | | --- | --- | --- | | len: | integer | -1 reads til eof, has to be 0+ |

ArrayStreamT~seek(offset:, whence:) ⇒ this

Sets the current position

Kind: inner method of ArrayStreamT

| Param | Type | Description | | --- | --- | --- | | offset: | integer | position | | whence: | integer | where to start seeking (start, current) |

ArrayStreamT~tell() ⇒ integer

Returns current position of the pointer

Kind: inner method of ArrayStreamT