1+ 'use strict' ;
2+
3+ const isString = ( a ) => typeof a === 'string' ;
14/* global ace */
25/* global join */
36
4- 'use strict' ;
5-
67require ( '../css/edward.css' ) ;
78
89const { createPatch} = require ( 'daffy' ) ;
@@ -48,7 +49,7 @@ function Edward(el, options, callback) {
4849 if ( ! callback )
4950 callback = options ;
5051
51- if ( typeof el === 'string' )
52+ if ( isString ( el ) )
5253 el = document . querySelector ( el ) ;
5354
5455 this . _maxSize = options . _maxSize || 512_000 ;
@@ -347,7 +348,7 @@ Edward.prototype._setUseOfWorker = function(mode) {
347348 const session = this . _getSession ( ) ;
348349 const isStr = typeof mode === 'string' ;
349350 const regStr = 'coffee|css|html|json|lua|php|xquery' ;
350- const regExp = new RegExp ( regStr ) ;
351+ const regExp = RegExp ( regStr ) ;
351352
352353 let isMatch ;
353354
@@ -436,6 +437,7 @@ Edward.prototype._getSession = function() {
436437Edward . prototype . sha = function ( ) {
437438 const value = this . getValue ( ) ;
438439 const shaObj = new jssha ( 'SHA-1' , 'TEXT' ) ;
440+
439441 shaObj . update ( value ) ;
440442
441443 return shaObj . getHash ( 'HEX' ) ;
@@ -557,12 +559,8 @@ Edward.prototype._loadFiles = function(callback) {
557559 } ;
558560
559561 const scripts = Object . keys ( obj )
560- . filter ( ( name ) => {
561- return ! window [ name ] ;
562- } )
563- . map ( ( name ) => {
564- return PREFIX + obj [ name ] ;
565- } ) ;
562+ . filter ( ( name ) => ! window [ name ] )
563+ . map ( ( name ) => PREFIX + obj [ name ] ) ;
566564
567565 if ( scripts . lengths )
568566 return callback ( ) ;
@@ -582,11 +580,7 @@ Edward.prototype._loadFiles = function(callback) {
582580 'language_tools' ,
583581 'searchbox' ,
584582 'modelist' ,
585- ] . map ( ( name ) => {
586- return 'ext-' + name ;
587- } ) . map ( ( name ) => {
588- return ace + name + '.js' ;
589- } ) ) ;
583+ ] . map ( ( name ) => 'ext-' + name ) . map ( ( name ) => ace + name + '.js' ) ) ;
590584
591585 await load . js ( url ) ;
592586 callback ( ) ;
0 commit comments