Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created April 28, 2015 23:29
Show Gist options
  • Select an option

  • Save Constellation/8dee9b7ba8cffb492ca8 to your computer and use it in GitHub Desktop.

Select an option

Save Constellation/8dee9b7ba8cffb492ca8 to your computer and use it in GitHub Desktop.
unsigned start = 0;
if (value.isUInt32())
start = value.asUInt32();
else {
double valueAsNumber = value.toInteger(exec);
if (exec->hadException())
return jsUndefined();
if (valueAsNumber < 0)
start = 0;
else {
if (valueAsNumber > length)
start = length;
else
start = static_cast<unsigned>(valueAsNumber);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment