Sha256: 405c05f624ab0ba14174bbc2ee7d9b4b98d23b7b19f06092e07ea93407a53fe5
Contents?: true
Size: 1.17 KB
Versions: 14
Compression:
Stored size: 1.17 KB
Contents
{ I" metadata:ET{ I" code; TI"p"use strict"; _.mixin({ // Strip an object any keys paired with null values compactObject: function compactObject(object) { var newObject = _.extend({}, object); _(newObject).each(function (v, k) { if (v == null) { delete newObject[k]; } }); return newObject; }, // If arrayOrObject is an array, map over it with iteree, otherwise pass // arrayOrObject to iteree once. Useful for removing conditionals from methods // that need to handle individual items and also handle arrays of items by // performing the same operation on each item. This is common when processing // JSON API structures. mapIfArray: function mapIfArray(arrayOrObject, iteree) { if (_.isArray(arrayOrObject)) { return arrayOrObject.map(iteree); } else { return iteree(arrayOrObject); } }, // Similar to mapIfArray from above, but it also flattens the resulting array flatMapIfArray: function flatMapIfArray(arrayOrObject, iteree) { if (_.isArray(arrayOrObject)) { return _.flatten(arrayOrObject.map(iteree)); } else { return iteree(arrayOrObject); } } });; TI"map; T0I"ast; T0
Version data entries
14 entries across 14 versions & 1 rubygems