Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove __guard__ functions added by decaffeinate
- Loading branch information
1 parent
ff15a45
commit 6f49a95
Showing
6 changed files
with
48 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
let { newPromise, allPromises } = require('../../helpers/promise-find-native'); | ||
let { newPromise, allPromises } = require('../../helpers/promise-find-native') | ||
if (!newPromise || !allPromises) { | ||
({newPromise, allPromises} = require('../../helpers/promise-find-library')); | ||
({newPromise, allPromises} = require('../../helpers/promise-find-library')) | ||
} | ||
if ((typeof window === 'undefined' || window === null) && !newPromise) { | ||
({newPromise, allPromises} = require('../../helpers/promise-node')); | ||
({newPromise, allPromises} = require('../../helpers/promise-node')) | ||
} | ||
|
||
if ((typeof window !== 'undefined' && window !== null) && !newPromise) { | ||
// Otherwise, show a warning (library can still be used with just callbacks) | ||
__guardFunc__(__guard__(console, x => x.warn), f => f('Octokat: A Promise API was not found. Supported libraries that have Promises are jQuery, angularjs, and es6-promise')); | ||
if (window.console && window.console.warn) { | ||
window.console.warn('Octokat: A Promise API was not found. Supported libraries that have Promises are jQuery, angularjs, and es6-promise') | ||
} | ||
|
||
} else if ((typeof window === 'undefined' || window === null) && !newPromise) { | ||
// Running in NodeJS | ||
throw new Error('Could not find a promise lib for node. Seems like a bug'); | ||
throw new Error('Could not find a promise lib for node. Seems like a bug') | ||
} | ||
|
||
module.exports = new class PreferNativeOverLibraryPromises { | ||
promiseCreator = {newPromise, allPromises}; | ||
}; | ||
|
||
function __guardFunc__(func, transform) { | ||
return typeof func === 'function' ? transform(func) : undefined; | ||
} | ||
function __guard__(value, transform) { | ||
return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined; | ||
promiseCreator = {newPromise, allPromises} | ||
} |