Commit Graph

17 Commits

Author SHA1 Message Date
Andrew Stewart 5974eb80cd Just use arguments directly instead of array 2014-06-18 16:02:54 -07:00
Andrew Stewart 5acfd4aed4 Remove Utils#bind in preference of built-in fn
We were re-implementing Function.prototype.bind, so let's just use that.
2014-06-17 19:35:07 -07:00
Andrew Stewart 6f42b061b3 Add #fetch Utility function
The #fetch utility acts in (roughly) the same way as Ruby's Hash#fetch function.
This addition should hopefully make constructors more rigorous and help to
prevent a few classes of errors.
2014-06-17 16:02:54 -07:00
edgarsilva 0869909521 Updated fromScale util to return top or bottom of scale, updated specs to reflect new fromScale behavior. 2014-06-11 16:32:40 -05:00
Andrew Stewart 1832e20e17 Expose commands as array, instead of function
For appropriate classes, #commands is now an array, instead of a function that
returns the same array.
2014-06-10 12:29:44 -07:00
Andrew Stewart 2b5e991ef3 Clean up some of the utility functions 2014-06-05 16:30:05 -07:00
Andrew Stewart f91dd7d5c3 Refactor Utils (mostly) out of global namespace
This commit reframes the Utils module to be more self-contained, and now only
the Number prototype methods and the every/after/constantly methods are exposed
globally.

I'm unsure about whether these methods can be more scoped such that people can
turn them off if they want, but that's potentially something to look into in the
future.

This commit also updates most of the other source files in Cylon, requiring the
Utils module rather than assuming the methods are in the global namespace.

A similar batch of commits will need to be made for all other Cylon modules to
make sure they don't explode when they can't find #subclass or something like
that.

To make the previously-global methods available, both in submodules and for
people looking for them, all the utility functions are exported in Cylon.Utils.
2014-06-05 12:17:29 -07:00
Andrew Stewart 789347f6f8 Improve inline docs for Utils functions 2014-06-05 09:32:20 -07:00
Andrew Stewart 2cca04873d Remove node-namespace from Utils 2014-05-13 18:25:31 -07:00
Andrew Stewart 1cffa6067e Add Utils to global.Cylon namespace, add bootstrap
This commit moves Utils to live in the global Cylon namespace, so they can be
accessed in test suites. This is necessary because Mocha, when setting up for
tests, will override our #after method, making TDR not work if any robots
contain a #after call in their work block.

To fix this, in test setup you can call global.Cylon.Utils.bootstrap();
which will re-setup our globals.
2014-04-01 12:31:13 -07:00
Adrian Zankich 1ee0b8b87a Ensure toScale stays within defined range 2014-03-11 18:33:39 -07:00
Andrew Stewart 4c464f0d88 Remove Math.ceil from #toScale, JS has no integers/floats anyways 2014-03-10 15:25:39 -07:00
Andrew Stewart 3c6696a78f Reorganize Utils for easier testing 2014-03-10 12:00:48 -07:00
Andrew Stewart c0c4ce6958 Small changes to appease JSHint 2014-03-07 23:33:59 -08:00
Andrew Stewart f307aad0cd Add global.bind method and tests 2014-02-28 10:31:10 -08:00
Andrew Stewart bbf4e413d8 Refactor utils.js 2014-02-27 13:32:05 -08:00
deadprogram b27756abfc WIP on pure JS revamp 2014-02-27 06:44:53 -08:00