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
<template> | |
<div ref="markdownContainer" class="nav-om-v1-markdown-container"></div> | |
</template> | |
<script> | |
// eslint-disable-next-line import/no-extraneous-dependencies | |
import { marked } from "marked"; | |
import { defineComponent } from "vue"; | |
const unmountedHook = "destroyed"; |
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 DAYS_MAP = { | |
'Mon': 0, | |
'Tue': 1, | |
'Wed': 2, | |
'Thur': 3, | |
'Fri': 4, | |
'Sat': 5, | |
'Sun': 6 | |
}; |
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 isEven(num) { | |
while(num > 0) { | |
num -= 2; | |
} | |
return num === 0; | |
} |
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 findPairOfTarget(arr, target) { | |
const diffMap = {}; | |
const pairs = []; | |
for(let i = 0; i < arr.length; i++) { | |
const diff = target - arr[i]; | |
if (diffMap[arr[i]]) { | |
pairs.push([diffMap[arr[i]], arr[i]]); | |
} |
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 toPromise(fn, context = {}) { | |
return function _toPromise(...rest) { | |
return new Promise((resolve, reject) => { | |
function handler(err, ...all) { | |
if (err) { | |
reject(err); | |
return; | |
} | |
resolve(...all); | |
} |
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 supportCallbackWithPromise(asyncFunc) { | |
return function _supportPromiseWithCallback (...args) { | |
const callback = args[args.length - 1]; | |
if (typeof callback !== 'function' ) { | |
return asyncFunc(...args); | |
} | |
asyncFunc.apply({}, args) | |
.then((...all) => callback(null, ...all)) |