Skip to content

A Javascript library that offers extended functionality to standard Javascript object types.

License

Notifications You must be signed in to change notification settings

lordliquid/Sugary

Repository files navigation

Sugary

A javascript library that offers extended functionality to standard javascript object types.

Currently in production, contributors welcome.

Array Prototype Functions

.cycle()

Returns an object with useful helper methods for stepping through the array with .next() and .previous()..

Usage

Step 1:

Assign an array

let array = [1, 2, 3, 4];

Step 2:

Assign a new variable to store the cycle object.

let arrayCycle = array.cycle();

Step 3:

Start the cycle

NOTE: Without providing arguments the cycle starts at the first index of the array. You can optionally pass in a starting index.

arrayCycle.start(); 

Optionally takes a starting index.

.start(1)

Step 4: Cycle by calling either next() or previous() methods.
arrayCycle.next();

Example

let arrayCycle = ['John Smith', 'Chris Johnson', 'Mike Henry', 'Amy Michelle'].cycle();
arrayCycle.start(1);
arrayCycle.next();
arrayCycle.previous();

About

A Javascript library that offers extended functionality to standard Javascript object types.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published