-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add deps * Add prettier.config.js * Prettify all * Add “Check prettier” step to CI * Refactor ymaps.js * Add .prettierignore
- Loading branch information
1 parent
b676157
commit 32c9767
Showing
10 changed files
with
74 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package.json | ||
node_modules/ | ||
dist/ |
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,7 +1,5 @@ | ||
{ | ||
"typeAcquisition": { | ||
"include": [ | ||
"jest" | ||
] | ||
"include": ["jest"] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
singleQuote: true | ||
}; |
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,29 +1,27 @@ | ||
export default { | ||
load(src) { | ||
src = src || '//api-maps.yandex.ru/2.1/?lang=en_RU'; | ||
|
||
load(src = '//api-maps.yandex.ru/2.1/?lang=en_RU') { | ||
const getNsParamValue = () => { | ||
var results = RegExp('[\\?&]ns=([^&#]*)').exec(src); | ||
return results === null ? '' : | ||
decodeURIComponent(results[1].replace(/\+/g, ' ')); | ||
const results = src.match(/[\\?&]ns=([^&#]*)/); | ||
return results === null | ||
? '' | ||
: decodeURIComponent(results[1].replace(/\+/g, ' ')); | ||
}; | ||
|
||
this.promise = this.promise || new Promise((resolve, reject) => { | ||
let elem = document.createElement('script'); | ||
elem.type = 'text/javascript'; | ||
elem.src = src; | ||
elem.onload = resolve; | ||
elem.onerror = e => reject(e) | ||
document.body.appendChild(elem); | ||
}) | ||
.then(() => { | ||
const ns = getNsParamValue(); | ||
if (ns && ns !== 'ymaps') { | ||
(1,eval)(`var ymaps = ${ns};`); | ||
} | ||
return new Promise(resolve => ymaps.ready(resolve)); | ||
}); | ||
|
||
if (!this.promise) { | ||
this.promise = new Promise((resolve, reject) => { | ||
const scriptElement = document.createElement('script'); | ||
scriptElement.onload = resolve; | ||
scriptElement.onerror = reject; | ||
scriptElement.type = 'text/javascript'; | ||
scriptElement.src = src; | ||
document.body.appendChild(scriptElement); | ||
}).then(() => { | ||
const ns = getNsParamValue(); | ||
if (ns && ns !== 'ymaps') { | ||
(1, eval)(`var ymaps = ${ns};`); | ||
} | ||
return new Promise(resolve => ymaps.ready(resolve)); | ||
}); | ||
} | ||
return this.promise; | ||
} | ||
}; |
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