4 examples of 'create file javascript' in JavaScript

Every line of 'create file javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
3return function javascript (module, callback) {
4 try {
5 callback(null, require(path.join(base, module)));
6 } catch (error) {
7 callback(error);
8 }
9}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

204function addJavascript(filename){
205 var fileref=document.createElement('script')
206 fileref.setAttribute("src", "/scripts/" + filename)
207 fileref.setAttribute("type","text/javascript")
208 document.head.appendChild(fileref);
209}
61function html_addjavascript(server, port, jsfile) {
62 return '<script src="' + static_server + '/static/js/' + jsfile + '"></script>';
63}
92function generateScript () {
93 var tmpEmojis = []
94 var tmpPattern = ''
95 var targetEmoji = $('.js-set-emoji-background').val()
96 var hubotScript = '"' + targetEmoji + '": {\n '
97 var emojiScript = ''
98
99 $('.cell').each(function(i) {
100 i++
101 var emoji = $(this).attr('data-emoji')
102 if(tmpEmojis.indexOf(emoji) < 0) tmpEmojis.push(emoji)
103
104 tmpPattern += tmpEmojis.indexOf(emoji)
105 emojiScript += emoji
106 if(i % Number($('.js-grid-cols').val()) === 0) {
107 tmpPattern += '|'
108 emojiScript += '\n'
109 }
110 })
111
112 // hubot
113 hubotScript += 'emoji: [ ' + tmpEmojis.map(function(e) { return '\'' + e + '\'' }).join(', ') + ' ]\n'
114 hubotScript += 'pattern: "' + tmpPattern + '"\n'
115 hubotScript += '}'
116
117 $('.js-hubot-script').val(hubotScript)
118 $('.js-emoji-script').val(emojiScript)
119}

Related snippets