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
class LRUCache { | |
capacity: number | |
map = new Map<number, DoubleListNode>() | |
young: DoubleListNode = new DoubleListNode() | |
old: DoubleListNode = new DoubleListNode() | |
// yound -> node1 -> node2 -> old | |
constructor(capacity: number) { | |
this.capacity = capacity | |
this.young.next = this.old | |
this.old.prev = this.young |
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
abstract class Heap<T> { | |
protected readonly list: (T | null)[] = [null] | |
constructor (items: T[]) { | |
this.list.push(...items) | |
const size = items.length | |
const op = size >> 1 | |
for (let i = op; i > 0; i--) { | |
this.heapify(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
export default { | |
methods: { | |
addEvent (bus, event, handler) { | |
if (!this.$_event_busMap) { | |
this.$_event_busMap = new Map() | |
} | |
bus.$on(event, handler) | |
if (!this.$_event_busMap.has(bus)) { | |
this.$_event_busMap.set(bus, new Map()) | |
} |
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 _ from 'lodash' | |
const arrayFy = value => Array.isArray(value) ? value : [value] | |
export default class Validator { | |
constructor () { | |
this.rulesMap = new Map() | |
this.validIdMap = new Map() | |
} | |
register (name, validateFunc) { | |
if (_.isRegExp(validateFunc)) { |
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 check = async function () { | |
let result={valid:true}; | |
for(const rule of rules){ | |
try{ | |
result = await validator.verify({value, ...rule}) | |
if (result.valid === false) { | |
return Promise.reject(result) | |
} | |
}catch (e){ | |
return Promise.reject(e) |
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
// setTimeout(function(){console.log(4)},0); | |
// process.nextTick(function () { | |
// console.log(6) | |
// }) | |
// setImmediate(function () { | |
// console.log(7) | |
// }) | |
// new Promise(function(resolve){ | |
// console.log(1) | |
// for( var i=0 ; i<10000 ; 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
from urllib.request import urlopen | |
import json | |
import subprocess, shlex | |
allProjects = urlopen("http://git.analysys.cn/api/v3/groups/fss-modules/projects/?private_token=UjGdeqGEgjhe4S524AME") | |
allProjectsDict = json.loads(allProjects.read().decode()) | |
for thisProject in allProjectsDict: | |
try: | |
thisProjectURL = thisProject['ssh_url_to_repo'] | |
command = shlex.split('git clone %s' % thisProjectURL) |
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 _ from 'lodash' | |
import table from './packages/table' | |
import tableColumn from './packages/table-column' | |
const createHead = function (columns) { | |
const h = this.$createElement // eslint-disable-line | |
return columns.map((col, index) => { | |
let children, scopedSlots | |
if (_.size(col.children)) { | |
children = createHead.call(this, col.children) | |
} |
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 renderToolTip = function (des) { | |
return `<span>${des.title}<span>姘旀场</span></span>` | |
} | |
const head = [ | |
{ | |
title:'瀵规瘮', | |
data:'compare', | |
fixed:true | |
}, | |
{ |
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 renderToolTip = function (des) { | |
return `<span>${des.title}<span>姘旀场</span></span>` | |
} | |
const head = [ | |
{ | |
title:'瀵规瘮', | |
fixed:true | |
}, | |
{ | |
title:'搴忓彿', |
NewerOlder