@@ -438,6 +438,8 @@ defineProperties(Object, {
438438 } ,
439439
440440 getType ( item : any ) {
441+ if ( item === null ) return "null" ;
442+ if ( typeof item != "object" ) return typeof item ;
441443 return Object . getPrototypeOf ( item ) . constructor . name ;
442444 } ,
443445
@@ -457,7 +459,7 @@ defineProperties(String.prototype, {
457459 return this . substr ( 0 , 1 ) . toUpperCase ( ) + this . substr ( 1 ) ;
458460 } ,
459461
460- escape ( nonSpecials : boolean = true ) {
462+ escape ( nonSpecials : boolean = true ) { //TODO: Improve me!
461463 let charArray = this . split ( "" ) ;
462464 if ( nonSpecials ) charArray = charArray . map ( ( char ) => [ '"' , "'" , "\\" ] . includes ( char ) ? "\\" + char : char )
463465 charArray = charArray . map ( ( char ) => [ "\n" , "\r" , "\t" ] . includes ( char ) ? "\\" + { "\n" : "n" , "\r" : "r" , "\t" : "t" } [ char ] : char ) ;
@@ -469,28 +471,9 @@ defineProperties(String.prototype, {
469471 } ,
470472
471473 interpolate ( this : string , values : Of < any > ) {
472- let from = 0 ;
473- let data : { content : string , type : "string" | "code" } [ ] = [ ] ;
474- let asString = ( obj ) =>
475- obj === null ? "null" : obj === undefined ? "undefined" :
476- typeof obj . toString == "function" ? obj . toString ( ) :
477- Object . prototype . toString . call ( obj ) ;
478- let push = ( content : string , code ?: boolean ) =>
479- data . push ( { content, "type" : code ? "code" : "string" } ) ;
480- [ ...this . matchAll ( / \\ ? \$ / g) , null ] . forEach ( val => {
481- if ( val && val [ 0 ] . startsWith ( "\\" ) ) return ;
482- let str = this . substring ( from , val ? val . index : this . length ) ;
483- if ( str ) push ( str ) ;
484- if ( val ) {
485- let pos = findPairs ( this , { "{" : num => ++ num , "}" : num => -- num } ) ;
486- let code = this . substring ( val . index + 2 , pos - 1 ) ;
487- if ( code ) push ( code , true ) ;
488- from = pos + 1 ;
489- }
490- } ) ;
491- return data . reduce ( ( acc , val ) => acc + ( val . type == "code" ?
492- asString ( evaluate ( val . content , values ) ) :
493- val . content ) , "" ) ;
474+ let charArray = this . split ( "" ) ;
475+ charArray = charArray . map ( char => char == "`" ? "\`" : char == "\\" ? "\\\\" : char ) ;
476+ return evaluate ( "`" + charArray . join ( "" ) + "`" , values ) ;
494477 }
495478} as Partial < String > ) ;
496479
@@ -520,8 +503,6 @@ const keywords = ["arguments", "in", "of", "for", "if", "else", "throw", "while"
520503 */
521504export function bound < Type extends ( ...a : any [ ] ) => any > ( proto : Object ,
522505 key : string , descriptor : TypedPropertyDescriptor < Type > ) {
523- if ( proto . constructor == Object ) descriptor = proto ; //BABEL Fix
524-
525506 let value = descriptor . value ;
526507 delete descriptor . writable ;
527508 delete descriptor . value ;
0 commit comments