Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function functionOrVariableIsAvailable(name, type, tries) {
- var iterator = tries || 1;
- if (type === 'function') {
- // if you are using a function
- dependencyAvailable = (typeof name === 'function') ? true : false;
- } else if (type === 'variable') {
- // if you are using a variable
- dependencyAvailable = (typeof name !== 'undefined' && typeof name !== 'function') ? true : false;
- }
- if (dependencyAvailable) {
- return name;
- } else if (iterator <= 10) {
- iterator++;
- setTimeout(function () {
- functionOrVariableIsAvailable(name, type, iterator);
- }, 500);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement