Giter VIP home page Giter VIP logo

circular's Introduction

#Circular

What

A simple and tiny Javascript implementation of a circular buffer. There are two implementations:

  • 'circular.js': based on the Prototype pattern ('Circular' object)
  • 'circularModule.js': based on the Module pattern ('circular' object)

Getting it

git clone --depth=1 https://github.com/ricca509/circular.git

Using it

Prototype pattern:

var buffer = new Circular();
// or
var buffer2 = new Circular(["a", "b", "c", "d"]); // Initialize with an array

Module pattern:

var buffer = circular();
// or
var buffer2 = circular(["a", "b", "c", "d"]); // Initialize with an array

Then

buffer.add("value-1");
buffer.add("value-2");

console.log(buffer.next());	// Output: "value-1"
console.log(buffer.next());	// Output: "value-2"
console.log(buffer.next());	// Output: "value-1"
console.log(buffer.prev());	// Output: "value-2"

Testing it

There is a Grunt file to run QUnit tests and Hinting.

$ grunt qunit
$ grunt jshint

or, easier

$ npm test

Tools used

If you have any questions or feedback, feel free to contact me using @CoppolaRiccardo on Twitter.

circular's People

Contributors

ricca509 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.