Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

megakorre/jsseq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A Seq libary for javascript

This libary dosen't use the window object so it can be 
used in google app's scripting
and anny other evnierment that dosent depend on the window object

this is a general purpose sequence libary for javascript
it suportes lazy cached sequnces (dont keep the head)
and comes with all the seq functions you shuld need.
(if it is missing anny you can file it as a bugg :D)

EXAMPLE:
 var x = seq([1,2,3]);
 var y = seq([2,3,4]);
 x.eq(y.select(function(v) { return v - 1; })) -> true
 
 methods:
  each: takes a function and calles it for every value in the seq
  select: takes a function and lazyly cales it on all items in seq
  where: takes a predicate function and lazily filters all items in the seq
  concatt: takes a second seq and lazily adds adds it to the seq
  reverse: reverses the seq
  order_by: takes a index and lazyly orders the seq after that index
  first: gives you the first item
  rest: gives you a new seq with all but the first item
  to_list: returns a new javascript array with all the items in the seq
  fold: takes a seed and a function and reduces the list
  reduce: takes a function and reduces the list
  cons: adds a item to the seq
  bind: (as in monads)
  count: counts the number of items in the seq
  flatten: flattens the seq one step
  sum: adds all the item in the seq and returns it
  where_index: like where but indexes the item in the seq to be applied to the predicate
  eq: compares all the items in a seq to a second seq only uses == (migth be empovered in the future)
  nth: gives you the nth item in the sequece  
  take: takes a number n and returns you a seq of n items or how manny there is in the seq 
  skip: skipes n items in the seq
  starts_with: takes a seq and returns true if the seq starts with the taken seq


 statics:
  from_list: takes a js arrar and returns seq
  add_methods: extends the seq object with methods takes a hash from names to functions
  add_dispatch: add a dispatche item to the seq function
  cons: cons a item to a seq
  from_range: takes [end], [start, end] or [start, step, end] and gives you a seq from that range
  from_hash: takes a object and gives you a seq with the structure { key: value: }
  from_callback: takes a function wich it calles every time a new item of the seq is requested
                 the function shuld return null when it has no more items
  empty: gives you a empty sequence

About

a seq libary for javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published