Skip to content

Instantly share code, notes, and snippets.

View jiangtao's full-sized avatar
:octocat:
但行好事,也问前程。Up!Up!Up!

jiangtao

:octocat:
但行好事,也问前程。Up!Up!Up!
View GitHub Profile
@jiangtao
jiangtao / promise_catch.js
Created November 15, 2018 09:05
promise catch
const sleep = (fn, d = 500, fail = '') => new Promise((resolve, reject) => {
setTimeout(() => {
if(fail.length) {
reject(fail)
return
} else {
resolve(fn())
}
}, d)
@jiangtao
jiangtao / extractStyle.js
Created December 24, 2018 06:29
Dom Extract Inner Style and Style Tag To One Style
/**
* 基于tokenizer,做页面处理
*/
const fs = require('fs')
const html = fs.readFileSync('./index.html', {
encoding: 'utf-8'
})
const $ = require('cheerio').load(html, {
withDomLvl1: false,
normalizeWhitespace: false,
@jiangtao
jiangtao / fileSaver.html
Created May 16, 2020 12:13
download any file in broswer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="btn" >download</div>
<script>