psiphi75 / ahrs

AHRS (Attitude Heading Reference Systems) calculation for JavaScript
Apache License 2.0
86 stars 16 forks source link

Make require algorithm names static #2

Closed rclai closed 8 years ago

rclai commented 8 years ago

The way you're including the algorithms dynamically breaks other platforms that rely on static analysis or don't allow dynamic requires, for example, React Native. Are you able to make the requires static, for example:

if (algorithmName === 'Mahony') {
    algorithmFn = new (require('./Mahony'))(sampleInterval, options);
} else if (algorithmName === 'Madgwick') {
    algorithmFn = new (require('./Madgwick'))(sampleInterval, options);
}