Utility methods

Part of: tag_Utilities

Each Sqimitive instance inherits a bunch of functions from your utility library – those used to sort, filter, transform, count, locate, cook, boil, slice up and serve nest’ed children as standard objects and arrays. For example:

sqim.filter(child => child.get('enabled'))
// Instead of:
_.filter(sqim.slice(), child => child.get('enabled'))

These functions are generally portable but with subtle differences in availability and behaviour between NoDash, Underscore un: and LoDash – check the compatibility table for details: squizzle.me/js/nodash/p_compat.….

For portability avoid using shortcut iterator syntax – it’s only supported in Underscore (un:iteratee), not in NoDash, LoDash or in standard Array/Object methods. Notable exceptions are pick()/omit(): in Underscore and NoDash the iterator may be a function or a list of property names, in LoDash – list only.

If doing several transformations one after another consider _() which allows chaining.

from unordered

Attention: JavaScript objects are unordered. See the description of Ordered.

For this reason some methods are only available when mixing-in Sqimitive\Ordered which guarantees iteration order.

Methods working with children keys (nested())

iterator = function (Sqimitive child, string parentKey)
Example: sqim.keys() → _.keys(sqim.nested()).

Methods available for Sqimitive\Base subclasses:

Methods working on children positions (slice())

iterator = function (Sqimitive child, int index)
Example: sqim.sample() → _.sample(sqim.slice()).

from unordered

Attention: JavaScript objects are unordered. See the description of Ordered.

If Sqimitive\Ordered is not used, index is an arbitrary number sequential in this particular call to the utility method; sqim.filter((c, i) => sqim.slice(i, 1)) may produce undefined behaviour. For Ordered, index is stable and can be given to at() or slice().

Methods available for Sqimitive\Base subclasses:

Methods available if mixed-in Sqimitive\Ordered:

Defined in: HELP.chem, lines 1373-1478 (106 lines)