repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
anicollection/anicollection | config/grunt/tasks/generate_db.js | createAnimationObject | function createAnimationObject(categoryName, fileName){
var animation,
inputFilepath = config.src + categoryName + '/' + fileName + '.css',
inputPlainFilepath = config.unprefixedSrc + categoryName + '/' + fileName + '.css',
outpuFilepath = config.dest + categoryName + '/' + 'db_'+ fileName +... | javascript | function createAnimationObject(categoryName, fileName){
var animation,
inputFilepath = config.src + categoryName + '/' + fileName + '.css',
inputPlainFilepath = config.unprefixedSrc + categoryName + '/' + fileName + '.css',
outpuFilepath = config.dest + categoryName + '/' + 'db_'+ fileName +... | [
"function",
"createAnimationObject",
"(",
"categoryName",
",",
"fileName",
")",
"{",
"var",
"animation",
",",
"inputFilepath",
"=",
"config",
".",
"src",
"+",
"categoryName",
"+",
"'/'",
"+",
"fileName",
"+",
"'.css'",
",",
"inputPlainFilepath",
"=",
"config",
... | Create and save the animation object as json
@author Dariel Noel <darielnoel@gmail.com>
@since 2015-03-10
@param {[type]} categoryName [description]
@param {[type]} fileName [description]
@return {[type]} [description] | [
"Create",
"and",
"save",
"the",
"animation",
"object",
"as",
"json"
] | f998306f29ae1d130eebcd4c64a9c9737a7613e9 | https://github.com/anicollection/anicollection/blob/f998306f29ae1d130eebcd4c64a9c9737a7613e9/config/grunt/tasks/generate_db.js#L95-L131 | train |
micromatch/expand-brackets | index.js | brackets | function brackets(pattern, options) {
const res = brackets.create(pattern, options);
return res.output;
} | javascript | function brackets(pattern, options) {
const res = brackets.create(pattern, options);
return res.output;
} | [
"function",
"brackets",
"(",
"pattern",
",",
"options",
")",
"{",
"const",
"res",
"=",
"brackets",
".",
"create",
"(",
"pattern",
",",
"options",
")",
";",
"return",
"res",
".",
"output",
";",
"}"
] | Parses the given POSIX character class `pattern` and returns a
string that can be used for creating regular expressions for matching.
@param {String} `pattern`
@param {Object} `options`
@return {Object}
@api public | [
"Parses",
"the",
"given",
"POSIX",
"character",
"class",
"pattern",
"and",
"returns",
"a",
"string",
"that",
"can",
"be",
"used",
"for",
"creating",
"regular",
"expressions",
"for",
"matching",
"."
] | 60d30312976b36065e24a81abdce23b868ccf0ef | https://github.com/micromatch/expand-brackets/blob/60d30312976b36065e24a81abdce23b868ccf0ef/index.js#L27-L30 | train |
riot/tmpl | src/notevil/index.js | safeEval | function safeEval(src, parentContext){
var tree = prepareAst(src)
var context = Object.create(parentContext || {})
return finalValue(evaluateAst(tree, context))
} | javascript | function safeEval(src, parentContext){
var tree = prepareAst(src)
var context = Object.create(parentContext || {})
return finalValue(evaluateAst(tree, context))
} | [
"function",
"safeEval",
"(",
"src",
",",
"parentContext",
")",
"{",
"var",
"tree",
"=",
"prepareAst",
"(",
"src",
")",
"var",
"context",
"=",
"Object",
".",
"create",
"(",
"parentContext",
"||",
"{",
"}",
")",
"return",
"finalValue",
"(",
"evaluateAst",
... | 'eval' with a controlled environment | [
"eval",
"with",
"a",
"controlled",
"environment"
] | e01c28f094ce293c61aba90b7c9242d9b050fb49 | https://github.com/riot/tmpl/blob/e01c28f094ce293c61aba90b7c9242d9b050fb49/src/notevil/index.js#L11-L15 | train |
riot/tmpl | src/notevil/index.js | FunctionFactory | function FunctionFactory(parentContext){
var context = Object.create(parentContext || {})
return function Function() {
// normalize arguments array
var args = Array.prototype.slice.call(arguments)
var src = args.slice(-1)[0]
args = args.slice(0,-1)
if (typeof src === 'string'){
//HACK: esp... | javascript | function FunctionFactory(parentContext){
var context = Object.create(parentContext || {})
return function Function() {
// normalize arguments array
var args = Array.prototype.slice.call(arguments)
var src = args.slice(-1)[0]
args = args.slice(0,-1)
if (typeof src === 'string'){
//HACK: esp... | [
"function",
"FunctionFactory",
"(",
"parentContext",
")",
"{",
"var",
"context",
"=",
"Object",
".",
"create",
"(",
"parentContext",
"||",
"{",
"}",
")",
"return",
"function",
"Function",
"(",
")",
"{",
"// normalize arguments array",
"var",
"args",
"=",
"Arra... | create a 'Function' constructor for a controlled environment | [
"create",
"a",
"Function",
"constructor",
"for",
"a",
"controlled",
"environment"
] | e01c28f094ce293c61aba90b7c9242d9b050fb49 | https://github.com/riot/tmpl/blob/e01c28f094ce293c61aba90b7c9242d9b050fb49/src/notevil/index.js#L20-L34 | train |
riot/tmpl | src/notevil/index.js | walkAll | function walkAll(nodes){
var result = undefined
for (var i=0;i<nodes.length;i++){
var childNode = nodes[i]
if (childNode.type === 'EmptyStatement') continue
result = walk(childNode)
if (result instanceof ReturnValue){
return result
}
}
return result
} | javascript | function walkAll(nodes){
var result = undefined
for (var i=0;i<nodes.length;i++){
var childNode = nodes[i]
if (childNode.type === 'EmptyStatement') continue
result = walk(childNode)
if (result instanceof ReturnValue){
return result
}
}
return result
} | [
"function",
"walkAll",
"(",
"nodes",
")",
"{",
"var",
"result",
"=",
"undefined",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"nodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"childNode",
"=",
"nodes",
"[",
"i",
"]",
"if",
"(",
"ch... | recursively walk every node in an array | [
"recursively",
"walk",
"every",
"node",
"in",
"an",
"array"
] | e01c28f094ce293c61aba90b7c9242d9b050fb49 | https://github.com/riot/tmpl/blob/e01c28f094ce293c61aba90b7c9242d9b050fb49/src/notevil/index.js#L54-L65 | train |
riot/tmpl | src/notevil/index.js | setValue | function setValue(object, left, right, operator){
var name = null
if (left.type === 'Identifier'){
name = left.name
// handle parent context shadowing
object = objectForKey(object, name, primitives)
} else if (left.type === 'MemberExpression'){
if (left.computed){
name = wal... | javascript | function setValue(object, left, right, operator){
var name = null
if (left.type === 'Identifier'){
name = left.name
// handle parent context shadowing
object = objectForKey(object, name, primitives)
} else if (left.type === 'MemberExpression'){
if (left.computed){
name = wal... | [
"function",
"setValue",
"(",
"object",
",",
"left",
",",
"right",
",",
"operator",
")",
"{",
"var",
"name",
"=",
"null",
"if",
"(",
"left",
".",
"type",
"===",
"'Identifier'",
")",
"{",
"name",
"=",
"left",
".",
"name",
"// handle parent context shadowing"... | set a value in the specified context if allowed | [
"set",
"a",
"value",
"in",
"the",
"specified",
"context",
"if",
"allowed"
] | e01c28f094ce293c61aba90b7c9242d9b050fb49 | https://github.com/riot/tmpl/blob/e01c28f094ce293c61aba90b7c9242d9b050fb49/src/notevil/index.js#L387-L415 | train |
riot/tmpl | src/notevil/index.js | unsupportedExpression | function unsupportedExpression(node){
console.error(node)
var err = new Error('Unsupported expression: ' + node.type)
err.node = node
throw err
} | javascript | function unsupportedExpression(node){
console.error(node)
var err = new Error('Unsupported expression: ' + node.type)
err.node = node
throw err
} | [
"function",
"unsupportedExpression",
"(",
"node",
")",
"{",
"console",
".",
"error",
"(",
"node",
")",
"var",
"err",
"=",
"new",
"Error",
"(",
"'Unsupported expression: '",
"+",
"node",
".",
"type",
")",
"err",
".",
"node",
"=",
"node",
"throw",
"err",
"... | when an unsupported expression is encountered, throw an error | [
"when",
"an",
"unsupported",
"expression",
"is",
"encountered",
"throw",
"an",
"error"
] | e01c28f094ce293c61aba90b7c9242d9b050fb49 | https://github.com/riot/tmpl/blob/e01c28f094ce293c61aba90b7c9242d9b050fb49/src/notevil/index.js#L420-L425 | train |
riot/tmpl | src/notevil/index.js | objectForKey | function objectForKey(object, key, primitives){
var proto = primitives.getPrototypeOf(object)
if (!proto || hasOwnProperty(object, key)){
return object
} else {
return objectForKey(proto, key, primitives)
}
} | javascript | function objectForKey(object, key, primitives){
var proto = primitives.getPrototypeOf(object)
if (!proto || hasOwnProperty(object, key)){
return object
} else {
return objectForKey(proto, key, primitives)
}
} | [
"function",
"objectForKey",
"(",
"object",
",",
"key",
",",
"primitives",
")",
"{",
"var",
"proto",
"=",
"primitives",
".",
"getPrototypeOf",
"(",
"object",
")",
"if",
"(",
"!",
"proto",
"||",
"hasOwnProperty",
"(",
"object",
",",
"key",
")",
")",
"{",
... | walk a provided object's prototypal hierarchy to retrieve an inherited object | [
"walk",
"a",
"provided",
"object",
"s",
"prototypal",
"hierarchy",
"to",
"retrieve",
"an",
"inherited",
"object"
] | e01c28f094ce293c61aba90b7c9242d9b050fb49 | https://github.com/riot/tmpl/blob/e01c28f094ce293c61aba90b7c9242d9b050fb49/src/notevil/index.js#L428-L435 | train |
riot/tmpl | src/notevil/index.js | canSetProperty | function canSetProperty(object, property, primitives){
if (property === '__proto__' || primitives.isPrimitive(object)){
return false
} else if (object != null){
if (hasOwnProperty(object, property)){
if (propertyIsEnumerable(object, property)){
return true
} else {
return false
... | javascript | function canSetProperty(object, property, primitives){
if (property === '__proto__' || primitives.isPrimitive(object)){
return false
} else if (object != null){
if (hasOwnProperty(object, property)){
if (propertyIsEnumerable(object, property)){
return true
} else {
return false
... | [
"function",
"canSetProperty",
"(",
"object",
",",
"property",
",",
"primitives",
")",
"{",
"if",
"(",
"property",
"===",
"'__proto__'",
"||",
"primitives",
".",
"isPrimitive",
"(",
"object",
")",
")",
"{",
"return",
"false",
"}",
"else",
"if",
"(",
"object... | determine if we have write access to a property | [
"determine",
"if",
"we",
"have",
"write",
"access",
"to",
"a",
"property"
] | e01c28f094ce293c61aba90b7c9242d9b050fb49 | https://github.com/riot/tmpl/blob/e01c28f094ce293c61aba90b7c9242d9b050fb49/src/notevil/index.js#L459-L477 | train |
howdyai/botkit-storage-firebase | src/index.js | get | function get(firebaseRef) {
return function(id, cb) {
firebaseRef.child(id).once('value').then(function(snapshot) {
cb(null, snapshot.val());
},
cb);
};
} | javascript | function get(firebaseRef) {
return function(id, cb) {
firebaseRef.child(id).once('value').then(function(snapshot) {
cb(null, snapshot.val());
},
cb);
};
} | [
"function",
"get",
"(",
"firebaseRef",
")",
"{",
"return",
"function",
"(",
"id",
",",
"cb",
")",
"{",
"firebaseRef",
".",
"child",
"(",
"id",
")",
".",
"once",
"(",
"'value'",
")",
".",
"then",
"(",
"function",
"(",
"snapshot",
")",
"{",
"cb",
"("... | Given a firebase ref, will return a function that will get a single value by ID
@param {Object} firebaseRef A reference to the firebase Object
@returns {Function} The get function | [
"Given",
"a",
"firebase",
"ref",
"will",
"return",
"a",
"function",
"that",
"will",
"get",
"a",
"single",
"value",
"by",
"ID"
] | 205d043124e2b253004458727ee12f5823b7ccc1 | https://github.com/howdyai/botkit-storage-firebase/blob/205d043124e2b253004458727ee12f5823b7ccc1/src/index.js#L57-L64 | train |
howdyai/botkit-storage-firebase | src/index.js | save | function save(firebaseRef) {
return function(data, cb) {
var firebase_update = {};
firebase_update[data.id] = data;
firebaseRef.update(firebase_update).then(cb);
};
} | javascript | function save(firebaseRef) {
return function(data, cb) {
var firebase_update = {};
firebase_update[data.id] = data;
firebaseRef.update(firebase_update).then(cb);
};
} | [
"function",
"save",
"(",
"firebaseRef",
")",
"{",
"return",
"function",
"(",
"data",
",",
"cb",
")",
"{",
"var",
"firebase_update",
"=",
"{",
"}",
";",
"firebase_update",
"[",
"data",
".",
"id",
"]",
"=",
"data",
";",
"firebaseRef",
".",
"update",
"(",... | Given a firebase ref, will return a function that will save an object. The object must have an id property
@param {Object} firebaseRef A reference to the firebase Object
@returns {Function} The save function | [
"Given",
"a",
"firebase",
"ref",
"will",
"return",
"a",
"function",
"that",
"will",
"save",
"an",
"object",
".",
"The",
"object",
"must",
"have",
"an",
"id",
"property"
] | 205d043124e2b253004458727ee12f5823b7ccc1 | https://github.com/howdyai/botkit-storage-firebase/blob/205d043124e2b253004458727ee12f5823b7ccc1/src/index.js#L72-L78 | train |
howdyai/botkit-storage-firebase | src/index.js | all | function all(firebaseRef) {
return function(cb) {
firebaseRef.once('value').then(function success(records) {
var results = records.val();
if (!results) {
return cb(null, []);
}
var list = Object.keys(results).map(function(key) {
... | javascript | function all(firebaseRef) {
return function(cb) {
firebaseRef.once('value').then(function success(records) {
var results = records.val();
if (!results) {
return cb(null, []);
}
var list = Object.keys(results).map(function(key) {
... | [
"function",
"all",
"(",
"firebaseRef",
")",
"{",
"return",
"function",
"(",
"cb",
")",
"{",
"firebaseRef",
".",
"once",
"(",
"'value'",
")",
".",
"then",
"(",
"function",
"success",
"(",
"records",
")",
"{",
"var",
"results",
"=",
"records",
".",
"val"... | Given a firebase ref, will return a function that will return all objects stored.
@param {Object} firebaseRef A reference to the firebase Object
@returns {Function} The all function | [
"Given",
"a",
"firebase",
"ref",
"will",
"return",
"a",
"function",
"that",
"will",
"return",
"all",
"objects",
"stored",
"."
] | 205d043124e2b253004458727ee12f5823b7ccc1 | https://github.com/howdyai/botkit-storage-firebase/blob/205d043124e2b253004458727ee12f5823b7ccc1/src/index.js#L86-L102 | train |
travist/jquery.go.js | lib/jquery.go.js | function(selector, context) {
this.selector = selector;
if (typeof context == 'function') {
this.context = null;
this.asyncExecute(null, null, context);
}
else {
this.context = context;
}
this.instance = -1;
this.index = -1;
this.length = -1;
} | javascript | function(selector, context) {
this.selector = selector;
if (typeof context == 'function') {
this.context = null;
this.asyncExecute(null, null, context);
}
else {
this.context = context;
}
this.instance = -1;
this.index = -1;
this.length = -1;
} | [
"function",
"(",
"selector",
",",
"context",
")",
"{",
"this",
".",
"selector",
"=",
"selector",
";",
"if",
"(",
"typeof",
"context",
"==",
"'function'",
")",
"{",
"this",
".",
"context",
"=",
"null",
";",
"this",
".",
"asyncExecute",
"(",
"null",
",",... | jQuery Interface class.
@param {string} selector
The selector to use for the interface.
@param {string} context
The context to use for the interface.
@returns {jQueryInterface} | [
"jQuery",
"Interface",
"class",
"."
] | 0aad43403b26ed73d892451a7dff8087004cc922 | https://github.com/travist/jquery.go.js/blob/0aad43403b26ed73d892451a7dff8087004cc922/lib/jquery.go.js#L100-L113 | train | |
travist/jquery.go.js | lib/jquery.go.js | function(url, callback) {
var self = this;
getPage(function(page) {
// Set the page size if it hasn't already been set.
if (!self.viewportSizeSet) {
self.viewportSizeSet = true;
page.set('viewportSize', {
width: self.config.width,
height: self.config.height
... | javascript | function(url, callback) {
var self = this;
getPage(function(page) {
// Set the page size if it hasn't already been set.
if (!self.viewportSizeSet) {
self.viewportSizeSet = true;
page.set('viewportSize', {
width: self.config.width,
height: self.config.height
... | [
"function",
"(",
"url",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"getPage",
"(",
"function",
"(",
"page",
")",
"{",
"// Set the page size if it hasn't already been set.",
"if",
"(",
"!",
"self",
".",
"viewportSizeSet",
")",
"{",
"self",
".... | Used to visit a page.
@param {string} url
The url you wish to visit.
@param {function} callback
Called when the page is done visiting. | [
"Used",
"to",
"visit",
"a",
"page",
"."
] | 0aad43403b26ed73d892451a7dff8087004cc922 | https://github.com/travist/jquery.go.js/blob/0aad43403b26ed73d892451a7dff8087004cc922/lib/jquery.go.js#L353-L399 | train | |
travist/jquery.go.js | lib/jquery.go.js | function(callback, nowait) {
var self = this;
var loadWait = function() {
setTimeout(function() {
self.waitForPage(callback, true);
}, 100);
};
if (nowait) {
if (loading) {
loadWait();
}
else {
getPage(function(page) {
page.evaluate(functio... | javascript | function(callback, nowait) {
var self = this;
var loadWait = function() {
setTimeout(function() {
self.waitForPage(callback, true);
}, 100);
};
if (nowait) {
if (loading) {
loadWait();
}
else {
getPage(function(page) {
page.evaluate(functio... | [
"function",
"(",
"callback",
",",
"nowait",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"loadWait",
"=",
"function",
"(",
")",
"{",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"self",
".",
"waitForPage",
"(",
"callback",
",",
"true",
")",
";"... | Wait for the page to load.
@param {type} callback
@returns {undefined} | [
"Wait",
"for",
"the",
"page",
"to",
"load",
"."
] | 0aad43403b26ed73d892451a7dff8087004cc922 | https://github.com/travist/jquery.go.js/blob/0aad43403b26ed73d892451a7dff8087004cc922/lib/jquery.go.js#L407-L436 | train | |
travist/jquery.go.js | lib/jquery.go.js | function(element, callback, nowait) {
var self = this;
if (!nowait) {
this.waitForPage(function() {
self.waitForElement(element, callback, true);
});
}
else {
var loadWait = function() {
setTimeout(function() {
self.waitForElement(element, callback, true);
... | javascript | function(element, callback, nowait) {
var self = this;
if (!nowait) {
this.waitForPage(function() {
self.waitForElement(element, callback, true);
});
}
else {
var loadWait = function() {
setTimeout(function() {
self.waitForElement(element, callback, true);
... | [
"function",
"(",
"element",
",",
"callback",
",",
"nowait",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"nowait",
")",
"{",
"this",
".",
"waitForPage",
"(",
"function",
"(",
")",
"{",
"self",
".",
"waitForElement",
"(",
"element",
",",... | Waits for an element to be present. | [
"Waits",
"for",
"an",
"element",
"to",
"be",
"present",
"."
] | 0aad43403b26ed73d892451a7dff8087004cc922 | https://github.com/travist/jquery.go.js/blob/0aad43403b26ed73d892451a7dff8087004cc922/lib/jquery.go.js#L441-L474 | train | |
travist/jquery.go.js | lib/jquery.go.js | function(filename, done) {
this.debug('Capturing page at ' + filename);
getPage(function(page) {
page.render(filename, done);
});
} | javascript | function(filename, done) {
this.debug('Capturing page at ' + filename);
getPage(function(page) {
page.render(filename, done);
});
} | [
"function",
"(",
"filename",
",",
"done",
")",
"{",
"this",
".",
"debug",
"(",
"'Capturing page at '",
"+",
"filename",
")",
";",
"getPage",
"(",
"function",
"(",
"page",
")",
"{",
"page",
".",
"render",
"(",
"filename",
",",
"done",
")",
";",
"}",
"... | Capture the page as an image. | [
"Capture",
"the",
"page",
"as",
"an",
"image",
"."
] | 0aad43403b26ed73d892451a7dff8087004cc922 | https://github.com/travist/jquery.go.js/blob/0aad43403b26ed73d892451a7dff8087004cc922/lib/jquery.go.js#L479-L484 | train | |
travist/jquery.go.js | lib/jquery.go.js | function(selector, filename, done) {
this.debug('Upload ' + filename + ' to ' + selector);
getPage(function(page) {
page.uploadFile(selector, filename, done);
});
done();
} | javascript | function(selector, filename, done) {
this.debug('Upload ' + filename + ' to ' + selector);
getPage(function(page) {
page.uploadFile(selector, filename, done);
});
done();
} | [
"function",
"(",
"selector",
",",
"filename",
",",
"done",
")",
"{",
"this",
".",
"debug",
"(",
"'Upload '",
"+",
"filename",
"+",
"' to '",
"+",
"selector",
")",
";",
"getPage",
"(",
"function",
"(",
"page",
")",
"{",
"page",
".",
"uploadFile",
"(",
... | Upload File to a Form. | [
"Upload",
"File",
"to",
"a",
"Form",
"."
] | 0aad43403b26ed73d892451a7dff8087004cc922 | https://github.com/travist/jquery.go.js/blob/0aad43403b26ed73d892451a7dff8087004cc922/lib/jquery.go.js#L489-L495 | train | |
misterhat/omdb | index.js | formatRuntime | function formatRuntime(raw) {
var hours, minutes;
if (!raw) {
return null;
}
hours = raw.match(/(\d+) h/);
minutes = raw.match(/(\d+) min/);
hours = hours ? hours[1] : 0;
minutes = minutes ? +minutes[1] : 0;
return (hours * 60) + minutes;
} | javascript | function formatRuntime(raw) {
var hours, minutes;
if (!raw) {
return null;
}
hours = raw.match(/(\d+) h/);
minutes = raw.match(/(\d+) min/);
hours = hours ? hours[1] : 0;
minutes = minutes ? +minutes[1] : 0;
return (hours * 60) + minutes;
} | [
"function",
"formatRuntime",
"(",
"raw",
")",
"{",
"var",
"hours",
",",
"minutes",
";",
"if",
"(",
"!",
"raw",
")",
"{",
"return",
"null",
";",
"}",
"hours",
"=",
"raw",
".",
"match",
"(",
"/",
"(\\d+) h",
"/",
")",
";",
"minutes",
"=",
"raw",
".... | Format strings of hours & minutes into minutes. For example, "1 h 30 min" == 90. | [
"Format",
"strings",
"of",
"hours",
"&",
"minutes",
"into",
"minutes",
".",
"For",
"example",
"1",
"h",
"30",
"min",
"==",
"90",
"."
] | bac33cae87a24d3d2ae9e57836f2e35d8f4deb7e | https://github.com/misterhat/omdb/blob/bac33cae87a24d3d2ae9e57836f2e35d8f4deb7e/index.js#L34-L48 | train |
misterhat/omdb | index.js | formatList | function formatList(raw) {
var list;
if (!raw) {
return [];
}
list = raw.replace(/\(.+?\)/g, '').split(', ');
list = list.map(function (item) {
return item.trim();
});
return list;
} | javascript | function formatList(raw) {
var list;
if (!raw) {
return [];
}
list = raw.replace(/\(.+?\)/g, '').split(', ');
list = list.map(function (item) {
return item.trim();
});
return list;
} | [
"function",
"formatList",
"(",
"raw",
")",
"{",
"var",
"list",
";",
"if",
"(",
"!",
"raw",
")",
"{",
"return",
"[",
"]",
";",
"}",
"list",
"=",
"raw",
".",
"replace",
"(",
"/",
"\\(.+?\\)",
"/",
"g",
",",
"''",
")",
".",
"split",
"(",
"', '",
... | Remove all the strings found within brackets and split by comma. | [
"Remove",
"all",
"the",
"strings",
"found",
"within",
"brackets",
"and",
"split",
"by",
"comma",
"."
] | bac33cae87a24d3d2ae9e57836f2e35d8f4deb7e | https://github.com/misterhat/omdb/blob/bac33cae87a24d3d2ae9e57836f2e35d8f4deb7e/index.js#L56-L69 | train |
misterhat/omdb | index.js | formatAwards | function formatAwards(raw) {
var wins, nominations;
if (!raw) {
return { wins: 0, nominations: 0, text: '' };
}
wins = raw.match(/(\d+) wins?/i);
nominations = raw.match(/(\d+) nominations?/i);
return {
wins: wins ? +wins[1] : 0,
nominations: nominations ? +nominations... | javascript | function formatAwards(raw) {
var wins, nominations;
if (!raw) {
return { wins: 0, nominations: 0, text: '' };
}
wins = raw.match(/(\d+) wins?/i);
nominations = raw.match(/(\d+) nominations?/i);
return {
wins: wins ? +wins[1] : 0,
nominations: nominations ? +nominations... | [
"function",
"formatAwards",
"(",
"raw",
")",
"{",
"var",
"wins",
",",
"nominations",
";",
"if",
"(",
"!",
"raw",
")",
"{",
"return",
"{",
"wins",
":",
"0",
",",
"nominations",
":",
"0",
",",
"text",
":",
"''",
"}",
";",
"}",
"wins",
"=",
"raw",
... | Try to find the win and nomination count, but also keep raw just in case. | [
"Try",
"to",
"find",
"the",
"win",
"and",
"nomination",
"count",
"but",
"also",
"keep",
"raw",
"just",
"in",
"case",
"."
] | bac33cae87a24d3d2ae9e57836f2e35d8f4deb7e | https://github.com/misterhat/omdb/blob/bac33cae87a24d3d2ae9e57836f2e35d8f4deb7e/index.js#L72-L87 | train |
BlockchainZoo/keyhub-vault | packages/keyhub-vault-nxt/lib/js/crypto/curve25519_.js | function(r, x) {
var r1 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var r2 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
curve25519_sqrmodp(r1, x); // r1 = x^2
curve25519_mulasmall(r2, x, 486662); // r2 = Ax
curve25519_addmodp(r, r1, r2); // r = x^2 + Ax
curve25519_addmodp(r1, r, curve25519_one()); ... | javascript | function(r, x) {
var r1 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var r2 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
curve25519_sqrmodp(r1, x); // r1 = x^2
curve25519_mulasmall(r2, x, 486662); // r2 = Ax
curve25519_addmodp(r, r1, r2); // r = x^2 + Ax
curve25519_addmodp(r1, r, curve25519_one()); ... | [
"function",
"(",
"r",
",",
"x",
")",
"{",
"var",
"r1",
"=",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
";",
... | Montgomery curve with A=486662 and B=1 | [
"Montgomery",
"curve",
"with",
"A",
"=",
"486662",
"and",
"B",
"=",
"1"
] | dbf4936224aa53a4a33acbe0fa84fb38a62bbd13 | https://github.com/BlockchainZoo/keyhub-vault/blob/dbf4936224aa53a4a33acbe0fa84fb38a62bbd13/packages/keyhub-vault-nxt/lib/js/crypto/curve25519_.js#L607-L615 | train | |
rdub80/aframe-gui | examples/visualizer/third-party/components/ring-on-beat.js | function () {
this.rings.forEach(function (ringEl) {
var scale = ringEl.getComputedAttribute('scale');
ringEl.setAttribute('scale', {
x: scale.x * 1.06 + .05,
y: scale.y * 1.06 + .05,
z: scale.z
});
});
} | javascript | function () {
this.rings.forEach(function (ringEl) {
var scale = ringEl.getComputedAttribute('scale');
ringEl.setAttribute('scale', {
x: scale.x * 1.06 + .05,
y: scale.y * 1.06 + .05,
z: scale.z
});
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"rings",
".",
"forEach",
"(",
"function",
"(",
"ringEl",
")",
"{",
"var",
"scale",
"=",
"ringEl",
".",
"getComputedAttribute",
"(",
"'scale'",
")",
";",
"ringEl",
".",
"setAttribute",
"(",
"'scale'",
",",
"{",
"x... | Expand ring radii. | [
"Expand",
"ring",
"radii",
"."
] | eb4549f17543b2ada039b1c65658dd72c35b19d1 | https://github.com/rdub80/aframe-gui/blob/eb4549f17543b2ada039b1c65658dd72c35b19d1/examples/visualizer/third-party/components/ring-on-beat.js#L34-L43 | train | |
MaartenDesnouck/google-apps-script | lib/functions/authenticate.js | getTokenDefault | function getTokenDefault(code, token, oauth2Client) {
return new Promise((resolve, reject) => {
const requestData = {
code,
token,
};
request({
url: 'https://us-central1-gas-include.cloudfunctions.net/getToken',
method: "POST",
json... | javascript | function getTokenDefault(code, token, oauth2Client) {
return new Promise((resolve, reject) => {
const requestData = {
code,
token,
};
request({
url: 'https://us-central1-gas-include.cloudfunctions.net/getToken',
method: "POST",
json... | [
"function",
"getTokenDefault",
"(",
"code",
",",
"token",
",",
"oauth2Client",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"requestData",
"=",
"{",
"code",
",",
"token",
",",
"}",
";",
"request",
"... | Get a token for a the defaut Oauth client.
@param {google.auth.OAuth2} code - Optional code to get token for.
@param {google.auth.OAuth2} token - Optional token to refresh.
@param {google.auth.OAuth2} oauth2Client - The OAuth2 client to get token for.
@returns {Promise} - A promise resolving a tokent | [
"Get",
"a",
"token",
"for",
"a",
"the",
"defaut",
"Oauth",
"client",
"."
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/authenticate.js#L37-L65 | train |
MaartenDesnouck/google-apps-script | lib/functions/authenticate.js | getTokenCustom | function getTokenCustom(code, oauth2Client) {
return new Promise((resolve, reject) => {
if (code) {
oauth2Client.getToken(code, (err, newToken) => {
if (err) {
reject(err);
return;
}
resolve(newToken);
... | javascript | function getTokenCustom(code, oauth2Client) {
return new Promise((resolve, reject) => {
if (code) {
oauth2Client.getToken(code, (err, newToken) => {
if (err) {
reject(err);
return;
}
resolve(newToken);
... | [
"function",
"getTokenCustom",
"(",
"code",
",",
"oauth2Client",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"code",
")",
"{",
"oauth2Client",
".",
"getToken",
"(",
"code",
",",
"(",
"err",
",",
... | Get a token for a custom Oauth client.
@param {google.auth.OAuth2} code - Optional code to get token for.
@param {google.auth.OAuth2} oauth2Client - The OAuth2 client to get token for.
@returns {Promise} - A promise resolving a token | [
"Get",
"a",
"token",
"for",
"a",
"custom",
"Oauth",
"client",
"."
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/authenticate.js#L74-L95 | train |
MaartenDesnouck/google-apps-script | lib/functions/getScripts.js | getScripts | function getScripts(auth, nameFilter, nextPageToken, allFiles) {
return new Promise((resolve, reject) => {
let query = '';
if (nameFilter) {
query = `mimeType='${constants.MIME_GAS}' and name contains '${nameFilter}'`;
} else {
query = `mimeType='${constants.MIME_GAS}... | javascript | function getScripts(auth, nameFilter, nextPageToken, allFiles) {
return new Promise((resolve, reject) => {
let query = '';
if (nameFilter) {
query = `mimeType='${constants.MIME_GAS}' and name contains '${nameFilter}'`;
} else {
query = `mimeType='${constants.MIME_GAS}... | [
"function",
"getScripts",
"(",
"auth",
",",
"nameFilter",
",",
"nextPageToken",
",",
"allFiles",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"query",
"=",
"''",
";",
"if",
"(",
"nameFilter",
")",
"{"... | Lists the names and IDs of script files.
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@param {String} nameFilter - String to filter results on.
@param {String} nextPageToken - Token of the resultpage to get.
@param {String} allFiles - String to filter results on.
@returns {Promise} - A promise resol... | [
"Lists",
"the",
"names",
"and",
"IDs",
"of",
"script",
"files",
"."
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/getScripts.js#L16-L63 | train |
MaartenDesnouck/google-apps-script | lib/config.js | endDialog | function endDialog(success, config) {
if (success) {
createConfigFile(config);
console.log();
process.stdout.write('Succesfully configured gas');
checkbox.display('green');
process.exit(0);
} else {
console.log(`Only 'y' and 'n' are accepted inputs.`);
pro... | javascript | function endDialog(success, config) {
if (success) {
createConfigFile(config);
console.log();
process.stdout.write('Succesfully configured gas');
checkbox.display('green');
process.exit(0);
} else {
console.log(`Only 'y' and 'n' are accepted inputs.`);
pro... | [
"function",
"endDialog",
"(",
"success",
",",
"config",
")",
"{",
"if",
"(",
"success",
")",
"{",
"createConfigFile",
"(",
"config",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"process",
".",
"stdout",
".",
"write",
"(",
"'Succesfully configured gas'"... | Create a config file based on the values provided
@param {String} success - Whether or not the dialog completed succesfully
@param {String} config - The config we created trough the dialog
@returns {void} | [
"Create",
"a",
"config",
"file",
"based",
"on",
"the",
"values",
"provided"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/config.js#L31-L44 | train |
MaartenDesnouck/google-apps-script | lib/config.js | importConfig | function importConfig(optionalPath) {
process.stdout.write(`Importing your config from '${optionalPath}'`);
let config;
try {
config = fs.readJsonSync(optionalPath, 'utf8');
} catch (err) {
checkbox.display('red');
process.stdout.write(`Can't seem to read '${optionalPath}'`);
... | javascript | function importConfig(optionalPath) {
process.stdout.write(`Importing your config from '${optionalPath}'`);
let config;
try {
config = fs.readJsonSync(optionalPath, 'utf8');
} catch (err) {
checkbox.display('red');
process.stdout.write(`Can't seem to read '${optionalPath}'`);
... | [
"function",
"importConfig",
"(",
"optionalPath",
")",
"{",
"process",
".",
"stdout",
".",
"write",
"(",
"`",
"${",
"optionalPath",
"}",
"`",
")",
";",
"let",
"config",
";",
"try",
"{",
"config",
"=",
"fs",
".",
"readJsonSync",
"(",
"optionalPath",
",",
... | Import a config file
@param {String} optionalPath - The path where we will import the config from
@returns {void} | [
"Import",
"a",
"config",
"file"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/config.js#L52-L70 | train |
MaartenDesnouck/google-apps-script | lib/config.js | exportConfig | function exportConfig(optionalPath) {
// Read content of the global config file
let config = fs.readFileSync(configFile, 'utf8');
if (!config) {
config = '{}';
}
// Create file or print output
if (optionalPath) {
process.stdout.write(`Exporting your config to '${optionalPath}'`... | javascript | function exportConfig(optionalPath) {
// Read content of the global config file
let config = fs.readFileSync(configFile, 'utf8');
if (!config) {
config = '{}';
}
// Create file or print output
if (optionalPath) {
process.stdout.write(`Exporting your config to '${optionalPath}'`... | [
"function",
"exportConfig",
"(",
"optionalPath",
")",
"{",
"// Read content of the global config file",
"let",
"config",
"=",
"fs",
".",
"readFileSync",
"(",
"configFile",
",",
"'utf8'",
")",
";",
"if",
"(",
"!",
"config",
")",
"{",
"config",
"=",
"'{}'",
";",... | Export a config file
@param {String} optionalPath - The path where we will export the config to
@returns {void} | [
"Export",
"a",
"config",
"file"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/config.js#L78-L100 | train |
MaartenDesnouck/google-apps-script | lib/config.js | enterConfig | function enterConfig() {
const config = {};
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question(`Do you want to use .gs as extension for your local code files instead of .js? [${'y'.green}/${'n'.red}]\n > `, (input) => {
if (input ... | javascript | function enterConfig() {
const config = {};
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question(`Do you want to use .gs as extension for your local code files instead of .js? [${'y'.green}/${'n'.red}]\n > `, (input) => {
if (input ... | [
"function",
"enterConfig",
"(",
")",
"{",
"const",
"config",
"=",
"{",
"}",
";",
"const",
"rl",
"=",
"readline",
".",
"createInterface",
"(",
"{",
"input",
":",
"process",
".",
"stdin",
",",
"output",
":",
"process",
".",
"stdout",
",",
"}",
")",
";"... | Enter a configuration using questions in the terminal
@returns {void} | [
"Enter",
"a",
"configuration",
"using",
"questions",
"in",
"the",
"terminal"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/config.js#L107-L147 | train |
MaartenDesnouck/google-apps-script | lib/functions/remoteDeleteProject.js | deleteRemote | function deleteRemote(auth, projectId, name) {
return new Promise((resolve, reject) => {
const drive = google.drive('v3');
const options = {
auth,
supportsTeamDrives: true,
fileId: projectId,
};
drive.files.delete(options, (err, result) => {
... | javascript | function deleteRemote(auth, projectId, name) {
return new Promise((resolve, reject) => {
const drive = google.drive('v3');
const options = {
auth,
supportsTeamDrives: true,
fileId: projectId,
};
drive.files.delete(options, (err, result) => {
... | [
"function",
"deleteRemote",
"(",
"auth",
",",
"projectId",
",",
"name",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"drive",
"=",
"google",
".",
"drive",
"(",
"'v3'",
")",
";",
"const",
"options",
... | Delete a remote script file
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@param {String} projectId - Id of file to delete.
@param {String} name - Name of project we'ere deleting.
@returns {Promise} - A promise resolving the metadata of the deleted project | [
"Delete",
"a",
"remote",
"script",
"file"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/remoteDeleteProject.js#L14-L37 | train |
tree-sitter/tree-sitter-cli | lib/api/properties.js | queryProperties | function queryProperties(props, nodeTypeStack, childIndexStack = [], text) {
let stateId = 0
for (let i = 0, {length} = nodeTypeStack; i < length; i++) {
const nodeType = nodeTypeStack[i];
const state = props.states[stateId];
let found_transition = false;
for (const transition of state.transitions) ... | javascript | function queryProperties(props, nodeTypeStack, childIndexStack = [], text) {
let stateId = 0
for (let i = 0, {length} = nodeTypeStack; i < length; i++) {
const nodeType = nodeTypeStack[i];
const state = props.states[stateId];
let found_transition = false;
for (const transition of state.transitions) ... | [
"function",
"queryProperties",
"(",
"props",
",",
"nodeTypeStack",
",",
"childIndexStack",
"=",
"[",
"]",
",",
"text",
")",
"{",
"let",
"stateId",
"=",
"0",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"{",
"length",
"}",
"=",
"nodeTypeStack",
";",
"i",
"<... | Test a property state machine against a node structure specified as an array of node types. | [
"Test",
"a",
"property",
"state",
"machine",
"against",
"a",
"node",
"structure",
"specified",
"as",
"an",
"array",
"of",
"node",
"types",
"."
] | 44ba293422c8b7f115e57ff247e454d5b66dee9e | https://github.com/tree-sitter/tree-sitter-cli/blob/44ba293422c8b7f115e57ff247e454d5b66dee9e/lib/api/properties.js#L10-L36 | train |
tree-sitter/tree-sitter-cli | lib/api/properties.js | parseProperties | function parseProperties(source, baseDirectory) {
// Get the raw SCSS concrete syntax tree.
const rawTree = parseCSS(source);
removeWhitespace(rawTree);
// Convert the concrete syntax tree into a more convenient AST.
let schema
const rootRules = []
for (const rule of rawTree.value) {
if (rule.type ==... | javascript | function parseProperties(source, baseDirectory) {
// Get the raw SCSS concrete syntax tree.
const rawTree = parseCSS(source);
removeWhitespace(rawTree);
// Convert the concrete syntax tree into a more convenient AST.
let schema
const rootRules = []
for (const rule of rawTree.value) {
if (rule.type ==... | [
"function",
"parseProperties",
"(",
"source",
",",
"baseDirectory",
")",
"{",
"// Get the raw SCSS concrete syntax tree.",
"const",
"rawTree",
"=",
"parseCSS",
"(",
"source",
")",
";",
"removeWhitespace",
"(",
"rawTree",
")",
";",
"// Convert the concrete syntax tree into... | Parse a property sheet written in CSS into the intermediate object structure that is passed to the `ts_compile_property_sheet` function. | [
"Parse",
"a",
"property",
"sheet",
"written",
"in",
"CSS",
"into",
"the",
"intermediate",
"object",
"structure",
"that",
"is",
"passed",
"to",
"the",
"ts_compile_property_sheet",
"function",
"."
] | 44ba293422c8b7f115e57ff247e454d5b66dee9e | https://github.com/tree-sitter/tree-sitter-cli/blob/44ba293422c8b7f115e57ff247e454d5b66dee9e/lib/api/properties.js#L41-L91 | train |
tree-sitter/tree-sitter-cli | lib/api/properties.js | removeWhitespace | function removeWhitespace(node) {
node.value = node.value.filter(node => !isWhitespace(node))
} | javascript | function removeWhitespace(node) {
node.value = node.value.filter(node => !isWhitespace(node))
} | [
"function",
"removeWhitespace",
"(",
"node",
")",
"{",
"node",
".",
"value",
"=",
"node",
".",
"value",
".",
"filter",
"(",
"node",
"=>",
"!",
"isWhitespace",
"(",
"node",
")",
")",
"}"
] | Get rid of useless nodes and properties. | [
"Get",
"rid",
"of",
"useless",
"nodes",
"and",
"properties",
"."
] | 44ba293422c8b7f115e57ff247e454d5b66dee9e | https://github.com/tree-sitter/tree-sitter-cli/blob/44ba293422c8b7f115e57ff247e454d5b66dee9e/lib/api/properties.js#L300-L302 | train |
MaartenDesnouck/google-apps-script | lib/functions/extensionAndFiletype.js | getExtensionFromFiletype | function getExtensionFromFiletype(filetype, codeExtensions) {
let extension;
if (filetype === 'HTML') {
extension = '.html';
} else if (filetype === 'JSON') {
extension = '.json';
} else {
extension = codeExtensions[0];
}
return extension;
} | javascript | function getExtensionFromFiletype(filetype, codeExtensions) {
let extension;
if (filetype === 'HTML') {
extension = '.html';
} else if (filetype === 'JSON') {
extension = '.json';
} else {
extension = codeExtensions[0];
}
return extension;
} | [
"function",
"getExtensionFromFiletype",
"(",
"filetype",
",",
"codeExtensions",
")",
"{",
"let",
"extension",
";",
"if",
"(",
"filetype",
"===",
"'HTML'",
")",
"{",
"extension",
"=",
"'.html'",
";",
"}",
"else",
"if",
"(",
"filetype",
"===",
"'JSON'",
")",
... | Get the correct extension from the filetype
@param {String} filetype - Filetype we will convert.
@param {array} codeExtensions - Array of extensions we should treat as pushable for code files
@returns {String} method - The extension matching the filetype. | [
"Get",
"the",
"correct",
"extension",
"from",
"the",
"filetype"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/extensionAndFiletype.js#L12-L23 | train |
MaartenDesnouck/google-apps-script | lib/functions/extensionAndFiletype.js | isPushable | function isPushable(extension, filename, codeExtensions, ignoreRegexes) {
const fullFilename = `${filename}${extension}`;
let ignored = false;
const filenameAndExtensionIsValid = (codeExtensions && codeExtensions.indexOf(extension) > -1 || extension === '.html' || (extension === '.json' && filename === 'a... | javascript | function isPushable(extension, filename, codeExtensions, ignoreRegexes) {
const fullFilename = `${filename}${extension}`;
let ignored = false;
const filenameAndExtensionIsValid = (codeExtensions && codeExtensions.indexOf(extension) > -1 || extension === '.html' || (extension === '.json' && filename === 'a... | [
"function",
"isPushable",
"(",
"extension",
",",
"filename",
",",
"codeExtensions",
",",
"ignoreRegexes",
")",
"{",
"const",
"fullFilename",
"=",
"`",
"${",
"filename",
"}",
"${",
"extension",
"}",
"`",
";",
"let",
"ignored",
"=",
"false",
";",
"const",
"f... | Check if we can push a file to remote
@param {String} extension - The extension of the file we are checking
@param {String} filename - The name without extension of the file we are checking
@param {array} codeExtensions - Array of extensions we should treat as pushable for code files
@param {array} ignoreRegexes - Arr... | [
"Check",
"if",
"we",
"can",
"push",
"a",
"file",
"to",
"remote"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/extensionAndFiletype.js#L53-L68 | train |
MaartenDesnouck/google-apps-script | lib/functions/checkbox.js | get | function get(color) {
const symbols = getSymbols();
let result;
if (color === 'green') {
result = `[${symbols.check.green}]`;
} else if (color === 'red') {
result = `[${symbols.cross.red}]`;
} else if (color === 'yellow') {
result = `[${symbols.check.yellow}]`;
}
retu... | javascript | function get(color) {
const symbols = getSymbols();
let result;
if (color === 'green') {
result = `[${symbols.check.green}]`;
} else if (color === 'red') {
result = `[${symbols.cross.red}]`;
} else if (color === 'yellow') {
result = `[${symbols.check.yellow}]`;
}
retu... | [
"function",
"get",
"(",
"color",
")",
"{",
"const",
"symbols",
"=",
"getSymbols",
"(",
")",
";",
"let",
"result",
";",
"if",
"(",
"color",
"===",
"'green'",
")",
"{",
"result",
"=",
"`",
"${",
"symbols",
".",
"check",
".",
"green",
"}",
"`",
";",
... | Get a checkbox
@param {String} color - Identifier of the type of checkbox you want to print
@returns {void} | [
"Get",
"a",
"checkbox"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/checkbox.js#L27-L38 | train |
MaartenDesnouck/google-apps-script | lib/functions/createFile.js | createFile | function createFile(file) {
fs.ensureFileSync(file.name);
fs.writeFileSync(file.name, file.source);
return;
} | javascript | function createFile(file) {
fs.ensureFileSync(file.name);
fs.writeFileSync(file.name, file.source);
return;
} | [
"function",
"createFile",
"(",
"file",
")",
"{",
"fs",
".",
"ensureFileSync",
"(",
"file",
".",
"name",
")",
";",
"fs",
".",
"writeFileSync",
"(",
"file",
".",
"name",
",",
"file",
".",
"source",
")",
";",
"return",
";",
"}"
] | Synch create file and necessary folders
@param {Object} file - File to create.
@returns {void} | [
"Synch",
"create",
"file",
"and",
"necessary",
"folders"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/createFile.js#L9-L13 | train |
MaartenDesnouck/google-apps-script | lib/functions/getMetadata.js | getMetadata | async function getMetadata(auth, identifier) {
// Try to get info assuming identifier is an id
const metadata = await new Promise((resolve, reject) => {
const script = google.script('v1');
script.projects.get({
auth,
scriptId: identifier,
}, (err, result) => {
... | javascript | async function getMetadata(auth, identifier) {
// Try to get info assuming identifier is an id
const metadata = await new Promise((resolve, reject) => {
const script = google.script('v1');
script.projects.get({
auth,
scriptId: identifier,
}, (err, result) => {
... | [
"async",
"function",
"getMetadata",
"(",
"auth",
",",
"identifier",
")",
"{",
"// Try to get info assuming identifier is an id",
"const",
"metadata",
"=",
"await",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"script",
"=",
"goo... | Get the metadata of a file with a given id
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@param {String} identifier - Identifier we want to get data from, could be id or a name.
@returns {Object} - metadata of the project | [
"Get",
"the",
"metadata",
"of",
"a",
"file",
"with",
"a",
"given",
"id"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/getMetadata.js#L15-L116 | train |
pugjs/then-pug | packages/pug-parser/index.js | Parser | function Parser(tokens, options) {
options = options || {};
if (!Array.isArray(tokens)) {
throw new Error('Expected tokens to be an Array but got "' + (typeof tokens) + '"');
}
if (typeof options !== 'object') {
throw new Error('Expected "options" to be an object but got "' + (typeof options) + '"');
... | javascript | function Parser(tokens, options) {
options = options || {};
if (!Array.isArray(tokens)) {
throw new Error('Expected tokens to be an Array but got "' + (typeof tokens) + '"');
}
if (typeof options !== 'object') {
throw new Error('Expected "options" to be an object but got "' + (typeof options) + '"');
... | [
"function",
"Parser",
"(",
"tokens",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"tokens",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Expected tokens to be an Array but got \"'... | Initialize `Parser` with the given input `str` and `filename`.
@param {String} str
@param {String} filename
@param {Object} options
@api public | [
"Initialize",
"Parser",
"with",
"the",
"given",
"input",
"str",
"and",
"filename",
"."
] | a96c2a9c6d1f0875aef4641064500f818f7e7571 | https://github.com/pugjs/then-pug/blob/a96c2a9c6d1f0875aef4641064500f818f7e7571/packages/pug-parser/index.js#L25-L38 | train |
pugjs/then-pug | packages/pug-parser/index.js | function(type){
if (this.peek().type === type) {
return this.advance();
} else {
this.error('INVALID_TOKEN', 'expected "' + type + '", but got "' + this.peek().type + '"', this.peek());
}
} | javascript | function(type){
if (this.peek().type === type) {
return this.advance();
} else {
this.error('INVALID_TOKEN', 'expected "' + type + '", but got "' + this.peek().type + '"', this.peek());
}
} | [
"function",
"(",
"type",
")",
"{",
"if",
"(",
"this",
".",
"peek",
"(",
")",
".",
"type",
"===",
"type",
")",
"{",
"return",
"this",
".",
"advance",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"error",
"(",
"'INVALID_TOKEN'",
",",
"'expected \"'"... | Expect the given type, or throw an exception.
@param {String} type
@api private | [
"Expect",
"the",
"given",
"type",
"or",
"throw",
"an",
"exception",
"."
] | a96c2a9c6d1f0875aef4641064500f818f7e7571 | https://github.com/pugjs/then-pug/blob/a96c2a9c6d1f0875aef4641064500f818f7e7571/packages/pug-parser/index.js#L133-L139 | train | |
pugjs/then-pug | packages/pug-parser/index.js | function(){
var tok = this.expect('call');
var name = tok.val;
var args = tok.args;
var mixin = {
type: 'Mixin',
name: name,
args: args,
block: this.emptyBlock(tok.loc.start.line),
call: true,
attrs: [],
attributeBlocks: [],
line: tok.loc.start.line,
... | javascript | function(){
var tok = this.expect('call');
var name = tok.val;
var args = tok.args;
var mixin = {
type: 'Mixin',
name: name,
args: args,
block: this.emptyBlock(tok.loc.start.line),
call: true,
attrs: [],
attributeBlocks: [],
line: tok.loc.start.line,
... | [
"function",
"(",
")",
"{",
"var",
"tok",
"=",
"this",
".",
"expect",
"(",
"'call'",
")",
";",
"var",
"name",
"=",
"tok",
".",
"val",
";",
"var",
"args",
"=",
"tok",
".",
"args",
";",
"var",
"mixin",
"=",
"{",
"type",
":",
"'Mixin'",
",",
"name"... | call ident block | [
"call",
"ident",
"block"
] | a96c2a9c6d1f0875aef4641064500f818f7e7571 | https://github.com/pugjs/then-pug/blob/a96c2a9c6d1f0875aef4641064500f818f7e7571/packages/pug-parser/index.js#L874-L898 | train | |
MaartenDesnouck/google-apps-script | lib/functions/triageGoogleError.js | triageGoogleError | async function triageGoogleError(err, origin) {
// console.log(err);
const triaged = {
err,
origin,
print: true,
};
if (err && err.code === 401) {
triaged.message = `Your credentials appear to be invalid.\nRun 'gas auth -f' to re-authenticate.`;
triaged.extraInfo... | javascript | async function triageGoogleError(err, origin) {
// console.log(err);
const triaged = {
err,
origin,
print: true,
};
if (err && err.code === 401) {
triaged.message = `Your credentials appear to be invalid.\nRun 'gas auth -f' to re-authenticate.`;
triaged.extraInfo... | [
"async",
"function",
"triageGoogleError",
"(",
"err",
",",
"origin",
")",
"{",
"// console.log(err);",
"const",
"triaged",
"=",
"{",
"err",
",",
"origin",
",",
"print",
":",
"true",
",",
"}",
";",
"if",
"(",
"err",
"&&",
"err",
".",
"code",
"===",
"401... | Triage Google error
@param {Object} err - The error to triage.
@param {String} origin - Origin of the error
@returns {Object} - Object with the error and extra info after triage | [
"Triage",
"Google",
"error"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/triageGoogleError.js#L15-L83 | train |
MaartenDesnouck/google-apps-script | lib/functions/downloadDependencies.js | processSource | function processSource(code, dependencyList, depedencyName) {
// Replace function declarations
const packageName = dependencyList[depedencyName].packageName;
code = code.replace(/(\s*)function\s([A-z]*)\s*\(*/g, `$1function ${packageName}_$2(`);
// TODO replace function calls to dependencies
const ... | javascript | function processSource(code, dependencyList, depedencyName) {
// Replace function declarations
const packageName = dependencyList[depedencyName].packageName;
code = code.replace(/(\s*)function\s([A-z]*)\s*\(*/g, `$1function ${packageName}_$2(`);
// TODO replace function calls to dependencies
const ... | [
"function",
"processSource",
"(",
"code",
",",
"dependencyList",
",",
"depedencyName",
")",
"{",
"// Replace function declarations",
"const",
"packageName",
"=",
"dependencyList",
"[",
"depedencyName",
"]",
".",
"packageName",
";",
"code",
"=",
"code",
".",
"replace... | Process all function declarations and calls to use the libraries
@param {String} code - Code to process
@param {Object} dependencyList - all dependencies
@param {String} depedencyName - name of the dependency
@returns {String} Processed code | [
"Process",
"all",
"function",
"declarations",
"and",
"calls",
"to",
"use",
"the",
"libraries"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/downloadDependencies.js#L17-L33 | train |
MaartenDesnouck/google-apps-script | lib/functions/downloadDependencies.js | downloadDependencies | async function downloadDependencies(rootFolder, dependencyList) {
const includeFolder = path.join(rootFolder, constants.INCLUDE_DIR);
fs.removeSync(includeFolder);
const contentPath = path.join(includeFolder, 'content.json');
// Create new content.json
createFile({
name: contentPath,
... | javascript | async function downloadDependencies(rootFolder, dependencyList) {
const includeFolder = path.join(rootFolder, constants.INCLUDE_DIR);
fs.removeSync(includeFolder);
const contentPath = path.join(includeFolder, 'content.json');
// Create new content.json
createFile({
name: contentPath,
... | [
"async",
"function",
"downloadDependencies",
"(",
"rootFolder",
",",
"dependencyList",
")",
"{",
"const",
"includeFolder",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"constants",
".",
"INCLUDE_DIR",
")",
";",
"fs",
".",
"removeSync",
"(",
"includeFolder",... | Download all necessary dependencies
@param {String} rootFolder - Folder where we will create the gas-include folder
@param {Object} dependencyList - List of exact dependencies that we need to download
@returns {void} | [
"Download",
"all",
"necessary",
"dependencies"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/downloadDependencies.js#L42-L94 | train |
MaartenDesnouck/google-apps-script | lib/functions/saveDependencies.js | saveDependencies | async function saveDependencies(dependency, includeFile, projectRoot) {
let gasInclude = {};
if (includeFile.found) {
gasInclude = fs.readJsonSync(path.join(includeFile.folder, constants.INCLUDE_FILE));
} else if (projectRoot.found) {
includeFile.folder = projectRoot.folder;
} else {
... | javascript | async function saveDependencies(dependency, includeFile, projectRoot) {
let gasInclude = {};
if (includeFile.found) {
gasInclude = fs.readJsonSync(path.join(includeFile.folder, constants.INCLUDE_FILE));
} else if (projectRoot.found) {
includeFile.folder = projectRoot.folder;
} else {
... | [
"async",
"function",
"saveDependencies",
"(",
"dependency",
",",
"includeFile",
",",
"projectRoot",
")",
"{",
"let",
"gasInclude",
"=",
"{",
"}",
";",
"if",
"(",
"includeFile",
".",
"found",
")",
"{",
"gasInclude",
"=",
"fs",
".",
"readJsonSync",
"(",
"pat... | Save a dependency to the gas-include file
@param {Object} dependency - Dedendencies to save
@param {Object} includeFile - Object indicating if and where the include file is
@param {Object} projectRoot - Object indicating if and where the .gas dir is
@returns {string} - FolderPath where we have stored the gas-inlcude.j... | [
"Save",
"a",
"dependency",
"to",
"the",
"gas",
"-",
"include",
"file"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/saveDependencies.js#L16-L66 | train |
pugjs/then-pug | packages/then-pug/lib/index.js | function (locals) {
var stream = new ReadableStream();
// streaming will be set to false whenever there is back-pressure
var streaming = false;
function release() {
streaming = true;
}
// make sure _read is always implemented
stream._read = release;
// then-yield unwrap fun... | javascript | function (locals) {
var stream = new ReadableStream();
// streaming will be set to false whenever there is back-pressure
var streaming = false;
function release() {
streaming = true;
}
// make sure _read is always implemented
stream._read = release;
// then-yield unwrap fun... | [
"function",
"(",
"locals",
")",
"{",
"var",
"stream",
"=",
"new",
"ReadableStream",
"(",
")",
";",
"// streaming will be set to false whenever there is back-pressure",
"var",
"streaming",
"=",
"false",
";",
"function",
"release",
"(",
")",
"{",
"streaming",
"=",
"... | convert it to a function that takes `locals` and returns a readable stream | [
"convert",
"it",
"to",
"a",
"function",
"that",
"takes",
"locals",
"and",
"returns",
"a",
"readable",
"stream"
] | a96c2a9c6d1f0875aef4641064500f818f7e7571 | https://github.com/pugjs/then-pug/blob/a96c2a9c6d1f0875aef4641064500f818f7e7571/packages/then-pug/lib/index.js#L315-L362 | train | |
pugjs/then-pug | packages/then-pug/lib/index.js | unwrap | function unwrap(value) {
if (streaming) return value;
return new Promise(function (resolve) {
stream._read = function () {
release();
this._read = release;
resolve(value);
}
});
} | javascript | function unwrap(value) {
if (streaming) return value;
return new Promise(function (resolve) {
stream._read = function () {
release();
this._read = release;
resolve(value);
}
});
} | [
"function",
"unwrap",
"(",
"value",
")",
"{",
"if",
"(",
"streaming",
")",
"return",
"value",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"stream",
".",
"_read",
"=",
"function",
"(",
")",
"{",
"release",
"(",
")",
";"... | then-yield unwrap function which implements the backpressure pause mechanism | [
"then",
"-",
"yield",
"unwrap",
"function",
"which",
"implements",
"the",
"backpressure",
"pause",
"mechanism"
] | a96c2a9c6d1f0875aef4641064500f818f7e7571 | https://github.com/pugjs/then-pug/blob/a96c2a9c6d1f0875aef4641064500f818f7e7571/packages/then-pug/lib/index.js#L330-L339 | train |
restify/enroute | lib/install.js | enrouteHotReloadProxy | function enrouteHotReloadProxy(req, res, next) {
return reloadProxy({
basePath: opts.basePath,
method: method,
req: req,
res: res,
... | javascript | function enrouteHotReloadProxy(req, res, next) {
return reloadProxy({
basePath: opts.basePath,
method: method,
req: req,
res: res,
... | [
"function",
"enrouteHotReloadProxy",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"return",
"reloadProxy",
"(",
"{",
"basePath",
":",
"opts",
".",
"basePath",
",",
"method",
":",
"method",
",",
"req",
":",
"req",
",",
"res",
":",
"res",
",",
"routeNa... | restify middleware wrapper for hot reload | [
"restify",
"middleware",
"wrapper",
"for",
"hot",
"reload"
] | df5f9f25149fcb248267db9d8927aba28b9a3d4e | https://github.com/restify/enroute/blob/df5f9f25149fcb248267db9d8927aba28b9a3d4e/lib/install.js#L77-L87 | train |
restify/enroute | lib/install.js | reloadProxy | function reloadProxy(opts, cb) {
assert.object(opts, 'opts');
assert.string(opts.basePath, 'opts.basePath');
assert.optionalString(opts.excludePath, 'opts.excludePath');
assert.string(opts.method, 'opts.method');
assert.object(opts.req, 'opts.req');
assert.object(opts.res, 'opts.res');
asser... | javascript | function reloadProxy(opts, cb) {
assert.object(opts, 'opts');
assert.string(opts.basePath, 'opts.basePath');
assert.optionalString(opts.excludePath, 'opts.excludePath');
assert.string(opts.method, 'opts.method');
assert.object(opts.req, 'opts.req');
assert.object(opts.res, 'opts.res');
asser... | [
"function",
"reloadProxy",
"(",
"opts",
",",
"cb",
")",
"{",
"assert",
".",
"object",
"(",
"opts",
",",
"'opts'",
")",
";",
"assert",
".",
"string",
"(",
"opts",
".",
"basePath",
",",
"'opts.basePath'",
")",
";",
"assert",
".",
"optionalString",
"(",
"... | using the restify handler composer, create a middleware on the fly that
re-requires the file on every load executes it.
@private
@function reloadProxy
@param {Object} opts an options object
@param {String} opts.basePath The basepath to resolve source files.
@param {String} opts.method http verb
@param {Object} opts.log... | [
"using",
"the",
"restify",
"handler",
"composer",
"create",
"a",
"middleware",
"on",
"the",
"fly",
"that",
"re",
"-",
"requires",
"the",
"file",
"on",
"every",
"load",
"executes",
"it",
"."
] | df5f9f25149fcb248267db9d8927aba28b9a3d4e | https://github.com/restify/enroute/blob/df5f9f25149fcb248267db9d8927aba28b9a3d4e/lib/install.js#L154-L199 | train |
MaartenDesnouck/google-apps-script | lib/functions/downloadRemote.js | downloadRemote | function downloadRemote(auth, projectId, dir, method) {
return new Promise((resolve, reject) => {
const gasDir = path.join('.', dir, constants.META_DIR);
if (method === 'clone' && fs.existsSync(path.join('.', dir))) {
reject({
message: `Oops, the directory '${dir}' seems... | javascript | function downloadRemote(auth, projectId, dir, method) {
return new Promise((resolve, reject) => {
const gasDir = path.join('.', dir, constants.META_DIR);
if (method === 'clone' && fs.existsSync(path.join('.', dir))) {
reject({
message: `Oops, the directory '${dir}' seems... | [
"function",
"downloadRemote",
"(",
"auth",
",",
"projectId",
",",
"dir",
",",
"method",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"gasDir",
"=",
"path",
".",
"join",
"(",
"'.'",
",",
"dir",
","... | Download remote script json
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@param {String} projectId - Id of project to download.
@param {String} dir - Optional directory in which the project is located.
@param {String} method - Identifier for the flow calling this function.
@returns {Promise} - A pro... | [
"Download",
"remote",
"script",
"json"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/downloadRemote.js#L19-L61 | train |
victorquinn/memcache-plus | lib/client.js | Client | function Client(opts) {
if (!(this instanceof Client)) {
return new Client(opts);
}
var options = {};
// If single connection provided, array-ify it
if (typeof opts === 'string') {
options.hosts = [opts];
opts = options;
} else if (typeof opts === 'undefined') {
... | javascript | function Client(opts) {
if (!(this instanceof Client)) {
return new Client(opts);
}
var options = {};
// If single connection provided, array-ify it
if (typeof opts === 'string') {
options.hosts = [opts];
opts = options;
} else if (typeof opts === 'undefined') {
... | [
"function",
"Client",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Client",
")",
")",
"{",
"return",
"new",
"Client",
"(",
"opts",
")",
";",
"}",
"var",
"options",
"=",
"{",
"}",
";",
"// If single connection provided, array-ify it",
... | Constructor - Initiate client | [
"Constructor",
"-",
"Initiate",
"client"
] | cabf91d69eaff0cb6a80858561911f8e664a5e42 | https://github.com/victorquinn/memcache-plus/blob/cabf91d69eaff0cb6a80858561911f8e664a5e42/lib/client.js#L25-L67 | train |
MaartenDesnouck/google-apps-script | lib/functions/getUserInfo.js | getUserInfo | function getUserInfo(auth) {
return new Promise((resolve, reject) => {
const oauth2 = google.oauth2({
auth,
version: 'v2',
});
oauth2.userinfo.v2.me.get((err, res) => {
if (err) {
reject(err);
} else {
resolve(r... | javascript | function getUserInfo(auth) {
return new Promise((resolve, reject) => {
const oauth2 = google.oauth2({
auth,
version: 'v2',
});
oauth2.userinfo.v2.me.get((err, res) => {
if (err) {
reject(err);
} else {
resolve(r... | [
"function",
"getUserInfo",
"(",
"auth",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"oauth2",
"=",
"google",
".",
"oauth2",
"(",
"{",
"auth",
",",
"version",
":",
"'v2'",
",",
"}",
")",
";",
"o... | Log info about users
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@returns {Promise} - A promise resolving user info of the current user | [
"Log",
"info",
"about",
"users"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/getUserInfo.js#L11-L27 | train |
MaartenDesnouck/google-apps-script | lib/functions/firebase.js | authWithFirebase | async function authWithFirebase(auth) {
try {
const config = {
apiKey: constants.FIREBASE_DATABASE_PUBLIC_APIKEY,
databaseURL: constants.FIREBASE_DATABASE_URL,
};
if (!firebase.apps.length) {
firebase.initializeApp(config);
}
const creden... | javascript | async function authWithFirebase(auth) {
try {
const config = {
apiKey: constants.FIREBASE_DATABASE_PUBLIC_APIKEY,
databaseURL: constants.FIREBASE_DATABASE_URL,
};
if (!firebase.apps.length) {
firebase.initializeApp(config);
}
const creden... | [
"async",
"function",
"authWithFirebase",
"(",
"auth",
")",
"{",
"try",
"{",
"const",
"config",
"=",
"{",
"apiKey",
":",
"constants",
".",
"FIREBASE_DATABASE_PUBLIC_APIKEY",
",",
"databaseURL",
":",
"constants",
".",
"FIREBASE_DATABASE_URL",
",",
"}",
";",
"if",
... | Get firebase credentails
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@returns {Promise} - Promise resolving a firebase credential | [
"Get",
"firebase",
"credentails"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/firebase.js#L17-L37 | train |
MaartenDesnouck/google-apps-script | lib/functions/firebase.js | setUserInfo | async function setUserInfo(auth) {
try {
const authenticated = await authWithFirebase(auth);
const token = await firebase.auth().currentUser.getIdToken();
const userId = firebase.auth().currentUser.uid;
const userInfo = await getUserInfo(auth);
userInfo.version = pjson.versio... | javascript | async function setUserInfo(auth) {
try {
const authenticated = await authWithFirebase(auth);
const token = await firebase.auth().currentUser.getIdToken();
const userId = firebase.auth().currentUser.uid;
const userInfo = await getUserInfo(auth);
userInfo.version = pjson.versio... | [
"async",
"function",
"setUserInfo",
"(",
"auth",
")",
"{",
"try",
"{",
"const",
"authenticated",
"=",
"await",
"authWithFirebase",
"(",
"auth",
")",
";",
"const",
"token",
"=",
"await",
"firebase",
".",
"auth",
"(",
")",
".",
"currentUser",
".",
"getIdToke... | Log user to firebase
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@returns {Promise} - a promise resolving true if user info has been set in firebase | [
"Log",
"user",
"to",
"firebase"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/firebase.js#L45-L73 | train |
MaartenDesnouck/google-apps-script | lib/functions/firebase.js | publish | async function publish(auth, rootPath) {
// check if version does not exist yet
// check if user is allowed to publish
// check if version is larger than last version
// names cant contain _- etc, maybe just stick to lowercase letters?
// if projectKey, check that we can access the file?
packag... | javascript | async function publish(auth, rootPath) {
// check if version does not exist yet
// check if user is allowed to publish
// check if version is larger than last version
// names cant contain _- etc, maybe just stick to lowercase letters?
// if projectKey, check that we can access the file?
packag... | [
"async",
"function",
"publish",
"(",
"auth",
",",
"rootPath",
")",
"{",
"// check if version does not exist yet",
"// check if user is allowed to publish",
"// check if version is larger than last version",
"// names cant contain _- etc, maybe just stick to lowercase letters?",
"// if proj... | Firebase test function
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@return {Boolean} - true if test was succesful, false otherwise | [
"Firebase",
"test",
"function"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/firebase.js#L81-L176 | train |
MaartenDesnouck/google-apps-script | lib/functions/getId.js | getId | function getId(rootFolder) {
return new Promise((resolve, reject) => {
const dir = path.join(rootFolder, constants.META_DIR, constants.META_ID);
fs.readFile(dir, 'utf8', (err, id) => {
if (err) {
reject(err);
return;
} else {
re... | javascript | function getId(rootFolder) {
return new Promise((resolve, reject) => {
const dir = path.join(rootFolder, constants.META_DIR, constants.META_ID);
fs.readFile(dir, 'utf8', (err, id) => {
if (err) {
reject(err);
return;
} else {
re... | [
"function",
"getId",
"(",
"rootFolder",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"dir",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"constants",
".",
"META_DIR",
",",
"constants",
".",
"ME... | Get the id of the current google apps script project
@param {String} rootFolder - relative path to the rootFolder of the project
@returns {Promise} - A promise resolving an id | [
"Get",
"the",
"id",
"of",
"the",
"current",
"google",
"apps",
"script",
"project"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/getId.js#L11-L24 | train |
MaartenDesnouck/google-apps-script | lib/functions/remoteRenameProject.js | renameRemote | function renameRemote(auth, projectId, name, newName) {
return new Promise((resolve, reject) => {
if (newName === name) {
resolve(false);
return;
}
const drive = google.drive('v3');
drive.files.update({
auth,
supportsTeamDrives: true,
... | javascript | function renameRemote(auth, projectId, name, newName) {
return new Promise((resolve, reject) => {
if (newName === name) {
resolve(false);
return;
}
const drive = google.drive('v3');
drive.files.update({
auth,
supportsTeamDrives: true,
... | [
"function",
"renameRemote",
"(",
"auth",
",",
"projectId",
",",
"name",
",",
"newName",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"if",
"(",
"newName",
"===",
"name",
")",
"{",
"resolve",
"(",
"false",
... | Rename a remote script file
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@param {String} projectId - Id of the script project to rename.
@param {String} name - Old name of the Google Apps Script project.
@param {String} newName - New name to give to the new Google Apps Script project.
@returns {Prom... | [
"Rename",
"a",
"remote",
"script",
"file"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/remoteRenameProject.js#L15-L43 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/util/ajaxUtils.js | doAjaxRequest | function doAjaxRequest(type, url, opts) {
var params = {};
params.type = type;
params.url = url;
// don't just do a blind copy of params here. we want to restrict what can be used to avoid any jquery specific options.
params.data = opts.data;
params.contentType = opts.co... | javascript | function doAjaxRequest(type, url, opts) {
var params = {};
params.type = type;
params.url = url;
// don't just do a blind copy of params here. we want to restrict what can be used to avoid any jquery specific options.
params.data = opts.data;
params.contentType = opts.co... | [
"function",
"doAjaxRequest",
"(",
"type",
",",
"url",
",",
"opts",
")",
"{",
"var",
"params",
"=",
"{",
"}",
";",
"params",
".",
"type",
"=",
"type",
";",
"params",
".",
"url",
"=",
"url",
";",
"// don't just do a blind copy of params here. we want to restrict... | Executes the request using an ajax call
@method doAjaxRequest
@private
@param {String} type The type of request, e.g. <code>GET</code> or <code>POST</code>
@param {String} url The url of the request
@param {Object} opts An associative array of options to configure the call
<ul>
<li>data: Any data to include with the re... | [
"Executes",
"the",
"request",
"using",
"an",
"ajax",
"call"
] | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/util/ajaxUtils.js#L52-L68 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/util/ajaxUtils.js | doPostBinary | function doPostBinary(binary, url, successCallback, errorCallback) {
var xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.onload = function() {
if(xhr.status === 200) {
successCallback(xhr.response);
} else {
errorCallback(xhr.respons... | javascript | function doPostBinary(binary, url, successCallback, errorCallback) {
var xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.onload = function() {
if(xhr.status === 200) {
successCallback(xhr.response);
} else {
errorCallback(xhr.respons... | [
"function",
"doPostBinary",
"(",
"binary",
",",
"url",
",",
"successCallback",
",",
"errorCallback",
")",
"{",
"var",
"xhr",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"xhr",
".",
"open",
"(",
"'POST'",
",",
"url",
")",
";",
"xhr",
".",
"onload",
"="... | Asynchronously posts binary data to the specified URL.
@method doPostBinary
@param {Blob} binary The binary data to be uploaded.
@param {String} url The URL to post to.
@param {Function} successCallback The function to call when the post successfuly completes.
This function takes the server's response as its parameter.... | [
"Asynchronously",
"posts",
"binary",
"data",
"to",
"the",
"specified",
"URL",
"."
] | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/util/ajaxUtils.js#L114-L127 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/widget/widget.js | saveState | function saveState(instanceId, stateObject, successCallback, errorCallback) {
var strObject = JSON.stringify(stateObject);
return neon.util.ajaxUtils.doPostJSON({
instanceId: instanceId,
state: strObject
}, neon.serviceUrl('widgetservice', 'savestate'), {
succ... | javascript | function saveState(instanceId, stateObject, successCallback, errorCallback) {
var strObject = JSON.stringify(stateObject);
return neon.util.ajaxUtils.doPostJSON({
instanceId: instanceId,
state: strObject
}, neon.serviceUrl('widgetservice', 'savestate'), {
succ... | [
"function",
"saveState",
"(",
"instanceId",
",",
"stateObject",
",",
"successCallback",
",",
"errorCallback",
")",
"{",
"var",
"strObject",
"=",
"JSON",
".",
"stringify",
"(",
"stateObject",
")",
";",
"return",
"neon",
".",
"util",
".",
"ajaxUtils",
".",
"do... | Save the current state of a widget.
@method saveState
@param {String} instanceId a unique identifier of an instance of a widget
@param {Object} stateObject an object that is to be saved.
@param {Function} successCallback The callback to execute when the state is saved. The callback will have no data.
@param {Function} ... | [
"Save",
"the",
"current",
"state",
"of",
"a",
"widget",
"."
] | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/widget/widget.js#L32-L42 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/widget/widget.js | getSavedState | function getSavedState(id, successCallback) {
return neon.util.ajaxUtils.doGet(
neon.serviceUrl('widgetservice', 'restorestate/' + encodeURIComponent(id)), {
success: function(data) {
if(!data) {
return;
}
... | javascript | function getSavedState(id, successCallback) {
return neon.util.ajaxUtils.doGet(
neon.serviceUrl('widgetservice', 'restorestate/' + encodeURIComponent(id)), {
success: function(data) {
if(!data) {
return;
}
... | [
"function",
"getSavedState",
"(",
"id",
",",
"successCallback",
")",
"{",
"return",
"neon",
".",
"util",
".",
"ajaxUtils",
".",
"doGet",
"(",
"neon",
".",
"serviceUrl",
"(",
"'widgetservice'",
",",
"'restorestate/'",
"+",
"encodeURIComponent",
"(",
"id",
")",
... | Gets the current state that has been saved.
@method getSavedState
@param {String} id an unique identifier of a client widget
@param {Function} successCallback The callback that contains the saved data.
@return {neon.util.AjaxRequest} The xhr request object | [
"Gets",
"the",
"current",
"state",
"that",
"has",
"been",
"saved",
"."
] | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/widget/widget.js#L51-L68 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/widget/widget.js | getPropertyKeys | function getPropertyKeys(successCallback, errorCallback) {
return neon.util.ajaxUtils.doGet(
neon.serviceUrl('propertyservice', '*'), {
success: successCallback,
error: errorCallback,
responseType: 'json'
}
);
} | javascript | function getPropertyKeys(successCallback, errorCallback) {
return neon.util.ajaxUtils.doGet(
neon.serviceUrl('propertyservice', '*'), {
success: successCallback,
error: errorCallback,
responseType: 'json'
}
);
} | [
"function",
"getPropertyKeys",
"(",
"successCallback",
",",
"errorCallback",
")",
"{",
"return",
"neon",
".",
"util",
".",
"ajaxUtils",
".",
"doGet",
"(",
"neon",
".",
"serviceUrl",
"(",
"'propertyservice'",
",",
"'*'",
")",
",",
"{",
"success",
":",
"succes... | Gets the list of property keys
@method getPropertyKeys
@param {Function} successCallback The callback that contains the array of key names
@param {Function} errorCallback The optional callback when an error occurs. This is a 3 parameter function that contains the xhr, a short error status and the full error message.
@r... | [
"Gets",
"the",
"list",
"of",
"property",
"keys"
] | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/widget/widget.js#L77-L85 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/widget/widget.js | removeProperty | function removeProperty(key, successCallback, errorCallback) {
return neon.util.ajaxUtils.doDelete(
neon.serviceUrl('propertyservice', key), {
success: successCallback,
error: errorCallback,
responseType: 'json'
}
);
} | javascript | function removeProperty(key, successCallback, errorCallback) {
return neon.util.ajaxUtils.doDelete(
neon.serviceUrl('propertyservice', key), {
success: successCallback,
error: errorCallback,
responseType: 'json'
}
);
} | [
"function",
"removeProperty",
"(",
"key",
",",
"successCallback",
",",
"errorCallback",
")",
"{",
"return",
"neon",
".",
"util",
".",
"ajaxUtils",
".",
"doDelete",
"(",
"neon",
".",
"serviceUrl",
"(",
"'propertyservice'",
",",
"key",
")",
",",
"{",
"success"... | Remove a property
@method removeProperty
@param {String} the property key to remove
@param {Function} successCallback The callback
@param {Function} errorCallback The optional callback when an error occurs. This is a 3 parameter function that contains the xhr, a short error status and the full error message.
@return {n... | [
"Remove",
"a",
"property"
] | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/widget/widget.js#L113-L121 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/widget/widget.js | setProperty | function setProperty(key, value, successCallback, errorCallback) {
return neon.util.ajaxUtils.doPost(
neon.serviceUrl('propertyservice', key), {
data: value,
contentType: 'text/plain',
success: successCallback,
error: errorCallback,
... | javascript | function setProperty(key, value, successCallback, errorCallback) {
return neon.util.ajaxUtils.doPost(
neon.serviceUrl('propertyservice', key), {
data: value,
contentType: 'text/plain',
success: successCallback,
error: errorCallback,
... | [
"function",
"setProperty",
"(",
"key",
",",
"value",
",",
"successCallback",
",",
"errorCallback",
")",
"{",
"return",
"neon",
".",
"util",
".",
"ajaxUtils",
".",
"doPost",
"(",
"neon",
".",
"serviceUrl",
"(",
"'propertyservice'",
",",
"key",
")",
",",
"{"... | Sets a property
@method setProperty
@param {String} the property key to set
@param {String} the new value for the property
@param {Function} successCallback The callback
@param {Function} errorCallback The optional callback when an error occurs. This is a 3 parameter function that contains the xhr, a short error status... | [
"Sets",
"a",
"property"
] | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/widget/widget.js#L132-L142 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/widget/widget.js | getInstanceId | function getInstanceId(qualifier, successCallback) {
// If the first argument is a function, assume that is the callback and that the caller
// wants the session id
if(typeof qualifier === 'function') {
successCallback = qualifier;
qualifier = null;
}
retu... | javascript | function getInstanceId(qualifier, successCallback) {
// If the first argument is a function, assume that is the callback and that the caller
// wants the session id
if(typeof qualifier === 'function') {
successCallback = qualifier;
qualifier = null;
}
retu... | [
"function",
"getInstanceId",
"(",
"qualifier",
",",
"successCallback",
")",
"{",
"// If the first argument is a function, assume that is the callback and that the caller",
"// wants the session id",
"if",
"(",
"typeof",
"qualifier",
"===",
"'function'",
")",
"{",
"successCallback... | Gets a unique id for a widget for a particular session. Repeated calls to this method in a single session with the
same parameters will result in the same id being returned.
@param {String} [qualifier] If a qualifier is specified, the id will be tied to that qualifier. This
allows multiple ids to be created for a singl... | [
"Gets",
"a",
"unique",
"id",
"for",
"a",
"widget",
"for",
"a",
"particular",
"session",
".",
"Repeated",
"calls",
"to",
"this",
"method",
"in",
"a",
"single",
"session",
"with",
"the",
"same",
"parameters",
"will",
"result",
"in",
"the",
"same",
"id",
"b... | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/widget/widget.js#L156-L177 | train |
NextCenturyCorporation/neon | neon-server/src/main/javascript/widget/widget.js | buildQualifierString | function buildQualifierString(qualifier) {
var fullQualifier = qualifier || '';
// when running in OWF, it is possible to have the same widget running multiple times so append
// the owf widget instanceid to the qualifier
if(neon.util.owfUtils.isRunningInOWF()) {
fullQualifie... | javascript | function buildQualifierString(qualifier) {
var fullQualifier = qualifier || '';
// when running in OWF, it is possible to have the same widget running multiple times so append
// the owf widget instanceid to the qualifier
if(neon.util.owfUtils.isRunningInOWF()) {
fullQualifie... | [
"function",
"buildQualifierString",
"(",
"qualifier",
")",
"{",
"var",
"fullQualifier",
"=",
"qualifier",
"||",
"''",
";",
"// when running in OWF, it is possible to have the same widget running multiple times so append",
"// the owf widget instanceid to the qualifier",
"if",
"(",
... | Given the text qualifier value, if running in OWF, the OWF instance id is appended to it. Otherwise, the original
value is returned.
@method buildQualifierString
@param {String} [qualifier]
@return {string} The full qualifier, which may include the OWF instance id if running in OWF | [
"Given",
"the",
"text",
"qualifier",
"value",
"if",
"running",
"in",
"OWF",
"the",
"OWF",
"instance",
"id",
"is",
"appended",
"to",
"it",
".",
"Otherwise",
"the",
"original",
"value",
"is",
"returned",
"."
] | 728ff8c494bf73812ffb3410e44018d60798fbd3 | https://github.com/NextCenturyCorporation/neon/blob/728ff8c494bf73812ffb3410e44018d60798fbd3/neon-server/src/main/javascript/widget/widget.js#L186-L194 | train |
MaartenDesnouck/google-apps-script | lib/functions/ignore.js | addGitIgnore | function addGitIgnore(rootFolder) {
// If no .gitignore files exists, add one
const gitignore = path.join(rootFolder, '.gitignore');
if (!fs.existsSync(gitignore)) {
fs.writeFileSync(gitignore, gitignoreContent);
}
} | javascript | function addGitIgnore(rootFolder) {
// If no .gitignore files exists, add one
const gitignore = path.join(rootFolder, '.gitignore');
if (!fs.existsSync(gitignore)) {
fs.writeFileSync(gitignore, gitignoreContent);
}
} | [
"function",
"addGitIgnore",
"(",
"rootFolder",
")",
"{",
"// If no .gitignore files exists, add one",
"const",
"gitignore",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"'.gitignore'",
")",
";",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"gitignore",
")"... | Add a gitignore file if none is present yet
@param {String} rootFolder - Folder to add .gitignore in
@returns {void} | [
"Add",
"a",
"gitignore",
"file",
"if",
"none",
"is",
"present",
"yet"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/ignore.js#L18-L25 | train |
MaartenDesnouck/google-apps-script | lib/functions/ignore.js | addGasIgnore | function addGasIgnore(rootFolder) {
// If no .gitignore files exists, add one
const gasignore = path.join(rootFolder, constants.IGNORE_FILE);
if (!fs.existsSync(gasignore)) {
fs.writeFileSync(gasignore, gasignoreContent);
}
} | javascript | function addGasIgnore(rootFolder) {
// If no .gitignore files exists, add one
const gasignore = path.join(rootFolder, constants.IGNORE_FILE);
if (!fs.existsSync(gasignore)) {
fs.writeFileSync(gasignore, gasignoreContent);
}
} | [
"function",
"addGasIgnore",
"(",
"rootFolder",
")",
"{",
"// If no .gitignore files exists, add one",
"const",
"gasignore",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"constants",
".",
"IGNORE_FILE",
")",
";",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",... | Add a .gasignore file if none is present yet
@param {String} rootFolder - Folder to add .gasignore in
@returns {void} | [
"Add",
"a",
".",
"gasignore",
"file",
"if",
"none",
"is",
"present",
"yet"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/ignore.js#L33-L40 | train |
MaartenDesnouck/google-apps-script | lib/functions/ignore.js | getIgnoreRegexes | function getIgnoreRegexes(rootFolder) {
const gasignoreFilepath = path.join(rootFolder, constants.IGNORE_FILE);
let regexes = [];
if (fs.existsSync(gasignoreFilepath)) {
regexes = parse(fs.readFileSync(gasignoreFilepath));
}
return regexes;
} | javascript | function getIgnoreRegexes(rootFolder) {
const gasignoreFilepath = path.join(rootFolder, constants.IGNORE_FILE);
let regexes = [];
if (fs.existsSync(gasignoreFilepath)) {
regexes = parse(fs.readFileSync(gasignoreFilepath));
}
return regexes;
} | [
"function",
"getIgnoreRegexes",
"(",
"rootFolder",
")",
"{",
"const",
"gasignoreFilepath",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"constants",
".",
"IGNORE_FILE",
")",
";",
"let",
"regexes",
"=",
"[",
"]",
";",
"if",
"(",
"fs",
".",
"existsSync"... | Get a list of regexes of filenames to ignore while pushing
@param {String} rootFolder - relative path to the rootFolder of the project
@returns {array} - An array of regexes | [
"Get",
"a",
"list",
"of",
"regexes",
"of",
"filenames",
"to",
"ignore",
"while",
"pushing"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/ignore.js#L48-L56 | train |
MaartenDesnouck/google-apps-script | lib/functions/downloadIncludedFiles.js | getAndWriteIncludedFile | function getAndWriteIncludedFile(file, includeDir) {
return new Promise((resolve, reject) => {
const fileName = file[0];
const fileURL = file[1];
const options = {
url: fileURL,
headers: {
'User-Agent': 'request',
},
};
re... | javascript | function getAndWriteIncludedFile(file, includeDir) {
return new Promise((resolve, reject) => {
const fileName = file[0];
const fileURL = file[1];
const options = {
url: fileURL,
headers: {
'User-Agent': 'request',
},
};
re... | [
"function",
"getAndWriteIncludedFile",
"(",
"file",
",",
"includeDir",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"fileName",
"=",
"file",
"[",
"0",
"]",
";",
"const",
"fileURL",
"=",
"file",
"[",
... | Get and write all included files
@param {Object} file - File to get and write.
@param {String} includeDir - Where to write the included files.
@returns {Promise} - Promise resolving an object with the fileName and if include was successful | [
"Get",
"and",
"write",
"all",
"included",
"files"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/downloadIncludedFiles.js#L16-L53 | train |
MaartenDesnouck/google-apps-script | lib/functions/downloadIncludedFiles.js | downloadIncludedFiles | function downloadIncludedFiles(included, dir) {
return new Promise((resolve, reject) => {
const includeDir = dir ? path.join('.', dir, constants.INCLUDE_DIR) : path.join('.', constants.INCLUDE_DIR);
// Create include folder if it doesn't exist yet
try {
if (!fs.existsSync(includ... | javascript | function downloadIncludedFiles(included, dir) {
return new Promise((resolve, reject) => {
const includeDir = dir ? path.join('.', dir, constants.INCLUDE_DIR) : path.join('.', constants.INCLUDE_DIR);
// Create include folder if it doesn't exist yet
try {
if (!fs.existsSync(includ... | [
"function",
"downloadIncludedFiles",
"(",
"included",
",",
"dir",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"includeDir",
"=",
"dir",
"?",
"path",
".",
"join",
"(",
"'.'",
",",
"dir",
",",
"const... | Download files specified by include file
@param {array} included - An authorized OAuth2 client.
@param {String} dir - Directory in which the project is located.
@returns {Promise} - Promise resolving | [
"Download",
"files",
"specified",
"by",
"include",
"file"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/downloadIncludedFiles.js#L62-L115 | train |
MaartenDesnouck/google-apps-script | lib/functions/displayProjectInfo.js | displayProjectInfo | function displayProjectInfo(metadata) {
console.log(`NAME ${metadata.name}`);
console.log(`ID ${metadata.projectId}`);
console.log(`CREATED_AT ${metadata.createTime}`);
console.log(`LAST_MODIFIED_AT ${metadata.updateTime}`);
console.log(`CREATOR ${metadata.cr... | javascript | function displayProjectInfo(metadata) {
console.log(`NAME ${metadata.name}`);
console.log(`ID ${metadata.projectId}`);
console.log(`CREATED_AT ${metadata.createTime}`);
console.log(`LAST_MODIFIED_AT ${metadata.updateTime}`);
console.log(`CREATOR ${metadata.cr... | [
"function",
"displayProjectInfo",
"(",
"metadata",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"metadata",
".",
"name",
"}",
"`",
")",
";",
"console",
".",
"log",
"(",
"`",
"${",
"metadata",
".",
"projectId",
"}",
"`",
")",
";",
"console",
".",
... | Display info about the project.
@param {Object} metadata - Metadata to display.
@returns {void} | [
"Display",
"info",
"about",
"the",
"project",
"."
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/displayProjectInfo.js#L7-L14 | train |
MaartenDesnouck/google-apps-script | lib/functions/pack.js | getFileJSON | function getFileJSON(rootFolder, file, fileName, extension, id) {
return new Promise((resolve, reject) => {
fs.stat(path.join(rootFolder, file), (err, stats) => {
if (err) {
reject();
return;
}
if (stats.isFile()) {
// Read ... | javascript | function getFileJSON(rootFolder, file, fileName, extension, id) {
return new Promise((resolve, reject) => {
fs.stat(path.join(rootFolder, file), (err, stats) => {
if (err) {
reject();
return;
}
if (stats.isFile()) {
// Read ... | [
"function",
"getFileJSON",
"(",
"rootFolder",
",",
"file",
",",
"fileName",
",",
"extension",
",",
"id",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"stat",
"(",
"path",
".",
"join",
"(",
"root... | Getting the json form of a file.
@param {String} rootFolder - relative path to the rootFOldr of the project.
@param {String} file - Full filename of the file to process.
@param {String} fileName - fileName without extension.
@param {String} extension - Only the extension of the filename.
@param {String} id - Optional ... | [
"Getting",
"the",
"json",
"form",
"of",
"a",
"file",
"."
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/pack.js#L19-L51 | train |
MaartenDesnouck/google-apps-script | lib/functions/pack.js | local | function local(rootFolder) {
// Construct name to remote id map
const remote = path.join(rootFolder, constants.META_DIR, constants.META_REMOTE);
const remoteSource = fs.readJsonSync(remote, 'utf8');
const destination = constants.META_LOCAL;
return pack(rootFolder, destination);
} | javascript | function local(rootFolder) {
// Construct name to remote id map
const remote = path.join(rootFolder, constants.META_DIR, constants.META_REMOTE);
const remoteSource = fs.readJsonSync(remote, 'utf8');
const destination = constants.META_LOCAL;
return pack(rootFolder, destination);
} | [
"function",
"local",
"(",
"rootFolder",
")",
"{",
"// Construct name to remote id map",
"const",
"remote",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"constants",
".",
"META_DIR",
",",
"constants",
".",
"META_REMOTE",
")",
";",
"const",
"remoteSource",
"=... | Pack all seperate .js files into a raw google script file for pushing
@param {String} rootFolder - relative path to the rootFolder of the project
@returns {Promise} - A promise resolving no value | [
"Pack",
"all",
"seperate",
".",
"js",
"files",
"into",
"a",
"raw",
"google",
"script",
"file",
"for",
"pushing"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/pack.js#L133-L139 | train |
MaartenDesnouck/google-apps-script | lib/functions/pack.js | publish | function publish(rootFolder) {
// Read every local file and create a correct json file in .gas/${destination}
ignore.addGitIgnore(rootFolder);
ignore.addGasIgnore(rootFolder);
const destination = constants.META_PUBLISH;
return pack(rootFolder, destination);
} | javascript | function publish(rootFolder) {
// Read every local file and create a correct json file in .gas/${destination}
ignore.addGitIgnore(rootFolder);
ignore.addGasIgnore(rootFolder);
const destination = constants.META_PUBLISH;
return pack(rootFolder, destination);
} | [
"function",
"publish",
"(",
"rootFolder",
")",
"{",
"// Read every local file and create a correct json file in .gas/${destination}",
"ignore",
".",
"addGitIgnore",
"(",
"rootFolder",
")",
";",
"ignore",
".",
"addGasIgnore",
"(",
"rootFolder",
")",
";",
"const",
"destinat... | Pack all seperate .js files into a raw google script file for publishing
@param {String} rootFolder - relative path to the rootFolder of the project
@returns {Promise} - A promise resolving no value | [
"Pack",
"all",
"seperate",
".",
"js",
"files",
"into",
"a",
"raw",
"google",
"script",
"file",
"for",
"publishing"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/pack.js#L147-L153 | train |
restify/enroute | lib/index.js | function (opts, cb) {
assert.object(opts, 'opts');
assert.func(cb, 'cb');
// asserts of other inputs done by parse and installRoutes respectively
vasync.pipeline({arg: {}, funcs: [
function parse(ctx, _cb) {
parser.parse(opts, function (err, config) {
... | javascript | function (opts, cb) {
assert.object(opts, 'opts');
assert.func(cb, 'cb');
// asserts of other inputs done by parse and installRoutes respectively
vasync.pipeline({arg: {}, funcs: [
function parse(ctx, _cb) {
parser.parse(opts, function (err, config) {
... | [
"function",
"(",
"opts",
",",
"cb",
")",
"{",
"assert",
".",
"object",
"(",
"opts",
",",
"'opts'",
")",
";",
"assert",
".",
"func",
"(",
"cb",
",",
"'cb'",
")",
";",
"// asserts of other inputs done by parse and installRoutes respectively",
"vasync",
".",
"pip... | Installs configuration driven routes onto a restify server. Note only
one of opts.config or opts.configPath is needed.
exports
@param {object} opts Options object.
@param {string} [opts.config] The POJO of the config you want to
validate.
@param {string} [opts.configPath] The path to the data on disk to
validate.
@pa... | [
"Installs",
"configuration",
"driven",
"routes",
"onto",
"a",
"restify",
"server",
".",
"Note",
"only",
"one",
"of",
"opts",
".",
"config",
"or",
"opts",
".",
"configPath",
"is",
"needed",
"."
] | df5f9f25149fcb248267db9d8927aba28b9a3d4e | https://github.com/restify/enroute/blob/df5f9f25149fcb248267db9d8927aba28b9a3d4e/lib/index.js#L29-L55 | train | |
MaartenDesnouck/google-apps-script | lib/functions/remoteCreateProject.js | remoteCreateProject | function remoteCreateProject(auth, name) {
return new Promise((resolve, reject) => {
const drive = google.drive('v3');
const options = {
auth,
resource: {
name,
mimeType: constants.MIME_GAS_JSON,
},
media: {
... | javascript | function remoteCreateProject(auth, name) {
return new Promise((resolve, reject) => {
const drive = google.drive('v3');
const options = {
auth,
resource: {
name,
mimeType: constants.MIME_GAS_JSON,
},
media: {
... | [
"function",
"remoteCreateProject",
"(",
"auth",
",",
"name",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"drive",
"=",
"google",
".",
"drive",
"(",
"'v3'",
")",
";",
"const",
"options",
"=",
"{",
... | Create a new remote script file
@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@param {String} name - Name to give to the new Google Apps Script file.
@returns {Promise} - A promise resolving the metadata of the newly created project | [
"Create",
"a",
"new",
"remote",
"script",
"file"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/remoteCreateProject.js#L26-L55 | train |
pugjs/then-pug | packages/then-pug/lib/pug-code-gen-module.js | function(block){
var escapePrettyMode = this.escapePrettyMode;
var pp = this.pp;
var ast = [];
// Pretty print multi-line text
if (pp && block.nodes.length > 1 && !escapePrettyMode &&
block.nodes[0].type === 'Text' && block.nodes[1].type === 'Text' ) {
push.apply(ast, this.prettyIndent... | javascript | function(block){
var escapePrettyMode = this.escapePrettyMode;
var pp = this.pp;
var ast = [];
// Pretty print multi-line text
if (pp && block.nodes.length > 1 && !escapePrettyMode &&
block.nodes[0].type === 'Text' && block.nodes[1].type === 'Text' ) {
push.apply(ast, this.prettyIndent... | [
"function",
"(",
"block",
")",
"{",
"var",
"escapePrettyMode",
"=",
"this",
".",
"escapePrettyMode",
";",
"var",
"pp",
"=",
"this",
".",
"pp",
";",
"var",
"ast",
"=",
"[",
"]",
";",
"// Pretty print multi-line text",
"if",
"(",
"pp",
"&&",
"block",
".",
... | Visit all nodes in `block`.
@param {Block} block
@api public | [
"Visit",
"all",
"nodes",
"in",
"block",
"."
] | a96c2a9c6d1f0875aef4641064500f818f7e7571 | https://github.com/pugjs/then-pug/blob/a96c2a9c6d1f0875aef4641064500f818f7e7571/packages/then-pug/lib/pug-code-gen-module.js#L538-L557 | train | |
pugjs/then-pug | packages/then-pug/lib/pug-code-gen-module.js | function(comment){
var ast = [];
if (!comment.buffer) return;
if (this.pp) push.apply(ast, this.prettyIndent(1, true));
push.apply(ast, this.buffer('<!--' + comment.val + '-->'));
return ast;
} | javascript | function(comment){
var ast = [];
if (!comment.buffer) return;
if (this.pp) push.apply(ast, this.prettyIndent(1, true));
push.apply(ast, this.buffer('<!--' + comment.val + '-->'));
return ast;
} | [
"function",
"(",
"comment",
")",
"{",
"var",
"ast",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"comment",
".",
"buffer",
")",
"return",
";",
"if",
"(",
"this",
".",
"pp",
")",
"push",
".",
"apply",
"(",
"ast",
",",
"this",
".",
"prettyIndent",
"(",
"1... | Visit a `comment`, only buffering when the buffer flag is set.
@param {Comment} comment
@api public | [
"Visit",
"a",
"comment",
"only",
"buffering",
"when",
"the",
"buffer",
"flag",
"is",
"set",
"."
] | a96c2a9c6d1f0875aef4641064500f818f7e7571 | https://github.com/pugjs/then-pug/blob/a96c2a9c6d1f0875aef4641064500f818f7e7571/packages/then-pug/lib/pug-code-gen-module.js#L929-L935 | train | |
pugjs/then-pug | packages/then-pug/lib/pug-code-gen-module.js | function(attrs, buffer){
var res = compileAttrs(attrs, {
terse: this.terse,
format: buffer ? 'html' : 'object',
runtime: this.runtime.bind(this)
});
return res;
} | javascript | function(attrs, buffer){
var res = compileAttrs(attrs, {
terse: this.terse,
format: buffer ? 'html' : 'object',
runtime: this.runtime.bind(this)
});
return res;
} | [
"function",
"(",
"attrs",
",",
"buffer",
")",
"{",
"var",
"res",
"=",
"compileAttrs",
"(",
"attrs",
",",
"{",
"terse",
":",
"this",
".",
"terse",
",",
"format",
":",
"buffer",
"?",
"'html'",
":",
"'object'",
",",
"runtime",
":",
"this",
".",
"runtime... | Compile attributes. | [
"Compile",
"attributes",
"."
] | a96c2a9c6d1f0875aef4641064500f818f7e7571 | https://github.com/pugjs/then-pug/blob/a96c2a9c6d1f0875aef4641064500f818f7e7571/packages/then-pug/lib/pug-code-gen-module.js#L1228-L1235 | train | |
MaartenDesnouck/google-apps-script | lib/init.js | createPackageFile | function createPackageFile(content) {
// todo in the rootfolder
createFile({
name: constants.INCLUDE_FILE,
source: `${JSON.stringify(content)}\n`,
});
} | javascript | function createPackageFile(content) {
// todo in the rootfolder
createFile({
name: constants.INCLUDE_FILE,
source: `${JSON.stringify(content)}\n`,
});
} | [
"function",
"createPackageFile",
"(",
"content",
")",
"{",
"// todo in the rootfolder",
"createFile",
"(",
"{",
"name",
":",
"constants",
".",
"INCLUDE_FILE",
",",
"source",
":",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"content",
")",
"}",
"\\n",
"`",
",",... | Create a package.json file based on the values provided
@param {Object} content - Package.json to create
@returns {void} | [
"Create",
"a",
"package",
".",
"json",
"file",
"based",
"on",
"the",
"values",
"provided"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/init.js#L13-L19 | train |
MaartenDesnouck/google-apps-script | lib/init.js | endDialog | function endDialog(success, content) {
if (success) {
createPackageFile(content);
process.stdout.write('Succesfully created gas-include.json');
checkbox.display('green');
process.exit(0);
} else {
process.stdout.write('Failed to create gas-include.json');
checkbox... | javascript | function endDialog(success, content) {
if (success) {
createPackageFile(content);
process.stdout.write('Succesfully created gas-include.json');
checkbox.display('green');
process.exit(0);
} else {
process.stdout.write('Failed to create gas-include.json');
checkbox... | [
"function",
"endDialog",
"(",
"success",
",",
"content",
")",
"{",
"if",
"(",
"success",
")",
"{",
"createPackageFile",
"(",
"content",
")",
";",
"process",
".",
"stdout",
".",
"write",
"(",
"'Succesfully created gas-include.json'",
")",
";",
"checkbox",
".",
... | Create a package file based on the values provided
@param {String} success - Whether or not the dialog completed succesfully
@param {String} content - Package.json to create
@returns {void} | [
"Create",
"a",
"package",
"file",
"based",
"on",
"the",
"values",
"provided"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/init.js#L28-L39 | train |
MaartenDesnouck/google-apps-script | lib/functions/findInProject.js | findInProject | function findInProject(dir, name) {
return new Promise((resolve, reject) => {
const fullPath = process.cwd();
const pieces = fullPath.split(path.sep);
let folderCounter = 0;
let found = false;
let folder = dir;
while (folderCounter < pieces.length - 1 && !found) {
... | javascript | function findInProject(dir, name) {
return new Promise((resolve, reject) => {
const fullPath = process.cwd();
const pieces = fullPath.split(path.sep);
let folderCounter = 0;
let found = false;
let folder = dir;
while (folderCounter < pieces.length - 1 && !found) {
... | [
"function",
"findInProject",
"(",
"dir",
",",
"name",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"fullPath",
"=",
"process",
".",
"cwd",
"(",
")",
";",
"const",
"pieces",
"=",
"fullPath",
".",
"... | Find the project root folder
@param {String} dir - Current directory
@param {String} name - Name of item of folder to find
@returns {void} | [
"Find",
"the",
"project",
"root",
"folder"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/findInProject.js#L11-L32 | train |
MaartenDesnouck/google-apps-script | lib/functions/unpackRemote.js | unpackRemote | function unpackRemote(rootFolder, fileName) {
let foundSingleFile = false;
const local = path.join(rootFolder, constants.META_DIR, constants.META_LOCAL);
const remote = path.join(rootFolder, constants.META_DIR, constants.META_REMOTE);
// Read local files
const localFiles = getAllFiles(rootFolder, '... | javascript | function unpackRemote(rootFolder, fileName) {
let foundSingleFile = false;
const local = path.join(rootFolder, constants.META_DIR, constants.META_LOCAL);
const remote = path.join(rootFolder, constants.META_DIR, constants.META_REMOTE);
// Read local files
const localFiles = getAllFiles(rootFolder, '... | [
"function",
"unpackRemote",
"(",
"rootFolder",
",",
"fileName",
")",
"{",
"let",
"foundSingleFile",
"=",
"false",
";",
"const",
"local",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"constants",
".",
"META_DIR",
",",
"constants",
".",
"META_LOCAL",
")",... | Unpack a remote google script file into seperate .js and .html files
@param {String} rootFolder - relative path to the rootFolder of the project
@param {String} fileName - if specified, only this file will get unpacked
@returns {Promise} - A promise resolving no value | [
"Unpack",
"a",
"remote",
"google",
"script",
"file",
"into",
"seperate",
".",
"js",
"and",
".",
"html",
"files"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/unpackRemote.js#L17-L104 | train |
MaartenDesnouck/google-apps-script | lib/functions/resolveDependencies.js | recDependencies | async function recDependencies(dependencies, root) {
let url;
// TODO think about doing this in parallel using promises
for (const dependency of Reflect.ownKeys(dependencies)) {
const range = dependencies[dependency];
url = `${constants.FIREBASE_DATABASE_URL}/package/${dependency}/versions... | javascript | async function recDependencies(dependencies, root) {
let url;
// TODO think about doing this in parallel using promises
for (const dependency of Reflect.ownKeys(dependencies)) {
const range = dependencies[dependency];
url = `${constants.FIREBASE_DATABASE_URL}/package/${dependency}/versions... | [
"async",
"function",
"recDependencies",
"(",
"dependencies",
",",
"root",
")",
"{",
"let",
"url",
";",
"// TODO think about doing this in parallel using promises",
"for",
"(",
"const",
"dependency",
"of",
"Reflect",
".",
"ownKeys",
"(",
"dependencies",
")",
")",
"{"... | Recursively resolve a set of dependencies to fixed versions
@param {Object} dependencies - Dedendencies with ranges to resolve
@param {Boolean} root - Boolean indicating if these are root dependencies
@returns {void} | [
"Recursively",
"resolve",
"a",
"set",
"of",
"dependencies",
"to",
"fixed",
"versions"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/resolveDependencies.js#L16-L77 | train |
MaartenDesnouck/google-apps-script | lib/functions/resolveDependencies.js | resolveDependencies | async function resolveDependencies(rootFolder) {
const includeFile = path.join(rootFolder, constants.INCLUDE_FILE);
const includeJson = fs.readJsonSync(includeFile, 'utf8');
await recDependencies(includeJson.dependencies, true);
return depencyList;
} | javascript | async function resolveDependencies(rootFolder) {
const includeFile = path.join(rootFolder, constants.INCLUDE_FILE);
const includeJson = fs.readJsonSync(includeFile, 'utf8');
await recDependencies(includeJson.dependencies, true);
return depencyList;
} | [
"async",
"function",
"resolveDependencies",
"(",
"rootFolder",
")",
"{",
"const",
"includeFile",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"constants",
".",
"INCLUDE_FILE",
")",
";",
"const",
"includeJson",
"=",
"fs",
".",
"readJsonSync",
"(",
"include... | Read the gas-include file a return a dependency tree with exact versions
@param {String} rootFolder - Folder where we can find the gas-include file
@returns {void} | [
"Read",
"the",
"gas",
"-",
"include",
"file",
"a",
"return",
"a",
"dependency",
"tree",
"with",
"exact",
"versions"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/resolveDependencies.js#L85-L90 | train |
MaartenDesnouck/google-apps-script | lib/functions/packLocalSingleFile.js | writeLocalJson | function writeLocalJson(source, rootFolder) {
// Write to local.json
const local = path.join(rootFolder, constants.META_DIR, constants.META_LOCAL);
const file = {
name: local,
source: JSON.stringify(source),
};
createFile(file);
} | javascript | function writeLocalJson(source, rootFolder) {
// Write to local.json
const local = path.join(rootFolder, constants.META_DIR, constants.META_LOCAL);
const file = {
name: local,
source: JSON.stringify(source),
};
createFile(file);
} | [
"function",
"writeLocalJson",
"(",
"source",
",",
"rootFolder",
")",
"{",
"// Write to local.json",
"const",
"local",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"constants",
".",
"META_DIR",
",",
"constants",
".",
"META_LOCAL",
")",
";",
"const",
"file"... | Write the source to the write file
@param {String} source - relative path to the rootFolder of the project
@param {String} rootFolder - relative path to the rootFolder of the project
@returns {void} | [
"Write",
"the",
"source",
"to",
"the",
"write",
"file"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/packLocalSingleFile.js#L16-L24 | train |
MaartenDesnouck/google-apps-script | lib/functions/getAllFolders.js | getAllFolders | function getAllFolders(dir, folderlist) {
const files = fs.readdirSync(dir);
folderlist = folderlist || [];
files.forEach((file) => {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
folderlist = getAllFolders(path.join(dir, file), folderlist);
folderlist.push(path.join... | javascript | function getAllFolders(dir, folderlist) {
const files = fs.readdirSync(dir);
folderlist = folderlist || [];
files.forEach((file) => {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
folderlist = getAllFolders(path.join(dir, file), folderlist);
folderlist.push(path.join... | [
"function",
"getAllFolders",
"(",
"dir",
",",
"folderlist",
")",
"{",
"const",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
";",
"folderlist",
"=",
"folderlist",
"||",
"[",
"]",
";",
"files",
".",
"forEach",
"(",
"(",
"file",
")",
"=>",
"... | List all folders in a directory
@param {dir} dir - Current folder.
@param {object} folderlist - List of folders already found.
@returns {object} - List of all folders in dir | [
"List",
"all",
"folders",
"in",
"a",
"directory"
] | 07f2d40f396d932c34ef823670321b25c02ddded | https://github.com/MaartenDesnouck/google-apps-script/blob/07f2d40f396d932c34ef823670321b25c02ddded/lib/functions/getAllFolders.js#L11-L21 | train |
rrdelaney/ReasonablyTyped | lib/index.js | format | function format(source) {
var fmtedCode = 'NotInitialized'
try {
fmtedCode = reason.printRE(reason.parseRE(source))
} catch (e) {
fmtedCode =
'line ' +
e.location.startLine +
', characters ' +
e.location.startLineStartChar +
'-' +
e.location.endLineEndChar +
', ' ... | javascript | function format(source) {
var fmtedCode = 'NotInitialized'
try {
fmtedCode = reason.printRE(reason.parseRE(source))
} catch (e) {
fmtedCode =
'line ' +
e.location.startLine +
', characters ' +
e.location.startLineStartChar +
'-' +
e.location.endLineEndChar +
', ' ... | [
"function",
"format",
"(",
"source",
")",
"{",
"var",
"fmtedCode",
"=",
"'NotInitialized'",
"try",
"{",
"fmtedCode",
"=",
"reason",
".",
"printRE",
"(",
"reason",
".",
"parseRE",
"(",
"source",
")",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"fmtedCode",
"... | Runs `refmt` on a string of Reason code
@param {string} source Reason source code
@return {string} Formatted Reason code | [
"Runs",
"refmt",
"on",
"a",
"string",
"of",
"Reason",
"code"
] | 0b9cd39ac97f87f98a85b0a6491b50c9308c3be5 | https://github.com/rrdelaney/ReasonablyTyped/blob/0b9cd39ac97f87f98a85b0a6491b50c9308c3be5/lib/index.js#L10-L29 | train |
rrdelaney/ReasonablyTyped | lib/index.js | compile | function compile(
source,
filename = '',
includeModule = false,
debugMode = false,
) {
let res
let resName
let errors
try {
const [moduleName, bsCode, diagnosticErrors] = Retyped.compile(filename, source, debugMode)
const fmtCode = format(bsCode)
res = fmtCode
resName = moduleName
e... | javascript | function compile(
source,
filename = '',
includeModule = false,
debugMode = false,
) {
let res
let resName
let errors
try {
const [moduleName, bsCode, diagnosticErrors] = Retyped.compile(filename, source, debugMode)
const fmtCode = format(bsCode)
res = fmtCode
resName = moduleName
e... | [
"function",
"compile",
"(",
"source",
",",
"filename",
"=",
"''",
",",
"includeModule",
"=",
"false",
",",
"debugMode",
"=",
"false",
",",
")",
"{",
"let",
"res",
"let",
"resName",
"let",
"errors",
"try",
"{",
"const",
"[",
"moduleName",
",",
"bsCode",
... | Compiles a Flow libdef to a Reason interface, formatted and error handled
@param {string} source Flow libdef to compile
@param {string} [filename] Name of file being compiled for better error messages
@return {string} Reason interface | [
"Compiles",
"a",
"Flow",
"libdef",
"to",
"a",
"Reason",
"interface",
"formatted",
"and",
"error",
"handled"
] | 0b9cd39ac97f87f98a85b0a6491b50c9308c3be5 | https://github.com/rrdelaney/ReasonablyTyped/blob/0b9cd39ac97f87f98a85b0a6491b50c9308c3be5/lib/index.js#L38-L72 | train |
rappid/rAppid.js | js/core/NotificationManager.js | function (templateName, attributes, options) {
if (!this.$container) {
this.$container = this.createComponent(HtmlElement, {"class": this.$.containerClass, tagName: "div"});
this.$stage.addChild(this.$container);
}
if (!this.$templates[templateName]) ... | javascript | function (templateName, attributes, options) {
if (!this.$container) {
this.$container = this.createComponent(HtmlElement, {"class": this.$.containerClass, tagName: "div"});
this.$stage.addChild(this.$container);
}
if (!this.$templates[templateName]) ... | [
"function",
"(",
"templateName",
",",
"attributes",
",",
"options",
")",
"{",
"if",
"(",
"!",
"this",
".",
"$container",
")",
"{",
"this",
".",
"$container",
"=",
"this",
".",
"createComponent",
"(",
"HtmlElement",
",",
"{",
"\"class\"",
":",
"this",
"."... | Shows a notification with the given template.
The templates need to be defined in the NotificationManager instance via XAML.
@param {String} templateName - the name of the Template for the Notification
@param {Object} [attributes] - attributes for the template
@param {Object} [options] - options for
@returns {js.core.... | [
"Shows",
"a",
"notification",
"with",
"the",
"given",
"template",
".",
"The",
"templates",
"need",
"to",
"be",
"defined",
"in",
"the",
"NotificationManager",
"instance",
"via",
"XAML",
"."
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/NotificationManager.js#L34-L70 | train | |
rappid/rAppid.js | js/core/Router.js | function (to, createHistoryEntry, triggerRoute, force, callback) {
return this.history.navigate(to, createHistoryEntry, triggerRoute, force, callback);
} | javascript | function (to, createHistoryEntry, triggerRoute, force, callback) {
return this.history.navigate(to, createHistoryEntry, triggerRoute, force, callback);
} | [
"function",
"(",
"to",
",",
"createHistoryEntry",
",",
"triggerRoute",
",",
"force",
",",
"callback",
")",
"{",
"return",
"this",
".",
"history",
".",
"navigate",
"(",
"to",
",",
"createHistoryEntry",
",",
"triggerRoute",
",",
"force",
",",
"callback",
")",
... | shortcut to history.navigate
@param to
@param createHistoryEntry
@param triggerRoute | [
"shortcut",
"to",
"history",
".",
"navigate"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/js/core/Router.js#L206-L208 | train | |
rappid/rAppid.js | srv/auth/DataSourceAuthenticationProvider.js | function (password, algorithm, salt) {
salt = salt || Crypto.randomBytes(128).toString("hex");
algorithm = algorithm || this.$.algorithm;
var hash = Crypto.createHash(this.$.algorithm);
hash.update(salt + password, "utf8");
return [algorithm, salt, hash.dige... | javascript | function (password, algorithm, salt) {
salt = salt || Crypto.randomBytes(128).toString("hex");
algorithm = algorithm || this.$.algorithm;
var hash = Crypto.createHash(this.$.algorithm);
hash.update(salt + password, "utf8");
return [algorithm, salt, hash.dige... | [
"function",
"(",
"password",
",",
"algorithm",
",",
"salt",
")",
"{",
"salt",
"=",
"salt",
"||",
"Crypto",
".",
"randomBytes",
"(",
"128",
")",
".",
"toString",
"(",
"\"hex\"",
")",
";",
"algorithm",
"=",
"algorithm",
"||",
"this",
".",
"$",
".",
"al... | Creates an hash for a password
@param {String} password
@param {String} [algorithm] - default sha1
@param {String} [salt] - default is generated
@returns {String} | [
"Creates",
"an",
"hash",
"for",
"a",
"password"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/auth/DataSourceAuthenticationProvider.js#L77-L85 | train | |
rappid/rAppid.js | srv/auth/DataSourceAuthenticationProvider.js | function (password, algorithm, salt) {
return {
hash: this.createHash(password, algorithm, salt),
loginAttempts: 0,
loginBlocked: null
}
} | javascript | function (password, algorithm, salt) {
return {
hash: this.createHash(password, algorithm, salt),
loginAttempts: 0,
loginBlocked: null
}
} | [
"function",
"(",
"password",
",",
"algorithm",
",",
"salt",
")",
"{",
"return",
"{",
"hash",
":",
"this",
".",
"createHash",
"(",
"password",
",",
"algorithm",
",",
"salt",
")",
",",
"loginAttempts",
":",
"0",
",",
"loginBlocked",
":",
"null",
"}",
"}"... | Creates an authentication Object which contains all authentication relevant data for an user
@param password
@param algorithm
@param salt
@returns {{encryptedPassword: *, loginAttempts: number, loginBlocked: null}} | [
"Creates",
"an",
"authentication",
"Object",
"which",
"contains",
"all",
"authentication",
"relevant",
"data",
"for",
"an",
"user"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/auth/DataSourceAuthenticationProvider.js#L115-L123 | train | |
rappid/rAppid.js | srv/auth/DataSourceAuthenticationProvider.js | function (registrationRequest, cb) {
if (registrationRequest.$.password) {
var ret = {
providerUserId: registrationRequest.get(this.$.usernameField),
authenticationData: this.createAuthenticationData(registrationRequest.$.password)
};
... | javascript | function (registrationRequest, cb) {
if (registrationRequest.$.password) {
var ret = {
providerUserId: registrationRequest.get(this.$.usernameField),
authenticationData: this.createAuthenticationData(registrationRequest.$.password)
};
... | [
"function",
"(",
"registrationRequest",
",",
"cb",
")",
"{",
"if",
"(",
"registrationRequest",
".",
"$",
".",
"password",
")",
"{",
"var",
"ret",
"=",
"{",
"providerUserId",
":",
"registrationRequest",
".",
"get",
"(",
"this",
".",
"$",
".",
"usernameField... | RegistrationRequest requires a password to create the registrationData
@param registrationRequest
@param cb | [
"RegistrationRequest",
"requires",
"a",
"password",
"to",
"create",
"the",
"registrationData"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/auth/DataSourceAuthenticationProvider.js#L129-L139 | train | |
rappid/rAppid.js | srv/auth/DataSourceAuthenticationProvider.js | function (registrationRequest, callback) {
this.fetchUser(registrationRequest, function (err, user) {
if (!err && user) {
err = RegistrationError.USER_ALREADY_EXISTS
}
callback(err);
});
} | javascript | function (registrationRequest, callback) {
this.fetchUser(registrationRequest, function (err, user) {
if (!err && user) {
err = RegistrationError.USER_ALREADY_EXISTS
}
callback(err);
});
} | [
"function",
"(",
"registrationRequest",
",",
"callback",
")",
"{",
"this",
".",
"fetchUser",
"(",
"registrationRequest",
",",
"function",
"(",
"err",
",",
"user",
")",
"{",
"if",
"(",
"!",
"err",
"&&",
"user",
")",
"{",
"err",
"=",
"RegistrationError",
"... | Checks if the user already exists
@param registrationRequest
@param callback | [
"Checks",
"if",
"the",
"user",
"already",
"exists"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/auth/DataSourceAuthenticationProvider.js#L146-L153 | train | |
rappid/rAppid.js | srv/auth/DataSourceAuthenticationProvider.js | function (authenticationRequest, callback) {
// create query to fetch the user
var query = this._createQueryForUser(authenticationRequest.get(this.$.usernameField));
var collection = this.$.dataSource.createCollection(this.$collectionClass).query(query);
collection.fetch... | javascript | function (authenticationRequest, callback) {
// create query to fetch the user
var query = this._createQueryForUser(authenticationRequest.get(this.$.usernameField));
var collection = this.$.dataSource.createCollection(this.$collectionClass).query(query);
collection.fetch... | [
"function",
"(",
"authenticationRequest",
",",
"callback",
")",
"{",
"// create query to fetch the user",
"var",
"query",
"=",
"this",
".",
"_createQueryForUser",
"(",
"authenticationRequest",
".",
"get",
"(",
"this",
".",
"$",
".",
"usernameField",
")",
")",
";",... | Fetches a user by username, returns a User or NULL
@param {srv.auth.AuthenticationRequest} authenticationRequest
@param {Function} callback | [
"Fetches",
"a",
"user",
"by",
"username",
"returns",
"a",
"User",
"or",
"NULL"
] | 38ebcdcd73b06ae7825aba1111c734b56202abe9 | https://github.com/rappid/rAppid.js/blob/38ebcdcd73b06ae7825aba1111c734b56202abe9/srv/auth/DataSourceAuthenticationProvider.js#L175-L189 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.storage.js | function(key) {
var value = this.storage.get(key);
if (typeof value == 'undefined' || value == null || value == '') {
return value;
}
try {
return JSON.parse(value);
} catch(e) {
return value;
}
} | javascript | function(key) {
var value = this.storage.get(key);
if (typeof value == 'undefined' || value == null || value == '') {
return value;
}
try {
return JSON.parse(value);
} catch(e) {
return value;
}
} | [
"function",
"(",
"key",
")",
"{",
"var",
"value",
"=",
"this",
".",
"storage",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"typeof",
"value",
"==",
"'undefined'",
"||",
"value",
"==",
"null",
"||",
"value",
"==",
"''",
")",
"{",
"return",
"value",... | Returns the set value at `key`, parsing with `JSON.parse` and turning into an object if possible | [
"Returns",
"the",
"set",
"value",
"at",
"key",
"parsing",
"with",
"JSON",
".",
"parse",
"and",
"turning",
"into",
"an",
"object",
"if",
"possible"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.storage.js#L117-L127 | train | |
mikeal/node.couchapp.js | boiler/attachments/sammy/plugins/sammy.storage.js | function(callback) {
var found = false;
this.each(function(key, value) {
if (callback(key, value)) {
found = [key, value];
return false;
}
});
return found;
} | javascript | function(callback) {
var found = false;
this.each(function(key, value) {
if (callback(key, value)) {
found = [key, value];
return false;
}
});
return found;
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"found",
"=",
"false",
";",
"this",
".",
"each",
"(",
"function",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"callback",
"(",
"key",
",",
"value",
")",
")",
"{",
"found",
"=",
"[",
"key",
",",
"... | Works exactly like filter except only returns the first matching key value pair instead of all of them | [
"Works",
"exactly",
"like",
"filter",
"except",
"only",
"returns",
"the",
"first",
"matching",
"key",
"value",
"pair",
"instead",
"of",
"all",
"of",
"them"
] | e4ce61c342595148c37ad1ea1a88e7b53120c668 | https://github.com/mikeal/node.couchapp.js/blob/e4ce61c342595148c37ad1ea1a88e7b53120c668/boiler/attachments/sammy/plugins/sammy.storage.js#L191-L200 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.