exports.VERSION = '1.12.1'
-
-exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md']The current CoffeeScript version number.
+Require package.json, which is two levels above this file, as this file is
+evaluated from lib/coffee-script.
exports.VERSION = '1.12.1'
-
-exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md']packageJson = require '../../package.json'Expose helpers for testing.
+The current CoffeeScript version number.
-exports.helpers = helpersexports.VERSION = packageJson.version
+
+exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md']Expose helpers for testing.
+ + + +exports.helpers = helpersFunction that allows for btoa in both nodejs and the browser.
The contents of a <script> block are encoded via UTF-16, so if any extended
characters are used in the block, btoa will fail as it maxes out at UTF-8.
@@ -205,11 +221,11 @@ for the gory details, and for the solution implemented here.
Function wrapper to add source file information to SyntaxErrors thrown by the lexer/parser/compiler.
@@ -227,11 +243,11 @@ lexer/parser/compiler. -Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.
If options.sourceMap is specified, then options.filename must also be specified. All
@@ -256,11 +272,11 @@ lookups.
Pass a list of referenced variables, so that generated variables won’t get the same name.
@@ -274,11 +290,11 @@ the same name. -Check for import or export; if found, force bare mode
@@ -302,11 +318,11 @@ the same name. -Update the sourcemap with data from each fragment
@@ -317,11 +333,11 @@ the same name. -Do not include empty, whitespace, or semicolon-only fragments.
@@ -342,11 +358,11 @@ the same name. -Copy the code from each fragment into the final JavaScript.
@@ -379,11 +395,11 @@ the same name. -Tokenize a string of CoffeeScript code, and return the array of tokens.
@@ -395,11 +411,11 @@ the same name. -Parse a string of CoffeeScript code or an array of lexed tokens, and
return the AST. You can then compile it by calling .compile() on the root,
@@ -416,11 +432,11 @@ or traverse it by using .traverseChildren() with a callback.
Compile and execute a string of CoffeeScript (on the server), correctly
setting __filename, __dirname, and relative require().
__filename, __dirname, and relative requ
-
+
Set the filename.
@@ -449,11 +465,11 @@ setting __filename, __dirname, and relative requ
-
+
Clear the module cache.
@@ -464,11 +480,11 @@ setting __filename, __dirname, and relative requ
-
+
Assign paths for node_modules loading
@@ -483,11 +499,11 @@ setting __filename, __dirname, and relative requ
-
+
Compile.
@@ -502,11 +518,11 @@ setting __filename, __dirname, and relative requ
-
+
Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
The CoffeeScript REPL uses this to run the input.
@@ -536,11 +552,11 @@ The CoffeeScript REPL uses this to run the input.
-
+
define module/require only if they chose not to specify their own
@@ -557,11 +573,11 @@ The CoffeeScript REPL uses this to run the input.
-
+
use the same hack node currently uses for their own REPL
@@ -583,11 +599,11 @@ exports.register = ->
+
Throw error with deprecation warning when depending upon implicit require.extensions registration
@@ -615,11 +631,11 @@ exports._compileFile = (fi
-
+
As the filename and code of a dynamically loaded file will be different
from the original file compiled with CoffeeScript.run, add that
@@ -634,11 +650,11 @@ information to error so it can be pretty-printed later.
-
+
Instantiate a Lexer for our use here.
@@ -649,11 +665,11 @@ information to error so it can be pretty-printed later.
-
+
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
@@ -681,11 +697,11 @@ directly as a “Jison lexer”.
-
+
Make all the AST nodes visible to the parser.
@@ -696,11 +712,11 @@ directly as a “Jison lexer”.
-
+
Override Jison’s default error handling function.
@@ -711,11 +727,11 @@ directly as a “Jison lexer”.
-
+
Disregard Jison’s message, it contains redundant line number information.
Disregard the token, we take its value directly from the lexer in case
@@ -739,11 +755,11 @@ the error is caused by a generated token which might refer to its origin.
-
+
The second argument has a loc property, which should have the location
data for this token. Unfortunately, Jison seems to send an outdated loc
@@ -756,147 +772,6 @@ from the lexer.
-
-
-
-
-
- ¶
-
- Based on http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js
-Modified to handle sourceMap
-
-
-
- formatSourcePosition = (frame, getSourceMapping) ->
- fileName = undefined
- fileLocation = ''
-
- if frame.isNative()
- fileLocation = "native"
- else
- if frame.isEval()
- fileName = frame.getScriptNameOrSourceURL()
- fileLocation = "#{frame.getEvalOrigin()}, " unless fileName
- else
- fileName = frame.getFileName()
-
- fileName or= "<anonymous>"
-
- line = frame.getLineNumber()
- column = frame.getColumnNumber()
-
-
-
-
-
-
-
-
- ¶
-
- Check for a sourceMap position
-
-
-
- source = getSourceMapping fileName, line, column
- fileLocation =
- if source
- "#{fileName}:#{source[0]}:#{source[1]}"
- else
- "#{fileName}:#{line}:#{column}"
-
- functionName = frame.getFunctionName()
- isConstructor = frame.isConstructor()
- isMethodCall = not (frame.isToplevel() or isConstructor)
-
- if isMethodCall
- methodName = frame.getMethodName()
- typeName = frame.getTypeName()
-
- if functionName
- tp = as = ''
- if typeName and functionName.indexOf typeName
- tp = "#{typeName}."
- if methodName and functionName.indexOf(".#{methodName}") isnt functionName.length - methodName.length - 1
- as = " [as #{methodName}]"
-
- "#{tp}#{functionName}#{as} (#{fileLocation})"
- else
- "#{typeName}.#{methodName or '<anonymous>'} (#{fileLocation})"
- else if isConstructor
- "new #{functionName or '<anonymous>'} (#{fileLocation})"
- else if functionName
- "#{functionName} (#{fileLocation})"
- else
- fileLocation
-
-
-
-
-
-
-
-
- ¶
-
- Map of filenames -> sourceMap object.
-
-
-
- sourceMaps = {}
-
-
-
-
-
-
-
-
- ¶
-
- Generates the source map for a coffee file and stores it in the local cache variable.
-
-
-
- getSourceMap = (filename) ->
- return sourceMaps[filename] if sourceMaps[filename]
- for ext in exports.FILE_EXTENSIONS
- if helpers.ends filename, ext
- answer = exports._compileFile filename, true
- return sourceMaps[filename] = answer.sourceMap
- return null
-
-
-
-
-
-
-
-
- ¶
-
- Based on michaelficarra/CoffeeScriptRedux
-NodeJS / V8 have no support for transforming positions in stack traces using
-sourceMap, so we must monkey-patch Error to display CoffeeScript source
-positions.
-
-
-
- Error.prepareStackTrace = (err, stack) ->
- getSourceMapping = (filename, line, column) ->
- sourceMap = getSourceMap filename
- answer = sourceMap.sourceLocation [line - 1, column - 1] if sourceMap
- if answer then [answer[0] + 1, answer[1] + 1] else null
-
- frames = for frame in stack
- break if frame.getFunction() is exports.run
- " at #{formatSourcePosition frame, getSourceMapping}"
-
- "#{err.toString()}\n#{frames.join '\n'}\n"
-
-
-