Skip to content

Instantly share code, notes, and snippets.

@askucher
Created September 26, 2013 13:06
Show Gist options
  • Save askucher/6713889 to your computer and use it in GitHub Desktop.
Save askucher/6713889 to your computer and use it in GitHub Desktop.
Null Safe Prelude
const p = require \prelude-ls
const safe = (a, b, c) --> if c? then c |> p.filter (?) |> a b
module.exports =
each : safe p.each
map : safe p.map
compact : safe p.compact
filter : safe p.filter
reject : safe p.reject
partition : safe p.partition
find : safe p.find
head : safe p.head
first : safe p.first
tail : safe p.tail
last : safe p.last
initial : safe p.initial
empty : safe p.empty
reverse : safe p.reverse
unique : safe p.unique
fold : safe p.fold
foldl : safe p.foldl
fold1 : safe p.fold1
foldl1 : safe p.foldl1
foldr : safe p.foldr
foldr1 : safe p.foldr1
unfoldr : safe p.unfoldr
concat : safe p.concat
concat-map : safe p.concat-map
flatten : safe p.flatten
difference : safe p.difference
intersection : safe p.intersection
union : safe p.union
count-by : safe p.count-by
group-by : safe p.group-by
and-list : safe p.and-list
or-list : safe p.or-list
any : safe p.any
all : safe p.all
sort : safe p.sort
sort-with : safe p.sort-with
sort-by : safe p.sort-by
sum : safe p.sum
product : safe p.product
mean : safe p.mean
average : safe p.average
maximum : safe p.maximum
minimum : safe p.minimum
scan : safe p.scan
scanl : safe p.scanl
scan1 : safe p.scan1
scanl1 : safe p.scanl1
scanr : safe p.scanr
scanr1 : safe p.scanr1
slice : safe p.slice
take : safe p.take
drop : safe p.drop
split-at : safe p.split-at
take-while : safe p.take-while
drop-while : safe p.drop-while
span : safe p.span
break-list : safe p.break-list
zip : safe p.zip
zip-with : safe p.zip-with
zip-all : safe p.zip-all
zip-all-with : safe p.zip-all-with
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment