Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
从上面的示例可以看出,原始的 Vue 配置对象,只能够对 props 进行有限的类型检查,不能对 data、methods 等其他配置项做类型声明和类型检查。并且在对 props 进行类型声明时,只能使用下列原生构造函数:String Number Boolean Array Object Date Function Symbol 来做类型校验,不能进行更具体、深入的类型声明,可以说是非常鸡肋。
对一个对象进行 TypeScript 类型声明是比较困难的,而对 class 进行 TypeScript 类型声明是相对简单、自然的:我们可以很方便地对 class 的属性和方法添加类型,还可以通过 extends 继承父类的类型。如下所示:
cd ~/projects/node-redis # go into the package directory npm link # creates global link cd ~/projects/node-bloggy # go into some other package directory. npm link redis # link-install the package
eslint@7.25.0 dev node_modules/eslint dev eslint@"^7.25.0" from the root project peer eslint@">= 4.12.1" from babel-eslint@10.1.0 node_modules/babel-eslint dev babel-eslint@"^10.1.0" from the root project peer eslint@">=7.0.0" from eslint-config-prettier@8.3.0 node_modules/eslint-config-prettier dev eslint-config-prettier@"^8.3.0" from the root project ...
# --------------------------------------------------------------- # Site Information Settings # ---------------------------------------------------------------
# To get or check favicons visit: https://realfavicongenerator.net # Put your favicons into `hexo-site/source/` (recommend) or `hexo-site/themes/next/source/images/` directory.
# Default NexT favicons placed in `hexo-site/themes/next/source/images/` directory. # And if you want to place your icons in `hexo-site/source/` root directory, you must remove `/images` prefix from pathes.
# For example, you put your favicons into `hexo-site/source/images` directory. # Then need to rename & redefine they on any other names, otherwise icons from Next will rewrite your custom icons in Hexo. favicon: small: /favicon.ico medium: /favicon.ico apple_touch_icon: /images/apple-touch-icon-next.ico safari_pinned_tab: /logo.svg #android_manifest: /images/manifest.json #ms_browserconfig: /images/browserconfig.xml
在 a ~> a -> a(参见上面的波浪形箭头)中,a 可以为任意类型。半群 a => a ~> a -> a 会添加一个约束,使得类型 a 现在必须满足该半群的类型类。满足类型类意味着,须合法地实现该类型类指定所有函数/方法。
例如:
1 2 3 4 5 6
traverse :: Applicative f, Traversable t => t a ~> (TypeRep f, a -> f b) -> f (t b) '------' '--------------------------' '-' '-------------------' '-----' ' ' ' ' ' ' ' - type constraints ' ' - argument types ' - return type ' ' '- method name ' - method target type
u.traverse(Compose, x => new Compose(x)) 等价于 new Compose(u.traverse(F, x => x).map(x => x.traverse(G, x => x))),对下面定义的 Compose 和 任意 Applicatives F 和 G 都适用 (组合性)
var employeesByProjectName = R.pipe( R.propEq('codename'), R.flip(R.filter)(assignments), R.map(R.prop('name')) ); var onTime = R.filter(proj => proj.completed <= proj.due); var withinBudget = R.filter(proj => proj.cost <= proj.budget); var topProjects = R.converge(R.intersection, [onTime, withinBudget]); var bonusEligible = R.pipe( topProjects, R.map(R.prop('codename')), R.map(employeesByProjectName), R.flatten, R.uniq );
console.log(bonusEligible(projects)); // Live version at https://codepen.io/adispring/pen/WdQjXL?editors=0012 // 译者注:原文用的 ramda@0.22.1 版本比较旧了,converge 第二个之后的函数未加中括号 // 本文采用 ramda@0.25.0
这段代码是一段 “函数式” 的 pipeline。它是由模块化、可组合的函数构建而成,这些函数拼接在一起形成长长的管道,然后我们可以从管道入口传入待处理的数据。上面的每个 var 变量声明都代表一个单输入单输出的函数。每个函数的输出结果在管道中继续传递下去。