forked from LeetCode-OpenSource/hire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b13f10
commit 9f6c3e4
Showing
14 changed files
with
3,175 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
# Created by https://www.gitignore.io/api/node | ||
# Edit at https://www.gitignore.io/?templates=node | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
#DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# End of https://www.gitignore.io/api/node | ||
|
||
dist/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ | |
|
||
> WIP | ||
# 加入我们 | ||
|
||
> 完成一个或多个面试题,获取免第一轮面试的面试机会。完成的题目越多,质量越高,在面试中的加分更多。完成后的代码可以任意形式发送给 [email protected]。 | ||
## 中国团队 | ||
|
||
### 前端工程师 | ||
|
@@ -30,4 +34,9 @@ LeetCode 中国的前端团队工作内容: | |
|
||
#### 展现你的能力 | ||
|
||
[WIP] | ||
- [编写复杂的 TypeScript 类型](./typescript_zh.md) | ||
- [用 Webpack 实现 predictable long term cache](./webpack_zh.md) | ||
- [编写工程化的组件](./engineering_zh.md) | ||
- [用 RxJS 处理复杂的异步业务](./rxjs_zh.md) | ||
|
||
> 以上几个问题完成一个或多个都有可能获得面试机会,具体情况取决于提交给我们的代码。完成后的代码请发送给 [email protected]。 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 编写工程化的业务模块 | ||
|
||
## 题目描述 | ||
|
||
不限语言,不限框架,完成一个 `Autocomplete` 组件。 | ||
|
||
## 代码要求 | ||
|
||
- 样式不是考察的重点,可以参考 https://ant.design/components/auto-complete-cn/ 来完成样式部分,也可以参考其它组件库的 `Autocomplete`,不需要像素级别还原 | ||
- 你认为过于复杂的细节可以不实现,我们考察的是代码组织能力、抽象能力、代码风格等方面 | ||
- 单元测试的 coverage 越高越好 | ||
- 以 GitHub repo 的形式存放你的代码,`CI/CD` 越自动越好。比如 push 之后的 `lint`,`test`,`codestyle` 检查,`git push tags` 之后的自动发布到 `npm` 等 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# RxJS 题 | ||
|
||
[WIP] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# TypeScript 题 | ||
|
||
## 问题定义 | ||
|
||
假设有一个叫 `EffectModule` 的类 | ||
|
||
```ts | ||
class EffectModule {} | ||
``` | ||
|
||
这个对象上的方法**只可能**有两种类型签名: | ||
|
||
```ts | ||
interface Action<T> { | ||
payload?: T | ||
type: string | ||
} | ||
|
||
asyncMethod<T, U>(input: Promise<T>): Promise<Action<U>> | ||
|
||
syncMethod<T, U>(action: Action<T>): Action<U> | ||
``` | ||
|
||
这个对象上还可能有一些任意的**非函数属性**: | ||
|
||
```ts | ||
interface Action<T> { | ||
payload?: T; | ||
type: string; | ||
} | ||
|
||
class EffectModule { | ||
count = 1; | ||
message = "hello!"; | ||
|
||
delay(input: Promise<number>) { | ||
return input.then(i => ({ | ||
payload: `hello ${i}!`, | ||
type: 'delay' | ||
}); | ||
} | ||
|
||
setMessage(action: Action<Date>) { | ||
return { | ||
payload: action.payload!.getMilliseconds(), | ||
type: "set-message" | ||
}; | ||
} | ||
} | ||
``` | ||
现在有一个叫 `connect` 的函数,它接受 EffectModule 实例,将它变成另一个一个对象,这个对象上只有**EffectModule 的同名方法**,但是方法的类型签名被改变了: | ||
```ts | ||
asyncMethod<T, U>(input: Promise<T>): Promise<Action<U>> 变成了 | ||
asyncMethod<T, U>(input: T): Action<U> | ||
``` | ||
```ts | ||
syncMethod<T, U>(action: Action<T>): Action<U> 变成了 | ||
syncMethod<T, U>(action: T): Action<U> | ||
``` | ||
例子: | ||
EffectModule 定义如下: | ||
```ts | ||
interface Action<T> { | ||
payload?: T; | ||
type: string; | ||
} | ||
|
||
class EffectModule { | ||
count = 1; | ||
message = "hello!"; | ||
|
||
delay(input: Promise<number>) { | ||
return input.then(i => ({ | ||
payload: `hello ${i}!`, | ||
type: 'delay' | ||
}); | ||
} | ||
|
||
setMessage(action: Action<Date>) { | ||
return { | ||
payload: action.payload!.getMilliseconds(), | ||
type: "set-message" | ||
}; | ||
} | ||
} | ||
``` | ||
connect 之后: | ||
```ts | ||
type Connected = { | ||
delay(input: number): Action<string> | ||
setMessage(action: Date): Action<number> | ||
} | ||
const effectModule = new EffectModule() | ||
const connected: Connected = connect(effectModule) | ||
``` | ||
## 要求 | ||
在 [题目链接](https://codesandbox.io/s/o4wwpzyzkq) 里面的 `index.ts` 文件中,有一个 `type Connect = (module: EffectModule) => any`,将 `any` 替换成题目的解答,让编译能够顺利通过,并且 `index.ts` 中 `connected` 的类型与: | ||
```typescript | ||
type Connected = { | ||
delay(input: number): Action<string>; | ||
setMessage(action: Date): Action<number>; | ||
} | ||
``` | ||
**完全匹配**。 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# predictable long term cache 代码模板 | ||
|
||
## 项目依赖 | ||
|
||
- NodeJS >= 10 | ||
- yarn >= 1.12 | ||
|
||
## 解题步骤 | ||
|
||
- 使用 `yarn` 安装依赖 | ||
- 修改 [webpack.config.js](./webpack.config.js) 到符合题目要求 | ||
- 使用 `yarn build` 查看 build 结果 | ||
- 修改 `src` 目录下的任意一个文件后再次运行 `yarn build` 查看 `output hash` 是否满足题目要求 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "webpack-zh", | ||
"version": "1.0.0", | ||
"description": "predictable long term cache problem", | ||
"main": "index.js", | ||
"author": "[email protected]", | ||
"license": "MIT", | ||
"private": true, | ||
"devDependencies": { | ||
"webpack": "^4.26.1", | ||
"webpack-cli": "^3.1.2" | ||
}, | ||
"scripts": { | ||
"build": "webpack" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.11" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { sample as lodashSample } from 'lodash' | ||
|
||
export function sample(arr) { | ||
console.log('common!!!') | ||
return lodashSample(arr) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as Module1 from './module-1' | ||
import * as Module2 from './module-2' | ||
|
||
Module1.logger(['hello', 'world']) | ||
Module2.logData(new Date) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { sample } from '../common' | ||
|
||
export function logger(msgs) { | ||
console.log('module1') | ||
const msg = sample(msgs) | ||
console.info(msg) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { shuffle, keys } from 'lodash' | ||
import { sample } from '../common' | ||
|
||
export function logData(data) { | ||
return sample(shuffle(keys(data))) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @type {import('webpack').Configuration} | ||
*/ | ||
module.exports = { | ||
entry: './src/index.js', | ||
|
||
mode: 'production', | ||
|
||
output: { | ||
filename: '[name].[chunkhash:8].js', | ||
}, | ||
|
||
optimization: { | ||
runtimeChunk: true, | ||
splitChunks: {}, | ||
}, | ||
} |
Oops, something went wrong.