File: util.coffee

Defined in:

Method Summary

Method Details

? (void) root.defer()

? (void) encode(x)

? (void) qsFromList(pairs)

? (void) root.querystring(obj)

Serialize an object or array as a query string.

? (Promise) root.withCB(fs..., p)

Attach a node-style callback (err, result), yielding the original promise. @param f The callback @param p The promise

Returns:

  • (Promise) — The promise

? (void) root.take(n)

? (void) root.filter(f)

Curried version of filtering

? (void) root.uniqBy(f, xs)

? (void) root.find(xs, f)

? (void) root.escape(str)

XML escaping

? (void) root.omap(f)

Until I can find a nicer name for this... Basically a mapping over an object, taking a function of the form (oldk, oldv) -> [newk, newv] with the addition of shallowly copying any values that are arrays.

? (void) root.partition(f)

? (void) root.concatMap(f)

Implementation of concatmap.

This a function that applies a function to each member of an array, and combines the results through the natural method of combination. Arrays are concatenated, and strings are, well, concatenated. Objects are merged.

@param f The function to apply to each item. @param xs The things to apply them to.

? (void) root.map(f)

? (void) root.compose(fs...)

? (void) root.difference(xs, remove)

? (void) root.stringList(x)

? (void) root.any(xs, f = id)

? ((obj) -> ?) root.get(name)

Get a function that gets a named property off an object.

Parameters:

  • name (String) the name of the property

Returns:

  • ((obj) -> ?) — A function that gets a property's value.

? ((obj) -> ?) root.set(name, value)

Get a function that sets a named property, or set of properties on an object, returning the new state of the object.

Examples:

promise.then(set('name', 'Anne'))
promise.then(set({name: 'Bill', age: 43}))

Parameters:

  • name (String|Object) the name of the property, or an object of properties to set.
  • value (?) The value to set (optional).

Returns:

  • ((obj) -> ?) — A function that sets a property's value, and returns the object.

? (void) REQUIRES(required, got)

Make a function that lets users know when they are trying to use a service that isn't supported by their current service.

? (void) root.REQUIRES_VERSION(s, n, f)

A wrapper for functions that make requests to endpoints that require a certain version of the intermine API.

? (void) root.dejoin(q)

Helper function that makes sure a query doesn't have any implicit constraints through the use of inner-joins. All chains of references will be converted to outer-joins.

? (void) root.sequence(fns...)

? (void) root.pairsToObj(pairs)