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

peakle

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

peakle

  • 0.0.1
  • latest
  • npm
  • Socket score

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

Peakle is a tiny abstraction around lists that makes them more walkable.

Peakle's constructor takes only one parameter, a list of values.

var peakled = new Peakle([ 1, 2, 3 ]);

By default, the current position is always at the first element. If the initial list is empty, then the current position is 'null'.

Properties:

* length: returns a number of elements in the underlying list.
* current: returns a value of the current element.

Methods:

* next(): Moves to the next element and returns its value.
* prev(): Moves to the previous element and returns its value.
* peak(adv): Returns next element's value without moving its pointer.
  This method accepts an optional numeric parameter. Use it if you
  want to peak further.
* move(index): Moves to the specified element.

All methods return 'null' if they can't return a value.

Example:

var peakled = new Peakle([ 1, 2, 3 ]);

peakled.current;  // 1
peakled.peak();   // 2
peakled.peak(2);  // 3

peakled.next();   // 2
peakled.peak();   // 3
peakled.peak(2);  // null
peakled.peak(-1); // 1

peakled.prev();   // 1
peakled.move(2);  // 3

FAQs

Package last updated on 10 Aug 2012

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