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

unlimilists

v0.0.3

Published

Unlimited lists in javascript

Downloads

5

Readme

Unlimilists

Unlimilists is a way to create unlimited array-like objects. All objects created using Unlimilsts constructor don't store their values but calculate at the moment of accessing the array field.

Getting started

This section explains how to get started with Unlimilists. First of all install it.

npm i unlimilists

Then you can import it.

import {Ulist} from 'unlimilists';

Create a new Ulist by passing a formula to the constructor. You can use n variable in your formula, and it will be changed to current array index.

import {Ulist} from "./index.js";

const ulist = new Ulist('2*n + 1*n^3 - 0.2*n^4');

// calculate element of Ulist with index 10
const tenthElement = ulist[10]; // 2*10 + 10**3 - 0.2*10**4 = -980

API Ulist

constructor

Gets an initial formula which is calculated every time the user tries to get an element by index. The second parameter turns on memoization.

Available operations:

  • * - multiply
  • + - add
  • - - subtract
  • / - divide
  • ^ - power

Examples

const ulist_1 = new Ulist('2 * (2 - 4)'); // [-4, -4, -4, ....]
const ulist_2 = new Ulist('2*n + 1*n^3 - 0.2*n^4'); // [0, 2.8, 8.8, 16.8, ....]

const ulist_3 = new Ulist('2*n', true); // [0, 2, 4, 6, ...] memoization is turned on

getFormula

Returns an initial formula.

Example

const ulist_1 = new Ulist('2 * (2 - 4)'); // [-4, -4, -4, ....]
const formula = ulist_1.getFormula(); // 2 * (2 - 4)

slice

firstIndex: number
lastIndex: number
step?: number (default = 1)

Returns an array with elements from firstIndex to lastIndex (lastIndex is not included).

Example

const ulist_1 = new Ulist('2 * (2 - 4*n)'); 

const array_1 = ulist_1.slice(0, 5); // [ 4, -4, -12, -20, -28 ]
const array_2 = ulist_1.slice(0, 10, 2); // [ 4, -12, -28, -44, -60 ]

power, divide, multiply, subtract, add

anotherList: Ulist | number;

Modifies the current Ulist's formula.