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
| fns = [] | |
| for k, v of obj | |
| continue if k is 0 | |
| break if k is 1 | |
| fns.push (a) -> | |
| console.log k, v | |
| return k | |
| return k if k is 2 |
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
| # But keyword assignment should be smart enough not to stringify variables. | |
| func = -> | |
| this == 'this' | |
| ok func() is false |
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
| task 'build:browser', 'rebuild the merged script for inclusion in the browser', -> | |
| code = '' | |
| for name in ['helpers', 'rewriter', 'lexer', 'parser', 'scope', 'nodes', 'coffee-script', 'browser'] | |
| code += """ | |
| require['./#{name}'] = new function() { | |
| var exports = this; | |
| #{fs.readFileSync "lib/#{name}.js"} | |
| }; | |
| """ | |
| code = """ |
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
| result = fn a:1, b | |
| result = fn a:1 | |
| b | |
| result = fn | |
| a:1 | |
| b |
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
| result = fn | |
| a:a | |
| b | |
| c:c |
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
| result = fn a:1 | |
| b:2 |
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
| require 'openssl' | |
| def hmac key, message | |
| sha = OpenSSL::Digest::SHA256.new | |
| blocksize = 64 # SHA256 uses a 64 byte (512 bit) block size | |
| def xor str0, str1 # assuming strings are of equal length | |
| b0 = str0.bytes.to_a | |
| b1 = str1.bytes.to_a | |
| result = [] |
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
| // compute factorial of 5 | |
| Y(function(self){ | |
| return function(x){ | |
| return x == 0 ? 1 : x * self(x - 1); | |
| }; | |
| })(5); // === 120 |
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
| int random(int min, int max) { | |
| if(min == max) return min; | |
| if(min > max) { | |
| int tmp = max; | |
| max = min; | |
| min = tmp; | |
| } | |
| int range = max - min + 1; | |
| int randMax = RAND_MAX - ((RAND_MAX - range + 1) % range); |
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
| diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee | |
| --- a/src/coffee-script.coffee | |
| +++ b/src/coffee-script.coffee | |
| @@ -88,8 +88,7 @@ exports.eval = (code, options = {}) -> | |
| sandbox[k] = v for own k, v of options.sandbox | |
| sandbox.__filename = options.filename || 'eval' | |
| sandbox.__dirname = path.dirname sandbox.__filename | |
| - # define module/require only if they chose not to specify their own | |
| - unless sandbox.module or sandbox.require | |
| + unless options.sandbox? |