5.0.0 • Published 4 years ago

arc-array v5.0.0

Weekly downloads
2,950
License
ISC
Repository
github
Last release
4 years ago

arc-array Build Status

An array convenience subclass for javascript.

Install

$ npm install arc-array --save

Features

  • callback based join
  • native convenience binding (if desired)
  • extends native array so should be compatible

API

static ArcArray.wrap(array:Array)

Accept an array, and if it is already an ArcArray return the same object, otherwise create a new ArcArray utilizing the passed in array

new ArcArray(...args)

Create a new ArcArray object. Requires new

.shuffle()

Shuffles an array in place.

.rand()

Returns a random element from the array

async .pMap(async callable)

Iterates over an array like a map, but treating each callable as async, awaits for all to resolve like a Promise.all

const someArray = ArcArray.wrap([1,2,3]);
const someResolvedResponse = await someArray.pMap(async (val) => { 
    const response = await someRemoteCall(val);
    return response;
})

.joinCallback(callback:Function , separator:String)

Create a string based on the returned values from a callback on each index of an array.

callback is a function that receives each value of the array, and is expected to return a value that will be used to create the joined string.

//Example of joinCallback
const items = new ArcArray('item1','item2','item3');
const string = items.joinCallback(function(_val){
    return '<li>'+_val+'</li>'
},'');

//String returned is: <li>item1</li><li>item2</li><li>item3</li>

Testing

npm test
5.0.0

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.2.0

6 years ago

4.1.0

7 years ago

4.0.1

9 years ago

4.0.0

9 years ago

3.2.2

9 years ago

3.2.1

9 years ago

3.2.0

10 years ago

3.1.0

10 years ago

3.0.0

10 years ago

2.1.0

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago