id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
flosse/sloc:src/sloc.coffee:4:raw_corpus | raw_corpus | countComments = (code, regex) ->
myself = (code, idx, res) ->
return res if code is ''
start = regex.start?.exec code
single = regex.single?.exec code
return res unless start or single
type = getType single, start
match = switch type
when 'single' then single
when 'block' th... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 38 | 74 | ||
flosse/sloc:src/sloc.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
countComments = (code, regex) ->
myself = (code, idx, res) ->
return res if code is ''
start = regex.start?.exec code
single = regex.single?.exec code
return res unless start or single
type = getType single, start
match = switch ty... | var countComments;
countComments = function(code, regex) {
var myself;
myself = function(code, idx, res) {
var cContentIdx, comment, len, lines, match, ref, ref1, ref2, single, splitAt, start, startIdx, stop, type;
if (code === '') {
return res;
}
start = (ref = regex.start) != null ? ref.exe... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 38 | 74 |
flosse/sloc:src/sloc.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var countComments;
countComments = function(code, regex) {
var myself;
myself = function(code, idx, res) {
var cContentIdx, comment, len, lines, match, ref, ref1, ref2, single, splitAt, start, startIdx, stop, type;
if (code === '') {
return res;
... | countComments = (code, regex) ->
myself = (code, idx, res) ->
return res if code is ''
start = regex.start?.exec code
single = regex.single?.exec code
return res unless start or single
type = getType single, start
match = switch type
when 'single' then single
when 'block' th... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 38 | 74 |
flosse/sloc:src/sloc.coffee:4:completion | completion | countComments = (code, regex) ->
myself = (code, idx, res) ->
return res if code is ''
start = regex.start?.exec code
single = regex.single?.exec code
return res unless start or single
type = getType single, start
match = switch type
when 'single' then single
when 'block' th... | lines = code.substring(0, match.index).split '\n'
startIdx = lines.length - 1 + idx
stop = getStop comment, type, regex
unless stop
res.push type:'error', start: idx, stop: idx
return res
comment = comment.substring 0, stop.index
len = comment.match(newLines)?.lengt... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 38 | 74 |
flosse/sloc:src/sloc.coffee:5:raw_corpus | raw_corpus | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffeescript", "coffee", "python", "py"
/\#/
when "javascript", "js", "c", "cc", "java", "php", "php5", "go", "scss", "less", "styl", "stylus"
/\/{2}/
when "lua"
/--/
when "erl"
... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 76 | 118 | ||
flosse/sloc:src/sloc.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffeescript", "coffee", "python", "py"
/\#/
when "javascript", "js", "c", "cc", "java", "php", "php5", "go", "scss", "less", "styl", "stylus"
... | var getCommentExpressions;
getCommentExpressions = function(lang) {
var single, start, stop;
// single line comments
single = (function() {
switch (lang) {
case "coffeescript":
case "coffee":
case "python":
case "py":
return /\#/;
case "javascript":
case "js":
... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 76 | 118 |
flosse/sloc:src/sloc.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var getCommentExpressions;
getCommentExpressions = function(lang) {
var single, start, stop;
// single line comments
single = (function() {
switch (lang) {
case "coffeescript":
case "coffee":
case "python":
case "py":
retu... | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffeescript", "coffee", "python", "py"
/\#/
when "javascript", "js", "c", "cc", "java", "php", "php5", "go", "scss", "less", "styl", "stylus"
/\/{2}/
when "lua"
/--/
when "erl"
... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 76 | 118 |
flosse/sloc:src/sloc.coffee:5:completion | completion | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffeescript", "coffee", "python", "py"
/\#/
when "javascript", "js", "c", "cc", "java", "php", "php5", "go", "scss", "less", "styl", "stylus"
/\/{2}/
when "lua"
/--/
when "erl"
... | when "javascript", "js", "c", "cc", "java", "php", "php5", "go", "css", "scss", "less", "styl", "stylus"
start = /\/\*+/
stop = /\*\/{1}/
when "python", "py"
start = stop = /\"{3}|\'{3}/
when "html"
start = /<\!--/
stop = /-->/
when "lua"
start = /--\[{2}/
stop... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 76 | 118 |
flosse/sloc:src/sloc.coffee:7:raw_corpus | raw_corpus | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
loc = 1 + code.match(newLines)?.length or 0
nloc = code.match(/^\s*$/mg)?.length or 0
comments = countComments code, getCommentExpressions lang
res =
block : []
mixed : []
singl... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 124 | 173 | ||
flosse/sloc:src/sloc.coffee:7:completion | completion | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
loc = 1 + code.match(newLines)?.length or 0
nloc = code.match(/^\s*$/mg)?.length or 0
comments = countComments code, getCommentExpressions lang
res =
block : []
mixed : []
singl... | cloc = 0
for b, i in res.block
d = (b.stop - b.start) + 1
if (s for s in res.single when s.start is b.start or s.start is b.stop).length > 0
d -= 3
cloc += d
scloc = lineSum res.single
cloc += scloc
mcloc= lineSum res.block
mxloc= lineSum res.mixed
sloc = loc - scloc - mcloc - nloc + mx... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 124 | 173 |
flosse/sloc:src/sloc.coffee:8:raw_corpus | raw_corpus | "java"
"php", "php5"
"go"
"lua"
"scss"
"less"
"css"
"styl", "stylus"
"html" ]
slocModule.keys = keys
# AMD support
if define?.amd? then define -> slocModule
# Node.js support
else if module?.exports? then module.exports = slocModule
# Browser support
else if window? then window.sloc = slocModule | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 174 | 193 | ||
flosse/sloc:src/sloc.coffee:8:completion | completion | "java"
"php", "php5"
"go"
"lua"
"scss"
"less"
"css"
"styl", "stylus"
"html" ] | slocModule.keys = keys
# AMD support
if define?.amd? then define -> slocModule
# Node.js support
else if module?.exports? then module.exports = slocModule
# Browser support
else if window? then window.sloc = slocModule | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 174 | 193 |
flosse/sloc:src/sloc.coffee:2:raw_corpus | raw_corpus | slocModule = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php", "go", "scss"
comment = combi... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bb24947d23c6095856e71e9e8eb83035d1696990 | 969 | https://github.com/flosse/sloc/blob/bb24947d23c6095856e71e9e8eb83035d1696990/src/sloc.coffee | 77 | 126 | ||
flosse/sloc:src/sloc.coffee:2:completion | completion | slocModule = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php", "go", "scss"
comment = combi... | stopMultiLineComment = starSlashComment
when "python", "py"
startMultiLineComment = trippleQuoteComment
stopMultiLineComment = trippleQuoteComment
else
throw new TypeError "File extension '#{lang}' is not supported"
commentLineNumbers = []
nullLineNumbers = []
lines = code.spl... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bb24947d23c6095856e71e9e8eb83035d1696990 | 969 | https://github.com/flosse/sloc/blob/bb24947d23c6095856e71e9e8eb83035d1696990/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:3:raw_corpus | raw_corpus | start = true
startLine = i
else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test l
cCounter++
commentLineNumbers.push i
slo... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bb24947d23c6095856e71e9e8eb83035d1696990 | 969 | https://github.com/flosse/sloc/blob/bb24947d23c6095856e71e9e8eb83035d1696990/src/sloc.coffee | 127 | 161 | ||
flosse/sloc:src/sloc.coffee:3:completion | completion | start = true
startLine = i
else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test l
cCounter++
commentLineNumbers.push i
slo... | loc: loc # physical lines of code
sloc: sloc # source loc
cloc: totalC # total comment loc
scloc: cCounter # single line comments
mcloc: bCounter # multiline comment loc
nloc: nloc # null loc
# AMD support
if define?.amd?
define -> slocModule
# Browser support
else if... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bb24947d23c6095856e71e9e8eb83035d1696990 | 969 | https://github.com/flosse/sloc/blob/bb24947d23c6095856e71e9e8eb83035d1696990/src/sloc.coffee | 127 | 161 |
flosse/sloc:src/sloc.coffee:2:raw_corpus | raw_corpus | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php", "php5", "go"
comment = c... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 2e5f192b3c33116b610e93fe905f2b9a9816838a | 969 | https://github.com/flosse/sloc/blob/2e5f192b3c33116b610e93fe905f2b9a9816838a/src/sloc.coffee | 78 | 127 | ||
flosse/sloc:src/sloc.coffee:2:completion | completion | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php", "php5", "go"
comment = c... | when "javascript", "js", "c", "cc", "java", "php", "php5", "go", "css"
startMultiLineComment = slashStarComment
stopMultiLineComment = starSlashComment
when "python", "py"
startMultiLineComment = trippleQuoteComment
stopMultiLineComment = trippleQuoteComment
else
throw new Type... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 2e5f192b3c33116b610e93fe905f2b9a9816838a | 969 | https://github.com/flosse/sloc/blob/2e5f192b3c33116b610e93fe905f2b9a9816838a/src/sloc.coffee | 78 | 127 |
flosse/sloc:src/sloc.coffee:3:raw_corpus | raw_corpus | if start is false and startMultiLineComment.test l
start = true
startLine = i
else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test ... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 2e5f192b3c33116b610e93fe905f2b9a9816838a | 969 | https://github.com/flosse/sloc/blob/2e5f192b3c33116b610e93fe905f2b9a9816838a/src/sloc.coffee | 128 | 163 | ||
flosse/sloc:src/sloc.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
if start is false and startMultiLineComment.test l
start = true
startLine = i
else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bC... | var j, nr, ref, ref1, sloc, start, startLine, totalC, x;
if (start === false && startMultiLineComment.test(l)) {
start = true;
startLine = i;
} else if (start === true && stopMultiLineComment.test(l)) {
start = false;
x = i - startLine + 1;
for (nr = j = ref = startLine, ref1 = i; (ref <= ref1 ? j <= ref1 : ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 2e5f192b3c33116b610e93fe905f2b9a9816838a | 969 | https://github.com/flosse/sloc/blob/2e5f192b3c33116b610e93fe905f2b9a9816838a/src/sloc.coffee | 128 | 163 |
flosse/sloc:src/sloc.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var j, nr, ref, ref1, sloc, start, startLine, totalC, x;
if (start === false && startMultiLineComment.test(l)) {
start = true;
startLine = i;
} else if (start === true && stopMultiLineComment.test(l)) {
start = false;
x = i - startLine + 1;
for (nr = j =... | if start is false and startMultiLineComment.test l
start = true
startLine = i
else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test ... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 2e5f192b3c33116b610e93fe905f2b9a9816838a | 969 | https://github.com/flosse/sloc/blob/2e5f192b3c33116b610e93fe905f2b9a9816838a/src/sloc.coffee | 128 | 163 |
flosse/sloc:src/sloc.coffee:3:completion | completion | if start is false and startMultiLineComment.test l
start = true
startLine = i
else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test ... | loc: loc # physical lines of code
sloc: sloc # source loc
cloc: totalC # total comment loc
scloc: cCounter # single line comments
mcloc: bCounter # multiline comment loc
nloc: nloc # null loc
# AMD support
if define?.amd?
define -> slocModule
# Browser support
else if... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 2e5f192b3c33116b610e93fe905f2b9a9816838a | 969 | https://github.com/flosse/sloc/blob/2e5f192b3c33116b610e93fe905f2b9a9816838a/src/sloc.coffee | 128 | 163 |
flosse/sloc:src/sloc.coffee:2:raw_corpus | raw_corpus | slocModule = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php", "go"
comment = combine doubl... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 5aff10a62d6665ca6201b73a376d09a5ed565feb | 969 | https://github.com/flosse/sloc/blob/5aff10a62d6665ca6201b73a376d09a5ed565feb/src/sloc.coffee | 77 | 126 | ||
flosse/sloc:src/sloc.coffee:2:completion | completion | slocModule = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php", "go"
comment = combine doubl... | stopMultiLineComment = starSlashComment
when "python", "py"
startMultiLineComment = trippleQuoteComment
stopMultiLineComment = trippleQuoteComment
else
throw new TypeError "File extension '#{lang}' is not supported"
commentLineNumbers = []
nullLineNumbers = []
lines = code.spl... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 5aff10a62d6665ca6201b73a376d09a5ed565feb | 969 | https://github.com/flosse/sloc/blob/5aff10a62d6665ca6201b73a376d09a5ed565feb/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:2:raw_corpus | raw_corpus | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php", "go"
comment = combine d... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | e5d089a49fb901ef6b2e8dc3b8667fd6dedcda55 | 969 | https://github.com/flosse/sloc/blob/e5d089a49fb901ef6b2e8dc3b8667fd6dedcda55/src/sloc.coffee | 77 | 126 | ||
flosse/sloc:src/sloc.coffee:2:completion | completion | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php", "go"
comment = combine d... | stopMultiLineComment = starSlashComment
when "python", "py"
startMultiLineComment = trippleQuoteComment
stopMultiLineComment = trippleQuoteComment
else
throw new TypeError "File extension '#{lang}' is not supported"
commentLineNumbers = []
nullLineNumbers = []
lines = code.spl... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | e5d089a49fb901ef6b2e8dc3b8667fd6dedcda55 | 969 | https://github.com/flosse/sloc/blob/e5d089a49fb901ef6b2e8dc3b8667fd6dedcda55/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:3:raw_corpus | raw_corpus | start = true
startLine = i
else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test l
cCounter++
commentLineNumbers.push i
slo... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | e5d089a49fb901ef6b2e8dc3b8667fd6dedcda55 | 969 | https://github.com/flosse/sloc/blob/e5d089a49fb901ef6b2e8dc3b8667fd6dedcda55/src/sloc.coffee | 127 | 149 | ||
flosse/sloc:src/sloc.coffee:3:completion | completion | start = true
startLine = i
else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test l
cCounter++ | commentLineNumbers.push i
sloc = loc - cCounter - bCounter - nloc
totalC = cCounter + bCounter
# result
loc: loc # physical lines of code
sloc: sloc # source loc
cloc: totalC # total comment loc
scloc: cCounter # single line comments
mcloc: bCounter # multiline co... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | e5d089a49fb901ef6b2e8dc3b8667fd6dedcda55 | 969 | https://github.com/flosse/sloc/blob/e5d089a49fb901ef6b2e8dc3b8667fd6dedcda55/src/sloc.coffee | 127 | 149 |
flosse/sloc:src/sloc.coffee:2:raw_corpus | raw_corpus | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php"
comment = combine doubleS... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 1f21865a5eeeec48631aae562d67df63162cd427 | 969 | https://github.com/flosse/sloc/blob/1f21865a5eeeec48631aae562d67df63162cd427/src/sloc.coffee | 77 | 126 | ||
flosse/sloc:src/sloc.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js",... | module.exports = function(code, lang) {
var bCounter, cCounter, comment, commentLineNumbers, i, j, l, len, lines, loc, nloc, nullLineNumbers, results, start, startLine, startMultiLineComment, stopMultiLineComment;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
// single ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 1f21865a5eeeec48631aae562d67df63162cd427 | 969 | https://github.com/flosse/sloc/blob/1f21865a5eeeec48631aae562d67df63162cd427/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
module.exports = function(code, lang) {
var bCounter, cCounter, comment, commentLineNumbers, i, j, l, len, lines, loc, nloc, nullLineNumbers, results, start, startLine, startMultiLineComment, stopMultiLineComment;
if (typeof code !== "string") {
throw new T... | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php"
comment = combine doubleS... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 1f21865a5eeeec48631aae562d67df63162cd427 | 969 | https://github.com/flosse/sloc/blob/1f21865a5eeeec48631aae562d67df63162cd427/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:2:completion | completion | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc", "java", "php"
comment = combine doubleS... | when "python", "py"
startMultiLineComment = trippleQuoteComment
stopMultiLineComment = trippleQuoteComment
else
throw new TypeError "File extension '#{lang}' is not supported"
commentLineNumbers = []
nullLineNumbers = []
lines = code.split '\n'
loc = lines.length
nloc = (for ... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 1f21865a5eeeec48631aae562d67df63162cd427 | 969 | https://github.com/flosse/sloc/blob/1f21865a5eeeec48631aae562d67df63162cd427/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:3:raw_corpus | raw_corpus | else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test l
cCounter++
commentLineNumbers.push i
sloc = loc - cCounter - bCounter - n... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 1f21865a5eeeec48631aae562d67df63162cd427 | 969 | https://github.com/flosse/sloc/blob/1f21865a5eeeec48631aae562d67df63162cd427/src/sloc.coffee | 127 | 147 | ||
flosse/sloc:src/sloc.coffee:3:completion | completion | else if start is true and stopMultiLineComment.test l
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if start is false and comment.test l
cCounter++
commentLineNumbers.push i | sloc = loc - cCounter - bCounter - nloc
totalC = cCounter + bCounter
# result
loc: loc # physical lines of code
sloc: sloc # source loc
cloc: totalC # total comment loc
scloc: cCounter # single line comments
mcloc: bCounter # multiline comment loc
nloc: nloc ... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 1f21865a5eeeec48631aae562d67df63162cd427 | 969 | https://github.com/flosse/sloc/blob/1f21865a5eeeec48631aae562d67df63162cd427/src/sloc.coffee | 127 | 147 |
flosse/sloc:src/sloc.coffee:2:raw_corpus | raw_corpus | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc"
comment = combine doubleSlashComment, si... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 2cbdfbe9374582be997f467fd207555539a135f7 | 969 | https://github.com/flosse/sloc/blob/2cbdfbe9374582be997f467fd207555539a135f7/src/sloc.coffee | 77 | 126 | ||
flosse/sloc:src/sloc.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js",... | module.exports = function(code, lang) {
var bCounter, cCounter, comment, commentLineNumbers, i, j, l, len, lines, loc, nloc, nullLineNumbers, results, start, startLine, startMultiLineComment, stopMultiLineComment;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
// single ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 2cbdfbe9374582be997f467fd207555539a135f7 | 969 | https://github.com/flosse/sloc/blob/2cbdfbe9374582be997f467fd207555539a135f7/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
module.exports = function(code, lang) {
var bCounter, cCounter, comment, commentLineNumbers, i, j, l, len, lines, loc, nloc, nullLineNumbers, results, start, startLine, startMultiLineComment, stopMultiLineComment;
if (typeof code !== "string") {
throw new T... | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc"
comment = combine doubleSlashComment, si... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 2cbdfbe9374582be997f467fd207555539a135f7 | 969 | https://github.com/flosse/sloc/blob/2cbdfbe9374582be997f467fd207555539a135f7/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:2:completion | completion | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c", "cc"
comment = combine doubleSlashComment, si... | when "python", "py"
startMultiLineComment = trippleQuoteComment
stopMultiLineComment = trippleQuoteComment
else
throw new TypeError "File extension '#{lang}' is not supported"
commentLineNumbers = []
nullLineNumbers = []
lines = code.split '\n'
loc = lines.length
nloc = (for ... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 2cbdfbe9374582be997f467fd207555539a135f7 | 969 | https://github.com/flosse/sloc/blob/2cbdfbe9374582be997f467fd207555539a135f7/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:2:raw_corpus | raw_corpus | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c"
comment = combine doubleSlashComment, singleLi... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | be710428f9a881ef44c1417c9e1248216a68c50e | 969 | https://github.com/flosse/sloc/blob/be710428f9a881ef44c1417c9e1248216a68c50e/src/sloc.coffee | 77 | 126 | ||
flosse/sloc:src/sloc.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js",... | module.exports = function(code, lang) {
var bCounter, cCounter, comment, commentLineNumbers, i, j, l, len, lines, loc, nloc, nullLineNumbers, results, start, startMultiLineComment, stopMultiLineComment;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
// single line commen... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | be710428f9a881ef44c1417c9e1248216a68c50e | 969 | https://github.com/flosse/sloc/blob/be710428f9a881ef44c1417c9e1248216a68c50e/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
module.exports = function(code, lang) {
var bCounter, cCounter, comment, commentLineNumbers, i, j, l, len, lines, loc, nloc, nullLineNumbers, results, start, startMultiLineComment, stopMultiLineComment;
if (typeof code !== "string") {
throw new TypeError("'... | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c"
comment = combine doubleSlashComment, singleLi... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | be710428f9a881ef44c1417c9e1248216a68c50e | 969 | https://github.com/flosse/sloc/blob/be710428f9a881ef44c1417c9e1248216a68c50e/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:2:completion | completion | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
# single line comments
switch lang
when "coffeescript", "coffee", "python", "py"
comment = sharpComment
when "javascript", "js", "c"
comment = combine doubleSlashComment, singleLi... | when "python", "py"
startMultiLineComment = trippleQuoteComment
stopMultiLineComment = trippleQuoteComment
else
startMultiLineComment = slashStarComment
stopMultiLineComment = starSlashComment
commentLineNumbers = []
nullLineNumbers = []
lines = code.split '\n'
loc = line... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | be710428f9a881ef44c1417c9e1248216a68c50e | 969 | https://github.com/flosse/sloc/blob/be710428f9a881ef44c1417c9e1248216a68c50e/src/sloc.coffee | 77 | 126 |
flosse/sloc:src/sloc.coffee:3:raw_corpus | raw_corpus | startLine = i
else if stopMultiLineComment.test(l) and start is true
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if comment.test l
cCounter++
commentLineNumbers.push i
cCounter += bCounter
sloc = loc -... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | be710428f9a881ef44c1417c9e1248216a68c50e | 969 | https://github.com/flosse/sloc/blob/be710428f9a881ef44c1417c9e1248216a68c50e/src/sloc.coffee | 127 | 147 | ||
flosse/sloc:src/sloc.coffee:3:completion | completion | startLine = i
else if stopMultiLineComment.test(l) and start is true
start = false
x = i - startLine + 1
commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if comment.test l
cCounter++ | commentLineNumbers.push i
cCounter += bCounter
sloc = loc - cCounter - nloc
# result
loc: loc # physical lines of code
sloc: sloc # source loc
cloc: cCounter # comment loc
bcloc: bCounter # block comment loc
nloc: nloc # null loc | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | be710428f9a881ef44c1417c9e1248216a68c50e | 969 | https://github.com/flosse/sloc/blob/be710428f9a881ef44c1417c9e1248216a68c50e/src/sloc.coffee | 127 | 147 |
flosse/sloc:src/sloc.coffee:1:raw_corpus | raw_corpus | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
switch lang
when "coffeescript", "coffee"
startMultiLineComment = trippleSharpComment
stopMultiLineComment = trippleSharpComment
comment = sharpComment
when "... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 9781807f6218ceedd82a83d419f55fb3e7224a4c | 969 | https://github.com/flosse/sloc/blob/9781807f6218ceedd82a83d419f55fb3e7224a4c/src/sloc.coffee | 54 | 103 | ||
flosse/sloc:src/sloc.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
switch lang
when "coffeescript", "coffee"
startMultiLineComment = trippleSharpComment
stopMultiLineComment = trippleSharpComme... | module.exports = function(code, lang) {
var bCounter, cCounter, comment, commentLineNumbers, i, j, l, len, lines, loc, nloc, nullLineNumbers, results, start, startLine, startMultiLineComment, stopMultiLineComment, x;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
switch ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 9781807f6218ceedd82a83d419f55fb3e7224a4c | 969 | https://github.com/flosse/sloc/blob/9781807f6218ceedd82a83d419f55fb3e7224a4c/src/sloc.coffee | 54 | 103 |
flosse/sloc:src/sloc.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
module.exports = function(code, lang) {
var bCounter, cCounter, comment, commentLineNumbers, i, j, l, len, lines, loc, nloc, nullLineNumbers, results, start, startLine, startMultiLineComment, stopMultiLineComment, x;
if (typeof code !== "string") {
throw ne... | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
switch lang
when "coffeescript", "coffee"
startMultiLineComment = trippleSharpComment
stopMultiLineComment = trippleSharpComment
comment = sharpComment
when "... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 9781807f6218ceedd82a83d419f55fb3e7224a4c | 969 | https://github.com/flosse/sloc/blob/9781807f6218ceedd82a83d419f55fb3e7224a4c/src/sloc.coffee | 54 | 103 |
flosse/sloc:src/sloc.coffee:1:completion | completion | module.exports = (code, lang) ->
throw new TypeError "'code' has to be a string" unless typeof code is "string"
switch lang
when "coffeescript", "coffee"
startMultiLineComment = trippleSharpComment
stopMultiLineComment = trippleSharpComment
comment = sharpComment
when "... | stopMultiLineComment = starSlashComment
comment = slashComment
commentLineNumbers = []
nullLineNumbers = []
lines = code.split '\n'
loc = lines.length
nloc = (for l,i in lines when whiteSpaceLine.test l
nullLineNumbers.push i; l
).length
start ... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 9781807f6218ceedd82a83d419f55fb3e7224a4c | 969 | https://github.com/flosse/sloc/blob/9781807f6218ceedd82a83d419f55fb3e7224a4c/src/sloc.coffee | 54 | 103 |
flosse/sloc:src/sloc.coffee:2:raw_corpus | raw_corpus | commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if comment.test l
cCounter++
commentLineNumbers.push i
cCounter += bCounter
sloc = loc - cCounter - nloc
# result
loc: loc # physical lines of code
sloc: sloc # source loc
cloc: cCounter ... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 9781807f6218ceedd82a83d419f55fb3e7224a4c | 969 | https://github.com/flosse/sloc/blob/9781807f6218ceedd82a83d419f55fb3e7224a4c/src/sloc.coffee | 104 | 119 | ||
flosse/sloc:src/sloc.coffee:2:completion | completion | commentLineNumbers.push nr for nr in [startLine..i]
bCounter += x
else if comment.test l
cCounter++
commentLineNumbers.push i
cCounter += bCounter | sloc = loc - cCounter - nloc
# result
loc: loc # physical lines of code
sloc: sloc # source loc
cloc: cCounter # comment loc
bcloc: bCounter # block comment loc
nloc: nloc # null loc | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 9781807f6218ceedd82a83d419f55fb3e7224a4c | 969 | https://github.com/flosse/sloc/blob/9781807f6218ceedd82a83d419f55fb3e7224a4c/src/sloc.coffee | 104 | 119 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:raw_corpus | raw_corpus | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
# Optimization
if @isNumber()
return parseFloat(@exprString)
if @_isDirty()
@_updateCompiled... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 10 | 59 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
# Optimization
if @isNumber()
return parseFloa... | var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
},
_value: function() {
var circularReferencePa... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 10 | 59 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
... | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
# Optimization
if @isNumber()
return parseFloat(@exprString)
if @_isDirty()
@_updateCompiled... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 10 | 59 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:completion | completion | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
# Optimization
if @isNumber()
return parseFloat(@exprString)
if @_isDirty()
@_updateCompiled... | throw error
else
return error
_isDirty: ->
return true if !@hasOwnProperty("__compiledExpression")
return true if @__compiledExpression.exprString != @exprString
return false
_updateCompiledExpression: ->
compiledExpression = new CompiledExpression(this)
if compiledExpression.isS... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 10 | 59 |
cdglabs/apparatus:src/Model/Attribute.coffee:2:raw_corpus | raw_corpus | referenceLink.key = key
referenceLink.setTarget(attribute)
@addChild(referenceLink)
references: ->
references = {}
for referenceLink in @childrenOfType(Model.ReferenceLink)
key = referenceLink.key
attribute = referenceLink.target()
references[key] = attribute
return referenc... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 60 | 109 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:2:completion | completion | referenceLink.key = key
referenceLink.setTarget(attribute)
@addChild(referenceLink)
references: ->
references = {}
for referenceLink in @childrenOfType(Model.ReferenceLink)
key = referenceLink.key
attribute = referenceLink.target()
references[key] = attribute
return referenc... | # returned with two properties:
# dependencies: array consisting of the set of all recursive dependencies
# (will be reasonable even if a circular reference exists)
# circularReferencePath: a chain of dependencies resulting in a circular
# reference, if one exists, or null
_analyzeDependencies: ->... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 60 | 109 |
cdglabs/apparatus:src/Model/Attribute.coffee:3:raw_corpus | raw_corpus | return {
dependencies
circularReferencePath
}
# Returns all referenced attributes recursively. In other words every
# attribute which, if it changed, would affect me.
dependencies: ->
return @_analyzeDependencies().dependencies
# If there is a circular reference in the attribute's dependen... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 110 | 130 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:3:completion | completion | return {
dependencies
circularReferencePath
}
# Returns all referenced attributes recursively. In other words every
# attribute which, if it changed, would affect me.
dependencies: ->
return @_analyzeDependencies().dependencies | # If there is a circular reference in the attribute's dependency graph,
# returns a chain of dependencies representing it. Otherwise returns null.
circularReferencePath: ->
return @_analyzeDependencies().circularReferencePath
parentElement: ->
result = @parent()
until result.isVariantOf(Model.Element... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 110 | 130 |
cdglabs/apparatus:src/Model/Attribute.coffee:4:raw_corpus | raw_corpus | class CompiledExpression
constructor: (@attribute) ->
@exprString = @attribute.exprString
@referenceKeys = _.keys(@attribute.references())
if @exprString == ""
@_setSyntaxError()
return
if Util.isNumberString(@exprString)
value = parseFloat(@exprString)
@_setConstant(value)
... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 135 | 184 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
class CompiledExpression
constructor: (@attribute) ->
@exprString = @attribute.exprString
@referenceKeys = _.keys(@attribute.references())
if @exprString == ""
@_setSyntaxError()
return
if Util.isNumberString(@exprString)
val... | var CompiledExpression;
CompiledExpression = class CompiledExpression {
constructor(attribute) {
var compiled, error, value, wrapped;
this.attribute = attribute;
this.exprString = this.attribute.exprString;
this.referenceKeys = _.keys(this.attribute.references());
if (this.exprString === "") {
... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 135 | 184 |
cdglabs/apparatus:src/Model/Attribute.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var CompiledExpression;
CompiledExpression = class CompiledExpression {
constructor(attribute) {
var compiled, error, value, wrapped;
this.attribute = attribute;
this.exprString = this.attribute.exprString;
this.referenceKeys = _.keys(this.attrib... | class CompiledExpression
constructor: (@attribute) ->
@exprString = @attribute.exprString
@referenceKeys = _.keys(@attribute.references())
if @exprString == ""
@_setSyntaxError()
return
if Util.isNumberString(@exprString)
value = parseFloat(@exprString)
@_setConstant(value)
... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 135 | 184 |
cdglabs/apparatus:src/Model/Attribute.coffee:4:completion | completion | class CompiledExpression
constructor: (@attribute) ->
@exprString = @attribute.exprString
@referenceKeys = _.keys(@attribute.references())
if @exprString == ""
@_setSyntaxError()
return
if Util.isNumberString(@exprString)
value = parseFloat(@exprString)
@_setConstant(value)
... | value = compiled()
catch error
@_setConstant(error)
return
@_setConstant(value)
return
@_setFn(compiled)
_setSyntaxError: ->
@isSyntaxError = true
_setConstant: (value) ->
@isConstant = true
@fn = -> value
_setFn: (fn) ->
@fn = fn
evaluate: (referenceVa... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 135 | 184 |
cdglabs/apparatus:src/Model/Attribute.coffee:5:raw_corpus | raw_corpus | for referenceKey in @referenceKeys
result += " var #{referenceKey} = $$$referenceValues.#{referenceKey};\n"
if @exprString.indexOf("return") == -1
result += " return #{@exprString};\n"
else
result += "\n\n#{@exprString}\n\n"
result += "});"
return result
_wrapFunctionInSpreadC... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 185 | 207 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:5:completion | completion | for referenceKey in @referenceKeys
result += " var #{referenceKey} = $$$referenceValues.#{referenceKey};\n"
if @exprString.indexOf("return") == -1
result += " return #{@exprString};\n"
else
result += "\n\n#{@exprString}\n\n"
result += "});"
return result | _wrapFunctionInSpreadCheck: (fn) ->
return =>
result = fn(arguments...)
if result instanceof Dataflow.Spread
result.origin = @attribute
return result
Attribute.CircularReferenceError = class CircularReferenceError extends Error
constructor: (@attributePath) ->
labels = _.pluck(@attr... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0960682aaae907594029e9d53fdfcc0de1edac2f | 1,052 | https://github.com/cdglabs/apparatus/blob/0960682aaae907594029e9d53fdfcc0de1edac2f/src/Model/Attribute.coffee | 185 | 207 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:raw_corpus | raw_corpus | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if (circularReferenceError = @checkForCircularReferenceError())?
return circularReferenceError
# Optim... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 10 | 59 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if (circularReferenceError = @checkForCircularReferenceE... | var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
},
_value: function() {
var circularReferenceEr... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 10 | 59 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
... | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if (circularReferenceError = @checkForCircularReferenceError())?
return circularReferenceError
# Optim... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 10 | 59 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:completion | completion | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if (circularReferenceError = @checkForCircularReferenceError())?
return circularReferenceError
# Optim... | throw error
else
return error
_isDirty: ->
return true if !@hasOwnProperty("__compiledExpression")
return true if @__compiledExpression.exprString != @exprString
return false
_updateCompiledExpression: ->
compiledExpression = new CompiledExpression(this)
if compiledExpression.isS... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 10 | 59 |
cdglabs/apparatus:src/Model/Attribute.coffee:2:raw_corpus | raw_corpus | referenceLink.key = key
referenceLink.setTarget(attribute)
@addChild(referenceLink)
references: ->
references = {}
for referenceLink in @childrenOfType(Model.ReferenceLink)
key = referenceLink.key
attribute = referenceLink.target()
references[key] = attribute
return referenc... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 60 | 109 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:2:completion | completion | referenceLink.key = key
referenceLink.setTarget(attribute)
@addChild(referenceLink)
references: ->
references = {}
for referenceLink in @childrenOfType(Model.ReferenceLink)
key = referenceLink.key
attribute = referenceLink.target()
references[key] = attribute
return referenc... | # attribute which, if it changed, would affect me. (Also sets
# @__circularReferenceError to either null or an error regarding a circular
# reference in the attribute's dependency graph. Will still return a
# reasonable set of dependencies even in the presence of a circular
# reference.)
dependencies: ->
... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 60 | 109 |
cdglabs/apparatus:src/Model/Attribute.coffee:3:raw_corpus | raw_corpus | return dependencies
# If there is a circular reference in the attribute's dependency graph,
# returns a CircularReferenceError. Otherwise returns null.
checkForCircularReferenceError: ->
@dependencies()
return @__circularReferenceError
parentElement: ->
result = @parent()
until result.isVarian... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 110 | 122 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
return dependencies
# If there is a circular reference in the attribute's dependency graph,
# returns a CircularReferenceError. Otherwise returns null.
checkForCircularReferenceError: ->
@dependencies()
return @__circularReferenceError
parentEle... | return dependencies({
// If there is a circular reference in the attribute's dependency graph,
// returns a CircularReferenceError. Otherwise returns null.
checkForCircularReferenceError: function() {
this.dependencies();
return this.__circularReferenceError;
},
parentElement: function() {
var res... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 110 | 122 |
cdglabs/apparatus:src/Model/Attribute.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
return dependencies({
// If there is a circular reference in the attribute's dependency graph,
// returns a CircularReferenceError. Otherwise returns null.
checkForCircularReferenceError: function() {
this.dependencies();
return this.__circularReferen... | return dependencies
# If there is a circular reference in the attribute's dependency graph,
# returns a CircularReferenceError. Otherwise returns null.
checkForCircularReferenceError: ->
@dependencies()
return @__circularReferenceError
parentElement: ->
result = @parent()
until result.isVarian... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 110 | 122 |
cdglabs/apparatus:src/Model/Attribute.coffee:3:completion | completion | return dependencies
# If there is a circular reference in the attribute's dependency graph,
# returns a CircularReferenceError. Otherwise returns null.
checkForCircularReferenceError: ->
@dependencies() | return @__circularReferenceError
parentElement: ->
result = @parent()
until result.isVariantOf(Model.Element)
result = result.parent()
return result | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 8d3c3cdca10dfdfee9a2f23881c004e556db8518 | 1,052 | https://github.com/cdglabs/apparatus/blob/8d3c3cdca10dfdfee9a2f23881c004e556db8518/src/Model/Attribute.coffee | 110 | 122 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:raw_corpus | raw_corpus | class CircularReferenceError extends Error
constructor: (@attributePath) ->
labels = _.pluck(@attributePath, 'label')
@message = "Circular reference: #{labels.join(' -> ')}" | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 10 | 13 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:1:completion | completion | class CircularReferenceError extends Error
constructor: (@attributePath) -> | labels = _.pluck(@attributePath, 'label')
@message = "Circular reference: #{labels.join(' -> ')}" | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 10 | 13 |
cdglabs/apparatus:src/Model/Attribute.coffee:2:raw_corpus | raw_corpus | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if @__circularReferenceError
return @__circularReferenceError
# Optimization
if @isNumber()
... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 15 | 64 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if @__circularReferenceError
return @__circularRef... | var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
},
_value: function() {
var error, referenceVal... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 15 | 64 |
cdglabs/apparatus:src/Model/Attribute.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
... | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if @__circularReferenceError
return @__circularReferenceError
# Optimization
if @isNumber()
... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 15 | 64 |
cdglabs/apparatus:src/Model/Attribute.coffee:2:completion | completion | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if @__circularReferenceError
return @__circularReferenceError
# Optimization
if @isNumber()
... | throw error
else
return error
_isDirty: ->
return true if !@hasOwnProperty("__compiledExpression")
return true if @__compiledExpression.exprString != @exprString
return false
_updateCompiledExpression: ->
compiledExpression = new CompiledExpression(this)
if compiledExpression.isS... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 15 | 64 |
cdglabs/apparatus:src/Model/Attribute.coffee:3:raw_corpus | raw_corpus | referenceLink.key = key
referenceLink.setTarget(attribute)
@addChild(referenceLink)
references: ->
references = {}
for referenceLink in @childrenOfType(Model.ReferenceLink)
key = referenceLink.key
attribute = referenceLink.target()
references[key] = attribute
return referenc... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 65 | 114 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:3:completion | completion | referenceLink.key = key
referenceLink.setTarget(attribute)
@addChild(referenceLink)
references: ->
references = {}
for referenceLink in @childrenOfType(Model.ReferenceLink)
key = referenceLink.key
attribute = referenceLink.target()
references[key] = attribute
return referenc... | # attribute which, if it changed, would affect me.
dependencies: ->
dependencies = []
attributePath = []
recurse = (attribute) ->
# Make sure there aren't any circular references
if attributePath.indexOf(attribute) != -1
attributePath.push(attribute) # for error debugging
thro... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 65 | 114 |
cdglabs/apparatus:src/Model/Attribute.coffee:4:raw_corpus | raw_corpus | return dependencies
parentElement: ->
result = @parent()
until result.isVariantOf(Model.Element)
result = result.parent()
return result | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 115 | 121 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
return dependencies
parentElement: ->
result = @parent()
until result.isVariantOf(Model.Element)
result = result.parent()
return result
``` | return dependencies({
parentElement: function() {
var result;
result = this.parent();
while (!result.isVariantOf(Model.Element)) {
result = result.parent();
}
return result;
}
}); | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 115 | 121 |
cdglabs/apparatus:src/Model/Attribute.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
return dependencies({
parentElement: function() {
var result;
result = this.parent();
while (!result.isVariantOf(Model.Element)) {
result = result.parent();
}
return result;
}
});
``` | return dependencies
parentElement: ->
result = @parent()
until result.isVariantOf(Model.Element)
result = result.parent()
return result | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 115 | 121 |
cdglabs/apparatus:src/Model/Attribute.coffee:4:completion | completion | return dependencies
parentElement: -> | result = @parent()
until result.isVariantOf(Model.Element)
result = result.parent()
return result | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 115 | 121 |
cdglabs/apparatus:src/Model/Attribute.coffee:6:raw_corpus | raw_corpus | for referenceKey in @referenceKeys
result += " var #{referenceKey} = $$$referenceValues.#{referenceKey};\n"
if @exprString.indexOf("return") == -1
result += " return #{@exprString};\n"
else
result += "\n\n#{@exprString}\n\n"
result += "});"
return result
_wrapFunctionInSpreadC... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 176 | 193 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
for referenceKey in @referenceKeys
result += " var #{referenceKey} = $$$referenceValues.#{referenceKey};\n"
if @exprString.indexOf("return") == -1
result += " return #{@exprString};\n"
else
result += "\n\n#{@exprString}\n\n"
resu... | var i, len, ref, referenceKey;
ref = this.referenceKeys;
for (i = 0, len = ref.length; i < len; i++) {
referenceKey = ref[i];
result += ` var ${referenceKey} = $$$referenceValues.${referenceKey};\n`;
}
if (this.exprString.indexOf("return") === -1) {
result += ` return ${this.exprString};\n`;
} else {
result... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 176 | 193 |
cdglabs/apparatus:src/Model/Attribute.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var i, len, ref, referenceKey;
ref = this.referenceKeys;
for (i = 0, len = ref.length; i < len; i++) {
referenceKey = ref[i];
result += ` var ${referenceKey} = $$$referenceValues.${referenceKey};\n`;
}
if (this.exprString.indexOf("return") === -1) {
result... | for referenceKey in @referenceKeys
result += " var #{referenceKey} = $$$referenceValues.#{referenceKey};\n"
if @exprString.indexOf("return") == -1
result += " return #{@exprString};\n"
else
result += "\n\n#{@exprString}\n\n"
result += "});"
return result
_wrapFunctionInSpreadC... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 176 | 193 |
cdglabs/apparatus:src/Model/Attribute.coffee:6:completion | completion | for referenceKey in @referenceKeys
result += " var #{referenceKey} = $$$referenceValues.#{referenceKey};\n"
if @exprString.indexOf("return") == -1
result += " return #{@exprString};\n"
else
result += "\n\n#{@exprString}\n\n" | result += "});"
return result
_wrapFunctionInSpreadCheck: (fn) ->
return =>
result = fn(arguments...)
if result instanceof Dataflow.Spread
result.origin = @attribute
return result | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 0d6d0f6d0fa56b59fd533f33a2b905196e30e647 | 1,052 | https://github.com/cdglabs/apparatus/blob/0d6d0f6d0fa56b59fd533f33a2b905196e30e647/src/Model/Attribute.coffee | 176 | 193 |
cdglabs/apparatus:src/Model/Attribute.coffee:2:raw_corpus | raw_corpus | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if @circularReferenceError
return @circularReferenceError
# Optimization
if @isNumber()
retu... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 2a8a7023e6522ca21d8e02635c1c7281b288c4fc | 1,052 | https://github.com/cdglabs/apparatus/blob/2a8a7023e6522ca21d8e02635c1c7281b288c4fc/src/Model/Attribute.coffee | 15 | 64 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if @circularReferenceError
return @circularReferen... | var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
},
_value: function() {
var error, referenceVal... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 2a8a7023e6522ca21d8e02635c1c7281b288c4fc | 1,052 | https://github.com/cdglabs/apparatus/blob/2a8a7023e6522ca21d8e02635c1c7281b288c4fc/src/Model/Attribute.coffee | 15 | 64 |
cdglabs/apparatus:src/Model/Attribute.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
... | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if @circularReferenceError
return @circularReferenceError
# Optimization
if @isNumber()
retu... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 2a8a7023e6522ca21d8e02635c1c7281b288c4fc | 1,052 | https://github.com/cdglabs/apparatus/blob/2a8a7023e6522ca21d8e02635c1c7281b288c4fc/src/Model/Attribute.coffee | 15 | 64 |
cdglabs/apparatus:src/Model/Attribute.coffee:2:completion | completion | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
if @circularReferenceError
return @circularReferenceError
# Optimization
if @isNumber()
retu... | throw error
else
return error
_isDirty: ->
return true if !@hasOwnProperty("__compiledExpression")
return true if @__compiledExpression.exprString != @exprString
return false
_updateCompiledExpression: ->
compiledExpression = new CompiledExpression(this)
if compiledExpression.isS... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 2a8a7023e6522ca21d8e02635c1c7281b288c4fc | 1,052 | https://github.com/cdglabs/apparatus/blob/2a8a7023e6522ca21d8e02635c1c7281b288c4fc/src/Model/Attribute.coffee | 15 | 64 |
cdglabs/apparatus:src/Model/Attribute.coffee:3:raw_corpus | raw_corpus | referenceLink.key = key
referenceLink.setTarget(attribute)
@addChild(referenceLink)
references: ->
references = {}
for referenceLink in @childrenOfType(Model.ReferenceLink)
key = referenceLink.key
attribute = referenceLink.target()
references[key] = attribute
return referenc... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 2a8a7023e6522ca21d8e02635c1c7281b288c4fc | 1,052 | https://github.com/cdglabs/apparatus/blob/2a8a7023e6522ca21d8e02635c1c7281b288c4fc/src/Model/Attribute.coffee | 65 | 114 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:3:completion | completion | referenceLink.key = key
referenceLink.setTarget(attribute)
@addChild(referenceLink)
references: ->
references = {}
for referenceLink in @childrenOfType(Model.ReferenceLink)
key = referenceLink.key
attribute = referenceLink.target()
references[key] = attribute
return referenc... | # attribute which, if it changed, would affect me.
dependencies: ->
dependencies = []
attributePath = []
recurse = (attribute) ->
# Make sure there aren't any circular references
if attributePath.indexOf(attribute) != -1
attributePath.push(attribute) # for error debugging
thro... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | 2a8a7023e6522ca21d8e02635c1c7281b288c4fc | 1,052 | https://github.com/cdglabs/apparatus/blob/2a8a7023e6522ca21d8e02635c1c7281b288c4fc/src/Model/Attribute.coffee | 65 | 114 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:raw_corpus | raw_corpus | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
# Optimization
if @isNumber()
return parseFloat(@exprString)
if @_isDirty()
@_updateCompiled... | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | e12a991c0d8bd3ae6bcd06c057d52d2b2438b82a | 1,052 | https://github.com/cdglabs/apparatus/blob/e12a991c0d8bd3ae6bcd06c057d52d2b2438b82a/src/Model/Attribute.coffee | 10 | 59 | ||
cdglabs/apparatus:src/Model/Attribute.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
# Optimization
if @isNumber()
return parseFloa... | var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
},
_value: function() {
var error, referenceVal... | CoffeeScript | JavaScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | e12a991c0d8bd3ae6bcd06c057d52d2b2438b82a | 1,052 | https://github.com/cdglabs/apparatus/blob/e12a991c0d8bd3ae6bcd06c057d52d2b2438b82a/src/Model/Attribute.coffee | 10 | 59 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var Attribute,
hasProp = {}.hasOwnProperty;
module.exports = Attribute = Node.createVariant({
constructor: function() {
// Call "super" constructor
Node.constructor.apply(this, arguments);
return this.value = Dataflow.cell(this._value.bind(this));
... | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
# Optimization
if @isNumber()
return parseFloat(@exprString)
if @_isDirty()
@_updateCompiled... | JavaScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | e12a991c0d8bd3ae6bcd06c057d52d2b2438b82a | 1,052 | https://github.com/cdglabs/apparatus/blob/e12a991c0d8bd3ae6bcd06c057d52d2b2438b82a/src/Model/Attribute.coffee | 10 | 59 |
cdglabs/apparatus:src/Model/Attribute.coffee:1:completion | completion | module.exports = Attribute = Node.createVariant
constructor: ->
# Call "super" constructor
Node.constructor.apply(this, arguments)
@value = Dataflow.cell(@_value.bind(this))
_value: ->
# Optimization
if @isNumber()
return parseFloat(@exprString)
if @_isDirty()
@_updateCompiled... | _isDirty: ->
return true if !@hasOwnProperty("__compiledExpression")
return true if @__compiledExpression.exprString != @exprString
return false
_updateCompiledExpression: ->
compiledExpression = new CompiledExpression(this)
if compiledExpression.isSyntaxError
compiledExpression.fn = @__com... | CoffeeScript | CoffeeScript | cdglabs/apparatus | src/Model/Attribute.coffee | MIT | e12a991c0d8bd3ae6bcd06c057d52d2b2438b82a | 1,052 | https://github.com/cdglabs/apparatus/blob/e12a991c0d8bd3ae6bcd06c057d52d2b2438b82a/src/Model/Attribute.coffee | 10 | 59 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.