JSPM

  • Created
  • Published
  • Downloads 9419143
  • Score
    100M100P100Q219539F

ECMAScript5 extensions

Package Exports

  • es5-ext
  • es5-ext/lib/Function/aritize
  • es5-ext/lib/Function/bind-bind
  • es5-ext/lib/Function/curry
  • es5-ext/lib/Function/dscope
  • es5-ext/lib/Function/functionalize
  • es5-ext/lib/Function/invoke
  • es5-ext/lib/Function/is-function
  • es5-ext/lib/Function/k
  • es5-ext/lib/Function/noop
  • es5-ext/lib/Function/sequence
  • es5-ext/lib/List/concat
  • es5-ext/lib/List/every
  • es5-ext/lib/List/flatten
  • es5-ext/lib/List/map
  • es5-ext/lib/List/slice
  • es5-ext/lib/Object/bind-methods
  • es5-ext/lib/Object/extend
  • es5-ext/lib/Object/merge
  • es5-ext/lib/Object/plain/for-each
  • es5-ext/lib/Object/plain/map
  • es5-ext/lib/Object/plain/merge
  • es5-ext/lib/Object/plain/values
  • es5-ext/lib/String/convert/dash-to-camel-case
  • es5-ext/lib/global
  • es5-ext/lib/reserved

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (es5-ext) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

es5-ext - ECMAScript5 extensions

Useful functions and objects that are not part of the standard.
It's work in progress, new methods are added when needed.

Installation

Can be used in any environment that implements EcmaScript 5th edition.
To make it work with EcmaScript 3, apply es5-shim.

To use it with node:

$ npm install es5-ext

Usage

Recommended way is to require stuff you need individually:

var sequence = require('es5-ext/lib/Function/sequence')
  , merge = require('es5-ext/lib/Object/merge').call;

sequence(...);
merge(...);

but you can grab whole packs:

var fnExt = require('es5-ext/lib/Function');

fnExt.curry(...);
fnExt.sequence(...);

and if you prefer take them all:

var ext = require('es5-ext');

ext.Function.curry(...);
ext.Function.sequence(...);
ext.Object.merge.call(...);

Extensions

Each extension is documented at begin of its source file.

  • global
  • reserved

Function

Many of the following are inspired by http://osteele.com/sources/javascript/functional/

  • Function.aritize(f, n)
  • Function.bindApply(f)
  • Function.bindBind(f)
  • Function.bindCall(f)
  • Function.clone(f)
  • Function.curry(f[, ...])
  • Function.dscope(f, scope)
  • Function.flip(f)
  • Function.functionalize(f)
  • Function.inherit(f, g)
  • Function.invoke(methodName[, ...])
  • Function.isFunction(x)
  • Function.k(x)
  • Function.noop()
  • Function.pluck(name)
  • Function.s(f, g)
  • Function.saturate(f)
  • Function.sequence(f[, ...])

List

Extensions for Array-like objects.

  • List.compact()
  • List.concat([...])
  • List.every(f[, o])
  • List.filter(f[, o])
  • List.flatten()
  • List.forEach(f[, o])
  • List.isList(x)
  • List.map(f[, o])
  • List.reduce(f[, x])
  • List.slice([start[, end]])
  • List.some(f[, o])
  • List.toArray()

Object

Following takes into account all ES5 goodies (not enumerable properties, descriptors). For more tradtional ES3 like stuff see Object.plain below

  • Object.bindMethods([p[, q]])
  • Object.every(f[, p])
  • Object.extend(o)
  • Object.merge(p)
  • Object.pluck(name)
  • Object.same()

Object.plain

Following are about hash'es (simple enumerable key value pairs)

  • Object.plain.clone()
  • Object.plain.compare(p)
  • Object.plain.elevate([p])
  • Object.plain.every(f[, p])
  • Object.plain.filter(f[, p])
  • Object.plain.forEach(f[, p])
  • Object.plain.isEmpty()
  • Object.plain.isPlainObject()
  • Object.plain.link(p)
  • Object.plain.map(f[, p])
  • Object.plain.merge(p)
  • Object.plain.pluck(name)
  • Object.plain.same()
  • Object.plain.setTrue()
  • Object.plain.setValue(value)
  • Object.plain.set()
  • Object.plain.values()

String

Convertion methods:
  • String.convert.dashToCamelCase(str)