npm.io
0.1.0 • Published 11 years ago

array-wrapper

Licence
ISC
Version
0.1.0
Deps
1
Vulns
6
Weekly
0

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

Keywords