This file contains hidden or 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
| chainedOp = (obj) -> | |
| result = {} | |
| resultFunc = (i) -> | |
| if Array.isArray obj | |
| (result[i] = -> @) for i in obj | |
| else | |
| for key, value of obj | |
| if typeof value is 'function' | |
| result[key] = (args... ) -> |
This file contains hidden or 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
| toQueryString = (obj) -> | |
| queryArray = [] | |
| for key, value of obj | |
| queryArray.push "#{key}=#{value}" | |
| queryArray.join('&') |
This file contains hidden or 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
| bind = (func, context) -> -> func.apply(context, arguments) |
This file contains hidden or 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
| do (String) -> | |
| String::contains or= (searchString, position = 0) -> @toString().indexOf(searchString) >= position | |
| String::startsWith or= (searchString, position = 0) -> @toString.toString().indexOf(searchString) >= position | |
| String::endsWith or= (searchString, position = @length) -> @toString().lastIndexOf(searchString) is position - searchString.length | |
| String::repeat or= (count) -> | |
| newString = '' | |
| newString += @toString() for [1..count] | |
| newString | |
| String::toArray or= -> @toString().split '' | |
| String::reverse or= -> @toArray().reverse().join '' |
This file contains hidden or 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
| do (window = @) -> | |
| cache = {} | |
| window.module = (name) -> | |
| deps = [] | |
| requires = (dependencies) -> | |
| deps = if Array.isArray dependencies then dependencies else [dependencies] | |
| {requires, defines} |
This file contains hidden or 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
| do -> | |
| cache = {} | |
| window.module = (name, defines) -> | |
| return undefined unless name and defines | |
| if typeof defines is 'function' then define = defines else {define, require, context} = defines | |
| require = [] unless require? | |
| context = @ unless context? |
This file contains hidden or 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::property = (prop) -> | |
| for key, value of prop | |
| Object.defineProperty @prototype, key, value | |
| Function::staticProperty = (prop) -> | |
| for key, value of prop | |
| Object.defineProperty @, key, value | |
| class MyClass | |
| privateVar = 5 |
This file contains hidden or 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
| do (root = exports ? this) -> | |
| 'use check' | |
| root.ClassHelper = (object) -> | |
| objPrototype = object:: | |
| methods = | |
| property: (prop) -> | |
| for key, value of prop | |
| propObject = |
This file contains hidden or 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
| do (root = exports ? window.eos or= {}) -> | |
| root.each = (object, callback) -> | |
| if Array.isArray object | |
| callback key, value for value, key in object | |
| else | |
| callback key, value for own key, value of object | |
| null | |
| root.isEmptyObject = (object) -> Object.keys(object).length is 0 |
This file contains hidden or 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
| define('vendors', function() { | |
| return ['ms', 'moz', 'webkit', 'o']; | |
| }); | |
| define('requestAnimationFrame', ['root', 'vendors'], function(root, vendors) { | |
| // frameRate is only used if requestAnimationFrame is not available | |
| var frameRate = 60; | |
| var requestAnimationFrame = root.requestAnimationFrame; |