Guest User

Untitled

a guest
Dec 13th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. class SomeClass{
  2. constructor(){}
  3. mainMethod(HTMLElement|PaperElement element, StreamBuffer stream) /* I select this */
  4. }
  5.  
  6. class SomeClass{
  7. constructor(){}
  8. mainMethod(element, stream){
  9. if(element instanceof HTMLElement || element instanceof PaperElement){
  10. if(stream instanceof StreamBuffer){
  11. /* My cursor appear here */
  12. }
  13. else{
  14. throw new TypeError('2nd argument should be StreamBuffer');
  15. }
  16. }
  17. else{
  18. throw new TypeError('1st argument should be HTMLElement or PaperElement');
  19. }
  20. }
  21. }
  22.  
  23. class SomeClass{
  24. ...
  25. otherMethod(String str, notypearg, [optionalarg]) /* I select this */
  26. }
  27.  
  28. class SomeClass{
  29. ...
  30. otherMethod(str, notypearg, optionalarg){
  31. if(typeof(str) == 'string'){
  32. if(notypearg){
  33. /* My cursor appear here */
  34. // nothing for optionalarg
  35. }
  36. // No error for args without type
  37. }
  38. else{
  39. throw new TypeError('1st argument should be String');
  40. }
  41. }
  42. }
Add Comment
Please, Sign In to add comment