/**
* Check if value is primitive//检查该值是否是个原始值
*/
function isPrimitive (value) {
return typeof value === 'string' || typeof value === 'number'
} /**
* Create a cached version of a pure function.//创建一个纯粹的函数的缓存版本
*/
function cached (fn) {
var cache = Object.create(null);//创建一个缓存对象
return (function cachedFn (str) {//返回一个函数
var hit = cache[str];//以函数的参数为键
return hit || (cache[str] = fn(str))//如果缓存对象中存在这个键,那么就从缓存中返回这个函数,如果没有就把这个函数赋值到缓存对象中并且返回
})
} /**
* Camelize a hyphen-delimited string.//驼峰化一个连字符连接的字符串
*/
var camelizeRE = /-(\w)/g;
var camelize = cached(function (str) {
return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
}); /**
* Capitalize a string.//对一个字符串首字母大写
*/
var capitalize = cached(function (str) {
return str.charAt(0).toUpperCase() + str.slice(1)//把第一个字符串的首个字符大写,把除第一个字符的字符串返回与大写的首字符拼接
}); /**
* Hyphenate a camelCase string.用字符号连接一个驼峰的字符串
*/
var hyphenateRE = /([^-])([A-Z])/g;
var hyphenate = cached(function (str) {
return str
.replace(hyphenateRE, '$1-$2')//$1为正则表达式匹配的第一个元素$2为第二个元素
.replace(hyphenateRE, '$1-$2')
.toLowerCase()//使之最小化
}); /**
* Simple bind, faster than native//简单的绑定,会比原生的更快
*/
function bind (fn, ctx) {
function boundFn (a) {
var l = arguments.length;//获取实参的数量
return l
? l > 1//如果实参数量大于1
? fn.apply(ctx, arguments)
: fn.call(ctx, a)//实参数量等于1
: fn.call(ctx)//没有参数
}
// record original fn length//记录一下原始的形参数量
boundFn._length = fn.length;
return boundFn
} /**
* Convert an Array-like object to a real Array.//转换一个类数组的对象为真正的数组
*/
function toArray (list, start) {
start = start || 0;//如果start存在则用start如果不存在则用0;
var i = list.length - start;//设置新数组的数量
var ret = new Array(i);//新建数组
while (i--) {5
ret[i] = list[i + start];
}
return ret
}

vue.js源码学习分享(二)的更多相关文章

  1. vue.js源码学习分享(一)

    今天看了vue.js源码  发现非常不错,想一边看一遍写博客和大家分享 /** * Convert a value to a string that is actually rendered. *转换 ...

  2. vue.js源码学习分享(九)

    /* */ var arrayKeys = Object.getOwnPropertyNames(arrayMethods);//获取arrayMethods的属性名称 /** * By defaul ...

  3. vue.js源码学习分享(七)

    var _Set; /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) { // use ...

  4. vue.js源码学习分享(六)

    /* */ /* globals MutationObserver *///全局变化观察者 // can we use __proto__?//我们能用__proto__吗? var hasProto ...

  5. vue.js源码学习分享(八)

    /* */ var uid$1 = 0; /** * A dep is an observable that can have multiple * directives subscribing() ...

  6. vue.js源码学习分享(五)

    //配置项var config = { /** * Option merge strategies (used in core/util/options)//选项合并策略 */ optionMerge ...

  7. vue.js源码学习分享(四)

    /** * Generate a static keys string from compiler modules.//从编译器生成一个静态键字符串模块. */ function genStaticK ...

  8. vue.js源码学习分享(三)

    /** * Mix properties into target object.//把多个属性插入目标的对象 */ function extend (to, _from) { for (var key ...

  9. Vue.js 源码学习笔记

    最近饶有兴致的又把最新版 Vue.js 的源码学习了一下,觉得真心不错,个人觉得 Vue.js 的代码非常之优雅而且精辟,作者本身可能无 (bu) 意 (xie) 提及这些.那么,就让我来吧:) 程序 ...

随机推荐

  1. I/O理解

    I/O是什么 我的理解I/O就是用于读写的一个流 官方解释:I/O(英语:Input/Output),即输入/输出,通常指数据在内部存储器和外部存储器或其他周边设备之间的输入和输出. node中的io ...

  2. 【转】嵌入式操作系统VxWorks中TFFS文件系统的构建

    时间:2005-02-20 来源:21IC中国电子网 作者:771所加固机工程部 蔡本华 高文炜 关键字:VxWorks   TFFS   嵌入式操作系统   文件系统       摘要:目前的嵌入式 ...

  3. (70)zabbix telnet监控类型

    概述 zabbix监控的方式很多,例如前面讲到的agent.snmp以及后续后续要讲到ssh和今天要讲到的telnet.流程很简单,创建item-->配置ip.用户.密码.端口.脚本->z ...

  4. 解决 viewer.js 动态更新图片导致无法预览的问题

    1.viewer.js 使用 Demo http://fengyuanchen.github.io/viewerjs/ 2.viewer.js 下载地址 https://github.com/feng ...

  5. matplotlib学习记录 六

    # 绘制多数据条形图 # 假设你知道了列表a中电影分别在2017-09-14(b_14),2017-09-15(b_15), # 2017-09-16(b_16)三天的票房,为了展示列表中电影本身的票 ...

  6. Django之URL

    URL是用户请求路径与views视图处理函数的一个映射 简单的路由配置及实现 这里是pycharm编辑开发为例,新建的django项目,会在url.py下自动生成这样一段代码: from django ...

  7. python数据类型之集合(set)和其常用方法

    集合是一个无序的,不重复的数据组合 作用(集合的重点):1.去重,把一个列表变成集合就自动去重了2.关系测试,测试两组数据库之前的交集.差集.并集等关系 s = {1, 1, 2, 2, 3, 4, ...

  8. LeetCode(129) Sum Root to Leaf Numbers

    题目 Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a num ...

  9. LeetCode(149) Max Points on a Line

    题目 Given n points on a 2D plane, find the maximum number of points that lie on the same straight lin ...

  10. arm的开发工具

    网上有free的ide可以开发arm cortex的芯片,可以参考List of ARM Cortex-M development tools,Wikipedia,里面有emIDE,embitz等,虽 ...