jsdataframe.js
function ensureScalar(value) {
  if (isUndefined(value) || value === null) {
    return value;
  }
  var length = 1;
  var description = 'a scalar';
  if (value.type === vectorProto.type) {
    length = value.size();
    value = value.values[0];
    description = 'a vector';
  } else if (Array.isArray(value)) {
    length = value.length;
    value = value[0];
    description = 'an array';
  }
  if (length !== 1) {
    throw new Error('expected a single scalar value but got ' +
      description + ' of length ' + length);
  }
  return value;
}
function ensureScalar(value) {
  if (isUndefined(value) || value === null) {
    return value;
  }
  var length = 1;
  var description = 'a scalar';
  if (value.type === vectorProto.type) {
    length = value.size();
    value = value.values[0];
    description = 'a vector';
  } else if (Array.isArray(value)) {
    length = value.length;
    value = value[0];
    description = 'an array';
  }
  if (length !== 1) {
    throw new Error('expected a single scalar value but got ' +
      description + ' of length ' + length);
  }
  return value;
}
function ensureScalar ( value ) { if ( isUndefined ( value ) || value === null ) { return value ; } var length = 1 ; var description = 'a scalar' ; if ( value . type === vectorProto . type ) { length = value . size ( ) ; value = value . values [ 0 ] ; description = 'a vector' ; } else if ( Array . isArray ( value ) ) { length = value . length ; value = value [ 0 ] ; description = 'an array' ; } if ( length !== 1 ) { throw new Error ( 'expected a single scalar value but got ' + description + ' of length ' + length ) ; } return value ; }
If value is a vector or array, this function will return the single scalar value contained or throw an error if the length is not 1. If value isn't a vector or array, it is simply returned.
If value is a vector or array this function will return the single scalar value contained or throw an error if the length is not 1 . If value isn t a vector or array it is simply returned .