Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default class Type {
  2.   static string (str) {
  3.     if (str instanceof String) {
  4.       return str.valueOf()
  5.     } else if (typeof str !== 'string') {
  6.       throw new TypeError(`Expected ${typeof str} to be a string.`)
  7.     }
  8.     return str
  9.   }
  10.  
  11.   static number (num) {
  12.     if (num instanceof Number) {
  13.       return num.valueOf()
  14.     } else if (typeof num !== 'number') {
  15.       throw new TypeError(`Expected ${typeof num} to be a number.`)
  16.     }
  17.     return num
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement