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
function requireFromString(src, filename) { | |
var Module = module.constructor; | |
var m = new Module(); | |
m._compile(src, filename); | |
return m.exports; | |
} | |
console.log(requireFromString('module.exports = { test: 1}')); |
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
function LinkedList () { | |
function Node (node) { | |
this.node = node | |
this.next = null | |
} | |
let length = 0 | |
let head = null | |
this.append = function (node) { | |
var target = new Node(node) |
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
for循环对await的请求是按先后顺序的,forEach的请求是并发请求的 | |
function request () { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve('666') | |
}, 1000) | |
}) | |
} | |
async function geuli () { | |
let arr = [request,request,request,request,request,request] |