手写
·Q·
努力努力
展开
-
实现LRU缓存淘汰算法
LRU:缓存淘汰算法,最近最少使用淘汰队列class LRUCache{ constructor(size){ this.capacity = size; this.cache = new Map(); } // 队列 先前先出 对头进 队尾出 get(key){ if(this.cache.has(key)){ let temp = this.cache.get(key); .原创 2022-01-03 00:50:25 · 804 阅读 · 0 评论 -
手动搭建一个https服务器,并颁发证书
1.下载安装openssl(用于生成秘钥颁发证书)mac自带window:https://slproweb.com/products/Win32OpenSSL.html2.生成CA证书,CA钥和CA公钥生成CA私钥,并用des3算法进行加密:openssl genrsa -des3 -out ca-pri-key.pem 1024生成CA公钥:openssl req -new -key ca-pri-key.pem -out ca-pub-key.pem生成CA原创 2021-05-05 22:49:33 · 611 阅读 · 1 评论 -
手动封装获取文件子目录和内容
const fs = require("fs");const path = require("path");class File{ constructor(filename,size,name,ctime,utime,isFile){ this.filename = filename; this.name = name; this.size =size; this.ctime = ctime; this.uti.原创 2021-05-02 20:07:49 · 89 阅读 · 0 评论 -
手写数组方法
封装一个forEachArray.prototype.myForEach = function (fun) { for (var i in this) { if (this.hasOwnProperty(i)) { fun(this[i], i, this); } }}封装一个filterArray.prototype.myFilter = function (fun) { var arr = []; //定义一个新的原创 2021-04-26 23:49:06 · 95 阅读 · 0 评论