Skip to content

Instantly share code, notes, and snippets.

@kwhinnery
Created July 26, 2011 09:12
Show Gist options
  • Save kwhinnery/1106342 to your computer and use it in GitHub Desktop.
Save kwhinnery/1106342 to your computer and use it in GitHub Desktop.
var os = require('os').os;
//branch logic based on platform - saves you an if statement
os(function() {
alert('do this on android');
}, function() {
alert('do this on iOS');
});
var platformSpecificValue = os('android string','ios string');
var osname = Ti.Platform.osname; //grab this once
function os(androidValue,iosValue) {
if (osname === 'android') {
return (typeof androidValue === 'function') ? androidValue() : androidValue;
}
else {
return (typeof iosValue === 'function') ? iosValue() : iosValue;
}
}
exports.os = os;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment