@@ -244,9 +244,10 @@ Generator.prototype.instruct = function(options, done) {
244244Generator . prototype . generate = function ( cb ) {
245245 this . results = this . results || 1 ;
246246 let output = [ ] ;
247+ let hash = crypto . createHash ( 'md5' ) . update ( this . src ) . digest ( 'hex' ) ;
247248
248249 // Check if src code causes timeout
249- if ( crypto . createHash ( 'md5' ) . update ( this . src ) . digest ( 'hex' ) in this . timeoutCache ) {
250+ if ( hash in this . timeoutCache ) {
250251 return this . returnResults ( { error : "Error: Script execution timed out." } , [ { } ] , cb ) ;
251252 }
252253
@@ -345,7 +346,7 @@ if (_APISnippetKeys.length === 0) {
345346 }
346347 } catch ( e ) {
347348 if ( e . toString ( ) . indexOf ( 'Script execution timed out' ) !== - 1 ) {
348- this . timeoutCache [ crypto . createHash ( 'md5' ) . update ( this . src ) . digest ( 'hex' ) ] = true ;
349+ this . timeoutCache [ hash ] = true ;
349350 }
350351 this . returnResults ( { error : e . toString ( ) , stack : e . stack } , [ { } ] , cb ) ;
351352 }
@@ -391,6 +392,7 @@ Generator.prototype.availableFuncs = function() {
391392 }
392393 } ,
393394 list : ( obj , num ) => {
395+ if ( this . mode === 'snippet' ) throw new Error ( `Lists are not available in Snippets` ) ;
394396 if ( num !== '' && num !== undefined ) num = Number ( num ) ; // Convert string to num if it isn't undefined
395397 if ( num === '' ) num = undefined ;
396398 if ( obj === '' || obj === undefined ) throw new Error ( `Empty list value provided` ) ;
@@ -530,7 +532,7 @@ Generator.prototype.availableFuncs = function() {
530532
531533Generator . prototype . require = function ( signature ) {
532534 if ( signature === undefined || signature . length === 0 ) {
533- throw new Error ( `"${ signature } "No snippet signature provideda ` ) ;
535+ throw new Error ( `"${ signature } "No snippet signature provided ` ) ;
534536 return ;
535537 }
536538
@@ -641,7 +643,7 @@ Generator.prototype.emptySnippetCache = function() {
641643// Only global snippets can be required in other snippets
642644Generator . prototype . updateRequires = function ( ) {
643645 return new Promise ( ( resolve , reject ) => {
644- // Don't let snippets include other snippets or global requires in snippet edit mode
646+ // Don't let snippets include other snippets
645647 if ( this . mode === 'snippet' ) resolve ( ) ;
646648 else {
647649 let rawMatches = this . src . match ( / r e q u i r e \( [ ' " ] (?: ( (?: .* ) \/ (?: .* ) ) | ( ~ .* ) ) [ ' " ] \) / g) ;
0 commit comments