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
class Lexer | |
@EOF:-1 | |
@EOF_TYPE:1 | |
p:0 | |
c:"" | |
constructor:(@input)-> | |
@c = @input[@p] | |
### | |
get next char | |
### |
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 (factory) { | |
//factory是一个函数,下面的koExports就是他的参数 | |
// Support three module loading scenarios | |
if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') { | |
// [1] CommonJS/Node.js | |
// [1] 支持在module.exports.abc,或者直接exports.abc | |
var target = module['exports'] || exports; // module.exports is for Node.js | |
factory(target); |
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
isInteger=(n)-> | |
n%1 == 0 | |
foo=(num)-> | |
num=parseInt num, 10 | |
re=[] | |
if num == 0 | |
return num | |
while num > 0 |
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> | |
<head> | |
<meta charset="utf-8" /> | |
<!--允许全屏--> | |
<meta content="yes" name="apple-mobile-web-app-capable"/> | |
<meta content="yes" name="apple-touch-fullscreen"/> | |
<!--禁止电话号码和邮箱识别--> |
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
animate=do -> | |
requestAnimationFrame = window.requestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.msRequestAnimationFrame || | |
window.oRequestAnimationFrame || | |
(callback)-> | |
setTimeout(-> | |
callback(new Date()) | |
return |
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
{{Variable}} | |
{{#if conditions}} | |
BLOCK | |
{{/if}} | |
{{#if conditions}} | |
BLOCK | |
{{#elseif conditions}} | |
ELSEIF BLOCK |
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
### | |
AOP开始 | |
### | |
DO = | |
objs: {} | |
before: (fn, obj, sFn, c) -> | |
after: (fn, obj, sFn, c) -> | |
_inject: (when_, fn, obj, sFn) -> |
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 Vector; | |
Vector = (function() { | |
/* | |
构造函数这里使用了默认参数和属性参数 | |
*/ function Vector(x, y) { | |
var vector; | |
this.x = x != null ? x : 0; | |
this.y = y != null ? y : 0; | |
if (typeof this.x === "object") { | |
/* |
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
class Vector | |
### | |
构造函数这里使用了默认参数和属性参数 | |
### | |
constructor:(@x=0,@y=0) -> | |
if typeof @x is "object" | |
### | |
这里的vector为了解决给@x赋值的问题,当然使用 | |
@[email protected] | |
@[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
new Vector | |
new Vector 1,1 | |
new Vector {x:1,y:1} |