Giter VIP home page Giter VIP logo

spread.js's Introduction

Spread.js

Spread your data on arrays as you spread nutella on your bread. pretty even.

So what does it do?

Spread your data. for example inputting ["a","a","b"] will output ["a","b","a"].
So that if you need to bash things you do it controlled. no more nutella rests on one side!
And since it uses a odd-in-the-middle technique all the "unique" items get pushed into the middle ("aaaabc" becomes "aabcaa" f.x.).

How do I use it?

Install via NPM (npm i spread.js) or include spread.min.js to your webpage

in NodeJS use var Spread = require('spread.js')

Function reference

Async

Spread([ARRAY<number|string>],function(err,result)):

Spread([1,2,3,3,2,3,3],function(err,res){ console.log(res) });
> ["3", "2", "3", "1", "3", "2", "3"]

Spread([ARRAY<object|array>],KEY_IN_OBJECT,function(err,result)):

Spread([{"value":1,"index":0},{"value":2,"index":1},{"value":3,"index":2},{"value":3,"index":3},{"value":2,"index":4},{"value":3,"index":5},{"value":3,"index":6}],'value',function(err,res){ console.log(res) })
> [{"value":3,"index":2},{"value":2,"index":1},{"value":3,"index":3},{"value":1,"index":0},{"value":3,"index":5},{"value":2,"index":4},{"value":3,"index":6}]

Sync

Spread.async([ARRAY<number|string>])

Spread.async([ARRAY<object|array>],KEY_IN_OBJECT)

License

This all is licensed by the MIT license

spread.js's People

Contributors

the-eater 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.