Skip to content

igl/prelude

Repository files navigation

#Prelude Build Status

Utility set for JS.

Example

var sortPostsByName = prelude.array.sortBy(function (post) { return post.name; });
var sorted_posts = sortPostsByName posts

Installation

npm install prelude

Methods

All functions with 2 or more arguments are curried and generally return copies of their inputs, thus treating them as immutable (with the exception of object.assign and .deepAssign where this behavior is not always wanted).

Function collection are also exported by their uppercased initial letter. (prelude.S === prelude.string, prelude.A === prelude.array...)

Array prelude.array.<method>

  • empty
  • has
  • includes / contains
  • clone
  • head / first
  • tail
  • last
  • initial
  • slice
  • concat
  • flatten
  • reverse
  • each
  • map
  • filter
  • shuffle
  • every
  • some
  • zip
  • zipWith
  • partition
  • unique
  • uniqueBy
  • difference
  • intersection
  • union
  • sortBy
  • countBy
  • groupBy
  • splitAt
  • index
  • indices
  • findIndex
  • findIndices

Object prelude.object.<method>

  • empty
  • has
  • includes / contains
  • keys
  • values
  • clone
  • flatten
  • explode
  • each
  • map
  • filter
  • every
  • some
  • partition
  • keyOf
  • keysOf
  • findKey
  • findKeys
  • fromPairs
  • toPairs
  • fill
  • deepFill
  • assign / mixin
  • deepAssign / deepMixin
  • merge
  • deepMerge
  • freeze
  • deepFreeze
  • toJSON
  • fromJSON
  • fromJSONUnsafe
  • definePublic
  • definePrivate
  • defineStatic
  • defineMeta

String prelude.string.<method>

  • empty
  • includes / contains
  • startsWith
  • endsWith
  • trim
  • trimLeft
  • trimRight
  • repeat
  • reverse
  • capitalize
  • capitalizeSentence
  • decapitalize
  • decapitalizeSentence
  • camelize
  • dasherize

Number prelude.number.<method>

  • even
  • odd
  • random
  • range
  • gcd
  • lcm

Func prelude.func.<method>

  • id
  • curry
  • compose
  • apply
  • applyTo
  • applyNew
  • flip
  • delay
  • interval
  • immediate
  • tryCatch
  • chain

Type prelude.type.<method>

  • getType
  • isNumber
  • isString
  • isBoolean / isBool
  • isFunction
  • isArray
  • isSet
  • isObject
  • isMap
  • isArguments
  • isDate
  • isError
  • isRegExp
  • isSymbol
  • isDefined
  • isNull
  • isUndefined
  • isUUID
  • isInteger / isInt
  • inRange
  • isNumberArray
  • isStringArray
  • isBooleanArray / isBoolArray
  • isFunctionArray
  • isArrayArray
  • isSetArray
  • isMapArray
  • isArgumentsArray
  • isObjectArray
  • isDateArray
  • isErrorArray
  • isRegExpArray
  • isSymbolArray
  • isNullArray
  • isUndefinedArray
  • isUUIDArray
  • isIntegerArray / isIntArray
  • isDefinedArray

Kudos

Thanks to George Zahariev for LiveScript and prelude-ls which made an awesome base for this lib.