Skip to content

St-Random/iterables-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iterables.ts

Custom generic Iterable and IterableIterator implementation in TypeScript (compiled to ES6) that supports:

  • length property
  • indexOf(searchElement, fromIndex?)
  • includes(value, fromIndex?)
  • elementAt(position)
  • some(callback, thisArg?)
  • every(callback, thisArg?)
  • find(callback, thisArg?)
  • findIndex(callback, thisArg?)
  • forEach(callback, thisArg?)
  • reduce(callback, initialValue?, thisArg?)
  • filter(callback, thisArg?)
  • map(callback, thisArg?)

as well as BidirectedIterable that supports iteration in backwards direction. filter and map methods executes deferredly (they are implemented using generator functions) and return custom iterators, that allow chain calls (like iterable.filter(...).map(...).forEach(...)).

Also includes LinkedList implementation that supports backwards/forwards iteration on nodes and values (with all the above methods) as the proof of concept.

Covered with unit tests using AVA. Use npm run test and npm run test-report to run the tests and build coverage report respectively.

Code review would be welcome.

About

Custom generic Iterable, IterableIterator and LinkedList implemetation in TypeScript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published