1
1
import brace from 'brace' ;
2
2
import 'brace/ext/modelist' ;
3
3
4
- const regExpEscape = string => string . replace ( / [ - [ \] { } ( ) * + ? . , \\ ^ $ | ] / g, '\\$&' ) ;
4
+ export const regExpEscape = string => string . replace ( / [ - [ \] { } ( ) * + ? . , \\ ^ $ | ] / g, '\\$&' ) ;
5
5
6
- function download ( text , name , mime ) {
6
+ export function download ( text , name , mime ) {
7
7
// It seems it's the only way to initiate file downloading from JavaScript
8
8
// as of Jan 7, 2018. If you read this and know a better way, please submit
9
9
// a pull request! ;)
@@ -19,7 +19,7 @@ function download(text, name, mime) {
19
19
document . body . removeChild ( element ) ;
20
20
}
21
21
22
- function downloadSnippet ( snippet ) {
22
+ export function downloadSnippet ( snippet ) {
23
23
const { modesByName } = brace . acequire ( 'ace/ext/modelist' ) ;
24
24
25
25
// Despite using AceEditor's modes as syntaxes, we can imagine other setup
@@ -36,18 +36,16 @@ function downloadSnippet(snippet) {
36
36
download ( content , name , 'text/plain' ) ;
37
37
}
38
38
39
- function copyToClipboard ( e , id ) {
39
+ export function copyToClipboard ( e , id ) {
40
40
document . getElementById ( id ) . select ( ) ;
41
41
document . execCommand ( 'copy' ) ;
42
42
e . target . focus ( ) ;
43
43
}
44
44
45
45
// This function is here just because I don't want to pull the whole moment.js
46
46
// only for one tiny date
47
- function formatDate ( d ) {
47
+ export function formatDate ( d ) {
48
48
const ISOdate = d . split ( 'T' ) [ 0 ] ;
49
49
50
50
return ISOdate . split ( '-' ) . reverse ( ) . join ( '.' ) ;
51
51
}
52
-
53
- export { regExpEscape , downloadSnippet , copyToClipboard , formatDate } ;
0 commit comments