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
| function detectZero(arr) { | |
| const map = {}; | |
| for (var i=0; i<arr.length; i++) { | |
| if (arr[i] === 0) return true; | |
| if (map[arr[i]]) return true; | |
| map[arr[i] * -2] = true; | |
| if (find2Sum(arr.slice(i), -arr[i])) return true; | |
| } | |
| return false; | |
| } |
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 callerMap = {}; | |
| function getCaller(error) { | |
| if (error && error.stack) { | |
| const lines = error.stack.split('\n'); | |
| if (lines.length > 2) { | |
| let match = lines[2].match(/at ([a-zA-Z\-_$.]+) (.*)/); | |
| if (match) { | |
| return { | |
| name: match[1].replace(/^Proxy\./, ''), |
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 word = "A man, a plan, a canal. Panama"; | |
| /* | |
| * Checks if a string is a palindrome (as explained here: https://medium.freecodecamp.org/two-ways-to-check-for-palindromes-in-javascript-64fea8191fd7 | |
| * hard polindrome will not except string with white space. | |
| */ | |
| const palindrome = (w, hard = false) => { | |
| const str = hard ? w : w.toLowerCase().replace(/[^a-zA-Z0-9]/g,""); | |
| const left = str.substring(0, Math.floor(str.length/2)); |
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
| import EXIF from "exif-js"; | |
| const DEFAULT_MAX_SIZE = 1600; | |
| const JPEG_QUALITY = 0.9; | |
| const FILE_READER_STATE_DONE = 2; | |
| const JPEG_FILETYPE = "image/jpeg"; | |
| /** | |
| * Set up operations and degrees to rotate for each EXIF orientation (index). | |
| */ | |
| const ExifOrientations = [ |