Skip to content

Instantly share code, notes, and snippets.

View jacintoface's full-sized avatar

jacintoface jacintoface

  • jd
View GitHub Profile
@jacintoface
jacintoface / 将字符串以模块的形式导出
Created March 7, 2018 03:16
node编译字符串为模块
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}'));
@jacintoface
jacintoface / 单向链表
Created March 3, 2018 07:09
js实现一个单向链表
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)
@jacintoface
jacintoface / js
Created February 7, 2018 07:02
for循环和forEach在async的区别
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]