Skip to content

Commit 4d84f96

Browse files
committed
增加笔记相关代码和readme更新
1 parent ebba6e8 commit 4d84f96

159 files changed

Lines changed: 38093 additions & 18 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ES6-10/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Numerous always-ignore extensions
2+
*.bak
3+
*.patch
4+
*.diff
5+
*.err
6+
7+
# temp file for git conflict merging
8+
*.orig
9+
*.log
10+
*.rej
11+
*.swo
12+
*.swp
13+
# *.zip
14+
*.vi
15+
*~
16+
*.sass-cache
17+
*.tmp.html
18+
*.dump
19+
20+
# OS or Editor folders
21+
.DS_Store
22+
._*
23+
.cache
24+
# .project
25+
# .settings
26+
.tmproj
27+
*.esproj
28+
*.sublime-project
29+
*.sublime-workspace
30+
nbproject
31+
thumbs.db
32+
*.iml
33+
34+
# Folders to ignore
35+
.hg
36+
.svn
37+
.CVS
38+
.idea
39+
node_modules/
40+
jscoverage_lib/
41+
bower_components/
42+
# dist/

ES6-10/ES2019/.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env"
5+
]
6+
]
7+
}

ES6-10/ES2019/.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": "standard",
7+
"globals": {
8+
"Atomics": "readonly",
9+
"SharedArrayBuffer": "readonly",
10+
'BigInt':true
11+
},
12+
"parserOptions": {
13+
"ecmaVersion": 2019
14+
},
15+
"rules": {
16+
}
17+
};

ES6-10/ES2019/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

ES6-10/ES2019/.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// 使用 IntelliSense 了解相关属性。
3+
// 悬停以查看现有属性的描述。
4+
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "pwa-chrome",
9+
"request": "launch",
10+
"name": "Launch Chrome against localhost",
11+
"url": "http://localhost:8080",
12+
"webRoot": "${workspaceFolder}"
13+
}
14+
]
15+
}

ES6-10/ES2019/app.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Koa from 'koa'
2+
import path from 'path'
3+
import BodyParser from 'koa-bodyparser'
4+
import Views from 'koa-ejs'
5+
import Static from 'koa-static'
6+
import webpackConfig from './webpack.config.babel.js'
7+
import webpack from 'webpack'
8+
import webpackDevMiddleware from 'koa-webpack-dev-middleware'
9+
import webpackHotMiddleware from 'koa-webpack-hot-middleware'
10+
import Users from './routes/user.js'
11+
12+
const app = new Koa()
13+
14+
Views(app, {
15+
root: path.join(__dirname, 'views'),
16+
layout: 'layout',
17+
viewExt: 'ejs',
18+
cache: false,
19+
debug: false
20+
})
21+
22+
const compiler = webpack(webpackConfig)
23+
24+
const wdm = webpackDevMiddleware(compiler, {
25+
noInfo: true
26+
// publicPath: config.output.publicPath
27+
})
28+
app.use(wdm)
29+
app.use(webpackHotMiddleware(compiler))
30+
app.use(Static(path.join(__dirname, 'static')))
31+
app.use(BodyParser())
32+
33+
app.use(Users.routes()).use(Users.allowedMethods())
34+
app.listen(8080)
35+
36+
global.console.log(`server is listen, http://localhost:8080`)

ES6-10/ES2019/js/1.module.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export function hi() {
2+
console.log(`Hello`);
3+
}
4+
5+
export function bye() {
6+
console.log(`Bye`);
7+
}
8+
9+
export default function () {
10+
console.log("Module loaded (export default)!");
11+
}
12+
13+
export {
14+
run,
15+
say
16+
}
17+
from "./lesson2-14-mod";

ES6-10/ES2019/js/FileSaver.js

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
(function (global, factory) {
2+
if (typeof define === "function" && define.amd) {
3+
define([], factory);
4+
} else if (typeof exports !== "undefined") {
5+
factory();
6+
} else {
7+
var mod = {
8+
exports: {}
9+
};
10+
factory();
11+
global.FileSaver = mod.exports;
12+
}
13+
})(this, function () {
14+
"use strict";
15+
16+
/*
17+
* FileSaver.js
18+
* A saveAs() FileSaver implementation.
19+
*
20+
* By Eli Grey, http://eligrey.com
21+
*
22+
* License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)
23+
* source : http://purl.eligrey.com/github/FileSaver.js
24+
*/
25+
// The one and only way of getting global scope in all environments
26+
// https://stackoverflow.com/q/3277182/1008999
27+
var _global = typeof window === 'object' && window.window === window ? window : typeof self === 'object' && self.self === self ? self : typeof global === 'object' && global.global === global ? global : void 0;
28+
29+
function bom(blob, opts) {
30+
if (typeof opts === 'undefined') opts = {
31+
autoBom: false
32+
};
33+
else if (typeof opts !== 'object') {
34+
console.warn('Deprecated: Expected third argument to be a object');
35+
opts = {
36+
autoBom: !opts
37+
};
38+
} // prepend BOM for UTF-8 XML and text/* types (including HTML)
39+
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
40+
41+
if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
42+
return new Blob([String.fromCharCode(0xFEFF), blob], {
43+
type: blob.type
44+
});
45+
}
46+
47+
return blob;
48+
}
49+
50+
function download(url, name, opts) {
51+
var xhr = new XMLHttpRequest();
52+
xhr.open('GET', url);
53+
xhr.responseType = 'blob';
54+
55+
xhr.onload = function () {
56+
saveAs(xhr.response, name, opts);
57+
};
58+
59+
xhr.onerror = function () {
60+
console.error('could not download file');
61+
};
62+
63+
xhr.send();
64+
}
65+
66+
function corsEnabled(url) {
67+
var xhr = new XMLHttpRequest(); // use sync to avoid popup blocker
68+
69+
xhr.open('HEAD', url, false);
70+
71+
try {
72+
xhr.send();
73+
} catch (e) {}
74+
75+
return xhr.status >= 200 && xhr.status <= 299;
76+
} // `a.click()` doesn't work for all browsers (#465)
77+
78+
79+
function click(node) {
80+
try {
81+
node.dispatchEvent(new MouseEvent('click'));
82+
} catch (e) {
83+
var evt = document.createEvent('MouseEvents');
84+
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
85+
node.dispatchEvent(evt);
86+
}
87+
} // Detect WebView inside a native macOS app by ruling out all browsers
88+
// We just need to check for 'Safari' because all other browsers (besides Firefox) include that too
89+
// https://www.whatismybrowser.com/guides/the-latest-user-agent/macos
90+
91+
92+
var isMacOSWebView = /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent);
93+
var saveAs = _global.saveAs || ( // probably in some web worker
94+
typeof window !== 'object' || window !== _global ? function saveAs() {}
95+
/* noop */
96+
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
97+
:
98+
'download' in HTMLAnchorElement.prototype && !isMacOSWebView ? function saveAs(blob, name, opts) {
99+
var URL = _global.URL || _global.webkitURL;
100+
var a = document.createElement('a');
101+
name = name || blob.name || 'download';
102+
a.download = name;
103+
a.rel = 'noopener'; // tabnabbing
104+
// TODO: detect chrome extensions & packaged apps
105+
// a.target = '_blank'
106+
107+
if (typeof blob === 'string') {
108+
// Support regular links
109+
a.href = blob;
110+
111+
if (a.origin !== location.origin) {
112+
corsEnabled(a.href) ? download(blob, name, opts) : click(a, a.target = '_blank');
113+
} else {
114+
click(a);
115+
}
116+
} else {
117+
// Support blobs
118+
a.href = URL.createObjectURL(blob);
119+
setTimeout(function () {
120+
URL.revokeObjectURL(a.href);
121+
}, 4E4); // 40s
122+
123+
setTimeout(function () {
124+
click(a);
125+
}, 0);
126+
}
127+
} // Use msSaveOrOpenBlob as a second approach
128+
:
129+
'msSaveOrOpenBlob' in navigator ? function saveAs(blob, name, opts) {
130+
name = name || blob.name || 'download';
131+
132+
if (typeof blob === 'string') {
133+
if (corsEnabled(blob)) {
134+
download(blob, name, opts);
135+
} else {
136+
var a = document.createElement('a');
137+
a.href = blob;
138+
a.target = '_blank';
139+
setTimeout(function () {
140+
click(a);
141+
});
142+
}
143+
} else {
144+
navigator.msSaveOrOpenBlob(bom(blob, opts), name);
145+
}
146+
} // Fallback to using FileReader and a popup
147+
:
148+
function saveAs(blob, name, opts, popup) {
149+
// Open a popup immediately do go around popup blocker
150+
// Mostly only available on user interaction and the fileReader is async so...
151+
popup = popup || open('', '_blank');
152+
153+
if (popup) {
154+
popup.document.title = popup.document.body.innerText = 'downloading...';
155+
}
156+
157+
if (typeof blob === 'string') return download(blob, name, opts);
158+
var force = blob.type === 'application/octet-stream';
159+
160+
var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari;
161+
162+
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
163+
164+
if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== 'undefined') {
165+
// Safari doesn't allow downloading of blob URLs
166+
var reader = new FileReader();
167+
168+
reader.onloadend = function () {
169+
var url = reader.result;
170+
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;');
171+
if (popup) popup.location.href = url;
172+
else location = url;
173+
popup = null; // reverse-tabnabbing #460
174+
};
175+
176+
reader.readAsDataURL(blob);
177+
} else {
178+
var URL = _global.URL || _global.webkitURL;
179+
var url = URL.createObjectURL(blob);
180+
if (popup) popup.location = url;
181+
else location.href = url;
182+
popup = null; // reverse-tabnabbing #460
183+
184+
setTimeout(function () {
185+
URL.revokeObjectURL(url);
186+
}, 4E4); // 40s
187+
}
188+
});
189+
_global.saveAs = saveAs.saveAs = saveAs;
190+
191+
if (typeof module !== 'undefined') {
192+
module.exports = saveAs;
193+
}
194+
});

ES6-10/ES2019/js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './test0731'

ES6-10/ES2019/js/jszip.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)