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:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py", "ls", "rb"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"... | var getCommentExpressions;
getCommentExpressions = function(lang) {
var single, start, stop;
// single line comments
single = (function() {
switch (lang) {
case "coffee":
case "py":
case "ls":
case "rb":
return /\#/;
case "js":
case "c":
case "cc":
case... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:1: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 "coffee":
case "py":
case "ls":
case "rb":
return /\#/;
... | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py", "ls", "rb"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl", "scala"
/\/{2}/
when "lua"
/--/
... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:1:completion | completion | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py", "ls", "rb"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl", "scala"
/\/{2}/
when "lua"
/--/
... | when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", "ls", \
"php", "php5", "go", "css", "scss", "less", "styl", "scala"
start = /\/\*+/
stop = /\*\/{1}/
when "python", "py"
start = stop = /\"{3}|\'{3}/
when "html"
start = /<\!--/
stop = /-->/
when "lua"... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:3:raw_corpus | raw_corpus | countMixed = (lines, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.mixed.push start: idx, stop: idx
if (i=startIdx-idx) isnt 0 and nonEmptyLine.exec lines[i]
res.mixed.push start: startIdx, stop: startIdx | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 77 | 83 | ||
flosse/sloc:src/sloc.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
countMixed = (lines, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.mixed.push start: idx, stop: idx
if (i=startIdx-idx) isnt 0 and nonEmptyLine.exec lines[i]
res.mixed.push start: startIdx, stop: startIdx
``` | var countMixed;
countMixed = function(lines, idx, startIdx, res) {
var i;
if (nonEmptyLine.exec(lines[0]) && idx !== 0) {
res.mixed.push({
start: idx,
stop: idx
});
}
if ((i = startIdx - idx) !== 0 && nonEmptyLine.exec(lines[i])) {
return res.mixed.push({
start: startIdx,
st... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 77 | 83 |
flosse/sloc:src/sloc.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var countMixed;
countMixed = function(lines, idx, startIdx, res) {
var i;
if (nonEmptyLine.exec(lines[0]) && idx !== 0) {
res.mixed.push({
start: idx,
stop: idx
});
}
if ((i = startIdx - idx) !== 0 && nonEmptyLine.exec(lines[i])) {
... | countMixed = (lines, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.mixed.push start: idx, stop: idx
if (i=startIdx-idx) isnt 0 and nonEmptyLine.exec lines[i]
res.mixed.push start: startIdx, stop: startIdx | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 77 | 83 |
flosse/sloc:src/sloc.coffee:3:completion | completion | countMixed = (lines, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0 | res.mixed.push start: idx, stop: idx
if (i=startIdx-idx) isnt 0 and nonEmptyLine.exec lines[i]
res.mixed.push start: startIdx, stop: startIdx | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 77 | 83 |
flosse/sloc:src/sloc.coffee:4:raw_corpus | raw_corpus | getStop = (comment, type, regex) ->
comment.match switch type
when 'single' then endOfLine
when 'block' then regex.stop | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 85 | 88 | ||
flosse/sloc:src/sloc.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getStop = (comment, type, regex) ->
comment.match switch type
when 'single' then endOfLine
when 'block' then regex.stop
``` | var getStop;
getStop = function(comment, type, regex) {
return comment.match((function() {
switch (type) {
case 'single':
return endOfLine;
case 'block':
return regex.stop;
}
})());
}; | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 85 | 88 |
flosse/sloc:src/sloc.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var getStop;
getStop = function(comment, type, regex) {
return comment.match((function() {
switch (type) {
case 'single':
return endOfLine;
case 'block':
return regex.stop;
}
})());
};
``` | getStop = (comment, type, regex) ->
comment.match switch type
when 'single' then endOfLine
when 'block' then regex.stop | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 85 | 88 |
flosse/sloc:src/sloc.coffee:4:completion | completion | getStop = (comment, type, regex) ->
comment.match switch type | when 'single' then endOfLine
when 'block' then regex.stop | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 85 | 88 |
flosse/sloc:src/sloc.coffee:5:raw_corpus | raw_corpus | getType = (single, start) ->
if single and not start then 'single'
else if start and not single then 'block'
else
if start.index <= single.index then 'block' else 'single' | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 90 | 94 | ||
flosse/sloc:src/sloc.coffee:5:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getType = (single, start) ->
if single and not start then 'single'
else if start and not single then 'block'
else
if start.index <= single.index then 'block' else 'single'
``` | var getType;
getType = function(single, start) {
if (single && !start) {
return 'single';
} else if (start && !single) {
return 'block';
} else {
if (start.index <= single.index) {
return 'block';
} else {
return 'single';
}
}
}; | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 90 | 94 |
flosse/sloc:src/sloc.coffee:5:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var getType;
getType = function(single, start) {
if (single && !start) {
return 'single';
} else if (start && !single) {
return 'block';
} else {
if (start.index <= single.index) {
return 'block';
} else {
return 'single';
}
... | getType = (single, start) ->
if single and not start then 'single'
else if start and not single then 'block'
else
if start.index <= single.index then 'block' else 'single' | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 90 | 94 |
flosse/sloc:src/sloc.coffee:5:completion | completion | getType = (single, start) ->
if single and not start then 'single' | else if start and not single then 'block'
else
if start.index <= single.index then 'block' else 'single' | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 90 | 94 |
flosse/sloc:src/sloc.coffee:6: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
unless start or single
countMixed code.split('\n'), idx, idx, res
return res
type = getType single, start
match = switch type... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 96 | 134 | ||
flosse/sloc:src/sloc.coffee:6: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
unless start or single
countMixed code.split('\n'), idx, idx, res
return res
... | 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 | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 96 | 134 |
flosse/sloc:src/sloc.coffee:6: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
unless start or single
countMixed code.split('\n'), idx, idx, res
return res
type = getType single, start
match = switch type... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 96 | 134 |
flosse/sloc:src/sloc.coffee:6:completion | completion | countComments = (code, regex) ->
myself = (code, idx, res) ->
return res if code is ''
start = regex.start?.exec code
single = regex.single?.exec code
unless start or single
countMixed code.split('\n'), idx, idx, res
return res
type = getType single, start
match = switch type... | comment = code.substring cContentIdx
lines = code.substring(0, match.index).split '\n'
startIdx = lines.length - 1 + idx
stop = getStop comment, type, regex
unless stop
res.error = yes
return res
comment = comment.substring 0, stop.index
len = comment.match(... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 96 | 134 |
flosse/sloc:src/sloc.coffee:7:raw_corpus | raw_corpus | trampoline = (next) ->
next = next() while typeof next is 'function'
next | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 136 | 138 | ||
flosse/sloc:src/sloc.coffee:7:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
trampoline = (next) ->
next = next() while typeof next is 'function'
next
``` | var trampoline;
trampoline = function(next) {
while (typeof next === 'function') {
next = next();
}
return next;
}; | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 136 | 138 |
flosse/sloc:src/sloc.coffee:7:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var trampoline;
trampoline = function(next) {
while (typeof next === 'function') {
next = next();
}
return next;
};
``` | trampoline = (next) ->
next = next() while typeof next is 'function'
next | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 136 | 138 |
flosse/sloc:src/sloc.coffee:8:raw_corpus | raw_corpus | lineSum = (comments) ->
sum = 0
for c,i in comments
d = (c.stop - c.start) + 1
d-- if comments[i+1]?.start is c.stop
sum += d
sum | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 140 | 146 | ||
flosse/sloc:src/sloc.coffee:8:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
lineSum = (comments) ->
sum = 0
for c,i in comments
d = (c.stop - c.start) + 1
d-- if comments[i+1]?.start is c.stop
sum += d
sum
``` | var lineSum;
lineSum = function(comments) {
var c, d, i, j, len, ref, sum;
sum = 0;
for (i = j = 0, len = comments.length; j < len; i = ++j) {
c = comments[i];
d = (c.stop - c.start) + 1;
if (((ref = comments[i + 1]) != null ? ref.start : void 0) === c.stop) {
d--;
}
sum += d;
}
ret... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 140 | 146 |
flosse/sloc:src/sloc.coffee:8:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var lineSum;
lineSum = function(comments) {
var c, d, i, j, len, ref, sum;
sum = 0;
for (i = j = 0, len = comments.length; j < len; i = ++j) {
c = comments[i];
d = (c.stop - c.start) + 1;
if (((ref = comments[i + 1]) != null ? ref.start : void 0)... | lineSum = (comments) ->
sum = 0
for c,i in comments
d = (c.stop - c.start) + 1
d-- if comments[i+1]?.start is c.stop
sum += d
sum | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 140 | 146 |
flosse/sloc:src/sloc.coffee:8:completion | completion | lineSum = (comments) ->
sum = 0
for c,i in comments | d = (c.stop - c.start) + 1
d-- if comments[i+1]?.start is c.stop
sum += d
sum | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 140 | 146 |
flosse/sloc:src/sloc.coffee:9:raw_corpus | raw_corpus | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 148 | 197 | ||
flosse/sloc:src/sloc.coffee:9:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = co... | var slocModule,
indexOf = [].indexOf;
slocModule = function(code, lang) {
var b, bIdx, block, comment, empty, i, len, mixed, ref, ref1, ref2, ref3, res, s, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
code = code.replace(/\r/g, '');
total = ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 148 | 197 |
flosse/sloc:src/sloc.coffee:9:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var slocModule,
indexOf = [].indexOf;
slocModule = function(code, lang) {
var b, bIdx, block, comment, empty, i, len, mixed, ref, ref1, ref2, ref3, res, s, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a str... | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 148 | 197 |
flosse/sloc:src/sloc.coffee:9:completion | completion | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | "coffee"
"cpp"
"css"
"erl"
"go"
"h"
"hpp"
"html"
"hx"
"ino"
"java"
"js"
"less"
"lua"
"ls"
"monkey"
"php", "php5"
"py"
"rb"
"scala"
"scss"
"styl"
]
slocModule.keys = keys | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 148 | 197 |
flosse/sloc:src/sloc.coffee:10:raw_corpus | raw_corpus | # 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 | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 198 | 205 | ||
flosse/sloc:src/sloc.coffee:10:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# 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
``` | // AMD support
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
define(function() {
return slocModule;
});
// Node.js support
} else if ((typeof module !== "undefined" && module !== null ? module.exports : void 0) != null) {
module.exports = slocModule;
// Browser suppor... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 198 | 205 |
flosse/sloc:src/sloc.coffee:10:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// AMD support
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
define(function() {
return slocModule;
});
// Node.js support
} else if ((typeof module !== "undefined" && module !== null ? module.exports : void 0) != n... | # 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 | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 198 | 205 |
flosse/sloc:src/sloc.coffee:10:completion | completion | # 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 | 0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0 | 969 | https://github.com/flosse/sloc/blob/0ca201cfa0f4b5b511ad8510b0fcc982aa9862e0/src/sloc.coffee | 198 | 205 |
flosse/sloc:src/sloc.coffee:1:raw_corpus | raw_corpus | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py", "ls"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl", "scala"
/\/{2}/
when "lua"
/--/
w... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 21 | 70 | ||
flosse/sloc:src/sloc.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py", "ls"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl", "sca... | var getCommentExpressions;
getCommentExpressions = function(lang) {
var single, start, stop;
// single line comments
single = (function() {
switch (lang) {
case "coffee":
case "py":
case "ls":
return /\#/;
case "js":
case "c":
case "cc":
case "cpp":
cas... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:1: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 "coffee":
case "py":
case "ls":
return /\#/;
case "js":
... | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py", "ls"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl", "scala"
/\/{2}/
when "lua"
/--/
w... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:1:completion | completion | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py", "ls"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl", "scala"
/\/{2}/
when "lua"
/--/
w... | when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", "ls", \
"php", "php5", "go", "css", "scss", "less", "styl", "scala"
start = /\/\*+/
stop = /\*\/{1}/
when "python", "py"
start = stop = /\"{3}|\'{3}/
when "html"
start = /<\!--/
stop = /-->/
when "lua"... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:9:raw_corpus | raw_corpus | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 144 | 193 | ||
flosse/sloc:src/sloc.coffee:9:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = co... | var slocModule,
indexOf = [].indexOf;
slocModule = function(code, lang) {
var b, bIdx, block, comment, empty, i, len, mixed, ref, ref1, ref2, ref3, res, s, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
code = code.replace(/\r/g, '');
total = ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 144 | 193 |
flosse/sloc:src/sloc.coffee:9:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var slocModule,
indexOf = [].indexOf;
slocModule = function(code, lang) {
var b, bIdx, block, comment, empty, i, len, mixed, ref, ref1, ref2, ref3, res, s, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a str... | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 144 | 193 |
flosse/sloc:src/sloc.coffee:9:completion | completion | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | "cpp"
"css"
"erl"
"go"
"h"
"hpp"
"html"
"hx"
"ino"
"java"
"js"
"less"
"lua"
"ls"
"monkey"
"php", "php5"
"py"
"scala"
"scss"
"styl"
]
slocModule.keys = keys
# AMD support | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 144 | 193 |
flosse/sloc:src/sloc.coffee:10:raw_corpus | raw_corpus | 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 | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 194 | 200 | ||
flosse/sloc:src/sloc.coffee:10:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
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
``` | if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
define(function() {
return slocModule;
});
// Node.js support
} else if ((typeof module !== "undefined" && module !== null ? module.exports : void 0) != null) {
module.exports = slocModule;
// Browser support
} else if (ty... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 194 | 200 |
flosse/sloc:src/sloc.coffee:10:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
define(function() {
return slocModule;
});
// Node.js support
} else if ((typeof module !== "undefined" && module !== null ? module.exports : void 0) != null) {
module... | 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 | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 194 | 200 |
flosse/sloc:src/sloc.coffee:10:completion | completion | 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 | c197c7ebe6d068f9193635ddaef7c9fca712ca7d | 969 | https://github.com/flosse/sloc/blob/c197c7ebe6d068f9193635ddaef7c9fca712ca7d/src/sloc.coffee | 194 | 200 |
flosse/sloc:src/sloc.coffee:1:raw_corpus | raw_corpus | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 21 | 70 | ||
flosse/sloc:src/sloc.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/... | var getCommentExpressions;
getCommentExpressions = function(lang) {
var single, start, stop;
// single line comments
single = (function() {
switch (lang) {
case "coffee":
case "py":
return /\#/;
case "js":
case "c":
case "cc":
case "cpp":
case "h":
case... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:1: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 "coffee":
case "py":
return /\#/;
case "js":
case "c":
... | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:1:completion | completion | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
... | when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "css", "scss", "less", "styl"
start = /\/\*+/
stop = /\*\/{1}/
when "python", "py"
start = stop = /\"{3}|\'{3}/
when "html"
start = /<\!--/
stop = /-->/
when "lua"
start = ... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 21 | 70 |
flosse/sloc:src/sloc.coffee:9:raw_corpus | raw_corpus | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 144 | 193 | ||
flosse/sloc:src/sloc.coffee:9:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = co... | var slocModule,
indexOf = [].indexOf;
slocModule = function(code, lang) {
var b, bIdx, block, comment, empty, i, len, mixed, ref, ref1, ref2, ref3, res, s, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
code = code.replace(/\r/g, '');
total = ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 144 | 193 |
flosse/sloc:src/sloc.coffee:9:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var slocModule,
indexOf = [].indexOf;
slocModule = function(code, lang) {
var b, bIdx, block, comment, empty, i, len, mixed, ref, ref1, ref2, ref3, res, s, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a str... | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 144 | 193 |
flosse/sloc:src/sloc.coffee:9:completion | completion | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
single = ... | "c"
"cc"
"cpp"
"h"
"hpp"
"hx"
"ino"
"erl"
"monkey"
"java"
"php", "php5"
"go"
"lua"
"scss"
"less"
"css"
"styl",
"html" ]
slocModule.keys = keys
# AMD support
if define?.amd? then define -> slocModule
# Node.js support | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 144 | 193 |
flosse/sloc:src/sloc.coffee:10:raw_corpus | raw_corpus | else if module?.exports? then module.exports = slocModule
# Browser support
else if window? then window.sloc = slocModule | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 194 | 197 | ||
flosse/sloc:src/sloc.coffee:10:completion | completion | 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 | 626c629e80606f232d5ba0f26bf38860774272e8 | 969 | https://github.com/flosse/sloc/blob/626c629e80606f232d5ba0f26bf38860774272e8/src/sloc.coffee | 194 | 197 |
flosse/sloc:src/sloc.coffee:3:raw_corpus | raw_corpus | countMixed = (lines, match, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.mixed.push start: idx, stop: idx
if nonEmptyLine.exec lines[startIdx-idx]
res.mixed.push start: startIdx, stop: startIdx | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 73 | 79 | ||
flosse/sloc:src/sloc.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
countMixed = (lines, match, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.mixed.push start: idx, stop: idx
if nonEmptyLine.exec lines[startIdx-idx]
res.mixed.push start: startIdx, stop: startIdx
``` | var countMixed;
countMixed = function(lines, match, idx, startIdx, res) {
if (nonEmptyLine.exec(lines[0]) && idx !== 0) {
res.mixed.push({
start: idx,
stop: idx
});
}
if (nonEmptyLine.exec(lines[startIdx - idx])) {
return res.mixed.push({
start: startIdx,
stop: startIdx
})... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 73 | 79 |
flosse/sloc:src/sloc.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var countMixed;
countMixed = function(lines, match, idx, startIdx, res) {
if (nonEmptyLine.exec(lines[0]) && idx !== 0) {
res.mixed.push({
start: idx,
stop: idx
});
}
if (nonEmptyLine.exec(lines[startIdx - idx])) {
return res.mixed.pu... | countMixed = (lines, match, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.mixed.push start: idx, stop: idx
if nonEmptyLine.exec lines[startIdx-idx]
res.mixed.push start: startIdx, stop: startIdx | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 73 | 79 |
flosse/sloc:src/sloc.coffee:3:completion | completion | countMixed = (lines, match, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0 | res.mixed.push start: idx, stop: idx
if nonEmptyLine.exec lines[startIdx-idx]
res.mixed.push start: startIdx, stop: startIdx | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 73 | 79 |
flosse/sloc:src/sloc.coffee:6: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 | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 92 | 128 | ||
flosse/sloc:src/sloc.coffee:6: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 | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 92 | 128 |
flosse/sloc:src/sloc.coffee:6: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 | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 92 | 128 |
flosse/sloc:src/sloc.coffee:6: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.error = yes
return res
comment = comment.substring 0, stop.index
len = comment.match(newLines)?.length or 0
splitAt = cContent... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 92 | 128 |
flosse/sloc:src/sloc.coffee:9:raw_corpus | raw_corpus | countBlock = (res) ->
cloc = 0
for b,i in res.block
d = (b.stop - b.start) + 1
for s in res.single when s.start is b.start or s.start is b.stop
d -= 3
break
cloc += d
cloc | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 142 | 150 | ||
flosse/sloc:src/sloc.coffee:9:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
countBlock = (res) ->
cloc = 0
for b,i in res.block
d = (b.stop - b.start) + 1
for s in res.single when s.start is b.start or s.start is b.stop
d -= 3
break
cloc += d
cloc
``` | var countBlock;
countBlock = function(res) {
var b, cloc, d, i, j, k, len, len1, ref, ref1, s;
cloc = 0;
ref = res.block;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
b = ref[i];
d = (b.stop - b.start) + 1;
ref1 = res.single;
for (k = 0, len1 = ref1.length; k < len1; k++) {
s = r... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 142 | 150 |
flosse/sloc:src/sloc.coffee:9:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var countBlock;
countBlock = function(res) {
var b, cloc, d, i, j, k, len, len1, ref, ref1, s;
cloc = 0;
ref = res.block;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
b = ref[i];
d = (b.stop - b.start) + 1;
ref1 = res.single;
for (... | countBlock = (res) ->
cloc = 0
for b,i in res.block
d = (b.stop - b.start) + 1
for s in res.single when s.start is b.start or s.start is b.stop
d -= 3
break
cloc += d
cloc | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 142 | 150 |
flosse/sloc:src/sloc.coffee:9:completion | completion | countBlock = (res) ->
cloc = 0
for b,i in res.block
d = (b.stop - b.start) + 1 | for s in res.single when s.start is b.start or s.start is b.stop
d -= 3
break
cloc += d
cloc | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 142 | 150 |
flosse/sloc:src/sloc.coffee:10:raw_corpus | raw_corpus | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = ... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 152 | 201 | ||
flosse/sloc:src/sloc.coffee:10:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = co... | var slocModule;
slocModule = function(code, lang) {
var block, comment, empty, mixed, ref, ref1, res, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
code = code.replace(/\r/g, '');
total = 1 + ((ref = code.match(newLines)) != null ? ref.length :... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 152 | 201 |
flosse/sloc:src/sloc.coffee:10:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var slocModule;
slocModule = function(code, lang) {
var block, comment, empty, mixed, ref, ref1, res, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
code = code.replace(/\r/g, '');
total = 1... | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = ... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 152 | 201 |
flosse/sloc:src/sloc.coffee:10:completion | completion | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
code = code.replace /\r/g, ''
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = ... | "cc"
"cpp"
"h"
"hpp"
"hx"
"ino"
"erl"
"monkey"
"java"
"php", "php5"
"go"
"lua"
"scss"
"less"
"css"
"styl",
"html" ]
slocModule.keys = keys
# AMD support
if define?.amd? then define -> slocModule
# Node.js support
else if module?.exports? then module.exports = slocModule | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88 | 969 | https://github.com/flosse/sloc/blob/bfddb76c1c5bbbe4c0c360912f3e3a24e3c5ec88/src/sloc.coffee | 152 | 201 |
flosse/sloc:src/sloc.coffee:10:raw_corpus | raw_corpus | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = countBlock res
single = lineSu... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 5ba362236174dfef5a72cf25d877bff13cbc3e6a | 969 | https://github.com/flosse/sloc/blob/5ba362236174dfef5a72cf25d877bff13cbc3e6a/src/sloc.coffee | 152 | 201 | ||
flosse/sloc:src/sloc.coffee:10:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpre... | var slocModule;
slocModule = function(code, lang) {
var block, comment, empty, mixed, ref, ref1, res, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
total = 1 + ((ref = code.match(newLines)) != null ? ref.length : void 0) || 0;
empty = ((ref1 = ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 5ba362236174dfef5a72cf25d877bff13cbc3e6a | 969 | https://github.com/flosse/sloc/blob/5ba362236174dfef5a72cf25d877bff13cbc3e6a/src/sloc.coffee | 152 | 201 |
flosse/sloc:src/sloc.coffee:10:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var slocModule;
slocModule = function(code, lang) {
var block, comment, empty, mixed, ref, ref1, res, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
total = 1 + ((ref = code.match(newLines)) !... | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = countBlock res
single = lineSu... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 5ba362236174dfef5a72cf25d877bff13cbc3e6a | 969 | https://github.com/flosse/sloc/blob/5ba362236174dfef5a72cf25d877bff13cbc3e6a/src/sloc.coffee | 152 | 201 |
flosse/sloc:src/sloc.coffee:10:completion | completion | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = countBlock res
single = lineSu... | "h"
"hpp"
"hx"
"ino"
"erl"
"monkey"
"java"
"php", "php5"
"go"
"lua"
"scss"
"less"
"css"
"styl",
"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 | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 5ba362236174dfef5a72cf25d877bff13cbc3e6a | 969 | https://github.com/flosse/sloc/blob/5ba362236174dfef5a72cf25d877bff13cbc3e6a/src/sloc.coffee | 152 | 201 |
flosse/sloc:src/sloc.coffee:1:raw_corpus | raw_corpus | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c2cdea855a9849d15a177cdcabc048a0a336a335 | 969 | https://github.com/flosse/sloc/blob/c2cdea855a9849d15a177cdcabc048a0a336a335/src/sloc.coffee | 21 | 65 | ||
flosse/sloc:src/sloc.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/... | var getCommentExpressions;
getCommentExpressions = function(lang) {
var single, start, stop;
// single line comments
single = (function() {
switch (lang) {
case "coffee":
case "py":
return /\#/;
case "js":
case "c":
case "cc":
case "cpp":
case "h":
case... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | c2cdea855a9849d15a177cdcabc048a0a336a335 | 969 | https://github.com/flosse/sloc/blob/c2cdea855a9849d15a177cdcabc048a0a336a335/src/sloc.coffee | 21 | 65 |
flosse/sloc:src/sloc.coffee:1: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 "coffee":
case "py":
return /\#/;
case "js":
case "c":
... | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c2cdea855a9849d15a177cdcabc048a0a336a335 | 969 | https://github.com/flosse/sloc/blob/c2cdea855a9849d15a177cdcabc048a0a336a335/src/sloc.coffee | 21 | 65 |
flosse/sloc:src/sloc.coffee:1:completion | completion | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
... | when "js", "c", "cc", "cpp", "h", "hpp", "hx", "ino", "java", \
"php", "php5", "go", "css", "scss", "less", "styl"
start = /\/\*+/
stop = /\*\/{1}/
when "python", "py"
start = stop = /\"{3}|\'{3}/
when "html"
start = /<\!--/
stop = /-->/
when "lua"
start = ... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c2cdea855a9849d15a177cdcabc048a0a336a335 | 969 | https://github.com/flosse/sloc/blob/c2cdea855a9849d15a177cdcabc048a0a336a335/src/sloc.coffee | 21 | 65 |
flosse/sloc:src/sloc.coffee:9:raw_corpus | raw_corpus | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = countBlock res
single = lineSu... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c2cdea855a9849d15a177cdcabc048a0a336a335 | 969 | https://github.com/flosse/sloc/blob/c2cdea855a9849d15a177cdcabc048a0a336a335/src/sloc.coffee | 146 | 195 | ||
flosse/sloc:src/sloc.coffee:9:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpre... | var slocModule;
slocModule = function(code, lang) {
var block, comment, empty, mixed, ref, ref1, res, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
total = 1 + ((ref = code.match(newLines)) != null ? ref.length : void 0) || 0;
empty = ((ref1 = ... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | c2cdea855a9849d15a177cdcabc048a0a336a335 | 969 | https://github.com/flosse/sloc/blob/c2cdea855a9849d15a177cdcabc048a0a336a335/src/sloc.coffee | 146 | 195 |
flosse/sloc:src/sloc.coffee:9:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var slocModule;
slocModule = function(code, lang) {
var block, comment, empty, mixed, ref, ref1, res, single, source, total;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
total = 1 + ((ref = code.match(newLines)) !... | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = countBlock res
single = lineSu... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c2cdea855a9849d15a177cdcabc048a0a336a335 | 969 | https://github.com/flosse/sloc/blob/c2cdea855a9849d15a177cdcabc048a0a336a335/src/sloc.coffee | 146 | 195 |
flosse/sloc:src/sloc.coffee:9:completion | completion | slocModule = (code, lang) ->
unless typeof code is "string"
throw new TypeError "'code' has to be a string"
total = 1 + code.match(newLines)?.length or 0
empty = code.match(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
comment = countBlock res
single = lineSu... | "h"
"hpp"
"hx"
"ino"
"erl"
"java"
"php", "php5"
"go"
"lua"
"scss"
"less"
"css"
"styl",
"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 ... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | c2cdea855a9849d15a177cdcabc048a0a336a335 | 969 | https://github.com/flosse/sloc/blob/c2cdea855a9849d15a177cdcabc048a0a336a335/src/sloc.coffee | 146 | 195 |
flosse/sloc:src/sloc.coffee:9: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(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
cloc = countBlock res
scloc = lineSum res.sing... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 1f3678f1aba58e0f725ecc0d258883bd4d97488a | 969 | https://github.com/flosse/sloc/blob/1f3678f1aba58e0f725ecc0d258883bd4d97488a/src/sloc.coffee | 145 | 194 | ||
flosse/sloc:src/sloc.coffee:9:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
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(emptyLines)?.length or 0
res = countComments code, getCommentExpressions... | var slocModule;
slocModule = function(code, lang) {
var cloc, loc, mcloc, mxloc, nloc, ref, ref1, res, scloc, sloc;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
loc = 1 + ((ref = code.match(newLines)) != null ? ref.length : void 0) || 0;
nloc = ((ref1 = code.match(e... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 1f3678f1aba58e0f725ecc0d258883bd4d97488a | 969 | https://github.com/flosse/sloc/blob/1f3678f1aba58e0f725ecc0d258883bd4d97488a/src/sloc.coffee | 145 | 194 |
flosse/sloc:src/sloc.coffee:9:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var slocModule;
slocModule = function(code, lang) {
var cloc, loc, mcloc, mxloc, nloc, ref, ref1, res, scloc, sloc;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
loc = 1 + ((ref = code.match(newLines)) != null ? re... | 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(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
cloc = countBlock res
scloc = lineSum res.sing... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 1f3678f1aba58e0f725ecc0d258883bd4d97488a | 969 | https://github.com/flosse/sloc/blob/1f3678f1aba58e0f725ecc0d258883bd4d97488a/src/sloc.coffee | 145 | 194 |
flosse/sloc:src/sloc.coffee:9: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(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
cloc = countBlock res
scloc = lineSum res.sing... | "h"
"hpp"
"hx"
"ino"
"erl"
"java"
"php", "php5"
"go"
"lua"
"scss"
"less"
"css"
"styl",
"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 ... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 1f3678f1aba58e0f725ecc0d258883bd4d97488a | 969 | https://github.com/flosse/sloc/blob/1f3678f1aba58e0f725ecc0d258883bd4d97488a/src/sloc.coffee | 145 | 194 |
flosse/sloc:src/sloc.coffee:1:raw_corpus | raw_corpus | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
/\%... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | a99630c4ff2c4031bfd448251e897e72e5f5460e | 969 | https://github.com/flosse/sloc/blob/a99630c4ff2c4031bfd448251e897e72e5f5460e/src/sloc.coffee | 20 | 64 | ||
flosse/sloc:src/sloc.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
... | var getCommentExpressions;
getCommentExpressions = function(lang) {
var single, start, stop;
// single line comments
single = (function() {
switch (lang) {
case "coffee":
case "py":
return /\#/;
case "js":
case "c":
case "cc":
case "cpp":
case "h":
case... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | a99630c4ff2c4031bfd448251e897e72e5f5460e | 969 | https://github.com/flosse/sloc/blob/a99630c4ff2c4031bfd448251e897e72e5f5460e/src/sloc.coffee | 20 | 64 |
flosse/sloc:src/sloc.coffee:1: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 "coffee":
case "py":
return /\#/;
case "js":
case "c":
... | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
/\%... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | a99630c4ff2c4031bfd448251e897e72e5f5460e | 969 | https://github.com/flosse/sloc/blob/a99630c4ff2c4031bfd448251e897e72e5f5460e/src/sloc.coffee | 20 | 64 |
flosse/sloc:src/sloc.coffee:1:completion | completion | getCommentExpressions = (lang) ->
# single line comments
single =
switch lang
when "coffee", "py"
/\#/
when "js", "c", "cc", "cpp", "h", "hpp", "ino", "java", \
"php", "php5", "go", "scss", "less", "styl"
/\/{2}/
when "lua"
/--/
when "erl"
/\%... | when "js", "c", "cc", "cpp", "h", "hpp", "ino", "java", \
"php", "php5", "go", "css", "scss", "less", "styl"
start = /\/\*+/
stop = /\*\/{1}/
when "python", "py"
start = stop = /\"{3}|\'{3}/
when "html"
start = /<\!--/
stop = /-->/
when "lua"
start = /--\[{... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | a99630c4ff2c4031bfd448251e897e72e5f5460e | 969 | https://github.com/flosse/sloc/blob/a99630c4ff2c4031bfd448251e897e72e5f5460e/src/sloc.coffee | 20 | 64 |
flosse/sloc:src/sloc.coffee:9: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(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
cloc = countBlock res
scloc = lineSum res.sing... | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | a99630c4ff2c4031bfd448251e897e72e5f5460e | 969 | https://github.com/flosse/sloc/blob/a99630c4ff2c4031bfd448251e897e72e5f5460e/src/sloc.coffee | 145 | 193 | ||
flosse/sloc:src/sloc.coffee:9:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
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(emptyLines)?.length or 0
res = countComments code, getCommentExpressions... | var slocModule;
slocModule = function(code, lang) {
var cloc, loc, mcloc, mxloc, nloc, ref, ref1, res, scloc, sloc;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
loc = 1 + ((ref = code.match(newLines)) != null ? ref.length : void 0) || 0;
nloc = ((ref1 = code.match(e... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | a99630c4ff2c4031bfd448251e897e72e5f5460e | 969 | https://github.com/flosse/sloc/blob/a99630c4ff2c4031bfd448251e897e72e5f5460e/src/sloc.coffee | 145 | 193 |
flosse/sloc:src/sloc.coffee:9:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var slocModule;
slocModule = function(code, lang) {
var cloc, loc, mcloc, mxloc, nloc, ref, ref1, res, scloc, sloc;
if (typeof code !== "string") {
throw new TypeError("'code' has to be a string");
}
loc = 1 + ((ref = code.match(newLines)) != null ? re... | 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(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
cloc = countBlock res
scloc = lineSum res.sing... | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | a99630c4ff2c4031bfd448251e897e72e5f5460e | 969 | https://github.com/flosse/sloc/blob/a99630c4ff2c4031bfd448251e897e72e5f5460e/src/sloc.coffee | 145 | 193 |
flosse/sloc:src/sloc.coffee:9: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(emptyLines)?.length or 0
res = countComments code, getCommentExpressions lang
cloc = countBlock res
scloc = lineSum res.sing... | "cpp"
"h"
"hpp"
"ino"
"erl"
"java"
"php", "php5"
"go"
"lua"
"scss"
"less"
"css"
"styl",
"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... | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | a99630c4ff2c4031bfd448251e897e72e5f5460e | 969 | https://github.com/flosse/sloc/blob/a99630c4ff2c4031bfd448251e897e72e5f5460e/src/sloc.coffee | 145 | 193 |
flosse/sloc:src/sloc.coffee:1:raw_corpus | raw_corpus | countMixed = (lines, match, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.push {type: 'mixed', start: idx, stop: idx}
if nonEmptyLine.exec lines[startIdx-idx]
res.push {type: 'mixed', start: startIdx, stop: startIdx} | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 19 | 25 | ||
flosse/sloc:src/sloc.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
countMixed = (lines, match, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.push {type: 'mixed', start: idx, stop: idx}
if nonEmptyLine.exec lines[startIdx-idx]
res.push {type: 'mixed', start: startIdx, stop: startIdx}
``` | var countMixed;
countMixed = function(lines, match, idx, startIdx, res) {
if (nonEmptyLine.exec(lines[0]) && idx !== 0) {
res.push({
type: 'mixed',
start: idx,
stop: idx
});
}
if (nonEmptyLine.exec(lines[startIdx - idx])) {
return res.push({
type: 'mixed',
start: startId... | CoffeeScript | JavaScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 19 | 25 |
flosse/sloc:src/sloc.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var countMixed;
countMixed = function(lines, match, idx, startIdx, res) {
if (nonEmptyLine.exec(lines[0]) && idx !== 0) {
res.push({
type: 'mixed',
start: idx,
stop: idx
});
}
if (nonEmptyLine.exec(lines[startIdx - idx])) {
retu... | countMixed = (lines, match, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0
res.push {type: 'mixed', start: idx, stop: idx}
if nonEmptyLine.exec lines[startIdx-idx]
res.push {type: 'mixed', start: startIdx, stop: startIdx} | JavaScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 19 | 25 |
flosse/sloc:src/sloc.coffee:1:completion | completion | countMixed = (lines, match, idx, startIdx, res) ->
if nonEmptyLine.exec(lines[0]) and idx isnt 0 | res.push {type: 'mixed', start: idx, stop: idx}
if nonEmptyLine.exec lines[startIdx-idx]
res.push {type: 'mixed', start: startIdx, stop: startIdx} | CoffeeScript | CoffeeScript | flosse/sloc | src/sloc.coffee | MIT | 62d259259c1096614d816567a79eae4fa2389fa5 | 969 | https://github.com/flosse/sloc/blob/62d259259c1096614d816567a79eae4fa2389fa5/src/sloc.coffee | 19 | 25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.