Recursively pluck attributes from either a Model or Collection.

@param {Array|Object} data Array of Models or single Model
@returns {Mixed} Object or Array of objects
@api private
970086
function pluck(data) {
    //
    // Either map as array or return object through single map.
    //
    if (Array.isArray(data)) return data.map(map);
    return map(data);

    /**
     * Recursive mapping function.
     *
     * @param {Object} d Collection, Model or plain object.
     * @returns {Object} plucked object
     * @api private
     */
    function map(d) {
      if (isModel(d)) return pluck(d.attributes);

      for (var key in d) {
        if (isCollection(d[key])) {
          d[key] = pluck(d[key].models);
        }

        if (isModel(d[key])) {
          //
          // Delete MongoDB ObjectIDs. The stored state of the model is ambigious
          // as the referenced model could have different values in its own
          // collection. Hence doing recursive storage should be limited as much
          // as possible, since duplicate data will be stored.
          //
          d[key] = pluck(d[key].attributes);
          delete d[key]._id;
        }
      }

      return d;
    }
  }
370569
function (collection, data, action, options) {
                if (!(data instanceof Array)) {
                    throw "data has to be an array";
                }
                var context,
                    entity,
                    newData = [];
                for (var i = 0; i < data.length; i++) {
                    var value = data[i];
                    if (!(value instanceof Model)) {
                        // this is needed to determine the right context for collection models that are just links inside the collection
                        context = this.$dataSource._getContext(collection.$modelFactory, collection, value);
                        entity = context.createEntity(collection.$modelFactory, this._getIdForValue(value, collection.$modelFactory));
                        entity.set(this._parseModel(entity, value, action, options));
                        newData.push(entity);
                    }
                }

                return newData;
            }
606816
function(data) {

    var errors = [];

    // data.Errors is populated by sails-hook-validations and data.invalidAttributes is the default
    var targetAttributes = (data.Errors !== undefined)  ? data.Errors : data.invalidAttributes;

    for (var attributeName in targetAttributes) {

      var attributes = targetAttributes[attributeName];

      for (var index in attributes) {

        var error = attributes[index];

        errors.push({
          detail: error.message,
          source: {
            pointer: "data/attributes/" + this._convertCase(attributeName, this.getAttributesSerializedCaseSetting())
          }
        });
      }
    }

    return errors;
  }
649220
function cleanData(data) {
            hasQuantities = data.filter(hasQuantity).length === data.length;

            return data
                .reduce((acc, d) => {
                    if (d.quantity !== undefined && d.quantity !== null) {
                        d.quantity = +d.quantity;
                    }
                    d.name = String(d.name);
                    d.id = +d.id;

                    return [...acc, d];
                }, []);
        }
22876
function convertType (data) {
  switch (data.type) {
    case 'union':
      // If union of arrays
      if (Array.isArray(data.anyOf) && data.anyOf[0].type === 'array') {
        const items = data.anyOf.map(function (e) { return e.items })
        data.items = { anyOf: [] }
        data.items.anyOf = items
        data['type'] = 'array'
        delete data.anyOf
      } else {
        data['type'] = 'object'
      }
      break
    case 'nil':
      data['type'] = 'null'
      break
    case 'file':
      data = convertFileType(data)
      break
  }
  return data
}
10513
function reverseData(data) {
		data.labels = data.labels.reverse();
		for (var i = 0; i < data.datasets.length; i++) {
			for (var key in data.datasets[i]) {
				if (Array.isArray(data.datasets[i][key])) {
					data.datasets[i][key] = data.datasets[i][key].reverse();
				}
			}
		}
		return data;
	}
963686
function autoParse(data, models, options) {
  options = options || {};
  var parsed = {};

  // Go through each data point
  _.each(data, function(value, field) {
    var d = findField(field, models);

    // Find field in
    if (d) {
      parsed[d.modelName] = parsed[d.modelName] || {};
      parsed[d.modelName][d.field.name] = parse(value, d.field, options);
    }
  });

  return parsed;
}
1031474
function filterAttributes(obj) {
    var attribute;
    for (attribute in obj) {
        if (obj.hasOwnProperty(attribute)) {
            if (obj[attribute] === undefined || obj[attribute] === null) {
                delete obj[attribute];
            } else if (lodash.isString(obj[attribute])) {
                obj[attribute] = obj[attribute].quote();    // DO NOT quote type string. It is a JS variable.
            }
        }
    }
    return obj;
}
1237822
function _mapArray(data, schema, options) {
    var base = [];
    if (data instanceof Array && options.keep) {
        base = _clone(data);
    }
    if (typeof data === 'object' && options.keep) {
        base = Object
            .keys(data)
            .map(function(key) {
                return data[key];
            });
    }
    return schema
        .reduce(function (memo, nestedSchema) {
            memo.push(_mapDataValue(data, nestedSchema));
            return memo;
        }, base);
}
398851
function extractFixturesData( data ) {
    return Promise.map( data.section(), function( section ) {
      var markup  = section.markup();
      var ext     = path.extname( markup );
      var testDir = data.data.files[0].split("/")
            .filter(function(dir, i) {
              return i <= 2;
            })
            .concat([path.dirname( markup ), (path.basename( markup, ext ) + ext) ])
            .join('/');
  
      return Promise.props({
        header : section.header(),
        description : section.description(),
        markup : fs.readFileAsync( testDir, 'utf8' ).then( mustache.render ),
        name : path.basename( section.markup(), path.extname( section.markup() ) )
      });
   });
  }
770903
function(data) {
            var paramArray = [],
                key, value;
        // TODO: use `object` module
            for (key in data) {
                value = data[key];
                key = ENCODE_URI_COMPONENT(key);
                paramArray.push((value === null) ? key : (key + '=' + ENCODE_URI_COMPONENT(value)));
            }
            console.log(NAME, '_toQueryString --> '+paramArray.join('&'));
            return paramArray.join('&');
        }
318514
function sanitize (data) {
  if (
    !isPrimitive(data) &&
    !Array.isArray(data) &&
    !isPlainObject(data)
  ) {
    // handle types that will probably cause issues in
    // the structured clone
    return Object.prototype.toString.call(data)
  } else {
    return data
  }
}
246991
function(thisObj, data) {
    data = data || (thisObj = thisObj || {});
    
    //the 'data' argument can come in two flavours - array or non-array. Normalise it
    //here so that it always looks like an array.
    if (data.constructor.toString().indexOf("Array") == -1) {
      data = [data];
    }
    
    with(this) {
      for (var i=0; i < data.length; i++) {
        eval("(" + this.tpl.toString() + ").call(thisObj, data[i], i)");
      };
    }
    
    var roots  = this.getRoots(),
        output = "";
    
    for (var i=0; i < roots.length; i++) {
      output += roots[i].render();
    };
    
    return output;
  }
563655
function (data) {
    var material = this.material;
    data = getMaterialData(data);
    Object.keys(data).forEach(function (key) {
      material[key] = data[key];
    });
  }
171873
private List<?> convertDataToList(final Object data) {
		if (data == null) {
			return null;
		} else if (data instanceof List) {
			return (List<?>) data;
		} else if (data instanceof Object[]) {
			return Arrays.asList((Object[]) data);
		} else {
			return Arrays.asList(new Object[]{data});
		}
	}
698027
function condenseDataAttrs(attrs) {
		var out = [], data = null;
		var reData = /^data-/i;
		attrs.forEach(function(attr) {
			if (reData.test(attr.name)) {
				if (!data) {
					data = [];
					out.push({
						name: 'data',
						value: data
					});
				}

				data.push(utils.extend({}, attr, {name: attr.name.replace(reData, '')}));
			} else {
				out.push(attr);
			}
		});

		return out;
	}
183484
function (Schema, data) {
		var schemaKey = _.keys(data)[0];

		var mainSchema = this._parseSchemaHashKey(Schema, schemaKey);

		iterate.recursiveEach(data[schemaKey], mainSchema, function (v, k, schema) {
			if (/^=+$/.test(k)) {
				schema.validate(v);
				return;
			}

			schema = this._parseAndAddField(Schema, k, schema);
			if (_.isArray(v)) {
				schema.validate(v);
				return;
			}

			return schema;
		}, this);

		return mainSchema;
	}