@unavatar/core 3.7.50 → 3.7.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/avatar/auto.js +14 -4
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@unavatar/core",
|
|
3
3
|
"description": "Get unified user avatar from social networks, including Instagram, SoundCloud, Telegram, Twitter, YouTube & more.",
|
|
4
4
|
"homepage": "https://unavatar.io",
|
|
5
|
-
"version": "3.7.
|
|
5
|
+
"version": "3.7.51",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
package/src/avatar/auto.js
CHANGED
|
@@ -23,6 +23,12 @@ const getInputType = input => {
|
|
|
23
23
|
|
|
24
24
|
const factory = ({ constants, providers, providersBy, reachableUrl }) => {
|
|
25
25
|
const { REQUEST_TIMEOUT } = constants
|
|
26
|
+
const providerEntriesByType = Object.fromEntries(
|
|
27
|
+
Object.entries(providersBy).map(([inputType, providerNames]) => [
|
|
28
|
+
inputType,
|
|
29
|
+
providerNames.map(provider => [provider, providers[provider]])
|
|
30
|
+
])
|
|
31
|
+
)
|
|
26
32
|
|
|
27
33
|
const getAvatarContent = provider => async output => {
|
|
28
34
|
if (typeof output !== 'string' || output === '') {
|
|
@@ -78,10 +84,14 @@ const factory = ({ constants, providers, providersBy, reachableUrl }) => {
|
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
const resolveAutoByType = async (inputType, args) => {
|
|
81
|
-
const collection =
|
|
82
|
-
const promises = collection.
|
|
83
|
-
|
|
84
|
-
)
|
|
87
|
+
const collection = providerEntriesByType[inputType]
|
|
88
|
+
const promises = new Array(collection.length)
|
|
89
|
+
|
|
90
|
+
for (let index = 0; index < collection.length; index++) {
|
|
91
|
+
const [provider, fn] = collection[index]
|
|
92
|
+
promises[index] = getAvatar(fn, provider, args)
|
|
93
|
+
}
|
|
94
|
+
|
|
85
95
|
return pAny(promises)
|
|
86
96
|
}
|
|
87
97
|
|