Skip to content

Commit c601eb2

Browse files
committed
增加ramda目录
1 parent 19633c1 commit c601eb2

File tree

4 files changed

+69
-11
lines changed

4 files changed

+69
-11
lines changed
File renamed without changes.

Ramda/start.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const R = require('ramda');
2+
3+
// 测试输出
4+
const out = i => console.log(i);
5+
6+
// let sub = R.reduce(R.subtract, 0);
7+
// R.compose(out, sub)([1, 2, 3]);
8+
9+
// 在不增加函数的情况,使用 isEven 查找第一个奇数
10+
// complement 可以对函数返回值取反,接受一个函数 f ,返回一个新函数 g
11+
// const isEven = x => x % 2 === 0;
12+
// let find = R.find(R.complement(isEven));
13+
// R.compose(out, find)([1, 2, 3, 4]);
14+
15+
16+
// const gt10 = x => x > 10;
17+
// const even = x => x % 2 === 0;
18+
// const gt20 = x => x > 20;
19+
// var f = R.either(even, gt20, gt10);
20+
// R.compose(out, f)(17);
21+
22+
23+
const multiply = (a, b) => a * b
24+
const addOne = x => x + 1
25+
const square = x => x * x
26+
27+
// const operate = (x, y) => {
28+
// const product = multiply(x, y)
29+
// const incremented = addOne(product)
30+
// const squared = square(incremented)
31+
32+
// return squared
33+
// }
34+
35+
// also like
36+
// cosnt operate = (x, y) => square(addOne(multiply(x, y)));
37+
38+
// from left to right
39+
// const operate = R.pipe(
40+
// multiply,
41+
// addOne,
42+
// square
43+
// )
44+
45+
// from right to left
46+
const operate = R.compose(
47+
square,
48+
addOne,
49+
multiply
50+
);
51+
52+
// 有个用法是,定义函数的时候,使用 pipe,调用函数的时候,使用 compose
53+
54+
R.compose(out, operate)(3, 4) ;
55+

echarts/twoGrid.js

+12-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module.exports = {
99
devtool: 'source-map',
1010
// entry: path.resolve(__dirname, './react/components/HOC/index.js'),
1111
// entry: path.resolve(__dirname, './echarts/twoGrid.js'),
12-
entry: path.resolve(__dirname, './echarts/dynamicData.js'),
12+
entry: path.resolve(__dirname, './echarts/multipleX.js'),
13+
// entry: path.resolve(__dirname, './echarts/dynamicData.js'),
1314
output: {
1415
filename: '[name].js',
1516
path: path.resolve(__dirname, './build')

0 commit comments

Comments
 (0)