Skip to content

pantheonsh/ArrayThatStartsAnywhere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ArrayThatStartsAnywhere

How about an array that starts at Math.PI?

Node.js

npm install array-that-starts-anywhere
const ArrayThatStartsAt = require("array-that-starts-anywhere").ArrayThatStartsAt;

let arr = new ArrayThatStartsAt(72);
arr.push("ay");
arr.push("ay");
arr.push("captain");
arr.push("i can't hear you");
arr.push("ay");
arr.push("ay");
arr.push("captain");
arr[75] // => "i can't hear you"

Browser

<script src="./lib/index.js"></script>
let arr = new ArrayThatStartsAt(72);
arr.push("ay");
arr.push("ay");
arr.push("captain");
arr.push("i can't hear you");
arr.push("ay");
arr.push("ay");
arr.push("captain");
arr.filter(i => i === "ay"); // => {72: "ay", 73: "ay", 74: "ay", 75: "ay", startIndex: 72, length: 4}

Custom methods

ArrayThatStartsAt#keys ArrayThatStartsAt#asABoringJSArrayWhyAreYouEvenUsingThisFunctionIfYouCanHaveArraysThatStartWhereverYouWant

More fun

let arr = new ArrayThatStartsAt(Math.PI);
let arr = new ArrayThatStartsAt(Math.random());
let arr = new ArrayThatStartsAt(parseFloat(Date.now()));
let arr = new ArrayThatStartsAt(Infinity); // only one item supported in this, sadly :(

pls contribute

There are some Array methods currently unimplemented.

About

How about an array that starts at Math.PI?

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published