This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const isPrimitiveTypeOrFunction = (input) => | |
| typeof input !== 'object' || typeof input === 'function' || input === null; | |
| function getType(input) { | |
| const lowerCaseTheFirstLetter = (str) => str[0].toLowerCase() + str.slice(1); | |
| const type = typeof input; | |
| if (type !== 'object') return type; | |
| return lowerCaseTheFirstLetter( | |
| Object.prototype.toString.call(input).replace(/^\[object (\S+)\]$/, '$1'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input = [ | |
| ['google.com', '20'], | |
| ['mail.google.com', '10'], | |
| ['zhenghao.mail.google.com', '10'], | |
| ] | |
| output = { 'google.com': 40, | |
| 'mail.google.com': 20, | |
| 'zhenghao.mail.google.com': 10 } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // <body> | |
| // <div> | |
| // <span> | |
| // bar1 | |
| // bar2 | |
| // </span> | |
| // </div> | |
| // <div> | |
| // baz | |
| // </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Status = "pending" | "resolved" | "rejected"; | |
| type State<R, E = unknown> = { | |
| status: Status; | |
| data: null | R; | |
| error: null | E; | |
| }; | |
| type Action<R, E = unknown> = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Status = "pending" | "resolved" | "rejected"; | |
| type State<R, E = unknown> = { | |
| status: Status; | |
| data: null | R; | |
| error: null | E; | |
| }; | |
| type Action<R, E = unknown> = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Status = "pending" | "resolved" | "rejected"; | |
| type State<R, E = unknown> = { | |
| status: Status; | |
| data: null | R; | |
| error: null | E; | |
| }; | |
| type Action<R, E = unknown> = |