Pads and array
@param {Array <number>} data
@param {object} options
18835
function padArray (data, options) {
                options = extend({}, defaultOptions$o, options);

                if (Array.isArray(data)) {
                    if (Array.isArray(data[0]))
                        return matrixCase(data, options);
                    else
                        return arrayCase(data, options);
                }
                else
                    throw new TypeError('data should be an array');
            }
1131158
function pad(str, width) {
  var len = Math.max(0, width - str.length);
  return str + Array(len + 1).join(' ');
}
315044
function pad(number, length) {
	// Create an array of the remaining length +1 and join it with 0's
	return new Array((length || 2) + 1 - String(number).length).join(0) + number;
}
788630
function lpad(str, len, padstr) {
	var str = ""+str;
	if(str.length >= len) return str;
	return Array(len + 1 - str.length).join(padstr) + str;
}
1271817
function (data) {
    if (arguments.length === 2) {
      dotty.put(this.attributes, arguments[0], arguments[1]);
    } else if (_.isObject(data)) {
      for (var m in data) {
        dotty.put(this.attributes, m, data[m]);
      }
    }
  }
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);
}
172985
function(data) {
    var values = [],
        i      = 0;
    for (i = 0; i < data.length; i++) {
      values.push(this.normalise(data[i]));
    }
    return values;
  }
461294
function(options) {
	var constantsData = options.constantsData;
	var location = options.location;
	var index = options.index;
	var name = options.name;

	var bufferInfo;
	var addData = false;

	// Search for a buffer's info
	array_registers.forEach(function(arrayRegister) {
		if(name === arrayRegister.data) {
			bufferInfo = {
				'size': arrayRegister.size,
			};
			var importTypeData = true;
			if(arrayRegister.type) {
				if(arrayRegister.type !== 'raw') {
					bufferInfo.type = arrayRegister.type;
					importTypeData = false;
				}
			}
			if(importTypeData) {
				bufferInfo.type = constantsData[location][index].type;
			}
			addData = true;
		}
	});

	if(addData) {
		constantsData[location][index].bufferInfo = bufferInfo;
	}
}
1116407
function (items, options) {
            options = options || {};

            this.$items = [];
            this.$itemEventMap = {};

            this.callBase(options);

            if (items) {
                this.add(items);
            }

            var self = this;

            function updateLength() {
                self.length = self.size();
            }

            // TODO: allow array here to give multiple event hin
            this.bind('add', updateLength);
            this.bind('remove', updateLength);
            this.bind('reset', updateLength);

            this.length = this.size();
        }
1197159
function(array, n, pad) {
      var p = function(array) {
        if (array == null) return [];

        var part = _.take(array, n);

        if (n === _.size(part)) {
          return _.cons(part, p(_.drop(array, n)));
        }
        else {
          return pad ? [_.take(_.cat(part, pad), n)] : [];
        }
      };

      return p(array);
    }
536403
function pad(data) {
    if (typeof(data) !== 'string') {
      // handle fractions.
      if (typeof(data) === 'number') {
        data = parseInt(data);
      }
      data = String(data);
    }

    var len = data.length;

    switch (len) {
      case 0:
        return '00';
      case 1:
        return '0' + data;
      default:
        return data;
    }
  }
363177
function padString(str, len) {
  return str.split().concat(new Array(len-str.length)).join(' ');
}
814969
function joinFlairs(data) {
  let result = []
  for (let [ targetStringArray, ...rest ] of data) {
    // Raw flair containing only one flair don’t need to be modified.
    if (targetStringArray.length < 2) {
      result.push([ targetStringArray, ...rest ])
      continue
    }
    // Concatenate the flairs using one, two and three spaces.
    for (let i = 1; i <= 3; i++) {
      const SPACES = pad('', i)
      result.push([ targetStringArray.join(SPACES), ...rest ])
    }
  }
  return result
}
1088704
function TableFormatter(options) {
  const table = new Table(options);
  this.format = format;
  function format(result, formatOptions) {
    let data = [];
    _.each(result, function (item) {
      data.push(_.values(_.pick(item, options.values)));
    });
    if (formatOptions.format === 'csv') {
     _.each(data, function(row) {
       console.log(row.join(','));
     });
    } else if ( formatOptions.format === 'json') {
      console.log(JSON.stringify(result));
    } else {
      table.push.apply(table, data);
      console.log(table.toString());
    }
  }
}
79522
function __getType(data, options) {
	let type = typeof data;
	if (data === null) {
		type = DATA_TYPE.NULL;
	}
	else if (type === 'boolean') {
		type = (data) ? DATA_TYPE.TRUE : DATA_TYPE.FALSE;
	}
	else if ( type === "number" ) {
		type = DATA_TYPE.FLOAT64;
	}
	else if ( data instanceof Int8 ) {
		type = DATA_TYPE.INT8;
	}
	else if ( data instanceof UInt8 ) {
		type = DATA_TYPE.UINT8;
	}
	else if ( data instanceof Int16 ) {
		type = DATA_TYPE.INT16;
	}
	else if ( data instanceof UInt16 ) {
		type = DATA_TYPE.UINT16;
	}
	else if ( data instanceof Int32 ) {
		type = DATA_TYPE.INT32;
	}
	else if ( data instanceof UInt32 ) {
		type = DATA_TYPE.UINT32;
	}
	else if ( data instanceof Int64 ) {
		type = DATA_TYPE.INT64;
	}
	else if ( data instanceof UInt64 ) {
		type = DATA_TYPE.UINT64;
	}
	else if ( data instanceof Int256 ) {
		type = DATA_TYPE.INT256;
	}
	else if ( data instanceof UInt256 ) {
		type = DATA_TYPE.UINT256;
	}
	else if ( data instanceof Int512 ) {
		type = DATA_TYPE.INT512;
	}
	else if ( data instanceof UInt512 ) {
		type = DATA_TYPE.UINT512;
	}
	else if ( data instanceof Int128 ) {
		type = DATA_TYPE.INT128;
	}
	else if ( data instanceof UInt128 ) {
		type = DATA_TYPE.UINT128;
	}
	else if ( data instanceof IntVar ) {
		type = DATA_TYPE.INTVAR;
	}
	else if ( data instanceof UIntVar ) {
		type = DATA_TYPE.UINTVAR;
	}
	else if (type === 'string') {
		type = DATA_TYPE.STRING;
	}
	else if (Array.isArray(data)) {
		type = (options.streaming_array === true) ? DATA_TYPE.ARRAY_START : DATA_TYPE.ARRAY;
	}
	else if (data instanceof Date) {
		type = DATA_TYPE.DATE;
	}
	else if (data instanceof ObjectId) {
		type = DATA_TYPE.OBJECTID;
	}
	else if (data instanceof Binary) {
		type = DATA_TYPE.BINARY;
	}
	else if ( data instanceof ArrayBuffer) {
		type = DATA_TYPE.ARRAY_BUFFER;
	}
	else if ( data instanceof DataView) {
		type = DATA_TYPE.DATA_VIEW;
	}
	// NOTE: This line must be prior to Uint8Array since NodeJS Buffer is defined to be inheritance of Uint8Array
	else if ( HAS_NODE_BUFFER && data instanceof Buffer ) {
		type = DATA_TYPE.SPECIAL_BUFFER;
	}
	else if ( data instanceof Uint8Array) {
		type = DATA_TYPE.UINT8_ARRAY;
	}
	else if ( data instanceof Int8Array) {
		type = DATA_TYPE.INT8_ARRAY;
	}
	else if ( data instanceof Uint16Array) {
		type = DATA_TYPE.UINT16_ARRAY;
	}
	else if ( data instanceof Int16Array) {
		type = DATA_TYPE.INT16_ARRAY;
	}
	else if ( data instanceof Uint32Array) {
		type = DATA_TYPE.UINT32_ARRAY;
	}
	else if ( data instanceof Int32Array) {
		type = DATA_TYPE.INT32_ARRAY;
	}
	else if ( data instanceof Float32Array) {
		type = DATA_TYPE.FLOAT32_ARRAY;
	}
	else if ( data instanceof Float64Array) {
		type = DATA_TYPE.FLOAT64_ARRAY;
	}
	else if (type === 'object') {
		type = (options.streaming_object === true) ? DATA_TYPE.OBJECT_START : DATA_TYPE.OBJECT;
	}
	return type;
}
88301
function(data, padding) {

		var tempResult = [],
			child_padding = padding + "\t",
			name,
			type,
			result,
			is_complex = false,
			only_key = null,
			is_empty = true;

		// this may be faster than using Object.keys(data), but I haven't done speed comparison yet.
		// Purpose of the following code:
		// 1) if object has something in it then 'is_empty' will be set to false
		// 2) if there is only one property in it, then 'only_key' will contain it's name
		for (name in data) {
			if (only_key !== null) { // strict comparison - in case the key is valid, but evaluates to false
				only_key = null;
				break;
			}
			is_empty = false;
			only_key = name;
		}

		if (only_key) {

			type = Firestorm.getType(data[only_key]);

			if (type in this._complex_types) {
				is_complex = true;
			}

		}

		if (is_empty) {

			result = '{}';

		} else if (only_key && !is_complex) {

			// simple values can be written in one line
			result = '{' + this._serializeObjectProperty(only_key, data[only_key], child_padding) + '}';

		} else {

			for (name in data) {

				tempResult.push(
					this._serializeObjectProperty(name, data[name], child_padding)
				);

			}

			result = '{' + "\n\t" + padding + tempResult.join(",\n\t" + padding) + "\n" + padding + '}';

		}

		return result;

	}
238990
function(text, pad) {
			var result = [];
			var lines = this.splitByLines(text);
			var nl = '\n';
				
			result.push(lines[0]);
			for (var j = 1; j < lines.length; j++) 
				result.push(nl + pad + lines[j]);
				
			return result.join('');
		}