å useful object

What is å?
How to use it
å.store_data(data)
å.stripes(n)
å.methods()
I want to learn it

What is å?

I have a json Object with more than 100.000 data sets and I want to loop through each of them. I want to split the large json data response into smaller more consumable pieces (I call them "stripes").

To write less code in future I try to make use of my å object with some useful functions like .get_next_stripe(); or .get_prev_stripe(); to easily get the next or the prev stripe (Array with sliced data of the original json response).

å object

Note: You can type the character å by alt-a on mac and windows

You can download the source code for this article here:

Github

Wanna dive in the code directly? You can view the Pen here

Codepen

Your Console should say stripes count: 147... Jep? Fine!

If you see nothing or something like this:

console errow

You might switch to the <result-iframe>.

switch to result iframe

å.store_data(data)

I initialize å by calling the .store_data(data) function and pass a json object as argument. Like this:

å.stripes(n)

I want to split the original data into n stripes.I can do that by calling .stripes(n) function where n is the length of one stripe.

Fine! I'm ready now to call the first stripe by calling the å.get_next_stripe(). Result should be the first stripe. Yeah!

å.methods()

å.stripes(n);
split the data into multiple stripes. The length of each stripes is n. Default for n is 10.

å.get_prev_stripe();
returns the previous stripe.

å.get_next_stripe();
returns the next stripe.

å.get_stripe(n);
returns the n-th stripe.
Keep in mind that .get_prev_stripe() and .get_next_stripe() change too!

å.loop
Default is true. If there is no next stripe å will return the first stripe again (index is 0 based).

You can download the source code for this article here:

Github

Wanna dive in the code directly? You can view the Pen here

Codepen