0.3.0 • Published 7 years ago

iterables-js v0.3.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago
//Define a class
class Example {
  constructor(
    public id: number,
    public name: string
  ){}
}

//Create a collection that identifies objects by its 'id'
let collection = new Collection<Example>('id');

//Adding a new element
let obj = new Example(1, 'Example1');
collection.add(obj);

//Adding elements array
let array = [new Example(2, 'Example2')];
collection.addElements(array);

//Get element by index
let obj = collection.get(0); //Return obj

//Get element by key
let obj = collection.getByKey('1') //Return obj

//Removing element
collection.remove(obj);

//Check if collection contains an element
collection.contains(obj);

//Get collection size
let size = collection.size();

//Iterate
for(element of collection.elements())
{
  //
}
0.3.0

7 years ago

0.2.0

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago