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

array-encode-decode

v1.0.2

Published

The array-encode-decode library is a versatile JavaScript tool designed for creating 1D, 2D, or 3D arrays, as well as encoding or decoding them along with optional metadata. The library employs an efficient Run-Length Encoding algorithm for encoding and d

Downloads

22

Readme

Array Encode / Decode

A versatile package for creating, encoding, and decoding arrays of various dimensions.

Installation

npm install array-encode-decode

Available Methods

Method | Description ------------- | ------------- create1D | Creates a 1-Dimensional array along the x-axis create2D | Creates a 2-Dimensional array along the x and y axes create3D | Creates a 3-Dimensional array along the x, y, and z axes encode | Encodes an array and returns its run-length encoded representation along with its metadata (optional) decode | Decodes a run-length encoded array and its metadata to its original form

Usage

Import the package as follows:

const ArrayEncoderDecoder = require("array-encode-decode");

Creating a 1D array

The create1D method creates a 1-dimensional array of a specified size along the x-axis. The values field is optional. If not provided, the array will be populated with the default value - 0.

let x = 10;  // size along the x-axis
let value = 2;  // example value (optional)
let array1D = ArrayEncoderDecoder.create1D(x, value);

Creating a 2D array

The create2D method creates a 2-dimensional array of a specified size along the x and y axes. The values field is optional. If not provided, the array will be populated with the default value - 0.

let x = 5;  // size along the x-axis
let y = 4;  // size along the y-axis
let value = 3;   // example value (optional)
let array2D = ArrayEncoderDecoder.create2D(x, y, value);

Creating a 3D array

The create3D method creates a 3-dimensional array of a specified size along the x, y, and z axes. The values field is optional. If not provided, the array will be populated with the default value - 0.

let x = 3;  // size along the x-axis
let y = 2;  // size along the y-axis
let z = 1;   // size along the z-axis
let value = 4;   // example value (optional)
let array3D = ArrayEncoderDecoder.create3D(x, y, z, value);

Encoding an Array

let inputArray = ArrayEncoderDecoder.create3D(3, 2, 1);
let encodedArray = ArrayEncoderDecoder.encode(inputArray);
console.log("Encoded Array Size:", ArrayEncoderDecoder.displayBytes(JSON.stringify(encodedArray).length));

Decoding an Array

let decodedArray = ArrayEncoderDecoder.decode(encodedArray);
console.log("Decoded Array:", decodedArray);

License

MIT