0.1.0 • Published 9 years ago

array-wrapper v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
9 years ago

Array-Wrapper

Description

Simple wrapper around arrays providing a inbuilt interator to assist with callback functions

API Usage

var sampleLinks = ['http://www.google.com', 'http://www.nodejs.org', 'http://www.stackoverflow.com']; var Wrapper = require('array-wrapper'); var links = new Wrapper(sampleLinks); // builds the wrapper

console.log('get first element', links.get()); //gets the first element or the element the wrapper is currently pointing at console.log('shift the pointer to the second link', links.next()); //shifts the pointer console.log('get current element (second element)', links.get()); // prints 'http://www.nodejs.org', the next element

console.log('move the pointer to the previous link', links.previous());

Pointing the pointer to an out of bounds element returns undefined - it does not differentiate between an array with undefined elements and out of bounds elements