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
| deepEquals = (objA, objB) -> | |
| # Simplest of all checks | |
| return true if (objA is objB) | |
| # Both parameters need to be objects | |
| return false if (typeof objA isnt 'object') or (typeof objB isnt 'object') | |
| # Special case for Date objects | |
| if (objA instanceof Date) or (objB instanceof Date) | |
| return false if ((objA instanceof Date) isnt (objB instanceof Date)) or (objA.getTime isnt objB.getTime) |
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 strict' | |
| root.check = (variable, checkObject) -> | |
| stringedVar = {}.toString.call variable | |
| typeName = stringedVar.slice(8, stringedVar.length - 1).toLowerCase() | |
| checkType = (typeString, cb, inverse) -> | |
| if inverse |
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
| ((window, MilkSugar, $) -> | |
| "use strict" | |
| # Rebind method for JSHint | |
| check = window.check | |
| class MilkSugar.App | |
| constructor: (assets = ['image', 'view']) -> | |
| if assets? |
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
| namespace = (name, func) -> | |
| if name.indexOf('.') > 0 | |
| nameArray = name.split('.') | |
| else | |
| nameArray = [name] | |
| context = window | |
| for i in nameArray | |
| context = context[i] or= {} |
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
| class Entity | |
| componentList = {} | |
| constructor: (@name = @constructor.name) -> | |
| get: (componentName) -> | |
| if componentName | |
| componentList[componentName] | |
| else | |
| Object.keys componentList |
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
| fs = require 'fs' | |
| path = require 'path' | |
| coffeeScript = require 'coffee-script' | |
| convertCSON = (csonObject) -> | |
| return unless csonObject? | |
| completeObject = | |
| "csonObject = { | |
| #{csonObject} |
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
| class StringReader | |
| buffer = "" | |
| constructor: (@input) -> | |
| @reset() | |
| readUntil: (character, omitCharacter = false) -> | |
| loop | |
| break if @currentIndex is @input.length |
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
| # Example 1 | |
| # Adding properteies to Component instances | |
| console.log '--- Example 1 ---' | |
| comp1 = new Component('comp1') | |
| comp1.test = -> console.log 'Comp1' | |
| comp2 = new Component('comp2') | |
| comp2.test = -> console.log 'Comp2' | |
| myEntity = new Entity('myEntity') |
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
| class StringReader | |
| buffer = "" | |
| constructor: (@input) -> | |
| @reset() | |
| readUntil: (character, omitCharacter = false, notFoundFn) -> | |
| loop | |
| if @end() | |
| notFoundFn(buffer) if notFoundFn |
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 = if exports? and module.exports? then module.exports else @) -> | |
| class root.StringReader | |
| constructor: (@input) -> | |
| @buffer = "" | |
| @reset() | |
| readUntil: (character, omitCharacter = false, notFoundFn) -> | |
| loop |