Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-next

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-next

Advance to the next item in the array looping when hitting the end.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-36.95%
Maintainers
1
Weekly downloads
 
Created
Source

array-next

Super tiny module that returns the next item in an array when given an item in the array.

If you give it the last item in the array and call next it will loop around and give you the first.

installing

npm install array-next

how to use

var next = require('array-next');

// our demo array
var arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];

// if none specified next should return first
next(arr); // returns 'a'

// when given an item in the array it returns the next one
next(arr, 'a'); // returns 'b'

// it also loops if you give it the last item
next(arr, 'c'); // returns 'a'

credits

If you like this, follow @HenrikJoreteg on twitter.

Check out similar resources at: http://resources.humanjavascript.com.

And check out my book: http://humanjavascript.com

unit tests?

run them with npm test

read them here: test.js

license

MIT

Keywords

FAQs

Package last updated on 11 Nov 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc