0.8.2 • Published 8 years ago

prelude v0.8.2

Weekly downloads
28
License
MIT
Repository
github
Last release
8 years ago

Prelude

build status npm version npm downloads

Utility set for JS. All functions with 2 or more arguments can be partially applied and generally return copies of their inputs, thus treating them as immutable.

Github pages with more detailed examples are coming soon... (All methods are listed below)

  • Written in LiveScript.
  • Inspired by prelude-ls, underscore and fast.js.
  • Every function can be partially applied and never mutates input.
  • 300+ Tests

Examples

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

Get Functions:

import { array, O } from 'prelude'
import { isArray } from 'prelude/lib/type'

Use Functions:

if (isArray(xs)) {
    array.map(o => O.merge(o, { visited: true }))(xs)(xs)
}

Create helper using partial application:

const sortPostsByName = prelude.array.sortBy(post => post.name)
const sorted_posts = sortPostsByName(posts)

Handy for Promises (TODO: use rx):

getPosts('*')
    .then(sortPostsByName)
    .then(sorted_posts => joyful(true))

Installation

npm install --save prelude

Methods

Array prelude.array.<method>

  • empty
  • has
  • includes / contains
  • clone
  • head / first
  • tail / rest
  • last
  • initial
  • slice
  • splice
  • concat
  • remove
  • removeOne
  • flatten
  • reverse
  • each
  • map
  • filter / find
  • findOne
  • 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
  • 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
  • once
  • chain

Type prelude.type.<method>

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

Kudos

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

0.8.2

8 years ago

0.8.1

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago