Skip to content

Commit

Permalink
feat: 建立文档的目录结构
Browse files Browse the repository at this point in the history
  • Loading branch information
yangjin committed Sep 25, 2019
1 parent cfc6196 commit 4a7049b
Show file tree
Hide file tree
Showing 47 changed files with 151 additions and 8 deletions.
101 changes: 94 additions & 7 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,103 @@
module.exports = {
title: 'Hello VuePress',
description: 'Just playing around',

// webpack alias
title: 'fe-tutorial',
description: '前端学习笔记',
head: [
['link', {rel: 'icon', href: '/favicon.ico'}]
],
configureWebpack: {
resolve: {
alias: {
'@alias': 'path/to/some/dir'
}
}
},

// base path
base: '/docs/'
base: '/fe-tutorial/',
themeConfig: {
editLinkText: '在 GitHub 上编辑此页',
lastUpdated: '上次更新',
nav: [
{ text: '数据结构和算法', link: '/algorithm/' },
{ text: 'JavaScript', link: '/javaScript/' },
{ text: 'Webpack', link: '/webpack/' },
{ text: '个人博客', link: 'https://yangseas.github.io/' },
{ text: 'github', link: 'https://github.com/yangseas' },
],
sidebarDepth: 2,
sidebar: {
'/algorithm/': [
{
title: '数据结构',
collapsable: false,
sidebarDepth: 2,
children: []
},
{
title: '算法',
collapsable: false,
sidebarDepth: 2,
children: []
}
],
'/javaScript/': [
{
title: 'JavaScript',
collapsable: false,
sidebarDepth: 2,
children: [
['', '介绍'],
'执行上下文和执行栈',
'作用域和闭包',
'this',
'原型链',
'深拷贝和浅拷贝',
'节流函数和防抖函数',
'函数柯里化',
'高阶函数',
'EventEmitter',
'实现ES5继承',
'实现call,apply和bind',
'实现Promise',
'实现instanceof',
'实现异步打印',
'数组去重,扁平化和最值',
'数组乱序',
'懒加载',
'滚动加载',
'虚拟滚动'
]
},
{
title: 'RegExp',
collapsable: false,
sidebarDepth: 2,
children: [
'RegExp',
]
}
],
'/webpack/': [
{
title: 'Webpack',
collapsable: false,
sidebarDepth: 2,
children: [
['', '介绍'],
'webpack打包过程',
]
},
{
title: 'vue-cli2模板解析',
collapsable: false,
sidebarDepth: 2,
children: [
['vue-cli2介绍', '介绍'],
'vue-cli2模板解析',
]
}
],
}
},
plugins: [
['@vuepress/back-to-top', true]
]
}
1 change: 1 addition & 0 deletions docs/.vuepress/styles/index.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// 添加额外样式
1 change: 1 addition & 0 deletions docs/.vuepress/styles/palette.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// 对默认预设的样式应用简单的颜色替换,或者定义一些颜色变量供以后使用
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ heroImage: ./logo.jpg
heroText: fe-tutorial
tagline: 前端学习笔记
actionText: 开始阅读 →
actionLink: /dataStructure/
actionLink: /algorithm/
features:
- title: 数据结构和算法
details: 常见数据结构和算法的介绍,以及基本使用和实现。
Expand Down
File renamed without changes.
Empty file added docs/algorithm/分治/README.md
Empty file.
Empty file.
Empty file.
Empty file added docs/algorithm/排序/README.md
Empty file.
Empty file.
Empty file added docs/algorithm/查找/README.md
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added docs/golang/README.md
Empty file.
Empty file added docs/javaScript/EventEmitter.md
Empty file.
Empty file added docs/javaScript/RegExp.md
Empty file.
Empty file added docs/javaScript/this.md
Empty file.
Empty file added docs/javaScript/介绍.md
Empty file.
Empty file.
54 changes: 54 additions & 0 deletions docs/javaScript/函数柯里化.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: 函数柯里化
---

## 定义

在数学和计算机科学中,柯里化是一种将使用多个参数的一个函数转换成一系列使用一个参数的函数的技术。

> 通俗易懂的解释:用闭包把参数保存起来,当参数的数量足够执行函数了,就开始执行函数。

## 实现

- 判断当前函数传入的参数是否大于或等于`fn`需要参数的数量,如果是,直接执行`fn`
- 如果传入参数数量不够,返回一个闭包,暂存传入的参数,并重新返回`currying`函数

```js
function currying(fn, ...args) {
if (args.length >= fn.length) {
return fn(...args);
} else {
return (...args2) => currying(fn, ...args, ...args2);
}
}
```

我们来一个简单的实例验证一下:

```js
const curryingFun = currying(fun)
curryingFun(1)(2)(3); // 1 2 3
curryingFun(1, 2)(3); // 1 2 3
curryingFun(1, 2, 3); // 1 2 3
```

## 应用场景

### 参数复用

```js
function getUrl(protocol, domain, path) {
return protocol + "://" + domain + "/" + path;
}

var page1 = getUrl('http', 'www.conardli.top', 'page1.html');
var page2 = getUrl('http', 'www.conardli.top', 'page2.html');
```

我们使用`currying`来简化它:

```js
let conardliSite = currying(simpleURL)('http', 'www.conardli.top');
let page1 = conardliSite('page1.html');
```
Empty file added docs/javaScript/原型链.md
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added docs/javaScript/懒加载.md
Empty file.
Empty file.
Empty file added docs/javaScript/数组乱序.md
Empty file.
Empty file.
Empty file.
Empty file added docs/javaScript/滚动加载.md
Empty file.
Empty file.
Empty file added docs/javaScript/虚拟滚动.md
Empty file.
Empty file added docs/javaScript/高阶函数.md
Empty file.
Empty file added docs/node/README.md
Empty file.
Empty file added docs/webpack/README.md
Empty file.
Empty file added docs/webpack/vue-cli2介绍.md
Empty file.
Empty file.
Empty file.

0 comments on commit 4a7049b

Please sign in to comment.