@awayfl/avm2
Version:
Virtual machine for executing AS3 code
17 lines (16 loc) • 515 B
JavaScript
import { ASNumber } from '../nat/ASNumber';
import { Settings } from '../Settings';
export function axCoerceNumber(x) {
if (Settings.FOLLOW_AS3_BUG) {
if (typeof x === 'string') {
return ASNumber.convertStringToDouble(x);
}
if (x && typeof x === 'object') {
x = x.valueOf(); // Make sure to only call valueOf() once.
if (typeof x === 'string') {
return ASNumber.convertStringToDouble(x);
}
}
}
return +x;
}