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
Here is a list of scopes to use in Sublime Text 2 snippets - | |
ActionScript: source.actionscript.2 | |
AppleScript: source.applescript | |
ASP: source.asp | |
Batch FIle: source.dosbatch | |
C#: source.cs | |
C++: source.c++ | |
Clojure: source.clojure | |
CoffeeScript: source.coffee |
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
/* eslint-env node, mocha */ | |
var str1 = "你可以使用注释为文件指定 eslint 的环境 ↑"; | |
/* global var1: true, var2: false */ | |
var str2 = "你可以使用注释说明这两个变量是全局变量,并声明是否能被重写"; | |
/* eslint eqeqeq: 0, curly: 2, "plugin1/rule1": 2 */ | |
var str3 = "你可以使用注释让这些规则对你的文件进行特异性配置"; | |
/* eslint-disable */ /* eslint-disable no-alert, no-console */ |
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
/** | |
* 一段代码分析 CommandJS 的循环依赖 | |
* | |
* 一句话概括:出现循环依赖时,循环依赖的后者只会获取前者已执行部分的 exports | |
*/ | |
// a.js | |
exports.done = false; | |
var b = require('./b.js'); // 2. 出现 require,自身暂停执行,开始执行 b.js |
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
/** | |
* ES6 模块循环依赖时 | |
* 代码的运行过程与 CommonJS 一致 | |
* 不同的是变量引用的处理不同 | |
* ES6加载的变量,都是动态引用其所在的模块。只要引用存在,代码就能执行。 | |
*/ | |
/** | |
* module-a.js | |
*/ |
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
/** | |
* curring 用于为函数减少参数数量 | |
*/ | |
function currying(fn) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
return function() { | |
var innerArgs = Array.prototype.slice.call(arguments); | |
var concatArgs = args.concat(innerArgs); | |
return fn.apply(this, concatArgs); |
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
/** | |
* 为 类或构造函数 的原型部署 Iterable 接口 | |
* → 为 类或构造函数 的 prototype 对象部署 [Symbol.iterator] 方法 | |
*/ | |
function Obj(values) { | |
// values 为数组 | |
this.values = values; | |
} | |
// 假设我们的遍历的目标是:遍历对象 values 数组的所有元素值 |
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
<!DOCTYPE html> | |
<html lang="zh-cmn-Hans"> | |
<head> | |
<meta http-equiv="Access-Control-Allow-Origin" content="*"> | |
<meta charset="utf-8"> | |
<meta content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width" name="viewport" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
<meta name="renderer" content="webkit"> | |
<meta http-equiv="Cache-Control" content="no-siteapp" /> |
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
// 事件模拟器与执行器 | |
var eventSimulator = (function () { | |
function fn(element, type) { | |
var ctx = fn; | |
var options = extend(ctx.defaultOptions, arguments[2] || {}); | |
var oEvent, eventType = null; | |
for (var name in ctx.eventMatchers) { | |
if (ctx.eventMatchers[name].test(type)) { | |
eventType = name; |
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
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | |
typeof define === 'function' && define.amd ? define(factory) : | |
global.FakeXMLHttpRequest = factory() | |
}(this, function () { 'use strict'; | |
/** | |
* Minimal Event interface implementation | |
* | |
* Original implementation by Sven Fuchs: https://gist.github.com/995028 |
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
<!DOCTYPE html> | |
<html lang="zh-cmn-Hans"> | |
<head> | |
<meta http-equiv="Access-Control-Allow-Origin" content="*"> | |
<meta charset="utf-8"> | |
<meta content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width" name="viewport" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
<meta name="renderer" content="webkit"> | |
<meta http-equiv="Cache-Control" content="no-siteapp" /> |
OlderNewer