Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default class Type {
- static string (str) {
- if (str instanceof String) {
- return str.valueOf()
- } else if (typeof str !== 'string') {
- throw new TypeError(`Expected ${typeof str} to be a string.`)
- }
- return str
- }
- static number (num) {
- if (num instanceof Number) {
- return num.valueOf()
- } else if (typeof num !== 'number') {
- throw new TypeError(`Expected ${typeof num} to be a number.`)
- }
- return num
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement