This file contains 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
/** | |
* 伪代码 | |
*/ | |
var socket = {}; | |
socket.on('message', function() { | |
// listener 真正拿到结果 | |
}); |
This file contains 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
'use strict'; | |
const fs = require('fs'); | |
const exec = require('child_process').exec; | |
const npmPackageName = process.env.npm_package_name; | |
const uri = './.gitlab-ci.yml'; | |
const uuid = () => { | |
return `${Math.random() |
This file contains 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
{ | |
"parser": "babel-eslint", | |
"plugins": ["react", "react-native"], | |
"env": { | |
"browser": true, | |
"node": true | |
}, | |
"parserOptions": { | |
"ecmaFeatures": { | |
"jsx": true, |
This file contains 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
/** | |
* 百度BOS直传 | |
* @param {*} filePath | |
*/ | |
export default function uploadPicture(filePath) { | |
let filename = uuid() + filePath.substring(filePath.lastIndexOf("/") + 1); | |
const tokenObj = Taro.getStorageSync('bosUploadToken'); | |
let policy = `{"conditions":[{"bucket":"yztfile"},{"key":"${commonPath}${filename}"}]}`; | |
let base64 = Base64.encode(policy) | |
let signature = HmacSHA256(base64, secretAccessKey).toString(EncHex); |
This file contains 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 orderCancelTime = 48 * 3600 * 1000; | |
const timeCountDown = orderCancelTime - (30 * 60 * 1000); // 半小时开始倒计时 | |
const farawayTime = orderCancelTime - (60 * 60 * 1000); // 1小时以上不倒计时,避免定时器性能问题 | |
export const formatByTimestamp = (timestamp, hasHour) => { | |
let second = Math.floor(timestamp / 1000); | |
if (second < 1) { | |
return ''; | |
} |
This file contains 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 TreeNode { | |
constructor(key) { | |
this.key = key; | |
this.left = null; | |
this.right = null; | |
} | |
} |
This file contains 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 HashTable { | |
constructor() { | |
this.table = []; | |
} | |
/* 散列函数 */ | |
loseloseHashCode(key) { |
This file contains 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 LinkNode { | |
constructor(element) { | |
this.element = element; | |
this.next = null; | |
} |
This file contains 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
/** | |
* @author: giscafer ,https://github.com/giscafer | |
* @date: 2018-07-25 15:59:02 | |
* @description: 类实现队列模拟 | |
*/ | |
const Queue = (() => { | |
// 闭包实现私有变量 | |
let item = new WeakMap(); |
NewerOlder