Compare commits

...

98 Commits
2.0.3 ... 2.4.1

Author SHA1 Message Date
Geoffrey Booth
f4fcf65750 Don't publish .DS_Store to npm 2019-04-07 20:48:04 -07:00
Geoffrey Booth
92f69b2bca Release 2.4.1 (#5195)
* Fix #5133: Document that braces are required for object shorthand.

* Changelog for 2.4.1

* Update output
2019-04-07 20:41:37 -07:00
Geoffrey Booth
742224471f Actually publish the browser compilers to NPM (#5186)
* Actually publish the browser compilers to NPM

* Transpile and minify modern browser compiler; add to lib/ folder; update docs
2019-04-07 16:09:44 -07:00
Erik Demaine
d23919c430 Preserve environment when calling coffee from test (#5191)
This change spawns `coffee` with a new path, but without removing all other
environment variables.  This is useful for preserving environment needed by
Node, for example, `LD_LIBRARY_PATH` on Unix.  In particular, fix #5179.
2019-04-02 11:35:22 -07:00
Geoffrey Booth
e6f6aa8c85 Version bump in lockfile 2019-03-30 11:33:20 -07:00
Geoffrey Booth
c09d8fbedb Release 2.4.0 (#5182)
* cake doc:site:watch should also watch the changelog files

* Changelog for 2.4.0

* 2.4.0 output
2019-03-30 11:31:22 -07:00
Geoffrey Booth
f6d63776c3 ES module version of compiler for use in browsers; dynamic import() docs; revised Stage 3 policy (#5177)
* Build both a legacy and modern browser compiler

* Dynamic import example and documentation

* Update the docs to use the modern browser compiler if the browser supports it

* Update policy regarding Stage 3 features

* This never made sense, and assigning a string to index 0 *of a string* throws in Module mode (and silently does nothing in Script mode) so remove this unneeded code that throws when compiling `fn for i from from iterable` in Module mode

* Have browser-based tests use the ES module version if supported

* Simplify building logic

* Update output

* For the ES module version of the browser compiler, don't automatically attach the runScripts event handler

* Consistent comments

* Fix comment
2019-03-26 23:55:31 -07:00
Ruben Bridgewater
41b31c7293 Fix repl.rli deprecation (#5178)
The `rli` property is just a reference to itself. It still exists
for legacy reasons but it will likely be removed in a future major
version. This makes sure everything works as expected.
2019-03-24 19:12:32 -07:00
Geoffrey Booth
ec034e2673 Fix tests (#5176)
* Fix cake test:integrations per newer Webpack

* Update dependencies

* Update dependencies
2019-03-23 23:28:13 -07:00
Julian Rosse
ff24e5ce52 Dynamic import (#5169)
* dynamic import

* updated grammar

* specify callable

* DynamicImportCall

* Fix from code review

Co-Authored-By: helixbass <julian@helixbass.net>

* recompile
2019-03-20 13:08:10 -07:00
Julian Rosse
ca275c2a1c Fix #5128: parens around default param (#5167)
* compile params at LEVEL_PAREN

* test
2019-03-14 18:14:35 -07:00
Alex
63ffe0aead Fix 5085 (#5145)
* Add test for #5085

    $ cake test
    failed 1 and passed 1274 tests in 4.81 seconds

      #5085: Bug: @ reference to class not maintained in do block
      AssertionError [ERR_ASSERTION]: Expected undefined to equal 2

* Fix #5085: @ reference to class in "do" block

Assuming that a bound Code node inside an ExecutableClassBody without a
name must be a "do" block.

* Additional tests

https://github.com/jashkenas/coffeescript/pull/5145#issuecomment-462127244

Also switched to concat'g strings for test values, as opposed to
incrementing numbers: makes the tests a bit easier to read.
2019-02-11 07:28:04 -08:00
Robert de Forest
247b511c6a Remove extra word in comment in src/nodes.coffee (#5158) 2019-02-09 18:48:24 -08:00
Adrian
2f82b75862 implement coffeescript.registerCompiled method (#5130)
* implement coffeescript._addSoucrse method

This method enables an external module to implement caching of
compilation results. When the compiled js source is loaded from cache,
the original coffee code should be added with this method in order to
enable the Error.prepareStackTrace below to correctly adjust the stack
trace for the corresponding file (the source map will be generated on
demand).

* replace _addSource with registerCompiled

* extract the logic from _compileFile into _compileRawFileContent

_compileFile takes care of logging the file and calls _compileRawFileContent

this way an external caching implementation which computes cache key
based on raw content of the sources file, can reuse the logic of
_compileFile and avoid having calling `fs.readFileSync` for the file
more twice in case of cache miss

* remove 'output' argument from registerCompiled
2018-11-28 09:09:06 -08:00
Geoffrey Booth
294bb4754e Fix #5112: A string of ', ' in an array should not be detected as an elision (#5113) 2018-10-05 06:45:54 -07:00
Geoffrey Booth
6e86b67818 Release 2.3.2 (#5110)
* Bump version to 2.3.2

* 2.3.2 changelog

* Update output for 2.3.2
2018-09-19 23:53:49 -07:00
Geoffrey Booth
b4dceaea67 Fix #5086: Don't generate unnecessary interpolations in JSX tags when the tags contain only here (/* ... */) comments (#5108) 2018-09-18 08:02:41 -07:00
Julian Rosse
6225627579 Fix #4609: support new.target (#5106)
* support new.target

* check token type
2018-09-16 13:52:47 -07:00
Geoffrey Booth
c4245e50c2 Babel 7 (#5105)
* Port to Babel 7

Use the Babel 7 @babel/core transpiler, falling back to the older babel-core version if possible.

* Use Babel 7 and preset-env 7 to build the browser compiler and test Babel transpilation

* Update docs for Babel 7
2018-09-09 13:41:49 -07:00
Geoffrey Booth
98b2a69416 Update dependencies; disable some babel-minify transforms to work around https://github.com/babel/minify/issues/893 (#5095) 2018-08-14 08:47:38 -07:00
Geoffrey Booth
7f8b36a8bd Revert "fix momentum scrolling on iOS (#5083)" (#5084)
This reverts commit 812571843c.
2018-06-16 15:35:34 -07:00
Paul Nta
812571843c fix momentum scrolling on iOS (#5083) 2018-06-16 15:32:16 -07:00
Julian Rosse
70f6cb70e2 Allow yield indented object (#5072)
* allow yield indented object

* allow await indented object

* fixes from code review
2018-06-10 21:45:45 -07:00
Geoffrey Booth
be702d67f3 2.3.1 (#5069)
* Update links to use https://coffeescript.org

* 2.3.1 changelog

* Bump version to 2.3.1; update output

* Forgot one

* Another one

* Lock Babel versions for Node 6 build to succeed, until Babel 7 is out
2018-05-21 22:14:34 -07:00
Geoffrey Booth
68302e6da7 Docs headings and changelog refactor (#5067)
* Changelog sub-sections should use h3, not h2; no need for hack anchor tag anymore

* Internationalize dates to user’s locale

* Consistent names

* Split up the changelog into separate files per version; make HTML markup consistent with the other sections in the docs

* Fix sidebar links for introduction and overview
2018-05-20 09:39:53 -07:00
zdenko
0e7677ad62 Fix #5046: Adjacent JSX (#5049)
* Fix #5046: Adjacent JSX

* check CSX only when wrapped in parentheses

* Fix indentation

* Add test for unlikely, but valid, JSX syntax
2018-05-20 09:39:09 -07:00
Geoffrey Booth
7cf739e2b6 Lexer, helpers and comments cleanup (#5063)
* Move the building of the comments hash into its own function, to make clearer that it only happens once

* Abstract token comments dictionary

* Format comments

* Allow attaching a “data” property to tokens, to allow extra info to pass through the parser into the node classes

* Add data to StringLiteral tokens such that we should be able to deindent them in the nodes class

* Update output

* Another comment fix

* Add data to every token, with common properties

* Be more defensive, even though we apparently don't need to be

* Improve comments

* Remove the token data property, leaving all unrelated improvements

* Code review improvements; update output
2018-05-13 16:58:44 -07:00
Julian Rosse
41185ca7ac Normalize :: syntax (#5048)
* normalize :: syntax

* fixes from code review
2018-05-13 12:41:43 -07:00
Julian Rosse
7dbdca8c54 Allow implicit call with class with no body (#5053)
* allow implicit call with class with no body

* more tests
2018-05-13 12:20:09 -07:00
Julian Rosse
8e66ae404e fix JSX expression indentation bug (#5056)
* fix JSX expression indentation bug

* fixes from code review

* tweak test
2018-05-12 18:01:27 -07:00
Jeremy Ashkenas
7beb631694 Create CNAME 2018-05-03 15:51:03 -07:00
Jeremy Ashkenas
c2792e4840 Delete CNAME 2018-05-03 15:50:54 -07:00
Geoffrey Booth
d82272b6c2 Fix #1832: Browser compiler should run code using globally-scoped eval (#5047)
* Explicitly turn off minify mangling, because it was previously implicitly disabled by the existence of the `eval` call we’re about to remove

* Update babel-core

* Run browser-compiled scripts using window.eval rather than just eval, to use a clean scope (many times faster)

* Update output

* Fix browser-based test broken by #5028

* Update output
2018-05-01 08:11:40 -07:00
Geoffrey Booth
fe7554828a Fix #5034: Adjacent JSX elements must be wrapped in an enclosing tag (#5046) 2018-05-01 08:09:07 -07:00
Geoffrey Booth
708e57586c Fix README ASCII art 2018-04-28 19:03:21 -07:00
Geoffrey Booth
8061ecf0e2 2.3.0 (#5043)
* Move analytics initialization into docs.coffee

* Bump Bootstrap and CodeMirror versions

* Update output

* Merge CodeMirror styles

* Update CodeMirror styles

* Better flexbox layout for docs, including flex auto-sized sidebar and main column

* Minor styling fixes for Edge

* Fix scrollspy for new layout

* Update output

* Clicking on the CoffeeScript logo in the navbar should scroll to top; fix main column width on mobile

* Update output

* 2.3.0 changelog

* Update operators section for **

* Update docs for ES2018 object rest/spread

* Remove references to Node's experimental modules support

* Move the README coffee cup to the right side, so our name isn't cut off on the NPM page; update README and CONTRIBUTING text

* Update dependencies

* Add compatibility note for async generators

* Bump version to 2.3.0 and update output

* Have CI test in Node 10 instead of 9

* Somehow this gets generated slightly differently in Node 10

* Fix #4042: Update broken link
2018-04-28 18:57:15 -07:00
Geoffrey Booth
6df8f5ff17 Remove references to Node's experimental modules support 2018-04-27 10:27:20 -07:00
Geoffrey Booth
776e7e5328 Docs improvements (#5042)
* Move analytics initialization into docs.coffee

* Bump Bootstrap and CodeMirror versions

* Update output

* Merge CodeMirror styles

* Update CodeMirror styles

* Better flexbox layout for docs, including flex auto-sized sidebar and main column

* Minor styling fixes for Edge

* Fix scrollspy for new layout

* Update output

* Clicking on the CoffeeScript logo in the navbar should scroll to top; fix main column width on mobile

* Update output
2018-04-27 10:07:01 -07:00
zdenko
871079b25c Fix #4876: remove polyfill for object rest/spread (#4884)
* object rest/spread

* merge branch 'master' into 'object_rest_spread'

* explore

* Revert "merge branch 'master' into 'object_rest_spread'"

This reverts commit eeeffef55d.

* Revert "explore"

This reverts commit d21cd72aa3.

* split tests

* improvements

* unassignable rest property

* cleanup

* formatting, cleanup

* handle non-final object-destructured splat

* merge with @helixbass's branch
2018-04-23 09:50:42 -07:00
Ruben Bridgewater
be2b24310f Fix: a test relied on faulty behavior (#5028)
`assert.throws` did not test for the error message so far. This
changes it to actually test for the error message.
2018-04-10 09:21:40 -07:00
zdenko
1f9cd4eaf7 Fix #4875: Asynchronous iterators (#4893)
* async iterators

* tests; refactor 'For' grammar rules

* async iterator tests

* formatting
2018-04-08 13:42:54 -07:00
Geoffrey Booth
47c491ffa1 Regular expressions s (dotAll) flag (#4880)
* Support ES2018 regex dotall flag

* Test in Node 9

* Alphabetize regex flags

* Split regex dotall test into its own file, use new feature detection method of loading it

* Update docs to explain compatibility for ES2018 and newer Node features

* Remove unnecessary paragraph
2018-03-30 15:25:41 -07:00
Geoffrey Booth
195a46ab77 Fix #4877: Exponentiation operators (#4881)
* Passthrough exponentiation operator; remove tests that are invalid JavaScript

* Treat **= as a passthrough assignment

* Get tests passing in Node 6

* Improve scoping

* Move exponentiation tests into their own file, now that it's filtered out by Cakefile

* Restore original test
2018-03-30 00:47:40 -07:00
Geoffrey Booth
e5aa758dda 2.2.4 (#5025)
* Update changelog for 2.2.4

* Bump version to 2.2.4; update output
2018-03-29 20:00:45 -07:00
zdenko
001f97ac39 Fix #5013: return statement as an expression (#5014)
* fix #5013

* disallow statement in the expression
2018-03-17 23:08:43 -07:00
Robert de Forest
ce66a499de Make node --harmony bin/cake test pass on Node 9 (#5012)
* Make `node --harmony bin/cake test` pass on Node 9

Make classMaker() explicitly return an object

* Update Travis and AppVeyor to use --harmony and v9
2018-03-17 23:02:40 -07:00
zdenko
0268505119 Optimize 'for-range-by' loop when 'by' is literal number (#5016)
* optimize 'for-range-by' loop when 'by' is literal number

* small fix
2018-03-15 08:02:13 -07:00
Robert de Forest
5a43b2d7c5 simplified test file skipping (#4996) (#5003)
simplified test file skipping (#4996)
2018-03-12 19:03:44 -07:00
Geoffrey Booth
820942c3d0 2.2.3 (#5010)
* Bump version to 2.2.3; update packages

* Update output

* Update changelog
2018-03-11 13:48:14 -07:00
zdenko
1869f3121d Fix: destructuring assignment with an empty array in object (#5000)
* destructuring assignment with empty array in object

* improvements
2018-03-10 07:39:35 -08:00
zdenko
4c0363fb7c Fix #5004: incorrect compiled code when a destructuring array contains accessors (#5005) 2018-03-07 15:57:31 -08:00
Geoffrey Booth
746b0c7cc6 Code of Conduct (#4992)
* Code of Conduct

* Email address
2018-02-26 22:18:13 -08:00
Geoffrey Booth
b2fe7772c5 Pull request template (#4994) 2018-02-26 17:50:25 -08:00
Geoffrey Booth
23479eb486 Create issue template (#4993) 2018-02-26 17:50:14 -08:00
Geoffrey Booth
63b8543d73 Update output 2018-02-25 01:09:52 -08:00
zdenko
7542a75ff8 get/set example (#4990) 2018-02-25 00:18:57 -08:00
Joseph Lin
0875039d52 [update] copyright year to 2018 (#4988) 2018-02-24 23:40:11 -08:00
Geoffrey Booth
e0833c29ce 2.2.2 (#4986)
* Changelog for 2.2.2

* Bump version to 2.2.2

* Bump dependencies

* Update output
2018-02-22 00:31:14 -08:00
zdenko
72ab6feb2f Fix #4889: for...range loop condition (#4891)
* fix #4889

* test

* move test from 'control_flow' to 'ranges'

* More range tests
2018-02-20 00:46:20 -08:00
zdenko
eb7009268d fix #4898 (#4899) 2018-02-17 16:57:49 -08:00
zdenko
571e9df335 fix #4874 (#4888) 2018-02-08 21:11:11 -08:00
Geoffrey Booth
a73f66bc11 2.2.1 (#4885)
* 2.2.1 changelog

* Bump version to 2.2.1 and update output
2018-02-06 22:28:15 -08:00
zdenko
ba094126e2 Fix #4882: Range not declaring var for the "i" (#4883)
* fix #4882

* test
2018-02-04 13:33:08 -08:00
zdenko
794f65fbd7 Fix #4878: Compile error when using destructuring with a splat or expansion in an array (#4879)
* fix #4878

* improvements

* test

* refactor
2018-02-03 13:35:41 -08:00
Geoffrey Booth
0490eb9a3a 2.2.0 (#4873)
* Changelog for 2.2.0

* Bump version

* Bump package versions

* Fix `cake doc:source` for Docco 0.8.0

* Update output; some text tweaks
2018-02-01 20:14:26 -08:00
zdenko
9e80f6fa67 Fix #2047: Infinite loop possible when for loop with range uses variables (#4853)
* fix #2047

* Additional check for 'step'; tests

* Fix #4105 (#4855)

* Update output

* Throw warning for unsupported runtimes, e.g. Node < 6 (#4839)

* fix #1403 (#4854)

* Update output

* [Change]: Destructuring with non-final spread should still use rest syntax (#4517) (#4825)

* destructuring optimization

* refactor

* minor improvement, fix errors

* minor refactoring

* improvements

* Update output

* Update output

* Fix #4843: bad output when assigning to @prop in destructuring assignment with defaults (#4848)

* fix #4843

* improvements

* typo

* small fix

* Fix #3441: parentheses wrapping expression throw invalid error  (#4849)

* fix #3441

* improvements

* refactor

* Fix #1726: expression in property access causes unexpected results (#4851)

* fix #1726

* Explain what's happening, rather than just linking to an issue

* Updated output

* Optimization

* Update output

* remove casting to number

* cleanup tests
2018-01-31 19:51:43 -08:00
Geoffrey Booth
fc5ab1afa3 Update output 2018-01-31 06:33:17 -08:00
zdenko
0aa77f157a fix #4871 (#4872) 2018-01-31 06:31:52 -08:00
Geoffrey Booth
1849f0db76 Fix #4852, @get @set implicit object (#4867)
* Test cases for #4852, get/set oddities

* Fix soak before accessor call to `get` or `set`

* Fixes #4852: More get/set cases; cleanup style

* Check for tokens' existence before referencing them
2018-01-30 21:17:55 -08:00
zdenko
d86597dbad Fix #3306: trailing comma in a function call in the last line throws a syntax error (#4860)
* fix #3306

* added test
2018-01-30 21:09:50 -08:00
zdenko
bf91781888 Fix #4868: Incorrect ‘Can’t call super with @params’ error (#4869)
* fix #4868

* improvements

* tests
2018-01-30 21:06:54 -08:00
Geoffrey Booth
dcd6de9a77 Update output 2018-01-30 20:51:15 -08:00
zdenko
70b510bcb7 Fix #3933: Missing then doesn’t trigger nearby error (#4862)
* fix #3933

* tests
2018-01-30 15:04:29 -08:00
zdenko
84d596d534 Fix #4437: variable scope in chained calls (#4863)
* fix #4437

* tests
2018-01-29 23:01:25 -08:00
zdenko
c804087ec9 Fix #3921 & #2342: inline function without parentheses used in condition, inline 'else' (#4838)
* fix #3921: inline function without parentheses used in condition

* add grammar rules

* fix issue #2343

* typos

* multiple 'else' in line

* close 'else if'
2018-01-28 17:51:57 -08:00
zdenko
74bd537d6c fix #3909 (#4861) 2018-01-28 02:38:39 -08:00
zdenko
0217ed5505 Fix #1726: expression in property access causes unexpected results (#4851)
* fix #1726

* Explain what's happening, rather than just linking to an issue

* Updated output

* Optimization
2018-01-15 20:03:01 -08:00
zdenko
e53307b46b Fix #3441: parentheses wrapping expression throw invalid error (#4849)
* fix #3441

* improvements

* refactor
2018-01-15 19:32:27 -08:00
zdenko
c8c8c167d1 Fix #4843: bad output when assigning to @prop in destructuring assignment with defaults (#4848)
* fix #4843

* improvements

* typo

* small fix
2018-01-15 19:29:48 -08:00
zdenko
c1283ead45 [Change]: Destructuring with non-final spread should still use rest syntax (#4517) (#4825)
* destructuring optimization

* refactor

* minor improvement, fix errors

* minor refactoring

* improvements

* Update output

* Update output
2018-01-15 19:24:21 -08:00
Geoffrey Booth
3ade25a32c Update output 2018-01-15 19:06:57 -08:00
zdenko
7ea3ea92f3 fix #1403 (#4854) 2018-01-15 16:54:55 -08:00
Geoffrey Booth
a70f1a082e Throw warning for unsupported runtimes, e.g. Node < 6 (#4839) 2018-01-14 23:40:36 -08:00
Geoffrey Booth
2ccbb6b91a Update output 2018-01-14 20:56:26 -08:00
zdenko
e348026073 Fix #4105 (#4855) 2018-01-14 20:16:29 -08:00
Geoffrey Booth
7c6f3788ca Fix #4836: functions named get or set can be used without parentheses when attached to @ (#4837) 2018-01-06 13:58:43 -08:00
Geoffrey Booth
12fcbfc654 2.1.1 (#4835)
* Bump version to 2.1.1

* 2.1.1 changelog

* 2.1.1 updated output
2017-12-29 16:54:57 -08:00
Chris Connelly
38f5963b85 Use free variables for anonymous classes (#4826)
Fixes #4822.
2017-12-28 14:50:12 -08:00
Chris Connelly
ffbe51e374 Set the context of executable class body wrappers (#4828)
Fixes #4827.
2017-12-18 10:51:08 -08:00
Geoffrey Booth
926cb8463c 2.1.0 (#4823)
* Changelog for 2.1.0; remove text from objects section that is no longer valid for CS2/ES2015.

* Update packages

* 2.1.0 build

* Update output

* Correct reference to `//` division, per https://github.com/coffeescript6/discuss/issues/39#issuecomment-347144647
2017-12-10 23:12:33 -08:00
zdenko
b1286752b9 improve elision output (#4824) 2017-12-10 15:22:34 -08:00
zdenko
5eb9dded52 [Enhancement] Computed property keys (#4622) (#4803)
* Computed property keys

* refactor

* improvements

* refactor tests

* fix comments
2017-12-08 22:42:47 -08:00
zdenko
7f5ab7eb0d [Enhancement] CSX fragments syntax (#4802) (#4804)
* CSX fragments

* regex improvement; tests

* regex improvement

* regex improvement

* bug fix; regex

* Fix style

* Split fragment tests
2017-12-08 22:41:02 -08:00
zdenko
5bc85b8f6d Fix #4798: Incorrect output for object rest destructuring inside array destructuring (#4799)
* fix #4798

* additional tests
2017-12-04 08:00:45 -08:00
zdenko
81d1b511f0 Fix #4811: Heregex comments cannot contain three slashes in a row (#4814)
* fix comment with /// in heregex

* cleanup

* improved pattern for comments in heregex; fixed unescaped hashes in lexer.coffee

* improvements

* refactor RegExp

* cleanup

* Improved RegEx
2017-12-03 11:55:26 -08:00
Geoffrey Booth
2dc3f6c87a Cache node_modules for AppVeyor builds (#4817) 2017-12-02 20:49:22 -08:00
Geoffrey Booth
04959162c6 AppVeyor (#4812)
* First attempt at using AppVeyor

* Maybe it doesn't like the leading dot?

* Versions are an array

* Fix tests on Windows: for some reason, Windows requires `coffee` to be executed as `node coffee` (in the context of `spawnSync`, at least)

* Use npm@latest, see if that's less noisy

* Nevermind, only an issue on Node 6

* Better to see the NPM version before npm install
2017-12-01 13:19:48 -08:00
zdenko
f14c7ffa3f Fixes #4684: Elision (#4796)
* Elision

* test

* improvements

* grammar optimization

* cleanup
2017-11-28 21:24:18 -08:00
208 changed files with 16038 additions and 8989 deletions

View File

@@ -1,3 +1,3 @@
{
"presets": ["env"]
"presets": ["@babel/env"]
}

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ parser.output
/node_modules
npm-debug.log*
yarn.lock
.DS_Store

View File

@@ -3,6 +3,7 @@ language: node_js
node_js:
- 6
- 8
- 10
cache:
directories:
@@ -14,5 +15,6 @@ script:
- node ./bin/cake build:full
- node ./bin/cake build:browser
- node ./bin/cake test
- node --harmony ./bin/cake test
- node ./bin/cake test:browser
- node ./bin/cake test:integrations

46
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at maintainers@coffeescript.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@@ -6,4 +6,9 @@
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffeescript/tree/master/src). If youre just getting started with CoffeeScript, theres a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide).
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffeescript.js` file. Well do those things before cutting a new release. You _should,_ however, commit the updated compiled JavaScript files in `lib`.
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffeescript.js` file. Well do those things before cutting a new release. You _should,_ however, commit the updated compiled JavaScript files in `lib`.
* To get started, read the guides in the wiki:
* [Hacking on the CoffeeScript Compiler](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-Hacking-on-the-CoffeeScript-Compiler)
* [How parsing works](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-How-parsing-works)
* [Update the docs](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-Update-the-docs)

118
Cakefile
View File

@@ -19,9 +19,9 @@ unless process.env.NODE_DISABLE_COLORS
header = """
/**
* CoffeeScript Compiler v#{CoffeeScript.VERSION}
* http://coffeescript.org
* https://coffeescript.org
*
* Copyright 2011, Jeremy Ashkenas
* Copyright 2011-#{new Date().getFullYear()}, Jeremy Ashkenas
* Released under the MIT License
*/
"""
@@ -66,17 +66,21 @@ build = (callback) ->
buildParser()
buildExceptParser callback
transpile = (code) ->
babel = require 'babel-core'
transpile = (code, options = {}) ->
options.minify = process.env.MINIFY isnt 'false'
options.transform = process.env.TRANSFORM isnt 'false'
options.sourceType ?= 'script'
babel = require '@babel/core'
presets = []
# Exclude the `modules` plugin in order to not break the `}(this));`
# at the end of the `build:browser` code block.
presets.push ['env', {modules: no}] unless process.env.TRANSFORM is 'false'
presets.push 'minify' unless process.env.MINIFY is 'false'
presets.push ['@babel/env', {modules: no}] if options.transform
presets.push ['minify', {mangle: no, evaluate: no, removeUndefined: no}] if options.minify
babelOptions =
compact: process.env.MINIFY isnt 'false'
presets: presets
sourceType: 'script'
compact: not options.minify
comments: not options.minify
sourceType: options.sourceType
{ code } = babel.transform code, babelOptions unless presets.length is 0
code
@@ -140,13 +144,18 @@ task 'build:browser', 'merge the built scripts into a single file for use in a b
return module.exports;
})();
"""
# From here, we generate two outputs: a legacy script output for all browsers
# and a module output for browsers that support `<script type="module">`.
code = """
var CoffeeScript = function() {
function require(path){ return require[path]; }
#{code}
return require['./browser'];
}();
"""
scriptCode = transpile """
(function(root) {
var CoffeeScript = function() {
function require(path){ return require[path]; }
#{code}
return require['./browser'];
}();
#{code}
if (typeof define === 'function' && define.amd) {
define(function() { return CoffeeScript; });
@@ -155,10 +164,25 @@ task 'build:browser', 'merge the built scripts into a single file for use in a b
}
}(this));
"""
code = transpile code
outputFolder = "docs/v#{majorVersion}/browser-compiler"
fs.mkdirSync outputFolder unless fs.existsSync outputFolder
fs.writeFileSync "#{outputFolder}/coffeescript.js", header + '\n' + code
moduleCode = transpile """
#{code}
export default CoffeeScript;
const { VERSION, compile, eval: evaluate, load, run, runScripts } = CoffeeScript;
export { VERSION, compile, evaluate as eval, load, run, runScripts };
""", {sourceType: 'module'}
outputFolders = [
"docs/v#{majorVersion}/browser-compiler-legacy"
"docs/v#{majorVersion}/browser-compiler-modern"
"lib/coffeescript-browser-compiler-legacy"
"lib/coffeescript-browser-compiler-modern"
]
for outputFolder in outputFolders
fs.mkdirSync outputFolder unless fs.existsSync outputFolder
fs.writeFileSync "#{outputFolder}/coffeescript.js", """
#{header}
#{if outputFolder.includes('legacy') then scriptCode else moduleCode}
"""
task 'build:browser:full', 'merge the built scripts into a single file for use in a browser, and test it', ->
invoke 'build:browser'
@@ -174,26 +198,19 @@ task 'build:watch:harmony', 'watch and continually rebuild the CoffeeScript comp
buildDocs = (watch = no) ->
# Constants
indexFile = 'documentation/site/index.html'
siteSourceFolder = "documentation/site"
sectionsSourceFolder = 'documentation/sections'
examplesSourceFolder = 'documentation/examples'
outputFolder = "docs/v#{majorVersion}"
indexFile = 'documentation/site/index.html'
siteSourceFolder = "documentation/site"
sectionsSourceFolder = 'documentation/sections'
changelogSourceFolder = 'documentation/sections/changelog'
examplesSourceFolder = 'documentation/examples'
outputFolder = "docs/v#{majorVersion}"
# Helpers
releaseHeader = (date, version, prevVersion) ->
monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
formatDate = (date) ->
date.replace /^(\d\d\d\d)-(\d\d)-(\d\d)$/, (match, $1, $2, $3) ->
"#{monthNames[$2 - 1]} #{+$3}, #{$1}"
"""
<div class="anchor" id="#{version}"></div>
<h2 class="header">
#{prevVersion and "<a href=\"https://github.com/jashkenas/coffeescript/compare/#{prevVersion}...#{version}\">#{version}</a>" or version}
<span class="timestamp"> &mdash; <time datetime="#{date}">#{formatDate date}</time></span>
</h2>
<h3>#{prevVersion and "<a href=\"https://github.com/jashkenas/coffeescript/compare/#{prevVersion}...#{version}\">#{version}</a>" or version}
<span class="timestamp"> &mdash; <time datetime="#{date}">#{date}</time></span>
</h3>
"""
codeFor = require "./documentation/site/code.coffee"
@@ -224,7 +241,7 @@ buildDocs = (watch = no) ->
"<blockquote class=\"uneditable-code-block\">#{defaultFence.apply @, arguments}</blockquote>"
(file, bookmark) ->
md = fs.readFileSync "#{sectionsSourceFolder}/#{file}.md", 'utf-8'
md = fs.readFileSync "#{sectionsSourceFolder}/#{file.replace /\//g, path.sep}.md", 'utf-8'
md = md.replace /<%= releaseHeader %>/g, releaseHeader
md = md.replace /<%= majorVersion %>/g, majorVersion
md = md.replace /<%= fullVersion %>/g, CoffeeScript.VERSION
@@ -269,7 +286,7 @@ buildDocs = (watch = no) ->
catch exception
if watch
for target in [indexFile, siteSourceFolder, examplesSourceFolder, sectionsSourceFolder]
for target in [indexFile, siteSourceFolder, examplesSourceFolder, sectionsSourceFolder, changelogSourceFolder]
fs.watch target, interval: 200, renderIndex
log 'watching...', green
@@ -332,7 +349,7 @@ task 'doc:test:watch', 'watch and continually rebuild the browser-based tests',
buildAnnotatedSource = (watch = no) ->
do generateAnnotatedSource = ->
exec "node_modules/docco/bin/docco src/*.*coffee --output docs/v#{majorVersion}/annotated-source", (err) -> throw err if err
exec "cd src && ../node_modules/docco/bin/docco *.*coffee --output ../docs/v#{majorVersion}/annotated-source", (err) -> throw err if err
log 'generated', green, "annotated source in docs/v#{majorVersion}/annotated-source/"
if watch
@@ -425,12 +442,6 @@ runTests = (CoffeeScript) ->
catch err
onFail description, fn, err
global.supportsAsync = try
new Function('async () => {}')()
yes
catch
no
helpers.extend global, require './test/support/helpers'
# When all the tests have run, collect and print errors.
@@ -448,10 +459,20 @@ runTests = (CoffeeScript) ->
console.log " #{source}" if source
return
# Run every test in the `test` folder, recording failures.
files = fs.readdirSync 'test'
unless global.supportsAsync # Except for async tests, if async isnt supported.
files = files.filter (filename) -> filename isnt 'async.coffee'
# Run every test in the `test` folder, recording failures, except for files
# were skipping because the features to be tested are unsupported in the
# current Node runtime.
testFilesToSkip = []
skipUnless = (featureDetect, filenames) ->
unless (try new Function featureDetect)
testFilesToSkip = testFilesToSkip.concat filenames
skipUnless 'async () => {}', ['async.coffee', 'async_iterators.coffee']
skipUnless 'async function* generator() { yield 42; }', ['async_iterators.coffee']
skipUnless 'var a = 2 ** 2; a **= 3', ['exponentiation.coffee']
skipUnless 'var {...a} = {}', ['object_rest_spread.coffee']
skipUnless '/foo.bar/s.test("foo\tbar")', ['regex_dotall.coffee']
files = fs.readdirSync('test').filter (filename) ->
filename not in testFilesToSkip
startTime = Date.now()
for file in files when helpers.isCoffee file
@@ -472,7 +493,7 @@ task 'test', 'run the CoffeeScript language test suite', ->
task 'test:browser', 'run the test suite against the merged browser script', ->
source = fs.readFileSync "docs/v#{majorVersion}/browser-compiler/coffeescript.js", 'utf-8'
source = fs.readFileSync "lib/coffeescript-browser-compiler-legacy/coffeescript.js", 'utf-8'
result = {}
global.testingBrowser = yes
(-> eval source).call result
@@ -490,6 +511,9 @@ task 'test:integrations', 'test the module integrated with other libraries and e
webpack = require 'webpack'
webpack {
entry: './'
optimization:
# Webpacks minification causes the CoffeeScript module to fail some tests.
minimize: off
output:
path: tmpdir
filename: 'coffeescript.js'

62
ISSUE_TEMPLATE.md Normal file
View File

@@ -0,0 +1,62 @@
<!---
Thanks for filing an issue 😄! Before you submit, please read the following:
Search open/closed issues before submitting since someone might have asked the same thing before!
Our issues history stretches back to 2009, so the odds are good that your topic has come up.
If you have a support request or question please use Stack Overflow:
https://stackoverflow.com/questions/tagged/coffeescript
Issues on GitHub are only related to problems of the CoffeeScript compiler itself and we cannot answer
support questions here.
-->
Choose one: is this a bug report or feature request?
<!---
Provide a general summary of the issue in the title above.
For bugs, please also preface your title with “Bug:”. For feature requests, please preface your title
with “Proposal:”. Once your issue is reviewed, a maintainer will edit the title to refer to the part
of the codebase most relevant to the issue (if applicable).
If your request is that CoffeeScript support a new feature recently arrived to JavaScript, please note
that we generally only add features that have reached Stage 4 in the specification (in other words,
the syntax is finalized and the feature is approved to be part of the next ES release). You can still
open an issue, but it will likely be tagged with “[Awaiting Stage 4]” until the relevant ES feature is
approved for release. See https://coffeescript.org/#contributing
There are also a handful of JavaScript features that CoffeeScript intentionally does not support.
Please do not open issues regarding these. Theyre listed in https://coffeescript.org/#unsupported
-->
### Input Code
<!--- If you're describing a bug, please let us know which sample code reproduces your problem. -->
<!--- If you have link from https://coffeescript.org/#try or a standalone repo please include that! -->
```coffee
your (code) => here
```
### Expected Behavior
<!--- If youre describing a bug, tell us what should happen. -->
<!--- If youre suggesting a change/improvement, tell us how it should work. -->
### Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior. -->
<!--- If suggesting a change/improvement, explain the difference from current behavior. -->
### Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change. -->
### Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world. -->
### Environment
<!--- For bugs, please let us know what version of CoffeeScript youre running: `coffee -v`. -->
<!--- If you think it might be relevant, please also let us know your version of Node. -->
* CoffeeScript version:
* Node.js version:

View File

@@ -1,4 +1,4 @@
Copyright (c) 2009-2017 Jeremy Ashkenas
Copyright (c) 2009-2018 Jeremy Ashkenas
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

22
PULL_REQUEST_TEMPLATE.md Normal file
View File

@@ -0,0 +1,22 @@
<!--
Before making a PR please make sure to read our contributing guidelines:
https://coffeescript.org/#contributing
For issue references: Add a comma-separated list of a
[closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by
the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
All new features require tests. All but the most trivial bug fixes should also have new or updated tests.
Ensure that all new code you add to the compiler can be run in the minimum version of Node listed in
`package.json`. New tests can require newer Node runtimes, but you may need to ensure that such tests
only run in supported runtimes; see `Cakefile` for examples of how to filter out certain tests in
runtimes that dont support them.
Please follow the code style of the rest of the CoffeeScript codebase. Write comments in complete
sentences using Markdown, as the comments become the [annotated source](https://coffeescript.org/#annotated-source).
For tests proving a bug is fixed, please mention the issue number in the test description (see examples
in the codebase).
Describe your changes below in as much detail as possible.
-->

View File

@@ -1,27 +1,29 @@
@@@@@@@ @@@@ @@@@@
{ @@@@@@@@@@ @@@ @@@
} } { @@@@ @@ @@@ @@@
{ { } } @@@@ @@@@@@@ @@@ @@@ @@@@@@ @@@@@@
} }{ { @@@@ @@@ @@ @@@@@ @@@@@@ @@@ @@ @@@@ @@
{ }{ } } @@@@ @@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@
{ }{ }{ { } @@@@ @@@@ @@ @@@ @@@ @@@@@@@@ @@@@@@@@
{ { } { } { } } @@@@@ @@@@ @@ @@@ @@@ @@@ @@@
{ } { } { } @@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@
@@@@@@ { } { } @@@@@@@ @@@@@ @@@ @@@ @@@@@ @@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@ @@@
@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@ @@@ @@@
@@ @@@@@@@@@@@@@@@@@@@@@@@@ @@@@ @@ @@@ @@@@
@@@ @@@@@@@@@@@@@@@@@@@@@ @@@@ @@@ @@ @@@@
@@@ @@@@@@@@@@@@@@@@@@ @@@@@ @@@@@ @@ @@ @@@ @@@@@@@ @@@@@
@@@ @@@@@@@@@@@@@@@@ @@@@@ @@@ @@@ @@@@@@@@ @@@@ @@@@ @@@@@@@
@@@@@@@@@@@@@@ @@@@@ @@@ @@@@ @@@@ @@@ @@@ @@@
@@@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
@@@ @@@@ @@@ @@@@ @@@@ @@@ @@@@ @@@@
@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
@@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@@@@@@ @@@@
@@@ @@@@
@@@
@@@
```
@@@@@@@ @@@@ @@@@@
@@@@@@@@@@ @@@ @@@ {
@@@@ @@ @@@ @@@ } } {
@@@@ @@@@@@@ @@@ @@@ @@@@@@ @@@@@@ { { } }
@@@@ @@@ @@ @@@@@ @@@@@@ @@@ @@ @@@@ @@ } }{ {
@@@@ @@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ { }{ } }
@@@@ @@@@ @@ @@@ @@@ @@@@@@@@ @@@@@@@@ { }{ }{ { }
@@@@@ @@@@ @@ @@@ @@@ @@@ @@@ { { } { } { } }
@@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ { } { } { }
@@@@@ @@@ @@@ @@@@@ @@@@@ @@@@@@ { } { } @@@@@@@
@@@ @@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@ @@@ @@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@ @@ @@@ @@@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@
@@@@ @@@ @@ @@@@ @@@ @@@@@@@@@@@@@@@@@@@@@
@@@@@ @@@@@ @@ @@ @@@ @@@@@@@ @@@@@ @@@ @@@@@@@@@@@@@@@@@@
@@@@@ @@@ @@@ @@@@@@@@ @@@@ @@@@ @@@@@@@ @@@ @@@@@@@@@@@@@@@@
@@@@@ @@@ @@@@ @@@@ @@@ @@@ @@@ @@@@@@@@@@@@@@
@@@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
@@@ @@@@ @@@ @@@@ @@@@ @@@ @@@@ @@@@
@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
@@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@@@@@@ @@@@
@@@ @@@@
@@@
@@@
```
CoffeeScript is a little language that compiles into JavaScript.
@@ -30,11 +32,13 @@ CoffeeScript is a little language that compiles into JavaScript.
Once you have Node.js installed:
```shell
# Install locally for a project:
npm install --save-dev coffeescript
# Install globally to execute .coffee files anywhere:
npm install --global coffeescript
```
Leave off the `--global` if you dont wish to install globally.
## Getting Started
Execute a script:
@@ -49,7 +53,7 @@ Compile a script:
coffee -c /path/to/script.coffee
```
For documentation, usage, and examples, see: http://coffeescript.org/
For documentation, usage, and examples, see: https://coffeescript.org/
To suggest a feature or report a bug: https://github.com/jashkenas/coffeescript/issues
@@ -57,6 +61,6 @@ If youd like to chat, drop by #coffeescript on Freenode IRC.
The source repository: https://github.com/jashkenas/coffeescript.git
Changelog: http://coffeescript.org/#changelog
Changelog: https://coffeescript.org/#changelog
Our lovely and talented contributors are listed here: https://github.com/jashkenas/coffeescript/contributors

29
appveyor.yml Normal file
View File

@@ -0,0 +1,29 @@
environment:
matrix:
- nodejs_version: '6'
- nodejs_version: '8'
- nodejs_version: '10'
- nodejs_version: '' # Installs latest.
install:
- ps: Install-Product node $env:nodejs_version
- node --version
- npm --version
- npm install
cache:
- node_modules
test_script:
- node ./bin/cake build:except-parser
- node ./bin/cake build:parser
- node ./bin/cake build:full
- node ./bin/cake build:browser
- node ./bin/cake test
- node --harmony ./bin/cake test
- node ./bin/cake test:browser
- node ./bin/cake test:integrations
build: off
version: "{build}"

View File

@@ -1,5 +1,12 @@
#!/usr/bin/env node
try {
new Function('var {a} = {a: 1}')();
} catch (error) {
console.error('Your JavaScript runtime does not support some features used by the cake command. Please use Node 6 or later.');
process.exit(1);
}
var path = require('path');
var fs = require('fs');

View File

@@ -1,5 +1,12 @@
#!/usr/bin/env node
try {
new Function('var {a} = {a: 1}')();
} catch (error) {
console.error('Your JavaScript runtime does not support some features used by the coffee command. Please use Node 6 or later.');
process.exit(1);
}
var path = require('path');
var fs = require('fs');

View File

@@ -1 +1 @@
coffeescript.org
coffeescript.org

View File

@@ -1 +1 @@
v2/browser-compiler
v2/browser-compiler-legacy

View File

@@ -0,0 +1 @@
v2/browser-compiler-legacy

View File

@@ -0,0 +1 @@
v2/browser-compiler-modern

View File

@@ -124,7 +124,7 @@ We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
<div class="content"><div class='highlight'><pre>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
compile = CoffeeScript.compile</pre></div></div>
{ compile } = CoffeeScript</pre></div></div>
</li>
@@ -135,13 +135,17 @@ compile = CoffeeScript.compile</pre></div></div>
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Use standard JavaScript <code>eval</code> to eval code.</p>
<p>Use <code>window.eval</code> to evaluate code, rather than just <code>eval</code>, to run the
script in a clean global scope rather than inheriting the scope of the
CoffeeScript compiler. (So that <code>cake test:browser</code> also works in Node,
use either <code>window.eval</code> or <code>global.eval</code> as appropriate).</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
options.bare ?= <span class="hljs-literal">on</span>
eval compile code, options</pre></div></div>
globalRoot = <span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>? <span class="hljs-keyword">then</span> <span class="hljs-built_in">window</span> <span class="hljs-keyword">else</span> <span class="hljs-built_in">global</span>
globalRoot[<span class="hljs-string">'eval'</span>] compile code, options</pre></div></div>
</li>
@@ -258,7 +262,7 @@ This happens on page load.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">runScripts</span> = -&gt;</span>
<div class="content"><div class='highlight'><pre>CoffeeScript.runScripts = <span class="hljs-function">-&gt;</span>
scripts = <span class="hljs-built_in">window</span>.<span class="hljs-built_in">document</span>.getElementsByTagName <span class="hljs-string">'script'</span>
coffeetypes = [<span class="hljs-string">'text/coffeescript'</span>, <span class="hljs-string">'text/literate-coffeescript'</span>]
coffees = (s <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> scripts <span class="hljs-keyword">when</span> s.type <span class="hljs-keyword">in</span> coffeetypes)
@@ -317,14 +321,19 @@ only one CoffeeScript script block to parse.</p>
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>Listen for window load, both in decent browsers and in IE.</p>
<p>Listen for window load, both in decent browsers and in IE.
Only attach this event handler on startup for the
non-ES module version of the browser compiler, to preserve
backward compatibility while letting the ES module version
be importable without side effects.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.addEventListener
<span class="hljs-built_in">window</span>.addEventListener <span class="hljs-string">'DOMContentLoaded'</span>, runScripts, <span class="hljs-literal">no</span>
<span class="hljs-keyword">else</span>
<span class="hljs-built_in">window</span>.attachEvent <span class="hljs-string">'onload'</span>, runScripts</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">is</span> <span class="hljs-built_in">window</span>
<span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.addEventListener
<span class="hljs-built_in">window</span>.addEventListener <span class="hljs-string">'DOMContentLoaded'</span>, CoffeeScript.runScripts, <span class="hljs-literal">no</span>
<span class="hljs-keyword">else</span>
<span class="hljs-built_in">window</span>.attachEvent <span class="hljs-string">'onload'</span>, CoffeeScript.runScripts</pre></div></div>
</li>

View File

@@ -282,6 +282,32 @@ its not likely to be used. Save in form of <code>filename</code>: [<code>(sou
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
</div>
<p>This is exported to enable an external module to implement caching of
compilation results. When the compiled js source is loaded from cache, the
original coffee code should be added with this method in order to enable the
Error.prepareStackTrace below to correctly adjust the stack trace for the
corresponding file (the source map will be generated on demand).</p>
</div>
<div class="content"><div class='highlight'><pre>exports.registerCompiled = registerCompiled = <span class="hljs-function"><span class="hljs-params">(filename, source, sourcemap)</span> -&gt;</span>
sources[filename] ?= []
sources[filename].push source
<span class="hljs-keyword">if</span> sourcemap?
sourceMaps[filename] ?= []
sourceMaps[filename].push sourcemap</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
</div>
<p>Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.</p>
<p>If <code>options.sourceMap</code> is specified, then <code>options.filename</code> must also be
specified. All options that can be passed to <code>SourceMap#generate</code> may also
@@ -298,11 +324,11 @@ doing programmatic lookups.</p>
</li>
<li id="section-11">
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<a class="pilcrow" href="#section-12">&#182;</a>
</div>
<p>Clone <code>options</code>, to avoid mutating the <code>options</code> object passed in.</p>
@@ -313,11 +339,11 @@ doing programmatic lookups.</p>
</li>
<li id="section-12">
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<a class="pilcrow" href="#section-13">&#182;</a>
</div>
<p>Always generate a source map if no filename is passed in, since without a
a filename we have no way to retrieve this source later in the event that
@@ -330,8 +356,6 @@ we need to recompile it to get a source map for <code>prepareStackTrace</code>.<
checkShebangLine filename, code
sources[filename] ?= []
sources[filename].push code
map = <span class="hljs-keyword">new</span> SourceMap <span class="hljs-keyword">if</span> generateSourceMap
tokens = lexer.tokenize code, options</pre></div></div>
@@ -339,11 +363,11 @@ we need to recompile it to get a source map for <code>prepareStackTrace</code>.<
</li>
<li id="section-13">
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<a class="pilcrow" href="#section-14">&#182;</a>
</div>
<p>Pass a list of referenced variables, so that generated variables wont get
the same name.</p>
@@ -357,11 +381,11 @@ the same name.</p>
</li>
<li id="section-14">
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Check for import or export; if found, force bare mode.</p>
@@ -385,11 +409,11 @@ the same name.</p>
</li>
<li id="section-15">
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Update the sourcemap with data from each fragment.</p>
@@ -400,11 +424,11 @@ the same name.</p>
</li>
<li id="section-16">
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>Do not include empty, whitespace, or semicolon-only fragments.</p>
@@ -425,11 +449,11 @@ the same name.</p>
</li>
<li id="section-17">
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>Copy the code from each fragment into the final JavaScript.</p>
@@ -443,8 +467,6 @@ the same name.</p>
<span class="hljs-keyword">if</span> generateSourceMap
v3SourceMap = map.generate options, code
sourceMaps[filename] ?= []
sourceMaps[filename].push map
<span class="hljs-keyword">if</span> options.transpile
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> options.transpile <span class="hljs-keyword">isnt</span> <span class="hljs-string">'object'</span></pre></div></div>
@@ -452,11 +474,11 @@ the same name.</p>
</li>
<li id="section-18">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>This only happens if run via the Node API and <code>transpile</code> is set to
something other than an object.</p>
@@ -468,11 +490,11 @@ something other than an object.</p>
</li>
<li id="section-19">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Get the reference to Babel that we have been passed if this compiler
is run via the CLI or Node API.</p>
@@ -487,11 +509,11 @@ is run via the CLI or Node API.</p>
</li>
<li id="section-20">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>See <a href="https://github.com/babel/babel/issues/827#issuecomment-77573107">https://github.com/babel/babel/issues/827#issuecomment-77573107</a>:
Babel can take a v3 source map object as input in <code>inputSourceMap</code>
@@ -512,6 +534,8 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
sourceURL = <span class="hljs-string">"//# sourceURL=<span class="hljs-subst">#{options.filename ? <span class="hljs-string">'coffeescript'</span>}</span>"</span>
js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n<span class="hljs-subst">#{sourceMapDataURI}</span>\n<span class="hljs-subst">#{sourceURL}</span>"</span>
registerCompiled filename, code, map
<span class="hljs-keyword">if</span> options.sourceMap
{
js
@@ -524,11 +548,11 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
</li>
<li id="section-21">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p>
@@ -540,11 +564,11 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
</li>
<li id="section-22">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
@@ -561,11 +585,11 @@ or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
</li>
<li id="section-23">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>This file used to export these methods; leave stubs that throw warnings
instead. These methods have been moved into <code>index.coffee</code> to provide
@@ -581,11 +605,11 @@ environment.</p>
</li>
<li id="section-24">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Instantiate a Lexer for our use here.</p>
@@ -596,15 +620,15 @@ environment.</p>
</li>
<li id="section-25">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>The real Lexer produces a generic stream of tokens. This object provides a
thin wrapper around it, compatible with the Jison API. We can then pass it
directly as a “Jison lexer”.</p>
directly as a “Jison lexer.</p>
</div>
@@ -626,11 +650,11 @@ directly as a “Jison lexer”.</p>
</li>
<li id="section-26">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Make all the AST nodes visible to the parser.</p>
@@ -641,11 +665,11 @@ directly as a “Jison lexer”.</p>
</li>
<li id="section-27">
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>Override Jisons default error handling function.</p>
@@ -656,11 +680,11 @@ directly as a “Jison lexer”.</p>
</li>
<li id="section-28">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>Disregard Jisons message, it contains redundant line number information.
Disregard the token, we take its value directly from the lexer in case
@@ -684,11 +708,11 @@ the error is caused by a generated token which might refer to its origin.</p>
</li>
<li id="section-29">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>The second argument has a <code>loc</code> property, which should have the location
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
@@ -702,11 +726,11 @@ from the lexer.</p>
</li>
<li id="section-30">
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<a class="pilcrow" href="#section-31">&#182;</a>
</div>
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
Modified to handle sourceMap</p>
@@ -734,11 +758,11 @@ Modified to handle sourceMap</p>
</li>
<li id="section-31">
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<a class="pilcrow" href="#section-32">&#182;</a>
</div>
<p>Check for a sourceMap position</p>
@@ -781,11 +805,11 @@ Modified to handle sourceMap</p>
</li>
<li id="section-32">
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<a class="pilcrow" href="#section-33">&#182;</a>
</div>
<p>Skip files that we didnt compile, like Node system files that appear in
the stack trace, as they never have source maps.</p>
@@ -800,11 +824,11 @@ the stack trace, as they never have source maps.</p>
</li>
<li id="section-33">
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<a class="pilcrow" href="#section-34">&#182;</a>
</div>
<p>CoffeeScript compiled in a browser or via <code>CoffeeScript.compile</code> or <code>.run</code>
may get compiled with <code>options.filename</code> thats missing, which becomes
@@ -819,11 +843,11 @@ filename of the script file. See if we have a source map cached under
</li>
<li id="section-34">
<li id="section-35">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<a class="pilcrow" href="#section-35">&#182;</a>
</div>
<p>Work backwards from the most recent anonymous source maps, until we find
one that works. This isnt foolproof; there is a chance that multiple
@@ -840,11 +864,11 @@ and its not foolproof either.</p>
</li>
<li id="section-35">
<li id="section-36">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a>
<a class="pilcrow" href="#section-36">&#182;</a>
</div>
<p>If all else fails, recompile this source to get a source map. We need the
previous section (for <code>&lt;anonymous&gt;</code>) despite this option, because after it
@@ -867,11 +891,11 @@ time the source map we want is the last one.</p>
</li>
<li id="section-36">
<li id="section-37">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a>
<a class="pilcrow" href="#section-37">&#182;</a>
</div>
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
NodeJS / V8 have no support for transforming positions in stack traces using

View File

@@ -875,8 +875,11 @@ browsers) or use a proper build chain like Gulp or Webpack.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">try</span>
<span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
<span class="hljs-keyword">catch</span></pre></div></div>
<span class="hljs-built_in">require</span> <span class="hljs-string">'@babel/core'</span>
<span class="hljs-keyword">catch</span>
<span class="hljs-keyword">try</span>
<span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
<span class="hljs-keyword">catch</span></pre></div></div>
</li>
@@ -892,21 +895,21 @@ locally or globally.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.resolve(<span class="hljs-string">'.'</span>).indexOf(process.cwd()) <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
To use --transpile, you must have babel-core installed:
npm install --save-dev babel-core
And you must save options to configure Babel in one of the places it looks to find its options.
See http://coffeescript.org/#transpilation
'''</span>
<span class="hljs-keyword">else</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
To use --transpile with globally-installed CoffeeScript, you must have babel-core installed globally:
npm install --global babel-core
And you must save options to configure Babel in one of the places it looks to find its options, relative to the file being compiled or to the current folder.
See http://coffeescript.org/#transpilation
'''</span>
process.exit <span class="hljs-number">1</span>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.resolve(<span class="hljs-string">'.'</span>).indexOf(process.cwd()) <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
To use --transpile, you must have @babel/core installed:
npm install --save-dev @babel/core
And you must save options to configure Babel in one of the places it looks to find its options.
See https://coffeescript.org/#transpilation
'''</span>
<span class="hljs-keyword">else</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
To use --transpile with globally-installed CoffeeScript, you must have @babel/core installed globally:
npm install --global @babel/core
And you must save options to configure Babel in one of the places it looks to find its options, relative to the file being compiled or to the current folder.
See https://coffeescript.org/#transpilation
'''</span>
process.exit <span class="hljs-number">1</span>
opts.transpile = {} <span class="hljs-keyword">unless</span> <span class="hljs-keyword">typeof</span> opts.transpile <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span></pre></div></div>

File diff suppressed because it is too large Load Diff

View File

@@ -396,6 +396,62 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
</div>
<p>Build a dictionary of extra token properties organized by tokens locations
used as lookup hashes.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildTokenDataDictionary</span> = <span class="hljs-params">(parserState)</span> -&gt;</span>
tokenData = {}
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> parserState.parser.tokens <span class="hljs-keyword">when</span> token.comments
tokenHash = buildLocationHash token[<span class="hljs-number">2</span>]</pre></div></div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
</div>
<p>Multiple tokens might have the same location hash, such as the generated
<code>JS</code> tokens added at the start or end of the token stream to hold
comments that start or end a file.</p>
</div>
<div class="content"><div class='highlight'><pre> tokenData[tokenHash] ?= {}
<span class="hljs-keyword">if</span> token.comments <span class="hljs-comment"># `comments` is always an array.</span></pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
</div>
<p>For “overlapping” tokens, that is tokens with the same location data
and therefore matching <code>tokenHash</code>es, merge the comments from both/all
tokens together into one array, even if there are duplicate comments;
they will get sorted out later.</p>
</div>
<div class="content"><div class='highlight'><pre> (tokenData[tokenHash].comments ?= []).push token.comments...
tokenData</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
</div>
<p>This returns a function which takes an object as a parameter, and if that
object is an AST node, updates that objects locationData.
The object is returned either way.</p>
@@ -408,13 +464,13 @@ The object is returned either way.</p>
</li>
<li id="section-16">
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<a class="pilcrow" href="#section-19">&#182;</a>
</div>
<p>Add location data</p>
<p>Add location data.</p>
</div>
@@ -424,30 +480,22 @@ The object is returned either way.</p>
</li>
<li id="section-17">
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<a class="pilcrow" href="#section-20">&#182;</a>
</div>
<p>Add comments data</p>
<p>Add comments, building the dictionary of token data if it hasnt been
built yet.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> parserState.tokenComments
parserState.tokenComments = {}
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> parserState.parser.tokens <span class="hljs-keyword">when</span> token.comments
tokenHash = buildLocationHash token[<span class="hljs-number">2</span>]
<span class="hljs-keyword">unless</span> parserState.tokenComments[tokenHash]?
parserState.tokenComments[tokenHash] = token.comments
<span class="hljs-keyword">else</span>
parserState.tokenComments[tokenHash].push token.comments...
<div class="content"><div class='highlight'><pre> parserState.tokenData ?= buildTokenDataDictionary parserState
<span class="hljs-keyword">if</span> obj.locationData?
objHash = buildLocationHash obj.locationData
<span class="hljs-keyword">if</span> parserState.tokenComments[objHash]?
attachCommentsToNode parserState.tokenComments[objHash], obj
<span class="hljs-keyword">if</span> parserState.tokenData[objHash]?.comments?
attachCommentsToNode parserState.tokenData[objHash].comments, obj
obj
exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function"><span class="hljs-params">(comments, node)</span> -&gt;</span>
@@ -458,11 +506,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
</li>
<li id="section-18">
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<a class="pilcrow" href="#section-21">&#182;</a>
</div>
<p>Convert jison location data to a string.
<code>obj</code> can be a token, or a locationData.</p>
@@ -482,11 +530,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
</li>
<li id="section-19">
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<a class="pilcrow" href="#section-22">&#182;</a>
</div>
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.</p>
@@ -505,11 +553,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
</li>
<li id="section-20">
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<a class="pilcrow" href="#section-23">&#182;</a>
</div>
<p>Determine if a filename represents a CoffeeScript file.</p>
@@ -520,11 +568,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
</li>
<li id="section-21">
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<a class="pilcrow" href="#section-24">&#182;</a>
</div>
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
@@ -535,11 +583,11 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
</li>
<li id="section-22">
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<a class="pilcrow" href="#section-25">&#182;</a>
</div>
<p>Throws a SyntaxError from a given location.
The errors <code>toString</code> will return an error message following the “standard”
@@ -556,11 +604,11 @@ marker showing where the error is.</p>
</li>
<li id="section-23">
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<a class="pilcrow" href="#section-26">&#182;</a>
</div>
<p>Instead of showing the compilers stacktrace, show our custom error message
(this is useful when the error bubbles up in Node.js applications that
@@ -575,11 +623,11 @@ compile CoffeeScript for example).</p>
</li>
<li id="section-24">
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<a class="pilcrow" href="#section-27">&#182;</a>
</div>
<p>Update a compiler SyntaxError with source code information if it didnt have
it already.</p>
@@ -591,11 +639,11 @@ it already.</p>
</li>
<li id="section-25">
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<a class="pilcrow" href="#section-28">&#182;</a>
</div>
<p>Avoid screwing up the <code>stack</code> property of other errors (i.e. possible bugs).</p>
@@ -621,11 +669,11 @@ it already.</p>
</li>
<li id="section-26">
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<a class="pilcrow" href="#section-29">&#182;</a>
</div>
<p>Show only the first line on multi-line errors.</p>
@@ -637,11 +685,11 @@ it already.</p>
</li>
<li id="section-27">
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<a class="pilcrow" href="#section-30">&#182;</a>
</div>
<p>Check to see if were running on a color-enabled TTY.</p>

View File

@@ -128,8 +128,11 @@ helpers = CoffeeScript.helpers
CoffeeScript.transpile = <span class="hljs-function"><span class="hljs-params">(js, options)</span> -&gt;</span>
<span class="hljs-keyword">try</span>
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
<span class="hljs-keyword">catch</span></pre></div></div>
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">'@babel/core'</span>
<span class="hljs-keyword">catch</span>
<span class="hljs-keyword">try</span>
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
<span class="hljs-keyword">catch</span></pre></div></div>
</li>
@@ -145,7 +148,7 @@ earlier if they dont have Babel installed.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">'To use the transpile option, you must have the \'babel-core\' module installed'</span>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">'To use the transpile option, you must have the \'@babel/core\' module installed'</span>
babel.transform js, options</pre></div></div>
</li>
@@ -400,8 +403,7 @@ CoffeeScript.register = <span class="hljs-function">-&gt;</span> <span class="hl
Use CoffeeScript.register() or require the coffeescript/register module to require <span class="hljs-subst">#{ext}</span> files.
"""</span>
CoffeeScript._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, options = {})</span> -&gt;</span>
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span></pre></div></div>
CoffeeScript._compileRawFileContent = <span class="hljs-function"><span class="hljs-params">(raw, filename, options = {})</span> -&gt;</span></pre></div></div>
</li>
@@ -447,6 +449,11 @@ information to error so it can be pretty-printed later.</p>
answer
CoffeeScript._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, options = {})</span> -&gt;</span>
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span>
CoffeeScript._compileRawFileContent raw, filename, options
<span class="hljs-built_in">module</span>.exports = CoffeeScript</pre></div></div>
</li>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -376,7 +376,7 @@ undeclared variable <code>__</code>.</p>
vm.runInContext js, context, filename
<span class="hljs-function">
<span class="hljs-title">addMultilineHandler</span> = <span class="hljs-params">(repl)</span> -&gt;</span>
{rli, inputStream, outputStream} = repl</pre></div></div>
{inputStream, outputStream} = repl</pre></div></div>
</li>
@@ -412,15 +412,15 @@ undeclared variable <code>__</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> nodeLineListener = rli.listeners(<span class="hljs-string">'line'</span>)[<span class="hljs-number">0</span>]
rli.removeListener <span class="hljs-string">'line'</span>, nodeLineListener
rli.<span class="hljs-literal">on</span> <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(cmd)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre> nodeLineListener = repl.listeners(<span class="hljs-string">'line'</span>)[<span class="hljs-number">0</span>]
repl.removeListener <span class="hljs-string">'line'</span>, nodeLineListener
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(cmd)</span> -&gt;</span>
<span class="hljs-keyword">if</span> multiline.enabled
multiline.buffer += <span class="hljs-string">"<span class="hljs-subst">#{cmd}</span>\n"</span>
rli.setPrompt multiline.prompt
rli.prompt <span class="hljs-literal">true</span>
repl.setPrompt multiline.prompt
repl.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">else</span>
rli.setPrompt origPrompt
repl.setPrompt origPrompt
nodeLineListener cmd
<span class="hljs-keyword">return</span></pre></div></div>
@@ -456,8 +456,8 @@ undeclared variable <code>__</code>.</p>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> multiline.buffer.match <span class="hljs-regexp">/\n/</span>
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
rli.setPrompt origPrompt
rli.prompt <span class="hljs-literal">true</span>
repl.setPrompt origPrompt
repl.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">return</span></pre></div></div>
</li>
@@ -473,7 +473,7 @@ undeclared variable <code>__</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> rli.line? <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> rli.line.match <span class="hljs-regexp">/^\s*$/</span></pre></div></div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> repl.line? <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> repl.line.match <span class="hljs-regexp">/^\s*$/</span></pre></div></div>
</li>
@@ -489,10 +489,10 @@ undeclared variable <code>__</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
rli.line = <span class="hljs-string">''</span>
rli.cursor = <span class="hljs-number">0</span>
rli.output.cursorTo <span class="hljs-number">0</span>
rli.output.clearLine <span class="hljs-number">1</span></pre></div></div>
repl.line = <span class="hljs-string">''</span>
repl.cursor = <span class="hljs-number">0</span>
repl.output.cursorTo <span class="hljs-number">0</span>
repl.output.clearLine <span class="hljs-number">1</span></pre></div></div>
</li>
@@ -508,12 +508,12 @@ undeclared variable <code>__</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> multiline.buffer = multiline.buffer.replace <span class="hljs-regexp">/\n/g</span>, <span class="hljs-string">'\uFF00'</span>
rli.emit <span class="hljs-string">'line'</span>, multiline.buffer
repl.emit <span class="hljs-string">'line'</span>, multiline.buffer
multiline.buffer = <span class="hljs-string">''</span>
<span class="hljs-keyword">else</span>
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
rli.setPrompt multiline.initialPrompt
rli.prompt <span class="hljs-literal">true</span>
repl.setPrompt multiline.initialPrompt
repl.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">return</span></pre></div></div>
</li>
@@ -580,7 +580,7 @@ undeclared variable <code>__</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history = buffer.toString().split(<span class="hljs-string">'\n'</span>).reverse()</pre></div></div>
<div class="content"><div class='highlight'><pre> repl.history = buffer.toString().split(<span class="hljs-string">'\n'</span>).reverse()</pre></div></div>
</li>
@@ -595,7 +595,7 @@ undeclared variable <code>__</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history.pop() <span class="hljs-keyword">if</span> stat.size &gt; maxSize</pre></div></div>
<div class="content"><div class='highlight'><pre> repl.history.pop() <span class="hljs-keyword">if</span> stat.size &gt; maxSize</pre></div></div>
</li>
@@ -610,13 +610,13 @@ undeclared variable <code>__</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> repl.rli.history.shift() <span class="hljs-keyword">if</span> repl.rli.history[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
repl.rli.historyIndex = <span class="hljs-number">-1</span>
lastLine = repl.rli.history[<span class="hljs-number">0</span>]
<div class="content"><div class='highlight'><pre> repl.history.shift() <span class="hljs-keyword">if</span> repl.history[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
repl.historyIndex = <span class="hljs-number">-1</span>
lastLine = repl.history[<span class="hljs-number">0</span>]
fd = fs.openSync filename, <span class="hljs-string">'a'</span>
repl.rli.addListener <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
repl.addListener <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
<span class="hljs-keyword">if</span> code <span class="hljs-keyword">and</span> code.length <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.history'</span> <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.exit'</span> <span class="hljs-keyword">and</span> lastLine <span class="hljs-keyword">isnt</span> code</pre></div></div>
</li>
@@ -667,7 +667,7 @@ undeclared variable <code>__</code>.</p>
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'history'</span>)] =
help: <span class="hljs-string">'Show command history'</span>
action: <span class="hljs-function">-&gt;</span>
repl.outputStream.write <span class="hljs-string">"<span class="hljs-subst">#{repl.rli.history[..].reverse().join <span class="hljs-string">'\n'</span>}</span>\n"</span>
repl.outputStream.write <span class="hljs-string">"<span class="hljs-subst">#{repl.history[..].reverse().join <span class="hljs-string">'\n'</span>}</span>\n"</span>
repl.displayPrompt()
<span class="hljs-function">
<span class="hljs-title">getCommandId</span> = <span class="hljs-params">(repl, commandName)</span> -&gt;</span></pre></div></div>
@@ -699,19 +699,22 @@ undeclared variable <code>__</code>.</p>
CoffeeScript.register()
process.argv = [<span class="hljs-string">'coffee'</span>].concat process.argv[<span class="hljs-number">2.</span>.]
<span class="hljs-keyword">if</span> opts.transpile
transpile = {}
<span class="hljs-keyword">try</span>
transpile = {}
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">'babel-core'</span>).transform
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@babel/core'</span>).transform
<span class="hljs-keyword">catch</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
To use --transpile with an interactive REPL, babel-core must be installed either in the current folder or globally:
npm install --save-dev babel-core
or
npm install --global babel-core
And you must save options to configure Babel in one of the places it looks to find its options.
See http://coffeescript.org/#transpilation
'''</span>
process.exit <span class="hljs-number">1</span>
<span class="hljs-keyword">try</span>
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">'babel-core'</span>).transform
<span class="hljs-keyword">catch</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
To use --transpile with an interactive REPL, @babel/core must be installed either in the current folder or globally:
npm install --save-dev @babel/core
or
npm install --global @babel/core
And you must save options to configure Babel in one of the places it looks to find its options.
See https://coffeescript.org/#transpilation
'''</span>
process.exit <span class="hljs-number">1</span>
transpile.options =
filename: path.resolve process.cwd(), <span class="hljs-string">'&lt;repl&gt;'</span></pre></div></div>
@@ -739,7 +742,7 @@ the REPL, the only applicable option is <code>transpile</code>.</p>
opts = merge replDefaults, opts
repl = nodeREPL.start opts
runInContext opts.prelude, repl.context, <span class="hljs-string">'prelude'</span> <span class="hljs-keyword">if</span> opts.prelude
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-&gt;</span> repl.outputStream.write <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.rli.closed
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-&gt;</span> repl.outputStream.write <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.closed
addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile</pre></div></div>

View File

@@ -676,7 +676,21 @@ class declaration or if-conditionals).</p>
endImplicitObject()
<span class="hljs-keyword">else</span>
stack.pop()
start = stack.pop()</pre></div></div>
start = stack.pop()
<span class="hljs-function">
<span class="hljs-title">inControlFlow</span> = =&gt;</span>
seenFor = @findTagsBackwards(i, [<span class="hljs-string">'FOR'</span>]) <span class="hljs-keyword">and</span> @findTagsBackwards(i, [<span class="hljs-string">'FORIN'</span>, <span class="hljs-string">'FOROF'</span>, <span class="hljs-string">'FORFROM'</span>])
controlFlow = seenFor <span class="hljs-keyword">or</span> @findTagsBackwards i, [<span class="hljs-string">'WHILE'</span>, <span class="hljs-string">'UNTIL'</span>, <span class="hljs-string">'LOOP'</span>, <span class="hljs-string">'LEADING_WHEN'</span>]
<span class="hljs-keyword">return</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">unless</span> controlFlow
isFunc = <span class="hljs-literal">no</span>
tagCurrentLine = token[<span class="hljs-number">2</span>].first_line
@detectEnd i,
<span class="hljs-function"><span class="hljs-params">(token, i)</span> -&gt;</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> LINEBREAKS
(token, i) -&gt;
[prevTag, ,{first_line}] = tokens[i - <span class="hljs-number">1</span>] || []
isFunc = tagCurrentLine <span class="hljs-keyword">is</span> first_line <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'-&gt;'</span>, <span class="hljs-string">'=&gt;'</span>]
returnOnNegativeLevel: <span class="hljs-literal">yes</span>
isFunc</pre></div></div>
</li>
@@ -698,7 +712,8 @@ Added support for spread dots on the left side: f …a</p>
(nextTag <span class="hljs-keyword">in</span> IMPLICIT_CALL <span class="hljs-keyword">or</span>
(nextTag <span class="hljs-keyword">is</span> <span class="hljs-string">'...'</span> <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">2</span>) <span class="hljs-keyword">in</span> IMPLICIT_CALL <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> @findTagsBackwards(i, [<span class="hljs-string">'INDEX_START'</span>, <span class="hljs-string">'['</span>])) <span class="hljs-keyword">or</span>
nextTag <span class="hljs-keyword">in</span> IMPLICIT_UNSPACED_CALL <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> nextToken.spaced <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> nextToken.newLine)
<span class="hljs-keyword">not</span> nextToken.spaced <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> nextToken.newLine) <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> inControlFlow()
tag = token[<span class="hljs-number">0</span>] = <span class="hljs-string">'FUNC_EXIST'</span> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'?'</span>
startImplicitCall i + <span class="hljs-number">1</span>
<span class="hljs-keyword">return</span> forward(<span class="hljs-number">2</span>)</pre></div></div>
@@ -835,7 +850,9 @@ like e.g.:</p>
stackItem[<span class="hljs-number">2</span>].sameLine = <span class="hljs-literal">no</span> <span class="hljs-keyword">if</span> isImplicitObject stackItem
newLine = prevTag <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">or</span> prevToken.newLine
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> IMPLICIT_END <span class="hljs-keyword">or</span> tag <span class="hljs-keyword">in</span> CALL_CLOSERS <span class="hljs-keyword">and</span> newLine
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> IMPLICIT_END <span class="hljs-keyword">or</span>
(tag <span class="hljs-keyword">in</span> CALL_CLOSERS <span class="hljs-keyword">and</span> newLine) <span class="hljs-keyword">or</span>
(tag <span class="hljs-keyword">in</span> [<span class="hljs-string">'..'</span>, <span class="hljs-string">'...'</span>] <span class="hljs-keyword">and</span> @findTagsBackwards(i, [<span class="hljs-string">"INDEX_START"</span>]))
<span class="hljs-keyword">while</span> inImplicit()
[stackTag, stackIdx, {sameLine, startsLine}] = stackTop()</pre></div></div>
@@ -852,7 +869,8 @@ like e.g.:</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> inImplicitCall() <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">isnt</span> <span class="hljs-string">','</span>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> inImplicitCall() <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">isnt</span> <span class="hljs-string">','</span> <span class="hljs-keyword">or</span>
(prevTag <span class="hljs-keyword">is</span> <span class="hljs-string">','</span> <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> nextTag?)
endImplicitCall()</pre></div></div>
</li>
@@ -892,6 +910,8 @@ the continuation of an object.</p>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> inImplicitObject() <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span> <span class="hljs-keyword">and</span> prevTag <span class="hljs-keyword">isnt</span> <span class="hljs-string">','</span> <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (startsLine <span class="hljs-keyword">and</span> @looksObjectish(i + <span class="hljs-number">1</span>))
endImplicitObject()
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> inImplicitControl() <span class="hljs-keyword">and</span> tokens[stackTop()[<span class="hljs-number">1</span>]][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'CLASS'</span> <span class="hljs-keyword">and</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span>
stack.pop()
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">break</span></pre></div></div>
@@ -1245,20 +1265,101 @@ blocks are added.</p>
<div class="content"><div class='highlight'><pre> normalizeLines: <span class="hljs-function">-&gt;</span>
starter = indent = outdent = <span class="hljs-literal">null</span>
leading_switch_when = <span class="hljs-literal">null</span>
leading_if_then = <span class="hljs-literal">null</span></pre></div></div>
</li>
<li id="section-50">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-50">&#182;</a>
</div>
<p>Count <code>THEN</code> tags</p>
</div>
<div class="content"><div class='highlight'><pre> ifThens = []
<span class="hljs-function">
<span class="hljs-title">condition</span> = <span class="hljs-params">(token, i)</span> -&gt;</span>
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">isnt</span> <span class="hljs-string">';'</span> <span class="hljs-keyword">and</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> SINGLE_CLOSERS <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span> <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">in</span> EXPRESSION_CLOSE) <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span> starter <span class="hljs-keyword">isnt</span> <span class="hljs-string">'THEN'</span>) <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span>
(starter <span class="hljs-keyword">isnt</span> <span class="hljs-string">'THEN'</span> <span class="hljs-keyword">or</span> (leading_if_then <span class="hljs-keyword">or</span> leading_switch_when))) <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'CATCH'</span>, <span class="hljs-string">'FINALLY'</span>] <span class="hljs-keyword">and</span> starter <span class="hljs-keyword">in</span> [<span class="hljs-string">'-&gt;'</span>, <span class="hljs-string">'=&gt;'</span>]) <span class="hljs-keyword">or</span>
token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> CALL_CLOSERS <span class="hljs-keyword">and</span>
(@tokens[i - <span class="hljs-number">1</span>].newLine <span class="hljs-keyword">or</span> @tokens[i - <span class="hljs-number">1</span>][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span>)
<span class="hljs-function">
<span class="hljs-title">action</span> = <span class="hljs-params">(token, i)</span> -&gt;</span>
ifThens.pop() <span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span> starter <span class="hljs-keyword">is</span> <span class="hljs-string">'THEN'</span>
@tokens.splice (<span class="hljs-keyword">if</span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">','</span> <span class="hljs-keyword">then</span> i - <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> i), <span class="hljs-number">0</span>, outdent
<span class="hljs-function">
<span class="hljs-title">closeElseTag</span> = <span class="hljs-params">(tokens, i)</span> =&gt;</span>
tlen = ifThens.length
<span class="hljs-keyword">return</span> i <span class="hljs-keyword">unless</span> tlen &gt; <span class="hljs-number">0</span>
lastThen = ifThens.pop()
[, outdentElse] = @indentation tokens[lastThen]</pre></div></div>
</li>
<li id="section-51">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-51">&#182;</a>
</div>
<p>Insert <code>OUTDENT</code> to close inner <code>IF</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> outdentElse[<span class="hljs-number">1</span>] = tlen*<span class="hljs-number">2</span>
tokens.splice(i, <span class="hljs-number">0</span>, outdentElse)</pre></div></div>
</li>
<li id="section-52">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-52">&#182;</a>
</div>
<p>Insert <code>OUTDENT</code> to close outer <code>IF</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> outdentElse[<span class="hljs-number">1</span>] = <span class="hljs-number">2</span>
tokens.splice(i + <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, outdentElse)</pre></div></div>
</li>
<li id="section-53">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-53">&#182;</a>
</div>
<p>Remove outdents from the end.</p>
</div>
<div class="content"><div class='highlight'><pre> @detectEnd i + <span class="hljs-number">2</span>,
<span class="hljs-function"><span class="hljs-params">(token, i)</span> -&gt;</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'OUTDENT'</span>, <span class="hljs-string">'TERMINATOR'</span>]
(token, i) -&gt;
<span class="hljs-keyword">if</span> @tag(i) <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span> <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'OUTDENT'</span>
tokens.splice i, <span class="hljs-number">2</span>
i + <span class="hljs-number">2</span>
@scanTokens (token, i, tokens) -&gt;
[tag] = token
conditionTag = tag <span class="hljs-keyword">in</span> [<span class="hljs-string">'-&gt;'</span>, <span class="hljs-string">'=&gt;'</span>] <span class="hljs-keyword">and</span>
@findTagsBackwards(i, [<span class="hljs-string">'IF'</span>, <span class="hljs-string">'WHILE'</span>, <span class="hljs-string">'FOR'</span>, <span class="hljs-string">'UNTIL'</span>, <span class="hljs-string">'SWITCH'</span>, <span class="hljs-string">'WHEN'</span>, <span class="hljs-string">'LEADING_WHEN'</span>, <span class="hljs-string">'['</span>, <span class="hljs-string">'INDEX_START'</span>]) <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (@findTagsBackwards i, [<span class="hljs-string">'THEN'</span>, <span class="hljs-string">'..'</span>, <span class="hljs-string">'...'</span>])
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span>
<span class="hljs-keyword">if</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">isnt</span> <span class="hljs-string">'OUTDENT'</span>
tokens.splice i, <span class="hljs-number">1</span>, @indentation()...
@@ -1275,10 +1376,31 @@ blocks are added.</p>
tokens.splice i + <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, indent, outdent
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> SINGLE_LINERS <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">isnt</span> <span class="hljs-string">'INDENT'</span> <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> (tag <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'IF'</span>)
<span class="hljs-keyword">not</span> (tag <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'IF'</span>) <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> conditionTag
starter = tag
[indent, outdent] = @indentation tokens[i]
indent.fromThen = <span class="hljs-literal">true</span> <span class="hljs-keyword">if</span> starter <span class="hljs-keyword">is</span> <span class="hljs-string">'THEN'</span>
<span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'THEN'</span>
leading_switch_when = @findTagsBackwards(i, [<span class="hljs-string">'LEADING_WHEN'</span>]) <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'IF'</span>
leading_if_then = @findTagsBackwards(i, [<span class="hljs-string">'IF'</span>]) <span class="hljs-keyword">and</span> @tag(i + <span class="hljs-number">1</span>) <span class="hljs-keyword">is</span> <span class="hljs-string">'IF'</span>
ifThens.push i <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'THEN'</span> <span class="hljs-keyword">and</span> @findTagsBackwards(i, [<span class="hljs-string">'IF'</span>])</pre></div></div>
</li>
<li id="section-54">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-54">&#182;</a>
</div>
<p><code>ELSE</code> tag is not closed.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'ELSE'</span> <span class="hljs-keyword">and</span> @tag(i - <span class="hljs-number">1</span>) <span class="hljs-keyword">isnt</span> <span class="hljs-string">'OUTDENT'</span>
i = closeElseTag tokens, i
tokens.splice i + <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, indent
@detectEnd i + <span class="hljs-number">2</span>, condition, action
tokens.splice i, <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">is</span> <span class="hljs-string">'THEN'</span>
@@ -1288,11 +1410,11 @@ blocks are added.</p>
</li>
<li id="section-50">
<li id="section-55">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-50">&#182;</a>
<a class="pilcrow" href="#section-55">&#182;</a>
</div>
<p>Tag postfix conditionals as such, so that we can parse them with a
different precedence.</p>
@@ -1320,11 +1442,11 @@ different precedence.</p>
</li>
<li id="section-51">
<li id="section-56">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-51">&#182;</a>
<a class="pilcrow" href="#section-56">&#182;</a>
</div>
<p>Generate the indentation tokens, based on another token on the same line.</p>
@@ -1345,11 +1467,11 @@ different precedence.</p>
</li>
<li id="section-52">
<li id="section-57">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-52">&#182;</a>
<a class="pilcrow" href="#section-57">&#182;</a>
</div>
<p>Look up a tag by token index.</p>
@@ -1360,11 +1482,11 @@ different precedence.</p>
</li>
<li id="section-53">
<li id="section-58">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-53">&#182;</a>
<a class="pilcrow" href="#section-58">&#182;</a>
</div>
<h2 id="constants">Constants</h2>
@@ -1373,11 +1495,11 @@ different precedence.</p>
</li>
<li id="section-54">
<li id="section-59">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-54">&#182;</a>
<a class="pilcrow" href="#section-59">&#182;</a>
</div>
</div>
@@ -1385,11 +1507,11 @@ different precedence.</p>
</li>
<li id="section-55">
<li id="section-60">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-55">&#182;</a>
<a class="pilcrow" href="#section-60">&#182;</a>
</div>
<p>List of the token pairs that must be balanced.</p>
@@ -1410,11 +1532,11 @@ different precedence.</p>
</li>
<li id="section-56">
<li id="section-61">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-56">&#182;</a>
<a class="pilcrow" href="#section-61">&#182;</a>
</div>
<p>The inverse mappings of <code>BALANCED_PAIRS</code> were trying to fix up, so we can
look things up from either end.</p>
@@ -1426,11 +1548,11 @@ look things up from either end.</p>
</li>
<li id="section-57">
<li id="section-62">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-57">&#182;</a>
<a class="pilcrow" href="#section-62">&#182;</a>
</div>
<p>The tokens that signal the start/end of a balanced pair.</p>
@@ -1446,11 +1568,11 @@ EXPRESSION_END = []
</li>
<li id="section-58">
<li id="section-63">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-58">&#182;</a>
<a class="pilcrow" href="#section-63">&#182;</a>
</div>
<p>Tokens that indicate the close of a clause of an expression.</p>
@@ -1461,11 +1583,11 @@ EXPRESSION_END = []
</li>
<li id="section-59">
<li id="section-64">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-59">&#182;</a>
<a class="pilcrow" href="#section-64">&#182;</a>
</div>
<p>Tokens that, if followed by an <code>IMPLICIT_CALL</code>, indicate a function invocation.</p>
@@ -1476,11 +1598,11 @@ EXPRESSION_END = []
</li>
<li id="section-60">
<li id="section-65">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-60">&#182;</a>
<a class="pilcrow" href="#section-65">&#182;</a>
</div>
<p>If preceded by an <code>IMPLICIT_FUNC</code>, indicates a function invocation.</p>
@@ -1500,11 +1622,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="hljs-string">'+'</span>, <span class="hlj
</li>
<li id="section-61">
<li id="section-66">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-61">&#182;</a>
<a class="pilcrow" href="#section-66">&#182;</a>
</div>
<p>Tokens that always mark the end of an implicit call for single-liners.</p>
@@ -1516,11 +1638,11 @@ IMPLICIT_UNSPACED_CALL = [<span class="hljs-string">'+'</span>, <span class="hlj
</li>
<li id="section-62">
<li id="section-67">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-62">&#182;</a>
<a class="pilcrow" href="#section-67">&#182;</a>
</div>
<p>Single-line flavors of block expressions that have unclosed endings.
The grammar cant disambiguate them, so we insert the implicit indentation.</p>
@@ -1533,11 +1655,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
</li>
<li id="section-63">
<li id="section-68">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-63">&#182;</a>
<a class="pilcrow" href="#section-68">&#182;</a>
</div>
<p>Tokens that end a line.</p>
@@ -1548,11 +1670,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
</li>
<li id="section-64">
<li id="section-69">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-64">&#182;</a>
<a class="pilcrow" href="#section-69">&#182;</a>
</div>
<p>Tokens that close open calls when they follow a newline.</p>
@@ -1563,11 +1685,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
</li>
<li id="section-65">
<li id="section-70">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-65">&#182;</a>
<a class="pilcrow" href="#section-70">&#182;</a>
</div>
<p>Tokens that prevent a subsequent indent from ending implicit calls/objects</p>
@@ -1578,11 +1700,11 @@ SINGLE_CLOSERS = [<span class="hljs-string">'TERMINATOR'</span>, <span class="
</li>
<li id="section-66">
<li id="section-71">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-66">&#182;</a>
<a class="pilcrow" href="#section-71">&#182;</a>
</div>
<p>Tokens that are swallowed up by the parser, never leading to code generation.
You can spot these in <code>grammar.coffee</code> because the <code>o</code> function second

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
# Your browser must support dynamic import to run this example.
do ->
{ run } = await import('./browser-compiler-modern/coffeescript.js')
run '''
if 5 < new Date().getHours() < 9
alert 'Time to make the coffee!'
else
alert 'Time to get some work done.'
'''

View File

@@ -6,4 +6,4 @@ Object.defineProperty screen, 'height',
get: ->
this.width / this.ratio
set: (val) ->
this.width = val / this.ratio
this.width = val * this.ratio

View File

@@ -1,4 +1,4 @@
import 'local-file.coffee'
import './local-file.coffee'
import 'coffeescript'
import _ from 'underscore'

View File

@@ -1,680 +1 @@
## Changelog
```
releaseHeader('2017-11-26', '2.0.3', '2.0.2')
```
* Bugfix for `export default` followed by an implicit object that contains an explicit object, for example `exportedMember: { obj... }`.
* Bugfix for `key, val of obj` after an implicit object member, e.g. `foo: bar for key, val of obj`.
* Bugfix for combining array and object destructuring, e.g. `[ ..., {a, b} ] = arr`.
* Bugfix for an edge case where it was possible to create a bound (`=>`) generator function, which should throw an error as such functions arent allowed in ES2015.
* Bugfix for source maps: `.map` files should always have the same base filename as the requested output filename. So `coffee --map --output foo.js test.coffee` should generate `foo.js` and `foo.js.map`.
* Bugfix for incorrect source maps generated when using `--transpile` with `--map` for multiple input files.
* Bugfix for comments at the beginning or end of input into the REPL (`coffee --interactive`).
```
releaseHeader('2017-10-26', '2.0.2', '2.0.1')
```
* `--transpile` now also applies to `require`d or `import`ed CoffeeScript files.
* `--transpile` can be used with the REPL: `coffee --interactive --transpile`.
* Improvements to comments output that should now cover all of the [Flow comment-based syntax](https://flow.org/en/docs/types/comments/). Inline `###` comments near [variable](https://flow.org/en/docs/types/variables/) initial assignments are now output in the variable declaration statement, and `###` comments near a [class and method names](https://flow.org/en/docs/types/generics/) are now output where Flow expects them.
* Importing CoffeeScript keywords is now allowed, so long as theyre aliased: `import { and as andFn } from 'lib'`. (You could also do `import lib from 'lib'` and then reference `lib.and`.)
* Calls to functions named `get` and `set` no longer throw an error when given a bracketless object literal as an argument: `obj.set propertyName: propertyValue`.
* In the constructor of a derived class (a class that `extends` another class), you cannot call `super` with an argument that references `this`: `class Child extends Parent then constructor: (@arg) -> super(@arg)`. This isnt allowed in JavaScript, and now the CoffeeScript compiler will throw an error. Instead, assign to `this` after calling `super`: `(arg) -> super(arg); @arg = arg`.
* Bugfix for incorrect output when backticked statements and hoisted expressions were both in the same class body. This allows a backticked line like `` `field = 3` ``, for people using the experimental [class fields](https://github.com/tc39/proposal-class-fields) syntax, in the same class along with traditional class body expressions like `prop: 3` that CoffeeScript outputs as part of the class prototype.
* Bugfix for comments not output before a complex `?` operation, e.g. `@a ? b`.
* All tests now pass in Windows.
```
releaseHeader('2017-09-26', '2.0.1', '2.0.0')
```
* `babel-core` is no longer listed in `package.json`, even as an `optionalDependency`, to avoid it being automatically installed for most users. If you wish to use `--transpile`, simply install `babel-core` manually. See [Transpilation](#transpilation).
* `--transpile` now relies on Babel to find its options, i.e. the `.babelrc` file in the path of the file(s) being compiled. (Previously the CoffeeScript compiler was duplicating this logic, so nothing has changed from a users perspective.) This provides automatic support for additional ways to pass options to Babel in future versions, such as the `.babelrc.js` file coming in Babel 7.
* Backticked expressions in a class body, outside any class methods, are now output in the JavaScript class body itself. This allows for passing through experimental JavaScript syntax like the [class fields proposal](https://github.com/tc39/proposal-class-fields), assuming your [transpiler supports it](https://babeljs.io/docs/plugins/transform-class-properties/).
```
releaseHeader('2017-09-18', '2.0.0', '2.0.0-beta5')
```
* Added `--transpile` flag or `transpile` Node API option to tell the CoffeeScript compiler to pipe its output through Babel before saving or returning it; see [Transpilation](#transpilation). Also changed the `-t` short flag to refer to `--transpile` instead of `--tokens`.
* Always populate source maps `sourcesContent` property.
* Bugfixes for destructuring and for comments in JSX.
* _Note that these are only the changes between 2.0.0-beta5 and 2.0.0. See below for all changes since 1.x._
```
releaseHeader('2017-09-02', '2.0.0-beta5', '2.0.0-beta4')
```
* Node 6 is now supported, and we will try to maintain that as the minimum required version for CoffeeScript 2 via the `coffee` command or Node API. Older versions of Node, or non-evergreen browsers, can compile via the [browser compiler](./browser-compiler/coffeescript.js).
* The command line `--output` flag now allows you to specify an output filename, not just an output folder.
* The command line `--require` flag now properly handles filenames or module names that are invalid identifiers (like an NPM module with a hyphen in the name).
* `Object.assign`, output when object destructuring is used, is polyfilled using the same polyfill that Babel outputs. This means that polyfills shouldnt be required unless support for Internet Explorer 8 or below is desired (or your own code uses a feature that requires a polyfill). See [ES2015+ Output](#es2015plus-output).
* A string or JSX interpolation that contains only a comment (`"a#{### comment ###}b"` or `<div>{### comment ###}</div>`) is now output (`` `a${/* comment */}b` ``)
* Interpolated strings (ES2015 template literals) that contain quotation marks no longer have the quotation marks escaped: `` `say "${message}"` ``
* It is now possible to chain after a function literal (for example, to define a function and then call `.call` on it).
* The results of the async tests are included in the output when you run `cake test`.
* Bugfixes for object destructuring; expansions in function parameters; generated reference variables in function parameters; chained functions after `do`; splats after existential operator soaks in arrays (`[a?.b...]`); trailing `if` with splat in arrays or function parameters (`[a if b...]`); attempting to `throw` an `if`, `for`, `switch`, `while` or other invalid construct.
* Bugfixes for syntactical edge cases: semicolons after `=` and other “mid-expression” tokens; spaces after `::`; and scripts that begin with `:` or `*`.
* Bugfixes for source maps generated via the Node API; and stack trace line numbers when compiling CoffeeScript via the Node API from within a `.coffee` file.
```
releaseHeader('2017-08-03', '2.0.0-beta4', '2.0.0-beta3')
```
* This release includes [all the changes from 1.12.6 to 1.12.7](#1.12.7).
* [Line comments](#comments) (starting with `#`) are now output in the generated JavaScript.
* [Block comments](#comments) (delimited by `###`) are now allowed anywhere, including inline where they previously werent possible. This provides support for [static type annotations](#type-annotations) using Flows comments-based syntax.
* Spread syntax (`...` for objects) is now supported in JSX tags: `<div {props...} />`.
* Argument parsing for scripts run via `coffee` is improved. See [breaking changes](#breaking-changes-argument-parsing-and-shebang-lines).
* CLI: Propagate `SIGINT` and `SIGTERM` signals when node is forked.
* `await` in the REPL is now allowed without requiring a wrapper function.
* `do super` is now allowed, and other accesses of `super` like `super.x.y` or `super['x'].y` now work.
* Splat/spread syntax triple dots are now allowed on either the left or the right (so `props...` or `...props` are both valid).
* Tagged template literals are recognized as callable functions.
* Bugfixes for object spread syntax in nested properties.
* Bugfixes for destructured function parameter default values.
```
releaseHeader('2017-07-16', '1.12.7', '1.12.6')
```
* Fix regressions in 1.12.6 related to chained function calls and indented `return` and `throw` arguments.
* The REPL no longer warns about assigning to `_`.
```
releaseHeader('2017-06-30', '2.0.0-beta3', '2.0.0-beta2')
```
* [JSX](#jsx) is now supported.
* [Object rest/spread properties](#object-spread) are now supported.
* Bound (fat arrow) methods are once again supported in classes; though an error will be thrown if you attempt to call the method before it is bound. See [breaking changes for classes](#breaking-changes-classes).
* The REPL no longer warns about assigning to `_`.
* Bugfixes for destructured nested default values and issues related to chaining or continuing expressions across multiple lines.
```
releaseHeader('2017-05-16', '2.0.0-beta2', '2.0.0-beta1')
```
* This release includes [all the changes from 1.12.5 to 1.12.6](#1.12.6).
* Bound (fat arrow) methods in classes must be declared in the class constructor, after `super()` if the class is extending a parent class. See [breaking changes for classes](#breaking-changes-classes).
* All unnecessary utility helper functions have been removed, including the polyfills for `indexOf` and `bind`.
* The `extends` keyword now only works in the context of classes; it cannot be used to extend a function prototype. See [breaking changes for `extends`](#breaking-changes-super-extends).
* Literate CoffeeScript is now parsed entirely based on indentation, similar to the 1.x implementation; there is no longer a dependency for parsing Markdown. See [breaking changes for Literate CoffeeScript parsing](#breaking-changes-literate-coffeescript).
* JavaScript reserved words used as properties are no longer wrapped in quotes.
* `require('coffeescript')` should now work in non-Node environments such as the builds created by Webpack or Browserify. This provides a more convenient way to include the browser compiler in builds intending to run in a browser environment.
* Unreachable `break` statements are no longer added after `switch` cases that `throw` exceptions.
* The browser compiler is now compiled using Babili and transpiled down to Babels `env` preset (should be safe for use in all browsers in current use, not just evergreen versions).
* Calling functions `@get` or `@set` no longer throws an error about required parentheses. (Bare `get` or `set`, not attached to an object or `@`, [still intentionally throws a compiler error](#unsupported-get-set).)
* If `$XDG_CACHE_HOME` is set, the REPL `.coffee_history` file is saved there.
```
releaseHeader('2017-05-15', '1.12.6', '1.12.5')
```
* The `return` and `export` keywords can now accept implicit objects (defined by indentation, without needing braces).
* Support Unicode code point escapes (e.g. `\u{1F4A9}`).
* The `coffee` command now first looks to see if CoffeeScript is installed under `node_modules` in the current folder, and executes the `coffee` binary there if so; or otherwise it runs the globally installed one. This allows you to have one version of CoffeeScript installed globally and a different one installed locally for a particular project. (Likewise for the `cake` command.)
* Bugfixes for chained function calls not closing implicit objects or ternaries.
* Bugfixes for incorrect code generated by the `?` operator within a termary `if` statement.
* Fixed some tests, and failing tests now result in a nonzero exit code.
```
releaseHeader('2017-04-14', '2.0.0-beta1', '2.0.0-alpha1')
```
* Initial beta release of CoffeeScript 2. No further breaking changes are anticipated.
* Destructured objects and arrays now output using ES2015+ syntax whenever possible.
* Literate CoffeeScript now has much better support for parsing Markdown, thanks to using [Markdown-It](https://github.com/markdown-it/markdown-it) to detect Markdown sections rather than just looking at indentation.
* Calling a function named `get` or `set` now requires parentheses, to disambiguate from the `get` or `set` keywords (which are [disallowed](#unsupported-get-set)).
* The compiler now requires Node 7.6+, the first version of Node to support asynchronous functions without requiring a flag.
```
releaseHeader('2017-04-10', '1.12.5', '1.12.4')
```
* Better handling of `default`, `from`, `as` and `*` within `import` and `export` statements. You can now import or export a member named `default` and the compiler wont interpret it as the `default` keyword.
* Fixed a bug where invalid octal escape sequences werent throwing errors in the compiler.
```
releaseHeader('2017-02-21', '2.0.0-alpha1', '1.12.4')
```
* Initial alpha release of CoffeeScript 2. The CoffeeScript compiler now outputs ES2015+ syntax whenever possible. See [breaking changes](#breaking-changes).
* Classes are output using ES2015 `class` and `extends` keywords.
* Added support for `async`/`await`.
* Bound (arrow) functions now output as `=>` functions.
* Function parameters with default values now use ES2015 default values syntax.
* Splat function parameters now use ES2015 spread syntax.
* Computed properties now use ES2015 syntax.
* Interpolated strings (template literals) now use ES2015 backtick syntax.
* Improved support for recognizing Markdown in Literate CoffeeScript files.
* Mixing tabs and spaces in indentation is now disallowed.
* Browser compiler is now minified using the Google Closure Compiler (JavaScript version).
* Node 7+ required for CoffeeScript 2.
```
releaseHeader('2017-02-18', '1.12.4', '1.12.3')
```
* The `cake` commands have been updated, with new `watch` options for most tasks. Clone the [CoffeeScript repo](https://github.com/jashkenas/coffeescript) and run `cake` at the root of the repo to see the options.
* Fixed a bug where `export`ing a referenced variable was preventing the variable from being declared.
* Fixed a bug where the `coffee` command wasnt working for a `.litcoffee` file.
* Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.
```
releaseHeader('2017-01-24', '1.12.3', '1.12.2')
```
* `@` values can now be used as indices in `for` expressions. This loosens the compilation of `for` expressions to allow the index variable to be an `@` value, e.g. `do @visit for @node, @index in nodes`. Within `@visit`, the index of the current node (`@node`) would be available as `@index`.
* CoffeeScripts patched `Error.prepareStackTrace` has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2.
* The `//=` operators output now wraps parentheses around the right operand, like the other assignment operators.
```
releaseHeader('2016-12-16', '1.12.2', '1.12.1')
```
* The browser compiler can once again be built unminified via `MINIFY=false cake build:browser`.
* The error-prone patched version of `Error.prepareStackTrace` has been removed.
* Command completion in the REPL (pressing tab to get suggestions) has been fixed for Node 6.9.1+.
* The [browser-based tests](/v<%= majorVersion %>/test.html) now include all the tests as the Node-based version.
```
releaseHeader('2016-12-07', '1.12.1', '1.12.0')
```
* You can now import a module member named `default`, e.g. `import { default } from 'lib'`. Though like in ES2015, you cannot import an entire module and name it `default` (so `import default from 'lib'` is not allowed).
* Fix regression where `from` as a variable name was breaking `for` loop declarations. For the record, `from` is not a reserved word in CoffeeScript; you may use it for variable names. `from` behaves like a keyword within the context of `import` and `export` statements, and in the declaration of a `for` loop; though you should also be able to use variables named `from` in those contexts, and the compiler should be able to tell the difference.
```
releaseHeader('2016-12-04', '1.12.0', '1.11.1')
```
* CoffeeScript now supports ES2015 [tagged template literals](#tagged-template-literals). Note that using tagged template literals in your code makes you responsible for ensuring that either your runtime supports tagged template literals or that you transpile the output JavaScript further to a version your target runtime(s) support.
* CoffeeScript now provides a [`for…from`](#generator-iteration) syntax for outputting ES2015 [`for…of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of). (Sorry they couldnt match, but we came up with `for…of` first for something else.) This allows iterating over generators or any other iterable object. Note that using `for…from` in your code makes you responsible for ensuring that either your runtime supports `for…of` or that you transpile the output JavaScript further to a version your target runtime(s) support.
* Triple backticks (`` `````) allow the creation of embedded JavaScript blocks where escaping single backticks is not required, which should improve interoperability with ES2015 template literals and with Markdown.
* Within single-backtick embedded JavaScript, backticks can now be escaped via `` \```.
* The browser tests now run in the browser again, and are accessible [here](/v<%= majorVersion %>/test.html) if you would like to test your browser.
* CoffeeScript-only keywords in ES2015 `import`s and `export`s are now ignored.
* The compiler now throws an error on trying to export an anonymous class.
* Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.
```
releaseHeader('2016-10-02', '1.11.1', '1.11.0')
```
* Bugfix for shorthand object syntax after interpolated keys.
* Bugfix for indentation-stripping in `"""` strings.
* Bugfix for not being able to use the name “arguments” for a prototype property of class.
* Correctly compile large hexadecimal numbers literals to `2e308` (just like all other large number literals do).
```
releaseHeader('2016-09-24', '1.11.0', '1.10.0')
```
* CoffeeScript now supports ES2015 [`import` and `export` syntax](#modules).
* Added the `-M, --inline-map` flag to the compiler, allowing you embed the source map directly into the output JavaScript, rather than as a separate file.
* A bunch of fixes for `yield`:
* `yield return` can no longer mistakenly be used as an expression.
* `yield` now mirrors `return` in that it can be used stand-alone as well as with expressions. Where you previously wrote `yield undefined`, you may now write simply `yield`. However, this means also inheriting the same syntax limitations that `return` has, so these examples no longer compile:
```
doubles = ->
yield for i in [1..3]
i * 2
six = ->
yield
2 * 3
```
* The JavaScript output is a bit nicer, with unnecessary parentheses and spaces, double indentation and double semicolons around `yield` no longer present.
* `&&=`, `||=`, `and=` and `or=` no longer accidentally allow a space before the equals sign.
* Improved several error messages.
* Just like `undefined` compiles to `void 0`, `NaN` now compiles into `0/0` and `Infinity` into `2e308`.
* Bugfix for renamed destructured parameters with defaults. `({a: b = 1}) ->` no longer crashes the compiler.
* Improved the internal representation of a CoffeeScript program. This is only noticeable to tools that use `CoffeeScript.tokens` or `CoffeeScript.nodes`. Such tools need to update to take account for changed or added tokens and nodes.
* Several minor bug fixes, including:
* The caught error in `catch` blocks is no longer declared unnecessarily, and no longer mistakenly named `undefined` for `catch`-less `try` blocks.
* Unassignable parameter destructuring no longer crashes the compiler.
* Source maps are now used correctly for errors thrown from .coffee.md files.
* `coffee -e 'throw null'` no longer crashes.
* The REPL no longer crashes when using `.exit` to exit it.
* Invalid JavaScript is no longer output when lots of `for` loops are used in the same scope.
* A unicode issue when using stdin with the CLI.
```
releaseHeader('2015-09-03', '1.10.0', '1.9.3')
```
* CoffeeScript now supports ES2015-style destructuring defaults.
* `(offsetHeight: height) ->` no longer compiles. That syntax was accidental and partly broken. Use `({offsetHeight: height}) ->` instead. Object destructuring always requires braces.
* Several minor bug fixes, including:
* A bug where the REPL would sometimes report valid code as invalid, based on what you had typed earlier.
* A problem with multiple JS contexts in the jest test framework.
* An error in io.js where strict mode is set on internal modules.
* A variable name clash for the caught error in `catch` blocks.
```
releaseHeader('2015-05-27', '1.9.3', '1.9.2')
```
* Bugfix for interpolation in the first key of an object literal in an implicit call.
* Fixed broken error messages in the REPL, as well as a few minor bugs with the REPL.
* Fixed source mappings for tokens at the beginning of lines when compiling with the `--bare` option. This has the nice side effect of generating smaller source maps.
* Slight formatting improvement of compiled block comments.
* Better error messages for `on`, `off`, `yes` and `no`.
```
releaseHeader('2015-04-15', '1.9.2', '1.9.1')
```
* Fixed a **watch** mode error introduced in 1.9.1 when compiling multiple files with the same filename.
* Bugfix for `yield` around expressions containing `this`.
* Added a Ruby-style `-r` option to the REPL, which allows requiring a module before execution with `--eval` or `--interactive`.
* In `<script type="text/coffeescript">` tags, to avoid possible duplicate browser requests for .coffee files, you can now use the `data-src` attribute instead of `src`.
* Minor bug fixes for IE8, strict ES5 regular expressions and Browserify.
```
releaseHeader('2015-02-18', '1.9.1', '1.9.0')
```
* Interpolation now works in object literal keys (again). You can use this to dynamically name properties.
* Internal compiler variable names no longer start with underscores. This makes the generated JavaScript a bit prettier, and also fixes an issue with the completely broken and ungodly way that AngularJS “parses” function arguments.
* Fixed a few `yield`-related edge cases with `yield return` and `yield throw`.
* Minor bug fixes and various improvements to compiler error messages.
```
releaseHeader('2015-01-29', '1.9.0', '1.8.0')
```
* CoffeeScript now supports ES2015 generators. A generator is simply a function that `yield`s.
* More robust parsing and improved error messages for strings and regexes — especially with respect to interpolation.
* Changed strategy for the generation of internal compiler variable names. Note that this means that `@example` function parameters are no longer available as naked `example` variables within the function body.
* Fixed REPL compatibility with latest versions of Node and Io.js.
* Various minor bug fixes.
```
releaseHeader('2014-08-26', '1.8.0', '1.7.1')
```
* The `--join` option of the CLI is now deprecated.
* Source maps now use `.js.map` as file extension, instead of just `.map`.
* The CLI now exits with the exit code 1 when it fails to write a file to disk.
* The compiler no longer crashes on unterminated, single-quoted strings.
* Fixed location data for string interpolations, which made source maps out of sync.
* The error marker in error messages is now correctly positioned if the code is indented with tabs.
* Fixed a slight formatting error in CoffeeScripts source map-patched stack traces.
* The `%%` operator now coerces its right operand only once.
* It is now possible to require CoffeeScript files from Cakefiles without having to register the compiler first.
* The CoffeeScript REPL is now exported and can be required using `require 'coffeescript/repl'`.
* Fixes for the REPL in Node 0.11.
```
releaseHeader('2014-01-29', '1.7.1', '1.7.0')
```
* Fixed a typo that broke node module lookup when running a script directly with the `coffee` binary.
```
releaseHeader('2014-01-28', '1.7.0', '1.6.3')
```
* When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with `require 'coffeescript/register'` or `CoffeeScript.register()`. Also for configuration such as Mochas, use **coffeescript/register**.
* Improved error messages, source maps and stack traces. Source maps now use the updated `//#` syntax.
* Leading `.` now closes all open calls, allowing for simpler chaining syntax.
* Added `**`, `//` and `%%` operators and `...` expansion in parameter lists and destructuring expressions.
* Multiline strings are now joined by a single space and ignore all indentation. A backslash at the end of a line can denote the amount of whitespace between lines, in both strings and heredocs. Backslashes correctly escape whitespace in block regexes.
* Closing brackets can now be indented and therefore no longer cause unexpected error.
* Several breaking compilation fixes. Non-callable literals (strings, numbers etc.) dont compile in a call now and multiple postfix conditionals compile properly. Postfix conditionals and loops always bind object literals. Conditional assignment compiles properly in subexpressions. `super` is disallowed outside of methods and works correctly inside `for` loops.
* Formatting of compiled block comments has been improved.
* No more `-p` folders on Windows.
* The `options` object passed to CoffeeScript is no longer mutated.
```
releaseHeader('2013-06-02', '1.6.3', '1.6.2')
```
* The CoffeeScript REPL now remembers your history between sessions. Just like a proper REPL should.
* You can now use `require` in Node to load `.coffee.md` Literate CoffeeScript files. In the browser, `text/literate-coffeescript` script tags.
* The old `coffee --lint` command has been removed. It was useful while originally working on the compiler, but has been surpassed by JSHint. You may now use `-l` to pass literate files in over **stdio**.
* Bugfixes for Windows path separators, `catch` without naming the error, and executable-class-bodies-with- prototypal-property-attachment.
```
releaseHeader('2013-03-18', '1.6.2', '1.6.1')
```
* Source maps have been used to provide automatic line-mapping when running CoffeeScript directly via the `coffee` command, and for automatic line-mapping when running CoffeeScript directly in the browser. Also, to provide better error messages for semantic errors thrown by the compiler — [with colors, even](http://cl.ly/NdOA).
* Improved support for mixed literate/vanilla-style CoffeeScript projects, and generating source maps for both at the same time.
* Fixes for **1.6.x** regressions with overriding inherited bound functions, and for Windows file path management.
* The `coffee` command can now correctly `fork()` both `.coffee` and `.js` files. (Requires Node.js 0.9+)
```
releaseHeader('2013-03-05', '1.6.1', '1.5.0')
```
* First release of [source maps](#source-maps). Pass the `--map` flag to the compiler, and off you go. Direct all your thanks over to [Jason Walton](https://github.com/jwalton).
* Fixed a 1.5.0 regression with multiple implicit calls against an indented implicit object. Combinations of implicit function calls and implicit objects should generally be parsed better now — but it still isnt good _style_ to nest them too heavily.
* `.coffee.md` is now also supported as a Literate CoffeeScript file extension, for existing tooling. `.litcoffee` remains the canonical one.
* Several minor fixes surrounding member properties, bound methods and `super` in class declarations.
```
releaseHeader('2013-02-25', '1.5.0', '1.4.0')
```
* First release of [Literate CoffeeScript](#literate).
* The CoffeeScript REPL is now based on the Node.js REPL, and should work better and more familiarly.
* Returning explicit values from constructors is now forbidden. If you want to return an arbitrary value, use a function, not a constructor.
* You can now loop over an array backwards, without having to manually deal with the indexes: `for item in list by -1`
* Source locations are now preserved in the CoffeeScript AST, although source maps are not yet being emitted.
```
releaseHeader('2012-10-23', '1.4.0', '1.3.3')
```
* The CoffeeScript compiler now strips Microsofts UTF-8 BOM if it exists, allowing you to compile BOM-borked source files.
* Fix Node/compiler deprecation warnings by removing `registerExtension`, and moving from `path.exists` to `fs.exists`.
* Small tweaks to splat compilation, backticks, slicing, and the error for duplicate keys in object literals.
```
releaseHeader('2012-05-15', '1.3.3', '1.3.1')
```
* Due to the new semantics of JavaScripts strict mode, CoffeeScript no longer guarantees that constructor functions have names in all runtimes. See [#2052](https://github.com/jashkenas/coffeescript/issues/2052) for discussion.
* Inside of a nested function inside of an instance method, its now possible to call `super` more reliably (walks recursively up).
* Named loop variables no longer have different scoping heuristics than other local variables. (Reverts #643)
* Fix for splats nested within the LHS of destructuring assignment.
* Corrections to our compile time strict mode forbidding of octal literals.
```
releaseHeader('2012-04-10', '1.3.1', '1.2.0')
```
* CoffeeScript now enforces all of JavaScripts **Strict Mode** early syntax errors at compile time. This includes old-style octal literals, duplicate property names in object literals, duplicate parameters in a function definition, deleting naked variables, setting the value of `eval` or `arguments`, and more. See a full discussion at [#1547](https://github.com/jashkenas/coffeescript/issues/1547).
* The REPL now has a handy new multi-line mode for entering large blocks of code. Its useful when copy-and-pasting examples into the REPL. Enter multi-line mode with `Ctrl-V`. You may also now pipe input directly into the REPL.
* CoffeeScript now prints a `Generated by CoffeeScript VERSION` header at the top of each compiled file.
* Conditional assignment of previously undefined variables `a or= b` is now considered a syntax error.
* A tweak to the semantics of `do`, which can now be used to more easily simulate a namespace: `do (x = 1, y = 2) -> …`
* Loop indices are now mutable within a loop iteration, and immutable between them.
* Both endpoints of a slice are now allowed to be omitted for consistency, effectively creating a shallow copy of the list.
* Additional tweaks and improvements to `coffee --watch` under Nodes “new” file watching API. Watch will now beep by default if you introduce a syntax error into a watched script. We also now ignore hidden directories by default when watching recursively.
```
releaseHeader('2011-12-18', '1.2.0', '1.1.3')
```
* Multiple improvements to `coffee --watch` and `--join`. You may now use both together, as well as add and remove files and directories within a `--watch`d folder.
* The `throw` statement can now be used as part of an expression.
* Block comments at the top of the file will now appear outside of the safety closure wrapper.
* Fixed a number of minor 1.1.3 regressions having to do with trailing operators and unfinished lines, and a more major 1.1.3 regression that caused bound functions _within_ bound class functions to have the incorrect `this`.
```
releaseHeader('2011-11-08', '1.1.3', '1.1.2')
```
* Ahh, whitespace. CoffeeScripts compiled JS now tries to space things out and keep it readable, as you can see in the examples on this page.
* You can now call `super` in class level methods in class bodies, and bound class methods now preserve their correct context.
* JavaScript has always supported octal numbers `010 is 8`, and hexadecimal numbers `0xf is 15`, but CoffeeScript now also supports binary numbers: `0b10 is 2`.
* The CoffeeScript module has been nested under a subdirectory to make it easier to `require` individual components separately, without having to use **npm**. For example, after adding the CoffeeScript folder to your path: `require('coffeescript/lexer')`
* Theres a new “link” feature in Try CoffeeScript on this webpage. Use it to get a shareable permalink for your example script.
* The `coffee --watch` feature now only works on Node.js 0.6.0 and higher, but now also works properly on Windows.
* Lots of small bug fixes from **[@michaelficarra](https://github.com/michaelficarra)**, **[@geraldalewis](https://github.com/geraldalewis)**, **[@satyr](https://github.com/satyr)**, and **[@trevorburnham](https://github.com/trevorburnham)**.
```
releaseHeader('2011-08-04', '1.1.2', '1.1.1')
```
Fixes for block comment formatting, `?=` compilation, implicit calls against control structures, implicit invocation of a try/catch block, variadic arguments leaking from local scope, line numbers in syntax errors following heregexes, property access on parenthesized number literals, bound class methods and super with reserved names, a REPL overhaul, consecutive compiled semicolons, block comments in implicitly called objects, and a Chrome bug.
```
releaseHeader('2011-05-10', '1.1.1', '1.1.0')
```
Bugfix release for classes with external constructor functions, see issue #1182.
```
releaseHeader('2011-05-01', '1.1.0', '1.0.1')
```
When running via the `coffee` executable, `process.argv` and friends now report `coffee` instead of `node`. Better compatibility with **Node.js 0.4.x** module lookup changes. The output in the REPL is now colorized, like Nodes is. Giving your concatenated CoffeeScripts a name when using `--join` is now mandatory. Fix for lexing compound division `/=` as a regex accidentally. All `text/coffeescript` tags should now execute in the order theyre included. Fixed an issue with extended subclasses using external constructor functions. Fixed an edge-case infinite loop in `addImplicitParentheses`. Fixed exponential slowdown with long chains of function calls. Globals no longer leak into the CoffeeScript REPL. Splatted parameters are declared local to the function.
```
releaseHeader('2011-01-31', '1.0.1', '1.0.0')
```
Fixed a lexer bug with Unicode identifiers. Updated REPL for compatibility with Node.js 0.3.7\. Fixed requiring relative paths in the REPL. Trailing `return` and `return undefined` are now optimized away. Stopped requiring the core Node.js `util` module for back-compatibility with Node.js 0.2.5\. Fixed a case where a conditional `return` would cause fallthrough in a `switch` statement. Optimized empty objects in destructuring assignment.
```
releaseHeader('2010-12-24', '1.0.0', '0.9.6')
```
CoffeeScript loops no longer try to preserve block scope when functions are being generated within the loop body. Instead, you can use the `do` keyword to create a convenient closure wrapper. Added a `--nodejs` flag for passing through options directly to the `node` executable. Better behavior around the use of pure statements within expressions. Fixed inclusive slicing through `-1`, for all browsers, and splicing with arbitrary expressions as endpoints.
```
releaseHeader('2010-12-06', '0.9.6', '0.9.5')
```
The REPL now properly formats stacktraces, and stays alive through asynchronous exceptions. Using `--watch` now prints timestamps as files are compiled. Fixed some accidentally-leaking variables within plucked closure-loops. Constructors now maintain their declaration location within a class body. Dynamic object keys were removed. Nested classes are now supported. Fixes execution context for naked splatted functions. Bugfix for inversion of chained comparisons. Chained class instantiation now works properly with splats.
```
releaseHeader('2010-11-21', '0.9.5', '0.9.4')
```
0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from **satyr**s [Coco](https://github.com/satyr/coco) dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. `undefined` now works like `null`, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: `result = i for i in list`
used to parse as `result = (i for i in list)` by default … it now parses as
`(result = i) for i in list`.
```
releaseHeader('2010-09-21', '0.9.4', '0.9.3')
```
CoffeeScript now uses appropriately-named temporary variables, and recycles their references after use. Added `require.extensions` support for **Node.js 0.3**. Loading CoffeeScript in the browser now adds just a single `CoffeeScript` object to global scope. Fixes for implicit object and block comment edge cases.
```
releaseHeader('2010-09-16', '0.9.3', '0.9.2')
```
CoffeeScript `switch` statements now compile into JS `switch` statements — they previously compiled into `if/else` chains for JavaScript 1.3 compatibility. Soaking a function invocation is now supported. Users of the RubyMine editor should now be able to use `--watch` mode.
```
releaseHeader('2010-08-23', '0.9.2', '0.9.1')
```
Specifying the start and end of a range literal is now optional, eg. `array[3..]`. You can now say `a not instanceof b`. Fixed important bugs with nested significant and non-significant indentation (Issue #637). Added a `--require` flag that allows you to hook into the `coffee` command. Added a custom `jsl.conf` file for our preferred JavaScriptLint setup. Sped up Jison grammar compilation time by flattening rules for operations. Block comments can now be used with JavaScript-minifier-friendly syntax. Added JavaScripts compound assignment bitwise operators. Bugfixes to implicit object literals with leading number and string keys, as the subject of implicit calls, and as part of compound assignment.
```
releaseHeader('2010-08-11', '0.9.1', '0.9.0')
```
Bugfix release for **0.9.1**. Greatly improves the handling of mixed implicit objects, implicit function calls, and implicit indentation. String and regex interpolation is now strictly `#{ … }` (Ruby style). The compiler now takes a `--require` flag, which specifies scripts to run before compilation.
```
releaseHeader('2010-08-04', '0.9.0', '0.7.2')
```
The CoffeeScript **0.9** series is considered to be a release candidate for **1.0**; lets give her a shakedown cruise. **0.9.0** introduces a massive backwards-incompatible change: Assignment now uses `=`, and object literals use `:`, as in JavaScript. This allows us to have implicit object literals, and YAML-style object definitions. Half assignments are removed, in favor of `+=`, `or=`, and friends. Interpolation now uses a hash mark `#` instead of the dollar sign `$` — because dollar signs may be part of a valid JS identifier. Downwards range comprehensions are now safe again, and are optimized to straight for loops when created with integer endpoints. A fast, unguarded form of object comprehension was added: `for all key, value of object`. Mentioning the `super` keyword with no arguments now forwards all arguments passed to the function, as in Ruby. If you extend class `B` from parent class `A`, if `A` has an `extended` method defined, it will be called, passing in `B` — this enables static inheritance, among other things. Cleaner output for functions bound with the fat arrow. `@variables` can now be used in parameter lists, with the parameter being automatically set as a property on the object — useful in constructors and setter functions. Constructor functions can now take splats.
```
releaseHeader('2010-07-12', '0.7.2', '0.7.1')
```
Quick bugfix (right after 0.7.1) for a problem that prevented `coffee` command-line options from being parsed in some circumstances.
```
releaseHeader('2010-07-11', '0.7.1', '0.7.0')
```
Block-style comments are now passed through and printed as JavaScript block comments making them useful for licenses and copyright headers. Better support for running coffee scripts standalone via hashbangs. Improved syntax errors for tokens that are not in the grammar.
```
releaseHeader('2010-06-28', '0.7.0', '0.6.2')
```
Official CoffeeScript variable style is now camelCase, as in JavaScript. Reserved words are now allowed as object keys, and will be quoted for you. Range comprehensions now generate cleaner code, but you have to specify `by -1` if youd like to iterate downward. Reporting of syntax errors is greatly improved from the previous release. Running `coffee` with no arguments now launches the REPL, with Readline support. The `<-` bind operator has been removed from CoffeeScript. The `loop` keyword was added, which is equivalent to a `while true` loop. Comprehensions that contain closures will now close over their variables, like the semantics of a `forEach`. You can now use bound function in class definitions (bound to the instance). For consistency, `a in b` is now an array presence check, and `a of b` is an object-key check. Comments are no longer passed through to the generated JavaScript.
```
releaseHeader('2010-05-15', '0.6.2', '0.6.1')
```
The `coffee` command will now preserve directory structure when compiling a directory full of scripts. Fixed two omissions that were preventing the CoffeeScript compiler from running live within Internet Explorer. Theres now a syntax for block comments, similar in spirit to CoffeeScripts heredocs. ECMA Harmony DRY-style pattern matching is now supported, where the name of the property is the same as the name of the value: `{name, length}: func`. Pattern matching is now allowed within comprehension variables. `unless` is now allowed in block form. `until` loops were added, as the inverse of `while` loops. `switch` statements are now allowed without switch object clauses. Compatible with Node.js **v0.1.95**.
```
releaseHeader('2010-04-12', '0.6.1', '0.6.0')
```
Upgraded CoffeeScript for compatibility with the new Node.js **v0.1.90** series.
```
releaseHeader('2010-04-03', '0.6.0', '0.5.6')
```
Trailing commas are now allowed, a-la Python. Static properties may be assigned directly within class definitions, using `@property` notation.
```
releaseHeader('2010-03-23', '0.5.6', '0.5.5')
```
Interpolation can now be used within regular expressions and heredocs, as well as strings. Added the `<-` bind operator. Allowing assignment to half-expressions instead of special `||=`-style operators. The arguments object is no longer automatically converted into an array. After requiring `coffeescript`, Node.js can now directly load `.coffee` files, thanks to **registerExtension**. Multiple splats can now be used in function calls, arrays, and pattern matching.
```
releaseHeader('2010-03-08', '0.5.5', '0.5.4')
```
String interpolation, contributed by [Stan Angeloff](https://github.com/StanAngeloff). Since `--run` has been the default since **0.5.3**, updating `--stdio` and `--eval` to run by default, pass `--compile` as well if youd like to print the result.
```
releaseHeader('2010-03-03', '0.5.4', '0.5.3')
```
Bugfix that corrects the Node.js global constants `__filename` and `__dirname`. Tweaks for more flexible parsing of nested function literals and improperly-indented comments. Updates for the latest Node.js API.
```
releaseHeader('2010-02-27', '0.5.3', '0.5.2')
```
CoffeeScript now has a syntax for defining classes. Many of the core components (Nodes, Lexer, Rewriter, Scope, Optparse) are using them. Cakefiles can use `optparse.coffee` to define options for tasks. `--run` is now the default flag for the `coffee` command, use `--compile` to save JavaScripts. Bugfix for an ambiguity between RegExp literals and chained divisions.
```
releaseHeader('2010-02-25', '0.5.2', '0.5.1')
```
Added a compressed version of the compiler for inclusion in web pages as
`/v<%= majorVersion %>/browser-compiler/coffeescript.js`. Itll automatically run any script tags with type `text/coffeescript` for you. Added a `--stdio` option to the `coffee` command, for piped-in compiles.
```
releaseHeader('2010-02-24', '0.5.1', '0.5.0')
```
Improvements to null soaking with the existential operator, including soaks on indexed properties. Added conditions to `while` loops, so you can use them as filters with `when`, in the same manner as comprehensions.
```
releaseHeader('2010-02-21', '0.5.0', '0.3.2')
```
CoffeeScript 0.5.0 is a major release, While there are no language changes, the Ruby compiler has been removed in favor of a self-hosting compiler written in pure CoffeeScript.
```
releaseHeader('2010-02-08', '0.3.2', '0.3.0')
```
`@property` is now a shorthand for `this.property`.
Switched the default JavaScript engine from Narwhal to Node.js. Pass the `--narwhal` flag if youd like to continue using it.
```
releaseHeader('2010-01-26', '0.3.0', '0.2.6')
```
CoffeeScript 0.3 includes major syntax changes:
The function symbol was changed to `->`, and the bound function symbol is now `=>`.
Parameter lists in function definitions must now be wrapped in parentheses.
Added property soaking, with the `?.` operator.
Made parentheses optional, when invoking functions with arguments.
Removed the obsolete block literal syntax.
```
releaseHeader('2010-01-17', '0.2.6', '0.2.5')
```
Added Python-style chained comparisons, the conditional existence operator `?=`, and some examples from _Beautiful Code_. Bugfixes relating to statement-to-expression conversion, arguments-to-array conversion, and the TextMate syntax highlighter.
```
releaseHeader('2010-01-13', '0.2.5', '0.2.4')
```
The conditions in switch statements can now take multiple values at once — If any of them are true, the case will run. Added the long arrow `==>`, which defines and immediately binds a function to `this`. While loops can now be used as expressions, in the same way that comprehensions can. Splats can be used within pattern matches to soak up the rest of an array.
```
releaseHeader('2010-01-12', '0.2.4', '0.2.3')
```
Added ECMAScript Harmony style destructuring assignment, for dealing with extracting values from nested arrays and objects. Added indentation-sensitive heredocs for nicely formatted strings or chunks of code.
```
releaseHeader('2010-01-11', '0.2.3', '0.2.2')
```
Axed the unsatisfactory `ino` keyword, replacing it with `of` for object comprehensions. They now look like: `for prop, value of object`.
```
releaseHeader('2010-01-10', '0.2.2', '0.2.1')
```
When performing a comprehension over an object, use `ino`, instead of `in`, which helps us generate smaller, more efficient code at compile time.
Added `::` as a shorthand for saying `.prototype.`
The “splat” symbol has been changed from a prefix asterisk `*`, to a postfix ellipsis `...`
Added JavaScripts `in` operator, empty `return` statements, and empty `while` loops.
Constructor functions that start with capital letters now include a safety check to make sure that the new instance of the object is returned.
The `extends` keyword now functions identically to `goog.inherits` in Googles Closure Library.
```
releaseHeader('2010-01-05', '0.2.1', '0.2.0')
```
Arguments objects are now converted into real arrays when referenced.
```
releaseHeader('2010-01-05', '0.2.0', '0.1.6')
```
Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to [Liam OConnor-Davis](https://github.com/liamoc) for whitespace and expression help.
```
releaseHeader('2009-12-27', '0.1.6', '0.1.5')
```
Bugfix for running `coffee --interactive` and `--run` from outside of the CoffeeScript directory. Bugfix for nested function/if-statements.
```
releaseHeader('2009-12-26', '0.1.5', '0.1.4')
```
Array slice literals and array comprehensions can now both take Ruby-style ranges to specify the start and end. JavaScript variable declaration is now pushed up to the top of the scope, making all assignment statements into expressions. You can use `\` to escape newlines. The `coffeescript` command is now called `coffee`.
```
releaseHeader('2009-12-25', '0.1.4', '0.1.3')
```
The official CoffeeScript extension is now `.coffee` instead of `.cs`, which properly belongs to [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)). Due to popular demand, you can now also use `=` to assign. Unlike JavaScript, `=` can also be used within object literals, interchangeably with `:`. Made a grammatical fix for chained function calls like `func(1)(2)(3)(4)`. Inheritance and super no longer use `__proto__`, so they should be IE-compatible now.
```
releaseHeader('2009-12-25', '0.1.3', '0.1.2')
```
The `coffee` command now includes `--interactive`, which launches an interactive CoffeeScript session, and `--run`, which directly compiles and executes a script. Both options depend on a working installation of Narwhal. The `aint` keyword has been replaced by `isnt`, which goes together a little smoother with `is`. Quoted strings are now allowed as identifiers within object literals: eg. `{"5+5": 10}`. All assignment operators now use a colon: `+:`, `-:`, `*:`, etc.
```
releaseHeader('2009-12-24', '0.1.2', '0.1.1')
```
Fixed a bug with calling `super()` through more than one level of inheritance, with the re-addition of the `extends` keyword. Added experimental [Narwhal](http://narwhaljs.org/) support (as a Tusk package), contributed by [Tom Robinson](http://blog.tlrobinson.net/), including **bin/cs** as a CoffeeScript REPL and interpreter. New `--no-wrap` option to suppress the safety function wrapper.
```
releaseHeader('2009-12-24', '0.1.1', '0.1.0')
```
Added `instanceof` and `typeof` as operators.
```
releaseHeader('2009-12-24', '0.1.0', '8e9d637985d2dc9b44922076ad54ffef7fa8e9c2')
```
Initial CoffeeScript release.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2009-12-24', '0.1.0', '8e9d637985d2dc9b44922076ad54ffef7fa8e9c2')
```
Initial CoffeeScript release.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2009-12-24', '0.1.1', '0.1.0')
```
Added `instanceof` and `typeof` as operators.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2009-12-24', '0.1.2', '0.1.1')
```
Fixed a bug with calling `super()` through more than one level of inheritance, with the re-addition of the `extends` keyword. Added experimental [Narwhal](http://narwhaljs.org/) support (as a Tusk package), contributed by [Tom Robinson](http://blog.tlrobinson.net/), including **bin/cs** as a CoffeeScript REPL and interpreter. New `--no-wrap` option to suppress the safety function wrapper.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2009-12-25', '0.1.3', '0.1.2')
```
The `coffee` command now includes `--interactive`, which launches an interactive CoffeeScript session, and `--run`, which directly compiles and executes a script. Both options depend on a working installation of Narwhal. The `aint` keyword has been replaced by `isnt`, which goes together a little smoother with `is`. Quoted strings are now allowed as identifiers within object literals: eg. `{"5+5": 10}`. All assignment operators now use a colon: `+:`, `-:`, `*:`, etc.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2009-12-25', '0.1.4', '0.1.3')
```
The official CoffeeScript extension is now `.coffee` instead of `.cs`, which properly belongs to [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)). Due to popular demand, you can now also use `=` to assign. Unlike JavaScript, `=` can also be used within object literals, interchangeably with `:`. Made a grammatical fix for chained function calls like `func(1)(2)(3)(4)`. Inheritance and super no longer use `__proto__`, so they should be IE-compatible now.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2009-12-26', '0.1.5', '0.1.4')
```
Array slice literals and array comprehensions can now both take Ruby-style ranges to specify the start and end. JavaScript variable declaration is now pushed up to the top of the scope, making all assignment statements into expressions. You can use `\` to escape newlines. The `coffeescript` command is now called `coffee`.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2009-12-27', '0.1.6', '0.1.5')
```
Bugfix for running `coffee --interactive` and `--run` from outside of the CoffeeScript directory. Bugfix for nested function/if-statements.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-01-05', '0.2.0', '0.1.6')
```
Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to [Liam OConnor-Davis](https://github.com/liamoc) for whitespace and expression help.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-01-05', '0.2.1', '0.2.0')
```
Arguments objects are now converted into real arrays when referenced.

View File

@@ -0,0 +1,10 @@
```
releaseHeader('2010-01-10', '0.2.2', '0.2.1')
```
When performing a comprehension over an object, use `ino`, instead of `in`, which helps us generate smaller, more efficient code at compile time.
Added `::` as a shorthand for saying `.prototype.`
The “splat” symbol has been changed from a prefix asterisk `*`, to a postfix ellipsis `...`
Added JavaScripts `in` operator, empty `return` statements, and empty `while` loops.
Constructor functions that start with capital letters now include a safety check to make sure that the new instance of the object is returned.
The `extends` keyword now functions identically to `goog.inherits` in Googles Closure Library.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-01-11', '0.2.3', '0.2.2')
```
Axed the unsatisfactory `ino` keyword, replacing it with `of` for object comprehensions. They now look like: `for prop, value of object`.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-01-12', '0.2.4', '0.2.3')
```
Added ECMAScript Harmony style destructuring assignment, for dealing with extracting values from nested arrays and objects. Added indentation-sensitive heredocs for nicely formatted strings or chunks of code.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-01-13', '0.2.5', '0.2.4')
```
The conditions in switch statements can now take multiple values at once — If any of them are true, the case will run. Added the long arrow `==>`, which defines and immediately binds a function to `this`. While loops can now be used as expressions, in the same way that comprehensions can. Splats can be used within pattern matches to soak up the rest of an array.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-01-17', '0.2.6', '0.2.5')
```
Added Python-style chained comparisons, the conditional existence operator `?=`, and some examples from _Beautiful Code_. Bugfixes relating to statement-to-expression conversion, arguments-to-array conversion, and the TextMate syntax highlighter.

View File

@@ -0,0 +1,10 @@
```
releaseHeader('2010-01-26', '0.3.0', '0.2.6')
```
CoffeeScript 0.3 includes major syntax changes:
The function symbol was changed to `->`, and the bound function symbol is now `=>`.
Parameter lists in function definitions must now be wrapped in parentheses.
Added property soaking, with the `?.` operator.
Made parentheses optional, when invoking functions with arguments.
Removed the obsolete block literal syntax.

View File

@@ -0,0 +1,6 @@
```
releaseHeader('2010-02-08', '0.3.2', '0.3.0')
```
`@property` is now a shorthand for `this.property`.
Switched the default JavaScript engine from Narwhal to Node.js. Pass the `--narwhal` flag if youd like to continue using it.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-02-21', '0.5.0', '0.3.2')
```
CoffeeScript 0.5.0 is a major release, While there are no language changes, the Ruby compiler has been removed in favor of a self-hosting compiler written in pure CoffeeScript.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-02-24', '0.5.1', '0.5.0')
```
Improvements to null soaking with the existential operator, including soaks on indexed properties. Added conditions to `while` loops, so you can use them as filters with `when`, in the same manner as comprehensions.

View File

@@ -0,0 +1,6 @@
```
releaseHeader('2010-02-25', '0.5.2', '0.5.1')
```
Added a compressed version of the compiler for inclusion in web pages as
`/v<%= majorVersion %>/browser-compiler-legacy/coffeescript.js`. Itll automatically run any script tags with type `text/coffeescript` for you. Added a `--stdio` option to the `coffee` command, for piped-in compiles.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-02-27', '0.5.3', '0.5.2')
```
CoffeeScript now has a syntax for defining classes. Many of the core components (Nodes, Lexer, Rewriter, Scope, Optparse) are using them. Cakefiles can use `optparse.coffee` to define options for tasks. `--run` is now the default flag for the `coffee` command, use `--compile` to save JavaScripts. Bugfix for an ambiguity between RegExp literals and chained divisions.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-03-03', '0.5.4', '0.5.3')
```
Bugfix that corrects the Node.js global constants `__filename` and `__dirname`. Tweaks for more flexible parsing of nested function literals and improperly-indented comments. Updates for the latest Node.js API.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-03-08', '0.5.5', '0.5.4')
```
String interpolation, contributed by [Stan Angeloff](https://github.com/StanAngeloff). Since `--run` has been the default since **0.5.3**, updating `--stdio` and `--eval` to run by default, pass `--compile` as well if youd like to print the result.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-03-23', '0.5.6', '0.5.5')
```
Interpolation can now be used within regular expressions and heredocs, as well as strings. Added the `<-` bind operator. Allowing assignment to half-expressions instead of special `||=`-style operators. The arguments object is no longer automatically converted into an array. After requiring `coffeescript`, Node.js can now directly load `.coffee` files, thanks to **registerExtension**. Multiple splats can now be used in function calls, arrays, and pattern matching.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-04-03', '0.6.0', '0.5.6')
```
Trailing commas are now allowed, a-la Python. Static properties may be assigned directly within class definitions, using `@property` notation.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-04-12', '0.6.1', '0.6.0')
```
Upgraded CoffeeScript for compatibility with the new Node.js **v0.1.90** series.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-05-15', '0.6.2', '0.6.1')
```
The `coffee` command will now preserve directory structure when compiling a directory full of scripts. Fixed two omissions that were preventing the CoffeeScript compiler from running live within Internet Explorer. Theres now a syntax for block comments, similar in spirit to CoffeeScripts heredocs. ECMA Harmony DRY-style pattern matching is now supported, where the name of the property is the same as the name of the value: `{name, length}: func`. Pattern matching is now allowed within comprehension variables. `unless` is now allowed in block form. `until` loops were added, as the inverse of `while` loops. `switch` statements are now allowed without switch object clauses. Compatible with Node.js **v0.1.95**.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-06-28', '0.7.0', '0.6.2')
```
Official CoffeeScript variable style is now camelCase, as in JavaScript. Reserved words are now allowed as object keys, and will be quoted for you. Range comprehensions now generate cleaner code, but you have to specify `by -1` if youd like to iterate downward. Reporting of syntax errors is greatly improved from the previous release. Running `coffee` with no arguments now launches the REPL, with Readline support. The `<-` bind operator has been removed from CoffeeScript. The `loop` keyword was added, which is equivalent to a `while true` loop. Comprehensions that contain closures will now close over their variables, like the semantics of a `forEach`. You can now use bound function in class definitions (bound to the instance). For consistency, `a in b` is now an array presence check, and `a of b` is an object-key check. Comments are no longer passed through to the generated JavaScript.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-07-11', '0.7.1', '0.7.0')
```
Block-style comments are now passed through and printed as JavaScript block comments making them useful for licenses and copyright headers. Better support for running coffee scripts standalone via hashbangs. Improved syntax errors for tokens that are not in the grammar.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-07-12', '0.7.2', '0.7.1')
```
Quick bugfix (right after 0.7.1) for a problem that prevented `coffee` command-line options from being parsed in some circumstances.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-08-04', '0.9.0', '0.7.2')
```
The CoffeeScript **0.9** series is considered to be a release candidate for **1.0**; lets give her a shakedown cruise. **0.9.0** introduces a massive backwards-incompatible change: Assignment now uses `=`, and object literals use `:`, as in JavaScript. This allows us to have implicit object literals, and YAML-style object definitions. Half assignments are removed, in favor of `+=`, `or=`, and friends. Interpolation now uses a hash mark `#` instead of the dollar sign `$` — because dollar signs may be part of a valid JS identifier. Downwards range comprehensions are now safe again, and are optimized to straight for loops when created with integer endpoints. A fast, unguarded form of object comprehension was added: `for all key, value of object`. Mentioning the `super` keyword with no arguments now forwards all arguments passed to the function, as in Ruby. If you extend class `B` from parent class `A`, if `A` has an `extended` method defined, it will be called, passing in `B` — this enables static inheritance, among other things. Cleaner output for functions bound with the fat arrow. `@variables` can now be used in parameter lists, with the parameter being automatically set as a property on the object — useful in constructors and setter functions. Constructor functions can now take splats.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-08-11', '0.9.1', '0.9.0')
```
Bugfix release for **0.9.1**. Greatly improves the handling of mixed implicit objects, implicit function calls, and implicit indentation. String and regex interpolation is now strictly `#{ … }` (Ruby style). The compiler now takes a `--require` flag, which specifies scripts to run before compilation.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-08-23', '0.9.2', '0.9.1')
```
Specifying the start and end of a range literal is now optional, eg. `array[3..]`. You can now say `a not instanceof b`. Fixed important bugs with nested significant and non-significant indentation (Issue #637). Added a `--require` flag that allows you to hook into the `coffee` command. Added a custom `jsl.conf` file for our preferred JavaScriptLint setup. Sped up Jison grammar compilation time by flattening rules for operations. Block comments can now be used with JavaScript-minifier-friendly syntax. Added JavaScripts compound assignment bitwise operators. Bugfixes to implicit object literals with leading number and string keys, as the subject of implicit calls, and as part of compound assignment.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-09-16', '0.9.3', '0.9.2')
```
CoffeeScript `switch` statements now compile into JS `switch` statements — they previously compiled into `if/else` chains for JavaScript 1.3 compatibility. Soaking a function invocation is now supported. Users of the RubyMine editor should now be able to use `--watch` mode.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-09-21', '0.9.4', '0.9.3')
```
CoffeeScript now uses appropriately-named temporary variables, and recycles their references after use. Added `require.extensions` support for **Node.js 0.3**. Loading CoffeeScript in the browser now adds just a single `CoffeeScript` object to global scope. Fixes for implicit object and block comment edge cases.

View File

@@ -0,0 +1,7 @@
```
releaseHeader('2010-11-21', '0.9.5', '0.9.4')
```
0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from **satyr**s [Coco](https://github.com/satyr/coco) dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. `undefined` now works like `null`, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: `result = i for i in list`
used to parse as `result = (i for i in list)` by default … it now parses as
`(result = i) for i in list`.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-12-06', '0.9.6', '0.9.5')
```
The REPL now properly formats stacktraces, and stays alive through asynchronous exceptions. Using `--watch` now prints timestamps as files are compiled. Fixed some accidentally-leaking variables within plucked closure-loops. Constructors now maintain their declaration location within a class body. Dynamic object keys were removed. Nested classes are now supported. Fixes execution context for naked splatted functions. Bugfix for inversion of chained comparisons. Chained class instantiation now works properly with splats.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2010-12-24', '1.0.0', '0.9.6')
```
CoffeeScript loops no longer try to preserve block scope when functions are being generated within the loop body. Instead, you can use the `do` keyword to create a convenient closure wrapper. Added a `--nodejs` flag for passing through options directly to the `node` executable. Better behavior around the use of pure statements within expressions. Fixed inclusive slicing through `-1`, for all browsers, and splicing with arbitrary expressions as endpoints.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2011-01-31', '1.0.1', '1.0.0')
```
Fixed a lexer bug with Unicode identifiers. Updated REPL for compatibility with Node.js 0.3.7\. Fixed requiring relative paths in the REPL. Trailing `return` and `return undefined` are now optimized away. Stopped requiring the core Node.js `util` module for back-compatibility with Node.js 0.2.5\. Fixed a case where a conditional `return` would cause fallthrough in a `switch` statement. Optimized empty objects in destructuring assignment.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2011-05-01', '1.1.0', '1.0.1')
```
When running via the `coffee` executable, `process.argv` and friends now report `coffee` instead of `node`. Better compatibility with **Node.js 0.4.x** module lookup changes. The output in the REPL is now colorized, like Nodes is. Giving your concatenated CoffeeScripts a name when using `--join` is now mandatory. Fix for lexing compound division `/=` as a regex accidentally. All `text/coffeescript` tags should now execute in the order theyre included. Fixed an issue with extended subclasses using external constructor functions. Fixed an edge-case infinite loop in `addImplicitParentheses`. Fixed exponential slowdown with long chains of function calls. Globals no longer leak into the CoffeeScript REPL. Splatted parameters are declared local to the function.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2011-05-10', '1.1.1', '1.1.0')
```
Bugfix release for classes with external constructor functions, see issue #1182.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2011-08-04', '1.1.2', '1.1.1')
```
Fixes for block comment formatting, `?=` compilation, implicit calls against control structures, implicit invocation of a try/catch block, variadic arguments leaking from local scope, line numbers in syntax errors following heregexes, property access on parenthesized number literals, bound class methods and super with reserved names, a REPL overhaul, consecutive compiled semicolons, block comments in implicitly called objects, and a Chrome bug.

View File

@@ -0,0 +1,11 @@
```
releaseHeader('2011-11-08', '1.1.3', '1.1.2')
```
* Ahh, whitespace. CoffeeScripts compiled JS now tries to space things out and keep it readable, as you can see in the examples on this page.
* You can now call `super` in class level methods in class bodies, and bound class methods now preserve their correct context.
* JavaScript has always supported octal numbers `010 is 8`, and hexadecimal numbers `0xf is 15`, but CoffeeScript now also supports binary numbers: `0b10 is 2`.
* The CoffeeScript module has been nested under a subdirectory to make it easier to `require` individual components separately, without having to use **npm**. For example, after adding the CoffeeScript folder to your path: `require('coffeescript/lexer')`
* Theres a new “link” feature in Try CoffeeScript on this webpage. Use it to get a shareable permalink for your example script.
* The `coffee --watch` feature now only works on Node.js 0.6.0 and higher, but now also works properly on Windows.
* Lots of small bug fixes from **[@michaelficarra](https://github.com/michaelficarra)**, **[@geraldalewis](https://github.com/geraldalewis)**, **[@satyr](https://github.com/satyr)**, and **[@trevorburnham](https://github.com/trevorburnham)**.

View File

@@ -0,0 +1,11 @@
```
releaseHeader('2015-09-03', '1.10.0', '1.9.3')
```
* CoffeeScript now supports ES2015-style destructuring defaults.
* `(offsetHeight: height) ->` no longer compiles. That syntax was accidental and partly broken. Use `({offsetHeight: height}) ->` instead. Object destructuring always requires braces.
* Several minor bug fixes, including:
* A bug where the REPL would sometimes report valid code as invalid, based on what you had typed earlier.
* A problem with multiple JS contexts in the jest test framework.
* An error in io.js where strict mode is set on internal modules.
* A variable name clash for the caught error in `catch` blocks.

View File

@@ -0,0 +1,31 @@
```
releaseHeader('2016-09-24', '1.11.0', '1.10.0')
```
* CoffeeScript now supports ES2015 [`import` and `export` syntax](#modules).
* Added the `-M, --inline-map` flag to the compiler, allowing you embed the source map directly into the output JavaScript, rather than as a separate file.
* A bunch of fixes for `yield`:
* `yield return` can no longer mistakenly be used as an expression.
* `yield` now mirrors `return` in that it can be used stand-alone as well as with expressions. Where you previously wrote `yield undefined`, you may now write simply `yield`. However, this means also inheriting the same syntax limitations that `return` has, so these examples no longer compile:
```
doubles = ->
yield for i in [1..3]
i * 2
six = ->
yield
2 * 3
```
* The JavaScript output is a bit nicer, with unnecessary parentheses and spaces, double indentation and double semicolons around `yield` no longer present.
* `&&=`, `||=`, `and=` and `or=` no longer accidentally allow a space before the equals sign.
* Improved several error messages.
* Just like `undefined` compiles to `void 0`, `NaN` now compiles into `0/0` and `Infinity` into `2e308`.
* Bugfix for renamed destructured parameters with defaults. `({a: b = 1}) ->` no longer crashes the compiler.
* Improved the internal representation of a CoffeeScript program. This is only noticeable to tools that use `CoffeeScript.tokens` or `CoffeeScript.nodes`. Such tools need to update to take account for changed or added tokens and nodes.
* Several minor bug fixes, including:
* The caught error in `catch` blocks is no longer declared unnecessarily, and no longer mistakenly named `undefined` for `catch`-less `try` blocks.
* Unassignable parameter destructuring no longer crashes the compiler.
* Source maps are now used correctly for errors thrown from .coffee.md files.
* `coffee -e 'throw null'` no longer crashes.
* The REPL no longer crashes when using `.exit` to exit it.
* Invalid JavaScript is no longer output when lots of `for` loops are used in the same scope.
* A unicode issue when using stdin with the CLI.

View File

@@ -0,0 +1,8 @@
```
releaseHeader('2016-10-02', '1.11.1', '1.11.0')
```
* Bugfix for shorthand object syntax after interpolated keys.
* Bugfix for indentation-stripping in `"""` strings.
* Bugfix for not being able to use the name “arguments” for a prototype property of class.
* Correctly compile large hexadecimal numbers literals to `2e308` (just like all other large number literals do).

View File

@@ -0,0 +1,12 @@
```
releaseHeader('2016-12-04', '1.12.0', '1.11.1')
```
* CoffeeScript now supports ES2015 [tagged template literals](#tagged-template-literals). Note that using tagged template literals in your code makes you responsible for ensuring that either your runtime supports tagged template literals or that you transpile the output JavaScript further to a version your target runtime(s) support.
* CoffeeScript now provides a [`for…from`](#generator-iteration) syntax for outputting ES2015 [`for…of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of). (Sorry they couldnt match, but we came up with `for…of` first for something else.) This allows iterating over generators or any other iterable object. Note that using `for…from` in your code makes you responsible for ensuring that either your runtime supports `for…of` or that you transpile the output JavaScript further to a version your target runtime(s) support.
* Triple backticks (`` `````) allow the creation of embedded JavaScript blocks where escaping single backticks is not required, which should improve interoperability with ES2015 template literals and with Markdown.
* Within single-backtick embedded JavaScript, backticks can now be escaped via `` \```.
* The browser tests now run in the browser again, and are accessible [here](/v<%= majorVersion %>/test.html) if you would like to test your browser.
* CoffeeScript-only keywords in ES2015 `import`s and `export`s are now ignored.
* The compiler now throws an error on trying to export an anonymous class.
* Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.

View File

@@ -0,0 +1,6 @@
```
releaseHeader('2016-12-07', '1.12.1', '1.12.0')
```
* You can now import a module member named `default`, e.g. `import { default } from 'lib'`. Though like in ES2015, you cannot import an entire module and name it `default` (so `import default from 'lib'` is not allowed).
* Fix regression where `from` as a variable name was breaking `for` loop declarations. For the record, `from` is not a reserved word in CoffeeScript; you may use it for variable names. `from` behaves like a keyword within the context of `import` and `export` statements, and in the declaration of a `for` loop; though you should also be able to use variables named `from` in those contexts, and the compiler should be able to tell the difference.

View File

@@ -0,0 +1,8 @@
```
releaseHeader('2016-12-16', '1.12.2', '1.12.1')
```
* The browser compiler can once again be built unminified via `MINIFY=false cake build:browser`.
* The error-prone patched version of `Error.prepareStackTrace` has been removed.
* Command completion in the REPL (pressing tab to get suggestions) has been fixed for Node 6.9.1+.
* The [browser-based tests](/v<%= majorVersion %>/test.html) now include all the tests as the Node-based version.

View File

@@ -0,0 +1,7 @@
```
releaseHeader('2017-01-24', '1.12.3', '1.12.2')
```
* `@` values can now be used as indices in `for` expressions. This loosens the compilation of `for` expressions to allow the index variable to be an `@` value, e.g. `do @visit for @node, @index in nodes`. Within `@visit`, the index of the current node (`@node`) would be available as `@index`.
* CoffeeScripts patched `Error.prepareStackTrace` has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2.
* The `//=` operators output now wraps parentheses around the right operand, like the other assignment operators.

View File

@@ -0,0 +1,8 @@
```
releaseHeader('2017-02-18', '1.12.4', '1.12.3')
```
* The `cake` commands have been updated, with new `watch` options for most tasks. Clone the [CoffeeScript repo](https://github.com/jashkenas/coffeescript) and run `cake` at the root of the repo to see the options.
* Fixed a bug where `export`ing a referenced variable was preventing the variable from being declared.
* Fixed a bug where the `coffee` command wasnt working for a `.litcoffee` file.
* Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.

View File

@@ -0,0 +1,6 @@
```
releaseHeader('2017-04-10', '1.12.5', '1.12.4')
```
* Better handling of `default`, `from`, `as` and `*` within `import` and `export` statements. You can now import or export a member named `default` and the compiler wont interpret it as the `default` keyword.
* Fixed a bug where invalid octal escape sequences werent throwing errors in the compiler.

View File

@@ -0,0 +1,10 @@
```
releaseHeader('2017-05-15', '1.12.6', '1.12.5')
```
* The `return` and `export` keywords can now accept implicit objects (defined by indentation, without needing braces).
* Support Unicode code point escapes (e.g. `\u{1F4A9}`).
* The `coffee` command now first looks to see if CoffeeScript is installed under `node_modules` in the current folder, and executes the `coffee` binary there if so; or otherwise it runs the globally installed one. This allows you to have one version of CoffeeScript installed globally and a different one installed locally for a particular project. (Likewise for the `cake` command.)
* Bugfixes for chained function calls not closing implicit objects or ternaries.
* Bugfixes for incorrect code generated by the `?` operator within a termary `if` statement.
* Fixed some tests, and failing tests now result in a nonzero exit code.

View File

@@ -0,0 +1,6 @@
```
releaseHeader('2017-07-16', '1.12.7', '1.12.6')
```
* Fix regressions in 1.12.6 related to chained function calls and indented `return` and `throw` arguments.
* The REPL no longer warns about assigning to `_`.

View File

@@ -0,0 +1,8 @@
```
releaseHeader('2011-12-18', '1.2.0', '1.1.3')
```
* Multiple improvements to `coffee --watch` and `--join`. You may now use both together, as well as add and remove files and directories within a `--watch`d folder.
* The `throw` statement can now be used as part of an expression.
* Block comments at the top of the file will now appear outside of the safety closure wrapper.
* Fixed a number of minor 1.1.3 regressions having to do with trailing operators and unfinished lines, and a more major 1.1.3 regression that caused bound functions _within_ bound class functions to have the incorrect `this`.

View File

@@ -0,0 +1,12 @@
```
releaseHeader('2012-04-10', '1.3.1', '1.2.0')
```
* CoffeeScript now enforces all of JavaScripts **Strict Mode** early syntax errors at compile time. This includes old-style octal literals, duplicate property names in object literals, duplicate parameters in a function definition, deleting naked variables, setting the value of `eval` or `arguments`, and more. See a full discussion at [#1547](https://github.com/jashkenas/coffeescript/issues/1547).
* The REPL now has a handy new multi-line mode for entering large blocks of code. Its useful when copy-and-pasting examples into the REPL. Enter multi-line mode with `Ctrl-V`. You may also now pipe input directly into the REPL.
* CoffeeScript now prints a `Generated by CoffeeScript VERSION` header at the top of each compiled file.
* Conditional assignment of previously undefined variables `a or= b` is now considered a syntax error.
* A tweak to the semantics of `do`, which can now be used to more easily simulate a namespace: `do (x = 1, y = 2) -> …`
* Loop indices are now mutable within a loop iteration, and immutable between them.
* Both endpoints of a slice are now allowed to be omitted for consistency, effectively creating a shallow copy of the list.
* Additional tweaks and improvements to `coffee --watch` under Nodes “new” file watching API. Watch will now beep by default if you introduce a syntax error into a watched script. We also now ignore hidden directories by default when watching recursively.

View File

@@ -0,0 +1,9 @@
```
releaseHeader('2012-05-15', '1.3.3', '1.3.1')
```
* Due to the new semantics of JavaScripts strict mode, CoffeeScript no longer guarantees that constructor functions have names in all runtimes. See [#2052](https://github.com/jashkenas/coffeescript/issues/2052) for discussion.
* Inside of a nested function inside of an instance method, its now possible to call `super` more reliably (walks recursively up).
* Named loop variables no longer have different scoping heuristics than other local variables. (Reverts #643)
* Fix for splats nested within the LHS of destructuring assignment.
* Corrections to our compile time strict mode forbidding of octal literals.

View File

@@ -0,0 +1,7 @@
```
releaseHeader('2012-10-23', '1.4.0', '1.3.3')
```
* The CoffeeScript compiler now strips Microsofts UTF-8 BOM if it exists, allowing you to compile BOM-borked source files.
* Fix Node/compiler deprecation warnings by removing `registerExtension`, and moving from `path.exists` to `fs.exists`.
* Small tweaks to splat compilation, backticks, slicing, and the error for duplicate keys in object literals.

View File

@@ -0,0 +1,9 @@
```
releaseHeader('2013-02-25', '1.5.0', '1.4.0')
```
* First release of [Literate CoffeeScript](#literate).
* The CoffeeScript REPL is now based on the Node.js REPL, and should work better and more familiarly.
* Returning explicit values from constructors is now forbidden. If you want to return an arbitrary value, use a function, not a constructor.
* You can now loop over an array backwards, without having to manually deal with the indexes: `for item in list by -1`
* Source locations are now preserved in the CoffeeScript AST, although source maps are not yet being emitted.

View File

@@ -0,0 +1,8 @@
```
releaseHeader('2013-03-05', '1.6.1', '1.5.0')
```
* First release of [source maps](#source-maps). Pass the `--map` flag to the compiler, and off you go. Direct all your thanks over to [Jason Walton](https://github.com/jwalton).
* Fixed a 1.5.0 regression with multiple implicit calls against an indented implicit object. Combinations of implicit function calls and implicit objects should generally be parsed better now — but it still isnt good _style_ to nest them too heavily.
* `.coffee.md` is now also supported as a Literate CoffeeScript file extension, for existing tooling. `.litcoffee` remains the canonical one.
* Several minor fixes surrounding member properties, bound methods and `super` in class declarations.

View File

@@ -0,0 +1,8 @@
```
releaseHeader('2013-03-18', '1.6.2', '1.6.1')
```
* Source maps have been used to provide automatic line-mapping when running CoffeeScript directly via the `coffee` command, and for automatic line-mapping when running CoffeeScript directly in the browser. Also, to provide better error messages for semantic errors thrown by the compiler — [with colors, even](http://cl.ly/NdOA).
* Improved support for mixed literate/vanilla-style CoffeeScript projects, and generating source maps for both at the same time.
* Fixes for **1.6.x** regressions with overriding inherited bound functions, and for Windows file path management.
* The `coffee` command can now correctly `fork()` both `.coffee` and `.js` files. (Requires Node.js 0.9+)

View File

@@ -0,0 +1,8 @@
```
releaseHeader('2013-06-02', '1.6.3', '1.6.2')
```
* The CoffeeScript REPL now remembers your history between sessions. Just like a proper REPL should.
* You can now use `require` in Node to load `.coffee.md` Literate CoffeeScript files. In the browser, `text/literate-coffeescript` script tags.
* The old `coffee --lint` command has been removed. It was useful while originally working on the compiler, but has been surpassed by JSHint. You may now use `-l` to pass literate files in over **stdio**.
* Bugfixes for Windows path separators, `catch` without naming the error, and executable-class-bodies-with- prototypal-property-attachment.

View File

@@ -0,0 +1,14 @@
```
releaseHeader('2014-01-28', '1.7.0', '1.6.3')
```
* When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with `require 'coffeescript/register'` or `CoffeeScript.register()`. Also for configuration such as Mochas, use **coffeescript/register**.
* Improved error messages, source maps and stack traces. Source maps now use the updated `//#` syntax.
* Leading `.` now closes all open calls, allowing for simpler chaining syntax.
* Added `**`, `//` and `%%` operators and `...` expansion in parameter lists and destructuring expressions.
* Multiline strings are now joined by a single space and ignore all indentation. A backslash at the end of a line can denote the amount of whitespace between lines, in both strings and heredocs. Backslashes correctly escape whitespace in block regexes.
* Closing brackets can now be indented and therefore no longer cause unexpected error.
* Several breaking compilation fixes. Non-callable literals (strings, numbers etc.) dont compile in a call now and multiple postfix conditionals compile properly. Postfix conditionals and loops always bind object literals. Conditional assignment compiles properly in subexpressions. `super` is disallowed outside of methods and works correctly inside `for` loops.
* Formatting of compiled block comments has been improved.
* No more `-p` folders on Windows.
* The `options` object passed to CoffeeScript is no longer mutated.

View File

@@ -0,0 +1,5 @@
```
releaseHeader('2014-01-29', '1.7.1', '1.7.0')
```
* Fixed a typo that broke node module lookup when running a script directly with the `coffee` binary.

Some files were not shown because too many files have changed in this diff Show More