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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | processElement | function processElement( that, element, toBeRemoved, opts ) {
var status,
retVal = 0,
callbacksRetVal;
// Unprotect elements names previously protected by htmlDataProcessor
// (see protectElementNames and protectSelfClosingElements functions).
// Note: body, title, etc. are not protected by htmlDataP (or... | javascript | function processElement( that, element, toBeRemoved, opts ) {
var status,
retVal = 0,
callbacksRetVal;
// Unprotect elements names previously protected by htmlDataProcessor
// (see protectElementNames and protectSelfClosingElements functions).
// Note: body, title, etc. are not protected by htmlDataP (or... | [
"function",
"processElement",
"(",
"that",
",",
"element",
",",
"toBeRemoved",
",",
"opts",
")",
"{",
"var",
"status",
",",
"retVal",
"=",
"0",
",",
"callbacksRetVal",
";",
"// Unprotect elements names previously protected by htmlDataProcessor",
"// (see protectElementNam... | The actual function which filters, transforms and does other funny things with an element. @param {CKEDITOR.filter} that Context. @param {CKEDITOR.htmlParser.element} element The element to be processed. @param {Array} toBeRemoved Array into which elements rejected by the filter will be pushed. @param {Boolean} [opts.... | [
"The",
"actual",
"function",
"which",
"filters",
"transforms",
"and",
"does",
"other",
"funny",
"things",
"with",
"an",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1480-L1533 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | regexifyPropertiesWithWildcards | function regexifyPropertiesWithWildcards( validators ) {
var patterns = [],
i;
for ( i in validators ) {
if ( i.indexOf( '*' ) > -1 )
patterns.push( i.replace( /\*/g, '.*' ) );
}
if ( patterns.length )
return new RegExp( '^(?:' + patterns.join( '|' ) + ')$' );
else
return null;
} | javascript | function regexifyPropertiesWithWildcards( validators ) {
var patterns = [],
i;
for ( i in validators ) {
if ( i.indexOf( '*' ) > -1 )
patterns.push( i.replace( /\*/g, '.*' ) );
}
if ( patterns.length )
return new RegExp( '^(?:' + patterns.join( '|' ) + ')$' );
else
return null;
} | [
"function",
"regexifyPropertiesWithWildcards",
"(",
"validators",
")",
"{",
"var",
"patterns",
"=",
"[",
"]",
",",
"i",
";",
"for",
"(",
"i",
"in",
"validators",
")",
"{",
"if",
"(",
"i",
".",
"indexOf",
"(",
"'*'",
")",
">",
"-",
"1",
")",
"patterns... | Returns a regexp object which can be used to test if a property matches one of wildcard validators. | [
"Returns",
"a",
"regexp",
"object",
"which",
"can",
"be",
"used",
"to",
"test",
"if",
"a",
"property",
"matches",
"one",
"of",
"wildcard",
"validators",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1537-L1550 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | standardizeRule | function standardizeRule( rule ) {
rule.elements = convertValidatorToHash( rule.elements, /\s+/ ) || null;
rule.propertiesOnly = rule.propertiesOnly || ( rule.elements === true );
var delim = /\s*,\s*/,
i;
for ( i in validators ) {
rule[ i ] = convertValidatorToHash( rule[ i ], delim ) || null;
rule[... | javascript | function standardizeRule( rule ) {
rule.elements = convertValidatorToHash( rule.elements, /\s+/ ) || null;
rule.propertiesOnly = rule.propertiesOnly || ( rule.elements === true );
var delim = /\s*,\s*/,
i;
for ( i in validators ) {
rule[ i ] = convertValidatorToHash( rule[ i ], delim ) || null;
rule[... | [
"function",
"standardizeRule",
"(",
"rule",
")",
"{",
"rule",
".",
"elements",
"=",
"convertValidatorToHash",
"(",
"rule",
".",
"elements",
",",
"/",
"\\s+",
"/",
")",
"||",
"null",
";",
"rule",
".",
"propertiesOnly",
"=",
"rule",
".",
"propertiesOnly",
"|... | Standardize a rule by converting all validators to hashes. | [
"Standardize",
"a",
"rule",
"by",
"converting",
"all",
"validators",
"to",
"hashes",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1553-L1567 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | transformElement | function transformElement( that, element ) {
var transformations = that._.transformations[ element.name ],
i;
if ( !transformations )
return;
populateProperties( element );
for ( i = 0; i < transformations.length; ++i )
applyTransformationsGroup( that, element, transformations[ i ] );
// Do not c... | javascript | function transformElement( that, element ) {
var transformations = that._.transformations[ element.name ],
i;
if ( !transformations )
return;
populateProperties( element );
for ( i = 0; i < transformations.length; ++i )
applyTransformationsGroup( that, element, transformations[ i ] );
// Do not c... | [
"function",
"transformElement",
"(",
"that",
",",
"element",
")",
"{",
"var",
"transformations",
"=",
"that",
".",
"_",
".",
"transformations",
"[",
"element",
".",
"name",
"]",
",",
"i",
";",
"if",
"(",
"!",
"transformations",
")",
"return",
";",
"popul... | Does the element transformation by applying registered transformation rules. | [
"Does",
"the",
"element",
"transformation",
"by",
"applying",
"registered",
"transformation",
"rules",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1571-L1587 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | updateAttributes | function updateAttributes( element ) {
var attrs = element.attributes,
styles;
// Will be recreated later if any of styles/classes exists.
delete attrs.style;
delete attrs[ 'class' ];
if ( ( styles = CKEDITOR.tools.writeCssText( element.styles, true ) ) )
attrs.style = styles;
if ( element.classes.... | javascript | function updateAttributes( element ) {
var attrs = element.attributes,
styles;
// Will be recreated later if any of styles/classes exists.
delete attrs.style;
delete attrs[ 'class' ];
if ( ( styles = CKEDITOR.tools.writeCssText( element.styles, true ) ) )
attrs.style = styles;
if ( element.classes.... | [
"function",
"updateAttributes",
"(",
"element",
")",
"{",
"var",
"attrs",
"=",
"element",
".",
"attributes",
",",
"styles",
";",
"// Will be recreated later if any of styles/classes exists.",
"delete",
"attrs",
".",
"style",
";",
"delete",
"attrs",
"[",
"'class'",
"... | Copy element's styles and classes back to attributes array. | [
"Copy",
"element",
"s",
"styles",
"and",
"classes",
"back",
"to",
"attributes",
"array",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1590-L1603 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | updateElement | function updateElement( element, status ) {
var validAttrs = status.validAttributes,
validStyles = status.validStyles,
validClasses = status.validClasses,
attrs = element.attributes,
styles = element.styles,
classes = element.classes,
origClasses = element.classBackup,
origStyles = element.styleB... | javascript | function updateElement( element, status ) {
var validAttrs = status.validAttributes,
validStyles = status.validStyles,
validClasses = status.validClasses,
attrs = element.attributes,
styles = element.styles,
classes = element.classes,
origClasses = element.classBackup,
origStyles = element.styleB... | [
"function",
"updateElement",
"(",
"element",
",",
"status",
")",
"{",
"var",
"validAttrs",
"=",
"status",
".",
"validAttributes",
",",
"validStyles",
"=",
"status",
".",
"validStyles",
",",
"validClasses",
"=",
"status",
".",
"validClasses",
",",
"attrs",
"=",... | Update element object based on status of filtering. @returns Whether element was modified. | [
"Update",
"element",
"object",
"based",
"on",
"status",
"of",
"filtering",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1607-L1686 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | inlineNode | function inlineNode( node ) {
return node.type == CKEDITOR.NODE_TEXT ||
node.type == CKEDITOR.NODE_ELEMENT && DTD.$inline[ node.name ];
} | javascript | function inlineNode( node ) {
return node.type == CKEDITOR.NODE_TEXT ||
node.type == CKEDITOR.NODE_ELEMENT && DTD.$inline[ node.name ];
} | [
"function",
"inlineNode",
"(",
"node",
")",
"{",
"return",
"node",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_TEXT",
"||",
"node",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_ELEMENT",
"&&",
"DTD",
".",
"$inline",
"[",
"node",
".",
"name",
"]",
";",
"}"
] | Whether this is an inline element or text. | [
"Whether",
"this",
"is",
"an",
"inline",
"element",
"or",
"text",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1744-L1747 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | removeElement | function removeElement( element, enterTag, toBeChecked ) {
var name = element.name;
if ( DTD.$empty[ name ] || !element.children.length ) {
// Special case - hr in br mode should be replaced with br, not removed.
if ( name == 'hr' && enterTag == 'br' )
element.replaceWith( createBr() );
else {
// ... | javascript | function removeElement( element, enterTag, toBeChecked ) {
var name = element.name;
if ( DTD.$empty[ name ] || !element.children.length ) {
// Special case - hr in br mode should be replaced with br, not removed.
if ( name == 'hr' && enterTag == 'br' )
element.replaceWith( createBr() );
else {
// ... | [
"function",
"removeElement",
"(",
"element",
",",
"enterTag",
",",
"toBeChecked",
")",
"{",
"var",
"name",
"=",
"element",
".",
"name",
";",
"if",
"(",
"DTD",
".",
"$empty",
"[",
"name",
"]",
"||",
"!",
"element",
".",
"children",
".",
"length",
")",
... | Try to remove element in the best possible way. @param {Array} toBeChecked After executing this function this array will contain elements that should be checked because they were marked as potentially: * in wrong context (e.g. li in body), * empty elements from $removeEmpty, * incorrect img/a/other element validated b... | [
"Try",
"to",
"remove",
"element",
"in",
"the",
"best",
"possible",
"way",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1762-L1795 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | stripBlock | function stripBlock( element, enterTag, toBeChecked ) {
var children = element.children;
// First, check if element's children may be wrapped with <p/div>.
// Ignore that <p/div> may not be allowed in element.parent.
// This will be fixed when removing parent or by toBeChecked rule.
if ( checkChildren( child... | javascript | function stripBlock( element, enterTag, toBeChecked ) {
var children = element.children;
// First, check if element's children may be wrapped with <p/div>.
// Ignore that <p/div> may not be allowed in element.parent.
// This will be fixed when removing parent or by toBeChecked rule.
if ( checkChildren( child... | [
"function",
"stripBlock",
"(",
"element",
",",
"enterTag",
",",
"toBeChecked",
")",
"{",
"var",
"children",
"=",
"element",
".",
"children",
";",
"// First, check if element's children may be wrapped with <p/div>.",
"// Ignore that <p/div> may not be allowed in element.parent.",
... | Strip element block, but leave its content. Works in 'div' and 'p' enter modes. | [
"Strip",
"element",
"block",
"but",
"leave",
"its",
"content",
".",
"Works",
"in",
"div",
"and",
"p",
"enter",
"modes",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1799-L1850 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | getContentFormTransformationGroup | function getContentFormTransformationGroup( form, preferredForm ) {
var element, left;
if ( typeof form == 'string' )
element = form;
else if ( form instanceof CKEDITOR.style )
left = form;
else {
element = form[ 0 ];
left = form[ 1 ];
}
return [ {
element: element,
left: left,
right:... | javascript | function getContentFormTransformationGroup( form, preferredForm ) {
var element, left;
if ( typeof form == 'string' )
element = form;
else if ( form instanceof CKEDITOR.style )
left = form;
else {
element = form[ 0 ];
left = form[ 1 ];
}
return [ {
element: element,
left: left,
right:... | [
"function",
"getContentFormTransformationGroup",
"(",
"form",
",",
"preferredForm",
")",
"{",
"var",
"element",
",",
"left",
";",
"if",
"(",
"typeof",
"form",
"==",
"'string'",
")",
"element",
"=",
"form",
";",
"else",
"if",
"(",
"form",
"instanceof",
"CKEDI... | Return transformation group for content form. One content form makes one transformation rule in one group. | [
"Return",
"transformation",
"group",
"for",
"content",
"form",
".",
"One",
"content",
"form",
"makes",
"one",
"transformation",
"rule",
"in",
"one",
"group",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L1932-L1951 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | function( element ) {
if ( !( 'float' in element.styles ) ) {
var value = element.attributes.align;
if ( value == 'left' || value == 'right' )
element.styles[ 'float' ] = value; // Uh... GCC doesn't like the 'float' prop name.
}
delete element.attributes.align;
} | javascript | function( element ) {
if ( !( 'float' in element.styles ) ) {
var value = element.attributes.align;
if ( value == 'left' || value == 'right' )
element.styles[ 'float' ] = value; // Uh... GCC doesn't like the 'float' prop name.
}
delete element.attributes.align;
} | [
"function",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"(",
"'float'",
"in",
"element",
".",
"styles",
")",
")",
"{",
"var",
"value",
"=",
"element",
".",
"attributes",
".",
"align",
";",
"if",
"(",
"value",
"==",
"'left'",
"||",
"value",
"==",
"'ri... | Converts the `align` attribute to the `float` style if not set. Attribute
is always removed.
@param {CKEDITOR.htmlParser.element} element | [
"Converts",
"the",
"align",
"attribute",
"to",
"the",
"float",
"style",
"if",
"not",
"set",
".",
"Attribute",
"is",
"always",
"removed",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L2099-L2108 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/filter.js | function( el, form ) {
if ( typeof form == 'string' )
el.name = form;
// Form is an instance of CKEDITOR.style.
else {
var def = form.getDefinition(),
defStyles = def.styles,
defAttrs = def.attributes,
attrName, styleName,
existingClassesPattern, defClasses, cl;
el.name = def.e... | javascript | function( el, form ) {
if ( typeof form == 'string' )
el.name = form;
// Form is an instance of CKEDITOR.style.
else {
var def = form.getDefinition(),
defStyles = def.styles,
defAttrs = def.attributes,
attrName, styleName,
existingClassesPattern, defClasses, cl;
el.name = def.e... | [
"function",
"(",
"el",
",",
"form",
")",
"{",
"if",
"(",
"typeof",
"form",
"==",
"'string'",
")",
"el",
".",
"name",
"=",
"form",
";",
"// Form is an instance of CKEDITOR.style.",
"else",
"{",
"var",
"def",
"=",
"form",
".",
"getDefinition",
"(",
")",
",... | Transforms element to given form.
Form may be a:
* {@link CKEDITOR.style},
* string – the new name of an element.
@param {CKEDITOR.htmlParser.element} el
@param {CKEDITOR.style/String} form | [
"Transforms",
"element",
"to",
"given",
"form",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/filter.js#L2148-L2180 | train | |
klugjo/express-route-manager | index.js | RouteManager | function RouteManager(opts) {
var defaultActions = {
// Encapsulation of the next callback in express routes
next: function(req, res, next) {
next();
},
// Render view
render: function (req, res, next, data) {
res.render(data.render.viewPath, data.re... | javascript | function RouteManager(opts) {
var defaultActions = {
// Encapsulation of the next callback in express routes
next: function(req, res, next) {
next();
},
// Render view
render: function (req, res, next, data) {
res.render(data.render.viewPath, data.re... | [
"function",
"RouteManager",
"(",
"opts",
")",
"{",
"var",
"defaultActions",
"=",
"{",
"// Encapsulation of the next callback in express routes",
"next",
":",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"next",
"(",
")",
";",
"}",
",",
"// Render... | Initialize the Route Manager
@param opts - initialization options
@param opts.app - express app
@param opts.authenticated - used to check if the user is authenticated. fn(req, res, next) {..} -> call next if authenticated.
@param opts.checkRole - used to check the role. fn(role) { return fn(req, res, next) {..}} -> cal... | [
"Initialize",
"the",
"Route",
"Manager"
] | f83043bd66bf5108ed0ca696605967d9dd3407f1 | https://github.com/klugjo/express-route-manager/blob/f83043bd66bf5108ed0ca696605967d9dd3407f1/index.js#L13-L66 | train |
egg-/log-notifier | lib/notifier.js | function(message) {
var identifier = _makeIdentifier(message);
if (typeof _filter[identifier] !== 'undefined' && _filter[identifier] < ((+new Date()) + 10 * 60000)) {
console.error('duplicated error', identifier, message);
return _filter[identifier];
}
_filter[identifier] = +new Date();
return false;
... | javascript | function(message) {
var identifier = _makeIdentifier(message);
if (typeof _filter[identifier] !== 'undefined' && _filter[identifier] < ((+new Date()) + 10 * 60000)) {
console.error('duplicated error', identifier, message);
return _filter[identifier];
}
_filter[identifier] = +new Date();
return false;
... | [
"function",
"(",
"message",
")",
"{",
"var",
"identifier",
"=",
"_makeIdentifier",
"(",
"message",
")",
";",
"if",
"(",
"typeof",
"_filter",
"[",
"identifier",
"]",
"!==",
"'undefined'",
"&&",
"_filter",
"[",
"identifier",
"]",
"<",
"(",
"(",
"+",
"new",... | check whether duplicated message.
@param {object} message
@return {boolean | integer} whether duplicated | [
"check",
"whether",
"duplicated",
"message",
"."
] | ada3b90f8893140a5ed5757eb14d777b700fadb7 | https://github.com/egg-/log-notifier/blob/ada3b90f8893140a5ed5757eb14d777b700fadb7/lib/notifier.js#L149-L158 | train | |
nodesource/ah-fs | ah-fs.js | findWriteStream | function findWriteStream(arg, copy) {
if (copy.proto !== 'ReadableState') return null
if (copy.pipes != null && copy.pipes.proto !== 'WriteStream') return null
return arg.pipes
} | javascript | function findWriteStream(arg, copy) {
if (copy.proto !== 'ReadableState') return null
if (copy.pipes != null && copy.pipes.proto !== 'WriteStream') return null
return arg.pipes
} | [
"function",
"findWriteStream",
"(",
"arg",
",",
"copy",
")",
"{",
"if",
"(",
"copy",
".",
"proto",
"!==",
"'ReadableState'",
")",
"return",
"null",
"if",
"(",
"copy",
".",
"pipes",
"!=",
"null",
"&&",
"copy",
".",
"pipes",
".",
"proto",
"!==",
"'WriteS... | The WriteStream is attached to the pipes of a ReadableState
of the ReadStream that is piped into it.
If one is found, it is returned so it can be added to the copied args.
@name findWriteStream
@function
@private
@param {Object} arg the original arg found on the resource
@param {Object} copy the clone of the arg | [
"The",
"WriteStream",
"is",
"attached",
"to",
"the",
"pipes",
"of",
"a",
"ReadableState",
"of",
"the",
"ReadStream",
"that",
"is",
"piped",
"into",
"it",
"."
] | 5b52cb492a9e07c6beae60d42af548dca0a3ad8e | https://github.com/nodesource/ah-fs/blob/5b52cb492a9e07c6beae60d42af548dca0a3ad8e/ah-fs.js#L37-L41 | train |
bredele/mouth | index.js | parse | function parse(str, arr) {
return str.replace(/\.\w+|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g, function(expr) {
if(forbidden.indexOf(expr[0]) > -1) return expr;
if(!~arr.indexOf(expr)) arr.push(expr);
return 'model.' + expr;
});
} | javascript | function parse(str, arr) {
return str.replace(/\.\w+|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g, function(expr) {
if(forbidden.indexOf(expr[0]) > -1) return expr;
if(!~arr.indexOf(expr)) arr.push(expr);
return 'model.' + expr;
});
} | [
"function",
"parse",
"(",
"str",
",",
"arr",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"/",
"\\.\\w+|\"[^\"]*\"|'[^']*'|\\/([^/]+)\\/|[a-zA-Z_]\\w*",
"/",
"g",
",",
"function",
"(",
"expr",
")",
"{",
"if",
"(",
"forbidden",
".",
"indexOf",
"(",
"expr",... | Parse expression and replace
identifier.
Examples:
compile('name + last');
// => model.name + model.last
compile('name[0]');
// => model.name[0]
@param {String} str
@param {Array} arr
@return {String}
@api private | [
"Parse",
"expression",
"and",
"replace",
"identifier",
"."
] | 9d5846e50c64155e28670a076c7cb6a8d3c7c087 | https://github.com/bredele/mouth/blob/9d5846e50c64155e28670a076c7cb6a8d3c7c087/index.js#L57-L63 | train |
darrencruse/sugarlisp-core | gentab-native.js | handleYield | function handleYield(forms) {
var yieldType = sl.valueOf(forms[0]); // "yield" or "yield*"
if (forms.length != 2) {
forms.error(yieldType + " expects a single expression");
}
this.indent += this.indentSize;
this.transpileSubExpressions(forms);
var generated = sl.generated();
generated... | javascript | function handleYield(forms) {
var yieldType = sl.valueOf(forms[0]); // "yield" or "yield*"
if (forms.length != 2) {
forms.error(yieldType + " expects a single expression");
}
this.indent += this.indentSize;
this.transpileSubExpressions(forms);
var generated = sl.generated();
generated... | [
"function",
"handleYield",
"(",
"forms",
")",
"{",
"var",
"yieldType",
"=",
"sl",
".",
"valueOf",
"(",
"forms",
"[",
"0",
"]",
")",
";",
"// \"yield\" or \"yield*\"",
"if",
"(",
"forms",
".",
"length",
"!=",
"2",
")",
"{",
"forms",
".",
"error",
"(",
... | es6 yield expressions | [
"es6",
"yield",
"expressions"
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/gentab-native.js#L144-L156 | train |
darrencruse/sugarlisp-core | gentab-native.js | function(forms) {
if (forms.length < 2) {
forms.error("missing argument for operator");
}
if(forms.length > 2) {
// it's a normal binary (or more) minus
return handleArithOperator.call(this, forms);
}
// it's a unary minus
this.transpileSubExpressions(forms)
var generated... | javascript | function(forms) {
if (forms.length < 2) {
forms.error("missing argument for operator");
}
if(forms.length > 2) {
// it's a normal binary (or more) minus
return handleArithOperator.call(this, forms);
}
// it's a unary minus
this.transpileSubExpressions(forms)
var generated... | [
"function",
"(",
"forms",
")",
"{",
"if",
"(",
"forms",
".",
"length",
"<",
"2",
")",
"{",
"forms",
".",
"error",
"(",
"\"missing argument for operator\"",
")",
";",
"}",
"if",
"(",
"forms",
".",
"length",
">",
"2",
")",
"{",
"// it's a normal binary (or... | Minus is unique in that it can be a unary minus | [
"Minus",
"is",
"unique",
"in",
"that",
"it",
"can",
"be",
"a",
"unary",
"minus"
] | c6ff983ebc3d60268054d6fe046db4aff6c5f78c | https://github.com/darrencruse/sugarlisp-core/blob/c6ff983ebc3d60268054d6fe046db4aff6c5f78c/gentab-native.js#L795-L810 | train | |
forfuturellc/svc-fbr | src/lib/cli.js | startService | function startService() {
let me = this;
return server.start(me, function(err) {
if (err) {
return out.error("service failed to start: %j", err);
}
return server.ping(me, function() {
out.success("service started");
});
});
} | javascript | function startService() {
let me = this;
return server.start(me, function(err) {
if (err) {
return out.error("service failed to start: %j", err);
}
return server.ping(me, function() {
out.success("service started");
});
});
} | [
"function",
"startService",
"(",
")",
"{",
"let",
"me",
"=",
"this",
";",
"return",
"server",
".",
"start",
"(",
"me",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"out",
".",
"error",
"(",
"\"service failed to start: %j... | Start the service | [
"Start",
"the",
"service"
] | 8c07c71d6423d1dbd4f903a032dea0bfec63894e | https://github.com/forfuturellc/svc-fbr/blob/8c07c71d6423d1dbd4f903a032dea0bfec63894e/src/lib/cli.js#L35-L45 | train |
forfuturellc/svc-fbr | src/lib/cli.js | stopService | function stopService() {
return server.stop(this, function(err) {
if (err) {
return out.error("service did not respond well: %j", err);
}
return out.success("service stopped");
});
} | javascript | function stopService() {
return server.stop(this, function(err) {
if (err) {
return out.error("service did not respond well: %j", err);
}
return out.success("service stopped");
});
} | [
"function",
"stopService",
"(",
")",
"{",
"return",
"server",
".",
"stop",
"(",
"this",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"out",
".",
"error",
"(",
"\"service did not respond well: %j\"",
",",
"err",
")",
";",
... | Stop the service | [
"Stop",
"the",
"service"
] | 8c07c71d6423d1dbd4f903a032dea0bfec63894e | https://github.com/forfuturellc/svc-fbr/blob/8c07c71d6423d1dbd4f903a032dea0bfec63894e/src/lib/cli.js#L51-L58 | train |
forfuturellc/svc-fbr | src/lib/cli.js | checkStatus | function checkStatus() {
return server.ping(this, function(err, res) {
if (err) {
return out.error("error occurred: %j", err);
}
if (res.running) {
return out.success("service running");
}
return out.error("service not running");
});
} | javascript | function checkStatus() {
return server.ping(this, function(err, res) {
if (err) {
return out.error("error occurred: %j", err);
}
if (res.running) {
return out.success("service running");
}
return out.error("service not running");
});
} | [
"function",
"checkStatus",
"(",
")",
"{",
"return",
"server",
".",
"ping",
"(",
"this",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"out",
".",
"error",
"(",
"\"error occurred: %j\"",
",",
"err",
")",
";",... | Check status of the service | [
"Check",
"status",
"of",
"the",
"service"
] | 8c07c71d6423d1dbd4f903a032dea0bfec63894e | https://github.com/forfuturellc/svc-fbr/blob/8c07c71d6423d1dbd4f903a032dea0bfec63894e/src/lib/cli.js#L64-L74 | train |
75lb/common-dir | index.js | commonDir | function commonDir (files) {
return files
.map(path.dirname)
.map(function (dir) {
return dir.split(path.sep)
})
.reduce(commonSequence)
.concat([''])
.join(path.sep)
} | javascript | function commonDir (files) {
return files
.map(path.dirname)
.map(function (dir) {
return dir.split(path.sep)
})
.reduce(commonSequence)
.concat([''])
.join(path.sep)
} | [
"function",
"commonDir",
"(",
"files",
")",
"{",
"return",
"files",
".",
"map",
"(",
"path",
".",
"dirname",
")",
".",
"map",
"(",
"function",
"(",
"dir",
")",
"{",
"return",
"dir",
".",
"split",
"(",
"path",
".",
"sep",
")",
"}",
")",
".",
"redu... | Returns the parent directory common to each path.
@param {Array} files - An array of file paths to inspect
@returns {string} A single path ending with the path separator, e.g. '/user/some/folder/'
@alias module:common-dir
@example
> const commonDir = require('common-dir')
> files = [
'/Users/75lb/one/package.json',
'/U... | [
"Returns",
"the",
"parent",
"directory",
"common",
"to",
"each",
"path",
"."
] | 501382e13ae44a97eefa11a09b747cd740445d9f | https://github.com/75lb/common-dir/blob/501382e13ae44a97eefa11a09b747cd740445d9f/index.js#L25-L34 | train |
ItsAsbreuk/itsa-jsext | lib/object.js | function (fn, context) {
var obj = this,
keys = Object.keys(obj),
l = keys.length,
i = -1,
key;
while (++i < l) {
key = keys[i];
fn.call(context || obj, obj[key], key, obj);
}
return obj;
} | javascript | function (fn, context) {
var obj = this,
keys = Object.keys(obj),
l = keys.length,
i = -1,
key;
while (++i < l) {
key = keys[i];
fn.call(context || obj, obj[key], key, obj);
}
return obj;
} | [
"function",
"(",
"fn",
",",
"context",
")",
"{",
"var",
"obj",
"=",
"this",
",",
"keys",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
",",
"l",
"=",
"keys",
".",
"length",
",",
"i",
"=",
"-",
"1",
",",
"key",
";",
"while",
"(",
"++",
"i",
"... | Loops through all properties in the object. Equivalent to Array.forEach.
The callback is provided with the value of the property, the name of the property
and a reference to the whole object itself.
The context to run the callback in can be overriden, otherwise it is undefined.
@method itsa_each
@param fn {Function} ... | [
"Loops",
"through",
"all",
"properties",
"in",
"the",
"object",
".",
"Equivalent",
"to",
"Array",
".",
"forEach",
".",
"The",
"callback",
"is",
"provided",
"with",
"the",
"value",
"of",
"the",
"property",
"the",
"name",
"of",
"the",
"property",
"and",
"a",... | 792987963309c3d081b2495c15f68f23dcf617ab | https://github.com/ItsAsbreuk/itsa-jsext/blob/792987963309c3d081b2495c15f68f23dcf617ab/lib/object.js#L166-L177 | train | |
ItsAsbreuk/itsa-jsext | lib/object.js | function (descriptors) {
var instance = this,
m = Object.create(Object.getPrototypeOf(instance)),
keys = Object.getOwnPropertyNames(instance),
l = keys.length,
i = -1,
key, propDescriptor;
while (++i < l) {
key = keys[i];
... | javascript | function (descriptors) {
var instance = this,
m = Object.create(Object.getPrototypeOf(instance)),
keys = Object.getOwnPropertyNames(instance),
l = keys.length,
i = -1,
key, propDescriptor;
while (++i < l) {
key = keys[i];
... | [
"function",
"(",
"descriptors",
")",
"{",
"var",
"instance",
"=",
"this",
",",
"m",
"=",
"Object",
".",
"create",
"(",
"Object",
".",
"getPrototypeOf",
"(",
"instance",
")",
")",
",",
"keys",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"instance",
")... | Returns a shallow copy of the object.
It does not clone objects within the object, it does a simple, shallow clone.
Fast, mostly useful for plain hash maps.
@method itsa_shallowClone
@param [options.descriptors=false] {Boolean} If true, the full descriptors will be set. This takes more time, but avoids any info to be ... | [
"Returns",
"a",
"shallow",
"copy",
"of",
"the",
"object",
".",
"It",
"does",
"not",
"clone",
"objects",
"within",
"the",
"object",
"it",
"does",
"a",
"simple",
"shallow",
"clone",
".",
"Fast",
"mostly",
"useful",
"for",
"plain",
"hash",
"maps",
"."
] | 792987963309c3d081b2495c15f68f23dcf617ab | https://github.com/ItsAsbreuk/itsa-jsext/blob/792987963309c3d081b2495c15f68f23dcf617ab/lib/object.js#L314-L337 | train | |
ItsAsbreuk/itsa-jsext | lib/object.js | function(refObj) {
var instance = this,
keys = Object.getOwnPropertyNames(instance),
l = keys.length,
i = -1,
same, key;
same = (l===refObj.itsa_size(true));
// loop through the members:
while (same && (++i < l)) {
key = keys[i]... | javascript | function(refObj) {
var instance = this,
keys = Object.getOwnPropertyNames(instance),
l = keys.length,
i = -1,
same, key;
same = (l===refObj.itsa_size(true));
// loop through the members:
while (same && (++i < l)) {
key = keys[i]... | [
"function",
"(",
"refObj",
")",
"{",
"var",
"instance",
"=",
"this",
",",
"keys",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"instance",
")",
",",
"l",
"=",
"keys",
".",
"length",
",",
"i",
"=",
"-",
"1",
",",
"same",
",",
"key",
";",
"same",
... | Compares this object with the reference-object whether they have the same value.
Not by reference, but their content as simple types.
Compares both JSON.stringify objects
@method itsa_sameValue
@param refObj {Object} the object to compare with
@return {Boolean} whether both objects have the same value | [
"Compares",
"this",
"object",
"with",
"the",
"reference",
"-",
"object",
"whether",
"they",
"have",
"the",
"same",
"value",
".",
"Not",
"by",
"reference",
"but",
"their",
"content",
"as",
"simple",
"types",
"."
] | 792987963309c3d081b2495c15f68f23dcf617ab | https://github.com/ItsAsbreuk/itsa-jsext/blob/792987963309c3d081b2495c15f68f23dcf617ab/lib/object.js#L349-L362 | train | |
ItsAsbreuk/itsa-jsext | lib/object.js | function (obj, options) {
var instance = this,
i = -1,
deepForce, keys, l, key, force, replace, descriptors, propDescriptor;
if (!Object.itsa_isObject(obj)) {
return instance;
}
options || (options={});
keys = options.full ? Object.getOwnProper... | javascript | function (obj, options) {
var instance = this,
i = -1,
deepForce, keys, l, key, force, replace, descriptors, propDescriptor;
if (!Object.itsa_isObject(obj)) {
return instance;
}
options || (options={});
keys = options.full ? Object.getOwnProper... | [
"function",
"(",
"obj",
",",
"options",
")",
"{",
"var",
"instance",
"=",
"this",
",",
"i",
"=",
"-",
"1",
",",
"deepForce",
",",
"keys",
",",
"l",
",",
"key",
",",
"force",
",",
"replace",
",",
"descriptors",
",",
"propDescriptor",
";",
"if",
"(",... | Merges into this object the properties of the given object.
If the second argument is true, the properties on the source object will be overwritten
by those of the second object of the same name, otherwise, they are preserved.
@method itsa_merge
@param obj {Object} Object with the properties to be added to the origina... | [
"Merges",
"into",
"this",
"object",
"the",
"properties",
"of",
"the",
"given",
"object",
".",
"If",
"the",
"second",
"argument",
"is",
"true",
"the",
"properties",
"on",
"the",
"source",
"object",
"will",
"be",
"overwritten",
"by",
"those",
"of",
"the",
"s... | 792987963309c3d081b2495c15f68f23dcf617ab | https://github.com/ItsAsbreuk/itsa-jsext/blob/792987963309c3d081b2495c15f68f23dcf617ab/lib/object.js#L421-L459 | train | |
ItsAsbreuk/itsa-jsext | lib/object.js | function(obj, clone) {
var thisObj = this;
thisObj.itsa_emptyObject();
if (clone) {
deepCloneObj(obj, thisObj, true);
}
else {
thisObj.itsa_merge(obj);
}
return thisObj;
} | javascript | function(obj, clone) {
var thisObj = this;
thisObj.itsa_emptyObject();
if (clone) {
deepCloneObj(obj, thisObj, true);
}
else {
thisObj.itsa_merge(obj);
}
return thisObj;
} | [
"function",
"(",
"obj",
",",
"clone",
")",
"{",
"var",
"thisObj",
"=",
"this",
";",
"thisObj",
".",
"itsa_emptyObject",
"(",
")",
";",
"if",
"(",
"clone",
")",
"{",
"deepCloneObj",
"(",
"obj",
",",
"thisObj",
",",
"true",
")",
";",
"}",
"else",
"{"... | Sets the properties of `obj` to the instance. This will redefine the object, while remaining the instance.
This way, external references to the object-instance remain valid.
@method itsa_defineData
@param obj {Object} the Object that holds the new properties.
@param [clone=false] {Boolean} whether the properties shoul... | [
"Sets",
"the",
"properties",
"of",
"obj",
"to",
"the",
"instance",
".",
"This",
"will",
"redefine",
"the",
"object",
"while",
"remaining",
"the",
"instance",
".",
"This",
"way",
"external",
"references",
"to",
"the",
"object",
"-",
"instance",
"remain",
"val... | 792987963309c3d081b2495c15f68f23dcf617ab | https://github.com/ItsAsbreuk/itsa-jsext/blob/792987963309c3d081b2495c15f68f23dcf617ab/lib/object.js#L470-L480 | train | |
mikehedman/ampersand-hoodie-mixin | ampersand-hoodie-mixin.js | function (method, model, options) {
options = options ? _.clone(options) : {};
var jsonPayload;
var promise;
// Ensure that we have a hoodie object type.
if (!model.HOODIE_TYPE) {
throw new Error('A HOODIE_TYPE property must be specified');
}
// Ensu... | javascript | function (method, model, options) {
options = options ? _.clone(options) : {};
var jsonPayload;
var promise;
// Ensure that we have a hoodie object type.
if (!model.HOODIE_TYPE) {
throw new Error('A HOODIE_TYPE property must be specified');
}
// Ensu... | [
"function",
"(",
"method",
",",
"model",
",",
"options",
")",
"{",
"options",
"=",
"options",
"?",
"_",
".",
"clone",
"(",
"options",
")",
":",
"{",
"}",
";",
"var",
"jsonPayload",
";",
"var",
"promise",
";",
"// Ensure that we have a hoodie object type.",
... | This sync function is a modified version of the code in ampersand-sync | [
"This",
"sync",
"function",
"is",
"a",
"modified",
"version",
"of",
"the",
"code",
"in",
"ampersand",
"-",
"sync"
] | 0f66961cfed776b2a20182bdef481efb49da7592 | https://github.com/mikehedman/ampersand-hoodie-mixin/blob/0f66961cfed776b2a20182bdef481efb49da7592/ampersand-hoodie-mixin.js#L11-L69 | train | |
fritbot/fb-opt-facts | import_facts.js | processLine | function processLine (line, callback) {
var trigger = line[0];
// Required to drop the args to callback so async doesn't think we're throwing an error.
function cb () {
callback();
}
if (trigger === 'alias') {
bot.db.schemas.factTrigger.saveAlias(line[1], line[2]).then(cb);
} else {
bot.db.schemas.factTri... | javascript | function processLine (line, callback) {
var trigger = line[0];
// Required to drop the args to callback so async doesn't think we're throwing an error.
function cb () {
callback();
}
if (trigger === 'alias') {
bot.db.schemas.factTrigger.saveAlias(line[1], line[2]).then(cb);
} else {
bot.db.schemas.factTri... | [
"function",
"processLine",
"(",
"line",
",",
"callback",
")",
"{",
"var",
"trigger",
"=",
"line",
"[",
"0",
"]",
";",
"// Required to drop the args to callback so async doesn't think we're throwing an error.",
"function",
"cb",
"(",
")",
"{",
"callback",
"(",
")",
"... | Function to process a single line. Since we need these to happen strictly in sequence, so we can get aliases matched, we need to mix Q and async. | [
"Function",
"to",
"process",
"a",
"single",
"line",
".",
"Since",
"we",
"need",
"these",
"to",
"happen",
"strictly",
"in",
"sequence",
"so",
"we",
"can",
"get",
"aliases",
"matched",
"we",
"need",
"to",
"mix",
"Q",
"and",
"async",
"."
] | 3ce703c931aca344932564dd52e780fb5a259ca1 | https://github.com/fritbot/fb-opt-facts/blob/3ce703c931aca344932564dd52e780fb5a259ca1/import_facts.js#L31-L44 | train |
isuttell/two-factor | lib/generate.js | randomString | function randomString(options) {
var set = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
if (options.symbols === true) {
set += '!@#$%^&*()<>?/[]{},.:;';
}
var key = '';
for (var i = 0; i < options.length; i++) {
key += set.charAt(Math.floor(Math.random() * set.length));
}
re... | javascript | function randomString(options) {
var set = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
if (options.symbols === true) {
set += '!@#$%^&*()<>?/[]{},.:;';
}
var key = '';
for (var i = 0; i < options.length; i++) {
key += set.charAt(Math.floor(Math.random() * set.length));
}
re... | [
"function",
"randomString",
"(",
"options",
")",
"{",
"var",
"set",
"=",
"'0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'",
";",
"if",
"(",
"options",
".",
"symbols",
"===",
"true",
")",
"{",
"set",
"+=",
"'!@#$%^&*()<>?/[]{},.:;'",
";",
"}",
"var",
... | Creates a random string
@param {Object} options
@return {String} | [
"Creates",
"a",
"random",
"string"
] | 7572daa479774af1514b24d8e23738d8a8f55352 | https://github.com/isuttell/two-factor/blob/7572daa479774af1514b24d8e23738d8a8f55352/lib/generate.js#L19-L32 | train |
isuttell/two-factor | lib/generate.js | otpauth | function otpauth(key, name) {
var code = 'otpauth://totp/' + encodeURIComponent(name);
code += '?secret=' + encodeURIComponent(key);
code += '&issuer=' + encodeURIComponent('One Sony');
return code;
} | javascript | function otpauth(key, name) {
var code = 'otpauth://totp/' + encodeURIComponent(name);
code += '?secret=' + encodeURIComponent(key);
code += '&issuer=' + encodeURIComponent('One Sony');
return code;
} | [
"function",
"otpauth",
"(",
"key",
",",
"name",
")",
"{",
"var",
"code",
"=",
"'otpauth://totp/'",
"+",
"encodeURIComponent",
"(",
"name",
")",
";",
"code",
"+=",
"'?secret='",
"+",
"encodeURIComponent",
"(",
"key",
")",
";",
"code",
"+=",
"'&issuer='",
"+... | Generate link to encode in qrcode
@param {String} key
@param {String} name
@return {String} | [
"Generate",
"link",
"to",
"encode",
"in",
"qrcode"
] | 7572daa479774af1514b24d8e23738d8a8f55352 | https://github.com/isuttell/two-factor/blob/7572daa479774af1514b24d8e23738d8a8f55352/lib/generate.js#L41-L46 | train |
isuttell/two-factor | lib/generate.js | link | function link(key, options) {
if (options.google && options.name) {
return 'https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=' + otpauth(key, options.name);
} else {
return 'https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=' + encodeURIComponent(key);
}
} | javascript | function link(key, options) {
if (options.google && options.name) {
return 'https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=' + otpauth(key, options.name);
} else {
return 'https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=' + encodeURIComponent(key);
}
} | [
"function",
"link",
"(",
"key",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"google",
"&&",
"options",
".",
"name",
")",
"{",
"return",
"'https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl='",
"+",
"otpauth",
"(",
"key",
",",
"options",
... | Create a Google charts link to a QR Code with the key embeded in it
@param {String} key
@param {Object} options
@return {String} | [
"Create",
"a",
"Google",
"charts",
"link",
"to",
"a",
"QR",
"Code",
"with",
"the",
"key",
"embeded",
"in",
"it"
] | 7572daa479774af1514b24d8e23738d8a8f55352 | https://github.com/isuttell/two-factor/blob/7572daa479774af1514b24d8e23738d8a8f55352/lib/generate.js#L55-L61 | train |
isuttell/two-factor | lib/generate.js | qrcode | function qrcode(key, name, options) {
// Options
options = _.extend({
type: 'svg',
sync: false
}, options || {});
var link = otpauth(key, name);
if (options.sync) {
return qr.imageSync(link, {
type: options.type,
margin: 0
});
} else {
return qr.image(link, {
type: op... | javascript | function qrcode(key, name, options) {
// Options
options = _.extend({
type: 'svg',
sync: false
}, options || {});
var link = otpauth(key, name);
if (options.sync) {
return qr.imageSync(link, {
type: options.type,
margin: 0
});
} else {
return qr.image(link, {
type: op... | [
"function",
"qrcode",
"(",
"key",
",",
"name",
",",
"options",
")",
"{",
"// Options",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"type",
":",
"'svg'",
",",
"sync",
":",
"false",
"}",
",",
"options",
"||",
"{",
"}",
")",
";",
"var",
"link",
"=... | Creates a QR Code
@param {String} key
@param {Name} name
@param {Object} options
@return {Stream} | [
"Creates",
"a",
"QR",
"Code"
] | 7572daa479774af1514b24d8e23738d8a8f55352 | https://github.com/isuttell/two-factor/blob/7572daa479774af1514b24d8e23738d8a8f55352/lib/generate.js#L71-L91 | train |
isuttell/two-factor | lib/generate.js | generateKey | function generateKey(options) {
// Options
options = _.extend({
length: 32,
name: '',
symbols: false,
google: false,
qrCode: false,
type: 'base32'
}, options || {});
// Generate the random string
var key = randomString(options);
if (options.type === 'ascii') {
return key;
} e... | javascript | function generateKey(options) {
// Options
options = _.extend({
length: 32,
name: '',
symbols: false,
google: false,
qrCode: false,
type: 'base32'
}, options || {});
// Generate the random string
var key = randomString(options);
if (options.type === 'ascii') {
return key;
} e... | [
"function",
"generateKey",
"(",
"options",
")",
"{",
"// Options",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"length",
":",
"32",
",",
"name",
":",
"''",
",",
"symbols",
":",
"false",
",",
"google",
":",
"false",
",",
"qrCode",
":",
"false",
",",... | Generates a random base32 secret key and optionally a qrcode
@param {Object} options
@return {Object} | [
"Generates",
"a",
"random",
"base32",
"secret",
"key",
"and",
"optionally",
"a",
"qrcode"
] | 7572daa479774af1514b24d8e23738d8a8f55352 | https://github.com/isuttell/two-factor/blob/7572daa479774af1514b24d8e23738d8a8f55352/lib/generate.js#L99-L124 | train |
mrfishie/starmap | lib/Model.js | Model | function Model(io, name, itemDef, modelDef, filter) {
EventEmitter.call(this);
//name = name.toLowerCase();
this.io = io;
this.name = name;
this.url = utils.resolveName(name);
this.itemDef = itemDef || {};
this.modelDef = modelDef || {};
this.filter = filter || {};
this.children = ... | javascript | function Model(io, name, itemDef, modelDef, filter) {
EventEmitter.call(this);
//name = name.toLowerCase();
this.io = io;
this.name = name;
this.url = utils.resolveName(name);
this.itemDef = itemDef || {};
this.modelDef = modelDef || {};
this.filter = filter || {};
this.children = ... | [
"function",
"Model",
"(",
"io",
",",
"name",
",",
"itemDef",
",",
"modelDef",
",",
"filter",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"//name = name.toLowerCase();",
"this",
".",
"io",
"=",
"io",
";",
"this",
".",
"name",
"=",
"nam... | An actual model that syncs with the server
This object contains the internal model representation, and updates any
objects bound to it.
@param {object} io the socket.io object
@param {string} name
@param itemDef {object?}
@param modelDef {object?}
@param filter {object?}
@constructor | [
"An",
"actual",
"model",
"that",
"syncs",
"with",
"the",
"server"
] | 0d2637e7863d65c165abf63766605e6a643d2580 | https://github.com/mrfishie/starmap/blob/0d2637e7863d65c165abf63766605e6a643d2580/lib/Model.js#L23-L54 | train |
mongodb-js/mj | commands/create.js | function(callback) {
if (Object.keys(templateDependencies).indexOf(args['<template>']) === -1) {
return callback(new Error(format('Unknown template "%s". Run '
+ '`mj help create` for list of valid templates.', args['<template>'])));
}
return callback(null);
} | javascript | function(callback) {
if (Object.keys(templateDependencies).indexOf(args['<template>']) === -1) {
return callback(new Error(format('Unknown template "%s". Run '
+ '`mj help create` for list of valid templates.', args['<template>'])));
}
return callback(null);
} | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"Object",
".",
"keys",
"(",
"templateDependencies",
")",
".",
"indexOf",
"(",
"args",
"[",
"'<template>'",
"]",
")",
"===",
"-",
"1",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"format",
... | make sure the template exists. | [
"make",
"sure",
"the",
"template",
"exists",
"."
] | a643970372c74baf8cfc7087cda80d3f6001fe7b | https://github.com/mongodb-js/mj/blob/a643970372c74baf8cfc7087cda80d3f6001fe7b/commands/create.js#L28-L34 | train | |
mongodb-js/mj | commands/create.js | function(callback) {
fs.readdir(args['<directory>'], function(err, files) {
// error here means it does not exist, which is good.
if (err || args['--force']) {
return callback(null, args['<directory>']);
}
if (files.length > 0) {
return callback(new Error(format... | javascript | function(callback) {
fs.readdir(args['<directory>'], function(err, files) {
// error here means it does not exist, which is good.
if (err || args['--force']) {
return callback(null, args['<directory>']);
}
if (files.length > 0) {
return callback(new Error(format... | [
"function",
"(",
"callback",
")",
"{",
"fs",
".",
"readdir",
"(",
"args",
"[",
"'<directory>'",
"]",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"// error here means it does not exist, which is good.",
"if",
"(",
"err",
"||",
"args",
"[",
"'--force'",... | before copying, make sure the target directory is empty or does not exist. | [
"before",
"copying",
"make",
"sure",
"the",
"target",
"directory",
"is",
"empty",
"or",
"does",
"not",
"exist",
"."
] | a643970372c74baf8cfc7087cda80d3f6001fe7b | https://github.com/mongodb-js/mj/blob/a643970372c74baf8cfc7087cda80d3f6001fe7b/commands/create.js#L36-L48 | train | |
mongodb-js/mj | commands/create.js | function(template, parent) {
var templateLocation;
if (templateNameToRepo[template].startsWith('file://')) {
templateLocation = templateNameToRepo[template].slice(7);
} else {
templateLocation = path.join(path.homedir(), '.khaos', 'templates', template);
}
return function(callback, resul... | javascript | function(template, parent) {
var templateLocation;
if (templateNameToRepo[template].startsWith('file://')) {
templateLocation = templateNameToRepo[template].slice(7);
} else {
templateLocation = path.join(path.homedir(), '.khaos', 'templates', template);
}
return function(callback, resul... | [
"function",
"(",
"template",
",",
"parent",
")",
"{",
"var",
"templateLocation",
";",
"if",
"(",
"templateNameToRepo",
"[",
"template",
"]",
".",
"startsWith",
"(",
"'file://'",
")",
")",
"{",
"templateLocation",
"=",
"templateNameToRepo",
"[",
"template",
"]"... | add khaos tasks for each template in the dependency tree | [
"add",
"khaos",
"tasks",
"for",
"each",
"template",
"in",
"the",
"dependency",
"tree"
] | a643970372c74baf8cfc7087cda80d3f6001fe7b | https://github.com/mongodb-js/mj/blob/a643970372c74baf8cfc7087cda80d3f6001fe7b/commands/create.js#L92-L132 | train | |
bredele/lineup-stream | index.js | insert | function insert(arr, index, values) {
[].splice.apply(arr, [index, 0].concat(values));
} | javascript | function insert(arr, index, values) {
[].splice.apply(arr, [index, 0].concat(values));
} | [
"function",
"insert",
"(",
"arr",
",",
"index",
",",
"values",
")",
"{",
"[",
"]",
".",
"splice",
".",
"apply",
"(",
"arr",
",",
"[",
"index",
",",
"0",
"]",
".",
"concat",
"(",
"values",
")",
")",
";",
"}"
] | Insert array into an other array.
@param {Array}
@param {Number} index
@param {Any} values
@api private | [
"Insert",
"array",
"into",
"an",
"other",
"array",
"."
] | 006ee9b5a5461edc18da6f4e974376d1f9059ce1 | https://github.com/bredele/lineup-stream/blob/006ee9b5a5461edc18da6f4e974376d1f9059ce1/index.js#L58-L60 | train |
RnbWd/parse-browserify | lib/query.js | function(objectId, options) {
var self = this;
self.equalTo('objectId', objectId);
var firstOptions = {};
if (options && _.has(options, 'useMasterKey')) {
firstOptions = { useMasterKey: options.useMasterKey };
}
return self.first(firstOptions).then(function(response) {
... | javascript | function(objectId, options) {
var self = this;
self.equalTo('objectId', objectId);
var firstOptions = {};
if (options && _.has(options, 'useMasterKey')) {
firstOptions = { useMasterKey: options.useMasterKey };
}
return self.first(firstOptions).then(function(response) {
... | [
"function",
"(",
"objectId",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"equalTo",
"(",
"'objectId'",
",",
"objectId",
")",
";",
"var",
"firstOptions",
"=",
"{",
"}",
";",
"if",
"(",
"options",
"&&",
"_",
".",
"has",
"(... | Constructs a Parse.Object whose id is already known by fetching data from
the server. Either options.success or options.error is called when the
find completes.
@param {String} objectId The id of the object to be fetched.
@param {Object} options A Backbone-style options object.
Valid options are:<ul>
<li>success: A B... | [
"Constructs",
"a",
"Parse",
".",
"Object",
"whose",
"id",
"is",
"already",
"known",
"by",
"fetching",
"data",
"from",
"the",
"server",
".",
"Either",
"options",
".",
"success",
"or",
"options",
".",
"error",
"is",
"called",
"when",
"the",
"find",
"complete... | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/query.js#L120-L139 | train | |
RnbWd/parse-browserify | lib/query.js | function(options) {
var self = this;
options = options || {};
var request = Parse._request({
route: "classes",
className: this.className,
method: "GET",
useMasterKey: options.useMasterKey,
data: this.toJSON()
});
return request.then(function(respon... | javascript | function(options) {
var self = this;
options = options || {};
var request = Parse._request({
route: "classes",
className: this.className,
method: "GET",
useMasterKey: options.useMasterKey,
data: this.toJSON()
});
return request.then(function(respon... | [
"function",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"request",
"=",
"Parse",
".",
"_request",
"(",
"{",
"route",
":",
"\"classes\"",
",",
"className",
":",
"this",
".",
"classN... | Retrieves a list of ParseObjects that satisfy this query.
Either options.success or options.error is called when the find
completes.
@param {Object} options A Backbone-style options object. Valid options
are:<ul>
<li>success: Function to call when the find completes successfully.
<li>error: Function to call when the f... | [
"Retrieves",
"a",
"list",
"of",
"ParseObjects",
"that",
"satisfy",
"this",
"query",
".",
"Either",
"options",
".",
"success",
"or",
"options",
".",
"error",
"is",
"called",
"when",
"the",
"find",
"completes",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/query.js#L189-L213 | train | |
RnbWd/parse-browserify | lib/query.js | function(options) {
var self = this;
options = options || {};
var params = this.toJSON();
params.limit = 0;
params.count = 1;
var request = Parse._request({
route: "classes",
className: self.className,
method: "GET",
useMasterKey: options.useMasterKe... | javascript | function(options) {
var self = this;
options = options || {};
var params = this.toJSON();
params.limit = 0;
params.count = 1;
var request = Parse._request({
route: "classes",
className: self.className,
method: "GET",
useMasterKey: options.useMasterKe... | [
"function",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"params",
"=",
"this",
".",
"toJSON",
"(",
")",
";",
"params",
".",
"limit",
"=",
"0",
";",
"params",
".",
"count",
"=",... | Counts the number of objects that match this query.
Either options.success or options.error is called when the count
completes.
@param {Object} options A Backbone-style options object. Valid options
are:<ul>
<li>success: Function to call when the count completes successfully.
<li>error: Function to call when the find ... | [
"Counts",
"the",
"number",
"of",
"objects",
"that",
"match",
"this",
"query",
".",
"Either",
"options",
".",
"success",
"or",
"options",
".",
"error",
"is",
"called",
"when",
"the",
"count",
"completes",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/query.js#L231-L249 | train | |
RnbWd/parse-browserify | lib/query.js | function(items, options) {
options = options || {};
return new Parse.Collection(items, _.extend(options, {
model: this.objectClass,
query: this
}));
} | javascript | function(items, options) {
options = options || {};
return new Parse.Collection(items, _.extend(options, {
model: this.objectClass,
query: this
}));
} | [
"function",
"(",
"items",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"return",
"new",
"Parse",
".",
"Collection",
"(",
"items",
",",
"_",
".",
"extend",
"(",
"options",
",",
"{",
"model",
":",
"this",
".",
"objectClass"... | Returns a new instance of Parse.Collection backed by this query.
@param {Array} items An array of instances of <code>Parse.Object</code>
with which to start this Collection.
@param {Object} options An optional object with Backbone-style options.
Valid options are:<ul>
<li>model: The Parse.Object subclass that this coll... | [
"Returns",
"a",
"new",
"instance",
"of",
"Parse",
".",
"Collection",
"backed",
"by",
"this",
"query",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/query.js#L303-L309 | train | |
RnbWd/parse-browserify | lib/query.js | function(key) {
var self = this;
if (!this._order) {
this._order = [];
}
Parse._arrayEach(arguments, function(key) {
if (Array.isArray(key)) {
key = key.join();
}
self._order = self._order.concat(key.replace(/\s/g, "").split(","));
});
retur... | javascript | function(key) {
var self = this;
if (!this._order) {
this._order = [];
}
Parse._arrayEach(arguments, function(key) {
if (Array.isArray(key)) {
key = key.join();
}
self._order = self._order.concat(key.replace(/\s/g, "").split(","));
});
retur... | [
"function",
"(",
"key",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"this",
".",
"_order",
")",
"{",
"this",
".",
"_order",
"=",
"[",
"]",
";",
"}",
"Parse",
".",
"_arrayEach",
"(",
"arguments",
",",
"function",
"(",
"key",
")",
... | Sorts the results in ascending order by the given key,
but can also add secondary sort descriptors without overwriting _order.
@param {(String|String[]|...String} key The key to order by, which is a
string of comma separated values, or an Array of keys, or multiple keys.
@return {Parse.Query} Returns the query, so you... | [
"Sorts",
"the",
"results",
"in",
"ascending",
"order",
"by",
"the",
"given",
"key",
"but",
"can",
"also",
"add",
"secondary",
"sort",
"descriptors",
"without",
"overwriting",
"_order",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/query.js#L649-L661 | train | |
RnbWd/parse-browserify | lib/query.js | function() {
var self = this;
Parse._arrayEach(arguments, function(key) {
if (_.isArray(key)) {
self._include = self._include.concat(key);
} else {
self._include.push(key);
}
});
return this;
} | javascript | function() {
var self = this;
Parse._arrayEach(arguments, function(key) {
if (_.isArray(key)) {
self._include = self._include.concat(key);
} else {
self._include.push(key);
}
});
return this;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"Parse",
".",
"_arrayEach",
"(",
"arguments",
",",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"_",
".",
"isArray",
"(",
"key",
")",
")",
"{",
"self",
".",
"_include",
"=",
"self",
".",... | Include nested Parse.Objects for the provided key. You can use dot
notation to specify which fields in the included object are also fetch.
@param {String} key The name of the key to include.
@return {Parse.Query} Returns the query, so you can chain this call. | [
"Include",
"nested",
"Parse",
".",
"Objects",
"for",
"the",
"provided",
"key",
".",
"You",
"can",
"use",
"dot",
"notation",
"to",
"specify",
"which",
"fields",
"in",
"the",
"included",
"object",
"are",
"also",
"fetch",
"."
] | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/query.js#L786-L796 | train | |
RnbWd/parse-browserify | lib/query.js | function() {
var self = this;
this._select = this._select || [];
Parse._arrayEach(arguments, function(key) {
if (_.isArray(key)) {
self._select = self._select.concat(key);
} else {
self._select.push(key);
}
});
return this;
} | javascript | function() {
var self = this;
this._select = this._select || [];
Parse._arrayEach(arguments, function(key) {
if (_.isArray(key)) {
self._select = self._select.concat(key);
} else {
self._select.push(key);
}
});
return this;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_select",
"=",
"this",
".",
"_select",
"||",
"[",
"]",
";",
"Parse",
".",
"_arrayEach",
"(",
"arguments",
",",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"_",
".",
"isArr... | Restrict the fields of the returned Parse.Objects to include only the
provided keys. If this is called multiple times, then all of the keys
specified in each of the calls will be included.
@param {Array} keys The names of the keys to include.
@return {Parse.Query} Returns the query, so you can chain this call. | [
"Restrict",
"the",
"fields",
"of",
"the",
"returned",
"Parse",
".",
"Objects",
"to",
"include",
"only",
"the",
"provided",
"keys",
".",
"If",
"this",
"is",
"called",
"multiple",
"times",
"then",
"all",
"of",
"the",
"keys",
"specified",
"in",
"each",
"of",
... | c19c1b798e4010a552e130b1a9ce3b5d084dc101 | https://github.com/RnbWd/parse-browserify/blob/c19c1b798e4010a552e130b1a9ce3b5d084dc101/lib/query.js#L805-L816 | train | |
maidol/cw-logger | logstash/tcp-bunyan.js | LogstashStream | function LogstashStream(options) {
EventEmitter.call(this);
options = options || {};
this.name = 'bunyan';
this.level = options.level || 'info';
this.server = options.server || os.hostname();
this.host = options.host || '127.0.0.1';
this.port = options.port || 9999;
this.application = options.... | javascript | function LogstashStream(options) {
EventEmitter.call(this);
options = options || {};
this.name = 'bunyan';
this.level = options.level || 'info';
this.server = options.server || os.hostname();
this.host = options.host || '127.0.0.1';
this.port = options.port || 9999;
this.application = options.... | [
"function",
"LogstashStream",
"(",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"name",
"=",
"'bunyan'",
";",
"this",
".",
"level",
"=",
"options",
".",
"level",
... | This class implements the bunyan stream contract with a stream that
sends data to logstash.
@param {objects} options The constructions options. See the constructor for details.
TODO: Improve this doc.
@constructor | [
"This",
"class",
"implements",
"the",
"bunyan",
"stream",
"contract",
"with",
"a",
"stream",
"that",
"sends",
"data",
"to",
"logstash",
"."
] | 5bdc950113df6306ebfa7a7916a450915422f0ac | https://github.com/maidol/cw-logger/blob/5bdc950113df6306ebfa7a7916a450915422f0ac/logstash/tcp-bunyan.js#L40-L75 | train |
docvy/plugin-installer | lib/installer.js | npmInstall | function npmInstall(packages, callback) {
callback = utils.defineCallback(callback);
if (_.isString(packages)) {
packages = [ packages ];
}
return npm.load({
loglevel: "silent",
prefix: tmpDir,
}, function(loadErr) {
if (loadErr) {
return callback(new errors.NpmLoadError(loadErr));
}... | javascript | function npmInstall(packages, callback) {
callback = utils.defineCallback(callback);
if (_.isString(packages)) {
packages = [ packages ];
}
return npm.load({
loglevel: "silent",
prefix: tmpDir,
}, function(loadErr) {
if (loadErr) {
return callback(new errors.NpmLoadError(loadErr));
}... | [
"function",
"npmInstall",
"(",
"packages",
",",
"callback",
")",
"{",
"callback",
"=",
"utils",
".",
"defineCallback",
"(",
"callback",
")",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"packages",
")",
")",
"{",
"packages",
"=",
"[",
"packages",
"]",
";... | Install plugins using NPM
@param {String|String[]} packages - name of packages
@param {Function} [callback] | [
"Install",
"plugins",
"using",
"NPM"
] | eb645eb21f350a0fbbf783d83b25ab18feeee684 | https://github.com/docvy/plugin-installer/blob/eb645eb21f350a0fbbf783d83b25ab18feeee684/lib/installer.js#L50-L74 | train |
docvy/plugin-installer | lib/installer.js | dirInstall | function dirInstall(dirpath, callback) {
callback = utils.defineCallback(callback);
return fs.exists(dirpath, function(exists) {
if (!exists) {
return callback(new errors.DirectoryNotExistingError());
}
var pluginName = path.basename(dirpath);
var destPath = path.join(pluginsDir, pluginName);
... | javascript | function dirInstall(dirpath, callback) {
callback = utils.defineCallback(callback);
return fs.exists(dirpath, function(exists) {
if (!exists) {
return callback(new errors.DirectoryNotExistingError());
}
var pluginName = path.basename(dirpath);
var destPath = path.join(pluginsDir, pluginName);
... | [
"function",
"dirInstall",
"(",
"dirpath",
",",
"callback",
")",
"{",
"callback",
"=",
"utils",
".",
"defineCallback",
"(",
"callback",
")",
";",
"return",
"fs",
".",
"exists",
"(",
"dirpath",
",",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"!",
"e... | Install plugins from Directory
@param {String} dirpath - path to directory
@param {Function} [callback] | [
"Install",
"plugins",
"from",
"Directory"
] | eb645eb21f350a0fbbf783d83b25ab18feeee684 | https://github.com/docvy/plugin-installer/blob/eb645eb21f350a0fbbf783d83b25ab18feeee684/lib/installer.js#L83-L98 | train |
docvy/plugin-installer | lib/installer.js | listPlugins | function listPlugins(callback) {
callback = utils.defineCallback(callback);
return fs.readdir(pluginsDir, function(readdirErr, files) {
if (readdirErr) {
return callback(new errors.PluginsListingError(readdirErr));
}
var fullpath, pkg;
var descriptors = [ ];
files.forEach(function (file) {... | javascript | function listPlugins(callback) {
callback = utils.defineCallback(callback);
return fs.readdir(pluginsDir, function(readdirErr, files) {
if (readdirErr) {
return callback(new errors.PluginsListingError(readdirErr));
}
var fullpath, pkg;
var descriptors = [ ];
files.forEach(function (file) {... | [
"function",
"listPlugins",
"(",
"callback",
")",
"{",
"callback",
"=",
"utils",
".",
"defineCallback",
"(",
"callback",
")",
";",
"return",
"fs",
".",
"readdir",
"(",
"pluginsDir",
",",
"function",
"(",
"readdirErr",
",",
"files",
")",
"{",
"if",
"(",
"r... | Listing installed plugins
@param {Function} [callback] - callback(err, descriptors) | [
"Listing",
"installed",
"plugins"
] | eb645eb21f350a0fbbf783d83b25ab18feeee684 | https://github.com/docvy/plugin-installer/blob/eb645eb21f350a0fbbf783d83b25ab18feeee684/lib/installer.js#L106-L135 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/list/plugin.js | inheirtInlineStyles | function inheirtInlineStyles( parent, el ) {
var style = parent.getAttribute( 'style' );
// Put parent styles before child styles.
style && el.setAttribute( 'style', style.replace( /([^;])$/, '$1;' ) + ( el.getAttribute( 'style' ) || '' ) );
} | javascript | function inheirtInlineStyles( parent, el ) {
var style = parent.getAttribute( 'style' );
// Put parent styles before child styles.
style && el.setAttribute( 'style', style.replace( /([^;])$/, '$1;' ) + ( el.getAttribute( 'style' ) || '' ) );
} | [
"function",
"inheirtInlineStyles",
"(",
"parent",
",",
"el",
")",
"{",
"var",
"style",
"=",
"parent",
".",
"getAttribute",
"(",
"'style'",
")",
";",
"// Put parent styles before child styles.\r",
"style",
"&&",
"el",
".",
"setAttribute",
"(",
"'style'",
",",
"st... | Inheirt inline styles from another element. | [
"Inheirt",
"inline",
"styles",
"from",
"another",
"element",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/list/plugin.js#L34-L39 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/list/plugin.js | mergeListSiblings | function mergeListSiblings( listNode )
{
var mergeSibling;
( mergeSibling = function( rtl )
{
var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty );
if ( sibling &&
sibling.type == CKEDITOR.NODE_ELEMENT &&
sibling.is( listNode.getName() ) )
{
// Move childre... | javascript | function mergeListSiblings( listNode )
{
var mergeSibling;
( mergeSibling = function( rtl )
{
var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty );
if ( sibling &&
sibling.type == CKEDITOR.NODE_ELEMENT &&
sibling.is( listNode.getName() ) )
{
// Move childre... | [
"function",
"mergeListSiblings",
"(",
"listNode",
")",
"{",
"var",
"mergeSibling",
";",
"(",
"mergeSibling",
"=",
"function",
"(",
"rtl",
")",
"{",
"var",
"sibling",
"=",
"listNode",
"[",
"rtl",
"?",
"'getPrevious'",
":",
"'getNext'",
"]",
"(",
"nonEmpty",
... | Merge list adjacent, of same type lists. | [
"Merge",
"list",
"adjacent",
"of",
"same",
"type",
"lists",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/list/plugin.js#L680-L698 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/list/plugin.js | isTextBlock | function isTextBlock( node ) {
return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in CKEDITOR.dtd.$block || node.getName() in CKEDITOR.dtd.$listItem ) && CKEDITOR.dtd[ node.getName() ][ '#' ];
} | javascript | function isTextBlock( node ) {
return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in CKEDITOR.dtd.$block || node.getName() in CKEDITOR.dtd.$listItem ) && CKEDITOR.dtd[ node.getName() ][ '#' ];
} | [
"function",
"isTextBlock",
"(",
"node",
")",
"{",
"return",
"node",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_ELEMENT",
"&&",
"(",
"node",
".",
"getName",
"(",
")",
"in",
"CKEDITOR",
".",
"dtd",
".",
"$block",
"||",
"node",
".",
"getName",
"(",
")",
... | Check if node is block element that recieves text. | [
"Check",
"if",
"node",
"is",
"block",
"element",
"that",
"recieves",
"text",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/list/plugin.js#L715-L717 | train |
activethread/vulpejs | lib/routes/index.js | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'SAVE';
options.res = res;
if (req.params.model) {
options.model = req.params.model;
}
if (req.body) {
options.item = req.body;
}
if (req.params.data) {
options.data = req.param... | javascript | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'SAVE';
options.res = res;
if (req.params.model) {
options.model = req.params.model;
}
if (req.body) {
options.item = req.body;
}
if (req.params.data) {
options.data = req.param... | [
"function",
"(",
"req",
",",
"res",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"options",
".",
"operation",
"=",
"'SAVE'",
";",
"options",
".",
"res",
"=",
"res",
";",
"if",
"(",
"req",
".... | Save object in database.
@param {Object} req Request
@param {Object} res Response
@param {Object} options {model, data, callback} | [
"Save",
"object",
"in",
"database",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L212-L257 | train | |
activethread/vulpejs | lib/routes/index.js | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'REMOVE';
options.res = res;
if (!options) {
options = {};
}
if (req.params.model) {
options.model = req.params.model;
}
if (req.params.query) {
options.query = req.params.query... | javascript | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'REMOVE';
options.res = res;
if (!options) {
options = {};
}
if (req.params.model) {
options.model = req.params.model;
}
if (req.params.query) {
options.query = req.params.query... | [
"function",
"(",
"req",
",",
"res",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"options",
".",
"operation",
"=",
"'REMOVE'",
";",
"options",
".",
"res",
"=",
"res",
";",
"if",
"(",
"!",
"o... | Remove object from database by id and callback if success.
@param {Object} req Request
@param {Object} res Response
@param {Object} options {model, id, callback} | [
"Remove",
"object",
"from",
"database",
"by",
"id",
"and",
"callback",
"if",
"success",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L269-L319 | train | |
activethread/vulpejs | lib/routes/index.js | function (req, res) {
var options = {
operation: 'LIST',
res: res,
};
exports.list.before(req, res, options);
vulpejs.models.list({
model: req.params.model,
query: req.params.query || {},
populate: req.params.populate || '',
sort: req.params.sort || {},
userId: ... | javascript | function (req, res) {
var options = {
operation: 'LIST',
res: res,
};
exports.list.before(req, res, options);
vulpejs.models.list({
model: req.params.model,
query: req.params.query || {},
populate: req.params.populate || '',
sort: req.params.sort || {},
userId: ... | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"var",
"options",
"=",
"{",
"operation",
":",
"'LIST'",
",",
"res",
":",
"res",
",",
"}",
";",
"exports",
".",
"list",
".",
"before",
"(",
"req",
",",
"res",
",",
"options",
")",
";",
"vulpejs",
".",
... | List from database.
@param {Object} req Request
@param {Object} res Response | [
"List",
"from",
"database",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L330-L354 | train | |
activethread/vulpejs | lib/routes/index.js | function (req, res) {
var options = {
operation: 'PAGINATE',
res: res,
};
exports.paginate.before(req, res, options);
vulpejs.models.paginate({
model: req.params.model,
query: req.params.query || {},
populate: req.params.populate || '',
sort: req.params.sort || {},
... | javascript | function (req, res) {
var options = {
operation: 'PAGINATE',
res: res,
};
exports.paginate.before(req, res, options);
vulpejs.models.paginate({
model: req.params.model,
query: req.params.query || {},
populate: req.params.populate || '',
sort: req.params.sort || {},
... | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"var",
"options",
"=",
"{",
"operation",
":",
"'PAGINATE'",
",",
"res",
":",
"res",
",",
"}",
";",
"exports",
".",
"paginate",
".",
"before",
"(",
"req",
",",
"res",
",",
"options",
")",
";",
"vulpejs",... | Paginate list from database.
@param {Object} req Request
@param {Object} res Response | [
"Paginate",
"list",
"from",
"database",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L365-L392 | train | |
activethread/vulpejs | lib/routes/index.js | function (req, res) {
var options = {
operation: 'DISTINCT',
res: res,
};
exports.distinct.before(req, res, options);
vulpejs.models.distinct({
model: req.params.model,
query: req.params.query || {},
sort: req.params.sort || false,
array: req.params.array || false,
... | javascript | function (req, res) {
var options = {
operation: 'DISTINCT',
res: res,
};
exports.distinct.before(req, res, options);
vulpejs.models.distinct({
model: req.params.model,
query: req.params.query || {},
sort: req.params.sort || false,
array: req.params.array || false,
... | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"var",
"options",
"=",
"{",
"operation",
":",
"'DISTINCT'",
",",
"res",
":",
"res",
",",
"}",
";",
"exports",
".",
"distinct",
".",
"before",
"(",
"req",
",",
"res",
",",
"options",
")",
";",
"vulpejs",... | Retrive distinct list of objects from database.
@param {Object} req Request
@param {Object} res Response | [
"Retrive",
"distinct",
"list",
"of",
"objects",
"from",
"database",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L403-L425 | train | |
activethread/vulpejs | lib/routes/index.js | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'FIND';
options.res = res;
exports.find.before(req, res, options);
vulpejs.models.find({
model: req.params.model,
populate: req.params.populate,
history: true,
id: req.params.id || fa... | javascript | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'FIND';
options.res = res;
exports.find.before(req, res, options);
vulpejs.models.find({
model: req.params.model,
populate: req.params.populate,
history: true,
id: req.params.id || fa... | [
"function",
"(",
"req",
",",
"res",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"options",
".",
"operation",
"=",
"'FIND'",
";",
"options",
".",
"res",
"=",
"res",
";",
"exports",
".",
"find"... | Find object in database.
@param {Object} req Request
@param {Object} res Response
@param {Object} options {model, populate, callback} | [
"Find",
"object",
"in",
"database",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L437-L470 | train | |
activethread/vulpejs | lib/routes/index.js | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'STATUS';
options.res = res;
exports.status.before(req, res, options);
vulpejs.models.status({
model: req.params.model,
data: req.body,
callback: {
success: function (item) {
... | javascript | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'STATUS';
options.res = res;
exports.status.before(req, res, options);
vulpejs.models.status({
model: req.params.model,
data: req.body,
callback: {
success: function (item) {
... | [
"function",
"(",
"req",
",",
"res",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"options",
".",
"operation",
"=",
"'STATUS'",
";",
"options",
".",
"res",
"=",
"res",
";",
"exports",
".",
"sta... | Change status of object in database.
@param {Object} req Request
@param {Object} res Response
@param {Object} options {model, callback} | [
"Change",
"status",
"of",
"object",
"in",
"database",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L550-L574 | train | |
activethread/vulpejs | lib/routes/index.js | function (configObject) {
if (typeof configObject !== 'undefined') {
configuration.directory = configObject.directory || configuration.directory;
configuration.extension = configObject.extension || configuration.extension;
configuration.objectNotation = configObject.objectNotation || configuration... | javascript | function (configObject) {
if (typeof configObject !== 'undefined') {
configuration.directory = configObject.directory || configuration.directory;
configuration.extension = configObject.extension || configuration.extension;
configuration.objectNotation = configObject.objectNotation || configuration... | [
"function",
"(",
"configObject",
")",
"{",
"if",
"(",
"typeof",
"configObject",
"!==",
"'undefined'",
")",
"{",
"configuration",
".",
"directory",
"=",
"configObject",
".",
"directory",
"||",
"configuration",
".",
"directory",
";",
"configuration",
".",
"extensi... | Configure the express routes through which translations are served.
@param app
@param {Object} [configObject] | [
"Configure",
"the",
"express",
"routes",
"through",
"which",
"translations",
"are",
"served",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L1117-L1128 | train | |
activethread/vulpejs | lib/routes/index.js | function (request, response, next) {
response.locals.i18n = {
getLocale: function () {
return request.cookies.appLanguage || vulpejs.i18n.getLocale.apply(request, arguments);
},
};
// For backwards compatibility, also define 'acceptedLanguage'.
response.locals.acceptedLanguage = res... | javascript | function (request, response, next) {
response.locals.i18n = {
getLocale: function () {
return request.cookies.appLanguage || vulpejs.i18n.getLocale.apply(request, arguments);
},
};
// For backwards compatibility, also define 'acceptedLanguage'.
response.locals.acceptedLanguage = res... | [
"function",
"(",
"request",
",",
"response",
",",
"next",
")",
"{",
"response",
".",
"locals",
".",
"i18n",
"=",
"{",
"getLocale",
":",
"function",
"(",
")",
"{",
"return",
"request",
".",
"cookies",
".",
"appLanguage",
"||",
"vulpejs",
".",
"i18n",
".... | Middleware to allow retrieval of users locale in the template engine.
@param {Object} request
@param {Object} response
@param {Function} [next] | [
"Middleware",
"to",
"allow",
"retrieval",
"of",
"users",
"locale",
"in",
"the",
"template",
"engine",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L1136-L1149 | train | |
activethread/vulpejs | lib/routes/index.js | function (request, response) {
var locale = request.params.locale;
var sendFile = response.sendFile || response.sendfile;
sendFile.apply(response, [path.join(configuration.directory, locale + configuration.extension)]);
} | javascript | function (request, response) {
var locale = request.params.locale;
var sendFile = response.sendFile || response.sendfile;
sendFile.apply(response, [path.join(configuration.directory, locale + configuration.extension)]);
} | [
"function",
"(",
"request",
",",
"response",
")",
"{",
"var",
"locale",
"=",
"request",
".",
"params",
".",
"locale",
";",
"var",
"sendFile",
"=",
"response",
".",
"sendFile",
"||",
"response",
".",
"sendfile",
";",
"sendFile",
".",
"apply",
"(",
"respon... | Sends a translation file to the client.
@param request
@param response | [
"Sends",
"a",
"translation",
"file",
"to",
"the",
"client",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L1157-L1161 | train | |
activethread/vulpejs | lib/routes/index.js | function (request, response) {
var locale = request.params.locale;
var phrase = request.params.phrase;
var result;
if (request.query.plural) {
var singular = phrase;
var plural = request.query.plural;
// Make sure the information is added to the catalog if it doesn't exi... | javascript | function (request, response) {
var locale = request.params.locale;
var phrase = request.params.phrase;
var result;
if (request.query.plural) {
var singular = phrase;
var plural = request.query.plural;
// Make sure the information is added to the catalog if it doesn't exi... | [
"function",
"(",
"request",
",",
"response",
")",
"{",
"var",
"locale",
"=",
"request",
".",
"params",
".",
"locale",
";",
"var",
"phrase",
"=",
"request",
".",
"params",
".",
"phrase",
";",
"var",
"result",
";",
"if",
"(",
"request",
".",
"query",
"... | Translate a given string and provide the result.
@param request
@param response | [
"Translate",
"a",
"given",
"string",
"and",
"provide",
"the",
"result",
"."
] | cba9529ebb13892b2c7d07219c7fa69137151fbd | https://github.com/activethread/vulpejs/blob/cba9529ebb13892b2c7d07219c7fa69137151fbd/lib/routes/index.js#L1168-L1195 | train | |
byu-oit/aws-scatter-gather | bin/middleware.js | subscribe | function subscribe(topicArn) {
// validate the topic arn
if (!rxTopicArn.test(topicArn)) throw Error('Cannot subscribe to an invalid AWS Topic Arn: ' + topicArn);
// if already subscribed then return now
if (subscriptions[topicArn]) return subscriptions[topicArn].promise;
// c... | javascript | function subscribe(topicArn) {
// validate the topic arn
if (!rxTopicArn.test(topicArn)) throw Error('Cannot subscribe to an invalid AWS Topic Arn: ' + topicArn);
// if already subscribed then return now
if (subscriptions[topicArn]) return subscriptions[topicArn].promise;
// c... | [
"function",
"subscribe",
"(",
"topicArn",
")",
"{",
"// validate the topic arn",
"if",
"(",
"!",
"rxTopicArn",
".",
"test",
"(",
"topicArn",
")",
")",
"throw",
"Error",
"(",
"'Cannot subscribe to an invalid AWS Topic Arn: '",
"+",
"topicArn",
")",
";",
"// if alread... | Subscribe to an SNS Topic.
@param {string} topicArn
@returns {Promise} | [
"Subscribe",
"to",
"an",
"SNS",
"Topic",
"."
] | 708e7caa6bea706276d55b3678d8468438d6d163 | https://github.com/byu-oit/aws-scatter-gather/blob/708e7caa6bea706276d55b3678d8468438d6d163/bin/middleware.js#L150-L174 | train |
byu-oit/aws-scatter-gather | bin/middleware.js | unsubscribe | function unsubscribe(topicArn) {
// if not subscribed then return now
if (!subscriptions[topicArn]) {
debug('Not subscribed to ' + topicArn);
return Promise.resolve();
}
return new Promise(function(resolve, reject) {
const params = { SubscriptionArn:... | javascript | function unsubscribe(topicArn) {
// if not subscribed then return now
if (!subscriptions[topicArn]) {
debug('Not subscribed to ' + topicArn);
return Promise.resolve();
}
return new Promise(function(resolve, reject) {
const params = { SubscriptionArn:... | [
"function",
"unsubscribe",
"(",
"topicArn",
")",
"{",
"// if not subscribed then return now",
"if",
"(",
"!",
"subscriptions",
"[",
"topicArn",
"]",
")",
"{",
"debug",
"(",
"'Not subscribed to '",
"+",
"topicArn",
")",
";",
"return",
"Promise",
".",
"resolve",
"... | Unsubscribe from an SNS Topic
@param {string} topicArn
@returns {Promise} | [
"Unsubscribe",
"from",
"an",
"SNS",
"Topic"
] | 708e7caa6bea706276d55b3678d8468438d6d163 | https://github.com/byu-oit/aws-scatter-gather/blob/708e7caa6bea706276d55b3678d8468438d6d163/bin/middleware.js#L181-L198 | train |
byu-oit/aws-scatter-gather | bin/middleware.js | parseBody | function parseBody(req) {
return extractBody(req)
.then(() => {
if (req.body && typeof req.body === 'object') return req.body;
try {
return JSON.parse(req.body);
} catch (err) {
throw Error('Unexpected body format received. Expected applica... | javascript | function parseBody(req) {
return extractBody(req)
.then(() => {
if (req.body && typeof req.body === 'object') return req.body;
try {
return JSON.parse(req.body);
} catch (err) {
throw Error('Unexpected body format received. Expected applica... | [
"function",
"parseBody",
"(",
"req",
")",
"{",
"return",
"extractBody",
"(",
"req",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"req",
".",
"body",
"&&",
"typeof",
"req",
".",
"body",
"===",
"'object'",
")",
"return",
"req",
".",
"body",... | Parse the response body.
@param {Object} req
@returns {Promise} | [
"Parse",
"the",
"response",
"body",
"."
] | 708e7caa6bea706276d55b3678d8468438d6d163 | https://github.com/byu-oit/aws-scatter-gather/blob/708e7caa6bea706276d55b3678d8468438d6d163/bin/middleware.js#L225-L235 | train |
zouloux/semver-increment | index.js | function (version, semverIndex)
{
const splittedVersion = version.split('.');
splittedVersion[ semverIndex ] = parseInt(splittedVersion[ semverIndex ], 10) + 1;
while (semverIndex < 2)
{
splittedVersion[ ++semverIndex ] = '0';
}
return splittedVersion.join('.');
} | javascript | function (version, semverIndex)
{
const splittedVersion = version.split('.');
splittedVersion[ semverIndex ] = parseInt(splittedVersion[ semverIndex ], 10) + 1;
while (semverIndex < 2)
{
splittedVersion[ ++semverIndex ] = '0';
}
return splittedVersion.join('.');
} | [
"function",
"(",
"version",
",",
"semverIndex",
")",
"{",
"const",
"splittedVersion",
"=",
"version",
".",
"split",
"(",
"'.'",
")",
";",
"splittedVersion",
"[",
"semverIndex",
"]",
"=",
"parseInt",
"(",
"splittedVersion",
"[",
"semverIndex",
"]",
",",
"10",... | Increment a version which is as a string. | [
"Increment",
"a",
"version",
"which",
"is",
"as",
"a",
"string",
"."
] | 4c65abeb42a17ad05d147108d595cd490eaafc4d | https://github.com/zouloux/semver-increment/blob/4c65abeb42a17ad05d147108d595cd490eaafc4d/index.js#L25-L34 | train | |
zouloux/semver-increment | index.js | function (packagePath, semverIndex)
{
// Check if package file exists
if ( !fs.existsSync(packagePath) )
{
throw new Error(`Package file ${packagePath} is not found.`, 1);
}
// Read package file content
const packageData = JSON.parse( fs.readFileSync( packagePath ) );
// Increment version according ... | javascript | function (packagePath, semverIndex)
{
// Check if package file exists
if ( !fs.existsSync(packagePath) )
{
throw new Error(`Package file ${packagePath} is not found.`, 1);
}
// Read package file content
const packageData = JSON.parse( fs.readFileSync( packagePath ) );
// Increment version according ... | [
"function",
"(",
"packagePath",
",",
"semverIndex",
")",
"{",
"// Check if package file exists",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"packagePath",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"packagePath",
"}",
"`",
",",
"1",
")",
... | Increment any package.json version. | [
"Increment",
"any",
"package",
".",
"json",
"version",
"."
] | 4c65abeb42a17ad05d147108d595cd490eaafc4d | https://github.com/zouloux/semver-increment/blob/4c65abeb42a17ad05d147108d595cd490eaafc4d/index.js#L39-L58 | train | |
shenanigans/node-fauxmongo | lib/Project.js | multiproject | function multiproject (pointer, target, path) {
var pointerType = getTypeStr (pointer);
var mainTarget;
if (target)
mainTarget = target;
else
if (pointerType == 'object')
target = {};
else if (pointerType... | javascript | function multiproject (pointer, target, path) {
var pointerType = getTypeStr (pointer);
var mainTarget;
if (target)
mainTarget = target;
else
if (pointerType == 'object')
target = {};
else if (pointerType... | [
"function",
"multiproject",
"(",
"pointer",
",",
"target",
",",
"path",
")",
"{",
"var",
"pointerType",
"=",
"getTypeStr",
"(",
"pointer",
")",
";",
"var",
"mainTarget",
";",
"if",
"(",
"target",
")",
"mainTarget",
"=",
"target",
";",
"else",
"if",
"(",
... | in case we traverse any Arrays during this projection | [
"in",
"case",
"we",
"traverse",
"any",
"Arrays",
"during",
"this",
"projection"
] | 8aa4806f0f1da5dacc59c4fe2c1c7cd48904ce20 | https://github.com/shenanigans/node-fauxmongo/blob/8aa4806f0f1da5dacc59c4fe2c1c7cd48904ce20/lib/Project.js#L29-L101 | train |
wilmoore/node-git-origin-url | index.js | origin | function origin(fn) {
'use strict';
exec('git config --local --get remote.origin.url', function (errors, stdout, stderr) {
var url = "";
if (errors) return fn(errors.stack, url);
if (stderr) return fn(stderr, url);
url = trim.call(stdout);
if (!url) return fn('Unable to find remote origin U... | javascript | function origin(fn) {
'use strict';
exec('git config --local --get remote.origin.url', function (errors, stdout, stderr) {
var url = "";
if (errors) return fn(errors.stack, url);
if (stderr) return fn(stderr, url);
url = trim.call(stdout);
if (!url) return fn('Unable to find remote origin U... | [
"function",
"origin",
"(",
"fn",
")",
"{",
"'use strict'",
";",
"exec",
"(",
"'git config --local --get remote.origin.url'",
",",
"function",
"(",
"errors",
",",
"stdout",
",",
"stderr",
")",
"{",
"var",
"url",
"=",
"\"\"",
";",
"if",
"(",
"errors",
")",
"... | Retrieve the git remote origin URL of the current repo.
@param {Function} fn
Callback to receive the result. | [
"Retrieve",
"the",
"git",
"remote",
"origin",
"URL",
"of",
"the",
"current",
"repo",
"."
] | 881e3c9c7a22c1482b5ca3a7293eb45f8b350223 | https://github.com/wilmoore/node-git-origin-url/blob/881e3c9c7a22c1482b5ca3a7293eb45f8b350223/index.js#L15-L29 | train |
doowb/src-stream | index.js | srcStream | function srcStream(stream) {
var pass = through.obj();
pass.setMaxListeners(0);
var outputstream = duplexify.obj(pass, ms(stream, pass));
outputstream.setMaxListeners(0);
var isReading = false;
outputstream.on('pipe', function (src) {
isReading = true;
src.on('end', function () {
isReading =... | javascript | function srcStream(stream) {
var pass = through.obj();
pass.setMaxListeners(0);
var outputstream = duplexify.obj(pass, ms(stream, pass));
outputstream.setMaxListeners(0);
var isReading = false;
outputstream.on('pipe', function (src) {
isReading = true;
src.on('end', function () {
isReading =... | [
"function",
"srcStream",
"(",
"stream",
")",
"{",
"var",
"pass",
"=",
"through",
".",
"obj",
"(",
")",
";",
"pass",
".",
"setMaxListeners",
"(",
"0",
")",
";",
"var",
"outputstream",
"=",
"duplexify",
".",
"obj",
"(",
"pass",
",",
"ms",
"(",
"stream"... | Wrap a source stream to passthrough any data
that's being written to it.
```js
var src = require('src-stream');
// wrap something that returns a readable stream
var stream = src(plugin());
fs.createReadStream('./package.json')
.pipe(stream)
.on('data', console.log)
.on('end', function () {
console.log();
console.log... | [
"Wrap",
"a",
"source",
"stream",
"to",
"passthrough",
"any",
"data",
"that",
"s",
"being",
"written",
"to",
"it",
"."
] | 943a7222b1f7a72455a4a3f74cb0b8245f90ad81 | https://github.com/doowb/src-stream/blob/943a7222b1f7a72455a4a3f74cb0b8245f90ad81/index.js#L39-L62 | train |
llamadeus/data-to-png | cjs/index.js | createIHDRChunk | function createIHDRChunk(width, height) {
const data = buffer.Buffer.alloc(13);
// Width
data.writeUInt32BE(width);
// Height
data.writeUInt32BE(height, 4);
// Bit depth
data.writeUInt8(8, 8);
// RGBA mode
data.writeUInt8(6, 9);
// No compression
data.writeUInt8(0, 10);
// No filter
data.writeUInt8(0, 11)... | javascript | function createIHDRChunk(width, height) {
const data = buffer.Buffer.alloc(13);
// Width
data.writeUInt32BE(width);
// Height
data.writeUInt32BE(height, 4);
// Bit depth
data.writeUInt8(8, 8);
// RGBA mode
data.writeUInt8(6, 9);
// No compression
data.writeUInt8(0, 10);
// No filter
data.writeUInt8(0, 11)... | [
"function",
"createIHDRChunk",
"(",
"width",
",",
"height",
")",
"{",
"const",
"data",
"=",
"buffer",
".",
"Buffer",
".",
"alloc",
"(",
"13",
")",
";",
"// Width",
"data",
".",
"writeUInt32BE",
"(",
"width",
")",
";",
"// Height",
"data",
".",
"writeUInt... | Create the IHDR chunk.
@param width
@param height
@returns {Buffer} | [
"Create",
"the",
"IHDR",
"chunk",
"."
] | 8170197b4213d86a56c7b0cc4952f80a1e840766 | https://github.com/llamadeus/data-to-png/blob/8170197b4213d86a56c7b0cc4952f80a1e840766/cjs/index.js#L53-L72 | train |
llamadeus/data-to-png | cjs/index.js | createPng | function createPng(pixelData) {
const length = pixelData.length + 4 - (pixelData.length % 4);
const pixels = Math.ceil(length / 4);
const width = Math.min(pixels, MAX_WIDTH);
const height = Math.ceil(pixels / MAX_WIDTH);
const bytesPerRow = width * 4;
const buffer$$1 = buffer.Buffer.alloc((bytesPerRow + 1) * heig... | javascript | function createPng(pixelData) {
const length = pixelData.length + 4 - (pixelData.length % 4);
const pixels = Math.ceil(length / 4);
const width = Math.min(pixels, MAX_WIDTH);
const height = Math.ceil(pixels / MAX_WIDTH);
const bytesPerRow = width * 4;
const buffer$$1 = buffer.Buffer.alloc((bytesPerRow + 1) * heig... | [
"function",
"createPng",
"(",
"pixelData",
")",
"{",
"const",
"length",
"=",
"pixelData",
".",
"length",
"+",
"4",
"-",
"(",
"pixelData",
".",
"length",
"%",
"4",
")",
";",
"const",
"pixels",
"=",
"Math",
".",
"ceil",
"(",
"length",
"/",
"4",
")",
... | Create a png from the given pixel data.
@param pixelData
@returns {Promise<Buffer>} | [
"Create",
"a",
"png",
"from",
"the",
"given",
"pixel",
"data",
"."
] | 8170197b4213d86a56c7b0cc4952f80a1e840766 | https://github.com/llamadeus/data-to-png/blob/8170197b4213d86a56c7b0cc4952f80a1e840766/cjs/index.js#L99-L133 | train |
llamadeus/data-to-png | cjs/index.js | prependLength | function prependLength(data) {
const lengthAsBytes = buffer.Buffer.alloc(4);
lengthAsBytes.writeUInt32BE(data.length);
return buffer.Buffer.concat([lengthAsBytes, data]);
} | javascript | function prependLength(data) {
const lengthAsBytes = buffer.Buffer.alloc(4);
lengthAsBytes.writeUInt32BE(data.length);
return buffer.Buffer.concat([lengthAsBytes, data]);
} | [
"function",
"prependLength",
"(",
"data",
")",
"{",
"const",
"lengthAsBytes",
"=",
"buffer",
".",
"Buffer",
".",
"alloc",
"(",
"4",
")",
";",
"lengthAsBytes",
".",
"writeUInt32BE",
"(",
"data",
".",
"length",
")",
";",
"return",
"buffer",
".",
"Buffer",
... | Prepend length to the data.
@param data
@returns {Buffer} | [
"Prepend",
"length",
"to",
"the",
"data",
"."
] | 8170197b4213d86a56c7b0cc4952f80a1e840766 | https://github.com/llamadeus/data-to-png/blob/8170197b4213d86a56c7b0cc4952f80a1e840766/cjs/index.js#L141-L147 | train |
llamadeus/data-to-png | cjs/index.js | encode | function encode(data) {
const bytes = buffer.Buffer.from(data, 'utf8');
const pixelData = prependLength(bytes);
return createPng(pixelData);
} | javascript | function encode(data) {
const bytes = buffer.Buffer.from(data, 'utf8');
const pixelData = prependLength(bytes);
return createPng(pixelData);
} | [
"function",
"encode",
"(",
"data",
")",
"{",
"const",
"bytes",
"=",
"buffer",
".",
"Buffer",
".",
"from",
"(",
"data",
",",
"'utf8'",
")",
";",
"const",
"pixelData",
"=",
"prependLength",
"(",
"bytes",
")",
";",
"return",
"createPng",
"(",
"pixelData",
... | Encode the given data to png.
@param {string} data
@returns {Promise<Buffer>} | [
"Encode",
"the",
"given",
"data",
"to",
"png",
"."
] | 8170197b4213d86a56c7b0cc4952f80a1e840766 | https://github.com/llamadeus/data-to-png/blob/8170197b4213d86a56c7b0cc4952f80a1e840766/cjs/index.js#L155-L160 | train |
jkorona/grunt-release-bower | lib/semver-utils.js | function (increment) {
increment = increment || Semver.PATCH; // default is patch
switch (increment) {
/* jshint indent: false */
case Semver.MAJOR:
this.major++;
this.minor = this.patch = 0;
break;
case Semver.MINOR:
... | javascript | function (increment) {
increment = increment || Semver.PATCH; // default is patch
switch (increment) {
/* jshint indent: false */
case Semver.MAJOR:
this.major++;
this.minor = this.patch = 0;
break;
case Semver.MINOR:
... | [
"function",
"(",
"increment",
")",
"{",
"increment",
"=",
"increment",
"||",
"Semver",
".",
"PATCH",
";",
"// default is patch",
"switch",
"(",
"increment",
")",
"{",
"/* jshint indent: false */",
"case",
"Semver",
".",
"MAJOR",
":",
"this",
".",
"major",
"++"... | Increases version number using increment factor.
@param increment indicates which part of version should be pumped (major, minor, patch).
@returns {*} current Semver instance for method chaining. | [
"Increases",
"version",
"number",
"using",
"increment",
"factor",
"."
] | a1b0e0b4aa85eced889f75ee88f45e187af9ae24 | https://github.com/jkorona/grunt-release-bower/blob/a1b0e0b4aa85eced889f75ee88f45e187af9ae24/lib/semver-utils.js#L22-L39 | train | |
angeloocana/joj-core | dist-esnext/Game.js | isMyTurn | function isMyTurn(game, from) {
if (game.score.ended)
return false;
from = Board.getPositionFromBoard(game.board, from);
return isWhiteTurn(game) ? Position.hasWhitePiece(from) : Position.hasBlackPiece(from);
} | javascript | function isMyTurn(game, from) {
if (game.score.ended)
return false;
from = Board.getPositionFromBoard(game.board, from);
return isWhiteTurn(game) ? Position.hasWhitePiece(from) : Position.hasBlackPiece(from);
} | [
"function",
"isMyTurn",
"(",
"game",
",",
"from",
")",
"{",
"if",
"(",
"game",
".",
"score",
".",
"ended",
")",
"return",
"false",
";",
"from",
"=",
"Board",
".",
"getPositionFromBoard",
"(",
"game",
".",
"board",
",",
"from",
")",
";",
"return",
"is... | Returns true if from piece can be played. | [
"Returns",
"true",
"if",
"from",
"piece",
"can",
"be",
"played",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist-esnext/Game.js#L22-L27 | train |
angeloocana/joj-core | dist-esnext/Game.js | getTurnPieces | function getTurnPieces(game) {
const isBlack = isBlackTurn(game);
return game.board.reduce((piecesRow, row) => {
return piecesRow.concat(row.reduce((pieces, position) => (isBlack !== position.isBlack)
? pieces
: pieces.concat({ x: position.x, y: position.y, isBlack }), []));
... | javascript | function getTurnPieces(game) {
const isBlack = isBlackTurn(game);
return game.board.reduce((piecesRow, row) => {
return piecesRow.concat(row.reduce((pieces, position) => (isBlack !== position.isBlack)
? pieces
: pieces.concat({ x: position.x, y: position.y, isBlack }), []));
... | [
"function",
"getTurnPieces",
"(",
"game",
")",
"{",
"const",
"isBlack",
"=",
"isBlackTurn",
"(",
"game",
")",
";",
"return",
"game",
".",
"board",
".",
"reduce",
"(",
"(",
"piecesRow",
",",
"row",
")",
"=>",
"{",
"return",
"piecesRow",
".",
"concat",
"... | Gets all positions from current player turn. | [
"Gets",
"all",
"positions",
"from",
"current",
"player",
"turn",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist-esnext/Game.js#L32-L39 | train |
wigy/chronicles_of_grunt | lib/cog.js | prefix | function prefix(pattern) {
if (!pattern) {
pattern = 'grunt-available-tasks';
}
pattern = pattern.replace(/^node_modules\//, '');
var ret;
if (grunt.file.expand('node_modules/' + pattern).length) {
ret = 'node_modules/';
} else if (grunt.file.expan... | javascript | function prefix(pattern) {
if (!pattern) {
pattern = 'grunt-available-tasks';
}
pattern = pattern.replace(/^node_modules\//, '');
var ret;
if (grunt.file.expand('node_modules/' + pattern).length) {
ret = 'node_modules/';
} else if (grunt.file.expan... | [
"function",
"prefix",
"(",
"pattern",
")",
"{",
"if",
"(",
"!",
"pattern",
")",
"{",
"pattern",
"=",
"'grunt-available-tasks'",
";",
"}",
"pattern",
"=",
"pattern",
".",
"replace",
"(",
"/",
"^node_modules\\/",
"/",
",",
"''",
")",
";",
"var",
"ret",
"... | Find the path prefix to the node_modules containing needed utilities. | [
"Find",
"the",
"path",
"prefix",
"to",
"the",
"node_modules",
"containing",
"needed",
"utilities",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/cog.js#L45-L61 | train |
wigy/chronicles_of_grunt | lib/cog.js | getConfig | function getConfig(name, def) {
var i, j;
// Load initital config.
if (!config) {
var external;
config = grunt.config.get('cog') || {options: {}};
// Expand general external definitions to category specific definitions.
if (config.options.exte... | javascript | function getConfig(name, def) {
var i, j;
// Load initital config.
if (!config) {
var external;
config = grunt.config.get('cog') || {options: {}};
// Expand general external definitions to category specific definitions.
if (config.options.exte... | [
"function",
"getConfig",
"(",
"name",
",",
"def",
")",
"{",
"var",
"i",
",",
"j",
";",
"// Load initital config.",
"if",
"(",
"!",
"config",
")",
"{",
"var",
"external",
";",
"config",
"=",
"grunt",
".",
"config",
".",
"get",
"(",
"'cog'",
")",
"||",... | Safe fetch of configuration variable. | [
"Safe",
"fetch",
"of",
"configuration",
"variable",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/cog.js#L76-L133 | train |
wigy/chronicles_of_grunt | lib/cog.js | configuredFramework | function configuredFramework() {
var lib = getConfig('external.lib');
if (!lib) {
return null;
}
if (typeof(lib) === 'string') {
lib = [lib];
}
if (lib.indexOf('ember') >= 0) {
return 'ember';
}
if (lib.indexOf('angular'... | javascript | function configuredFramework() {
var lib = getConfig('external.lib');
if (!lib) {
return null;
}
if (typeof(lib) === 'string') {
lib = [lib];
}
if (lib.indexOf('ember') >= 0) {
return 'ember';
}
if (lib.indexOf('angular'... | [
"function",
"configuredFramework",
"(",
")",
"{",
"var",
"lib",
"=",
"getConfig",
"(",
"'external.lib'",
")",
";",
"if",
"(",
"!",
"lib",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"typeof",
"(",
"lib",
")",
"===",
"'string'",
")",
"{",
"lib",
... | Check the frameworks defined. | [
"Check",
"the",
"frameworks",
"defined",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/cog.js#L138-L153 | train |
wigy/chronicles_of_grunt | lib/cog.js | getOption | function getOption(name) {
var ret = getConfig('options.' + name);
if (ret === undefined) {
var framework = configuredFramework();
if (db.frameworks.options[framework] && (name in db.frameworks.options[framework])) {
ret = db.frameworks.options[framework][name];
... | javascript | function getOption(name) {
var ret = getConfig('options.' + name);
if (ret === undefined) {
var framework = configuredFramework();
if (db.frameworks.options[framework] && (name in db.frameworks.options[framework])) {
ret = db.frameworks.options[framework][name];
... | [
"function",
"getOption",
"(",
"name",
")",
"{",
"var",
"ret",
"=",
"getConfig",
"(",
"'options.'",
"+",
"name",
")",
";",
"if",
"(",
"ret",
"===",
"undefined",
")",
"{",
"var",
"framework",
"=",
"configuredFramework",
"(",
")",
";",
"if",
"(",
"db",
... | Get the value of a configuration flag. | [
"Get",
"the",
"value",
"of",
"a",
"configuration",
"flag",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/cog.js#L180-L196 | train |
flitbit/oops | examples/browser/vendor/angular-ui.js | function (inst) {
if (inst.isDirty()) {
inst.save();
ngModel.$setViewValue(elm.val());
if (!scope.$$phase)
scope.$apply();
}
} | javascript | function (inst) {
if (inst.isDirty()) {
inst.save();
ngModel.$setViewValue(elm.val());
if (!scope.$$phase)
scope.$apply();
}
} | [
"function",
"(",
"inst",
")",
"{",
"if",
"(",
"inst",
".",
"isDirty",
"(",
")",
")",
"{",
"inst",
".",
"save",
"(",
")",
";",
"ngModel",
".",
"$setViewValue",
"(",
"elm",
".",
"val",
"(",
")",
")",
";",
"if",
"(",
"!",
"scope",
".",
"$$phase",
... | Update model on button click | [
"Update",
"model",
"on",
"button",
"click"
] | 73c36d459b98d1ac9485327ab3d6bf180c78d254 | https://github.com/flitbit/oops/blob/73c36d459b98d1ac9485327ab3d6bf180c78d254/examples/browser/vendor/angular-ui.js#L758-L765 | train | |
flitbit/oops | examples/browser/vendor/angular-ui.js | function(event, jsEvent, view) {
if (view.name !== 'agendaDay') {
$(jsEvent.target).attr('title', event.title);
}
} | javascript | function(event, jsEvent, view) {
if (view.name !== 'agendaDay') {
$(jsEvent.target).attr('title', event.title);
}
} | [
"function",
"(",
"event",
",",
"jsEvent",
",",
"view",
")",
"{",
"if",
"(",
"view",
".",
"name",
"!==",
"'agendaDay'",
")",
"{",
"$",
"(",
"jsEvent",
".",
"target",
")",
".",
"attr",
"(",
"'title'",
",",
"event",
".",
"title",
")",
";",
"}",
"}"
... | add event name to title attribute on mouseover. | [
"add",
"event",
"name",
"to",
"title",
"attribute",
"on",
"mouseover",
"."
] | 73c36d459b98d1ac9485327ab3d6bf180c78d254 | https://github.com/flitbit/oops/blob/73c36d459b98d1ac9485327ab3d6bf180c78d254/examples/browser/vendor/angular-ui.js#L913-L917 | train | |
patgrasso/parsey | lib/cfg.js | CFG | function CFG(rules) {
let arr = [];
arr.__proto__ = CFG.prototype;
if (Array.isArray(rules)) {
rules.forEach(arr.rule.bind(arr));
}
return arr;
} | javascript | function CFG(rules) {
let arr = [];
arr.__proto__ = CFG.prototype;
if (Array.isArray(rules)) {
rules.forEach(arr.rule.bind(arr));
}
return arr;
} | [
"function",
"CFG",
"(",
"rules",
")",
"{",
"let",
"arr",
"=",
"[",
"]",
";",
"arr",
".",
"__proto__",
"=",
"CFG",
".",
"prototype",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"rules",
")",
")",
"{",
"rules",
".",
"forEach",
"(",
"arr",
".",
... | Constructs a new context-free grammar, which is just a container for
production rules
@class CFG
@extends Array
@constructor
@param {rules=} - Optional array of {@link Rule}s to initialize the grammar
with | [
"Constructs",
"a",
"new",
"context",
"-",
"free",
"grammar",
"which",
"is",
"just",
"a",
"container",
"for",
"production",
"rules"
] | d28b3f330ee03b5c273f1ce5871a5b86dac79fb0 | https://github.com/patgrasso/parsey/blob/d28b3f330ee03b5c273f1ce5871a5b86dac79fb0/lib/cfg.js#L27-L36 | train |
wilmoore/reapply.js | index.js | reapply | function reapply (parameters) {
return (arguments.length > 1)
? reapplyer(parameters, arguments[1])
: reapplyer.bind(null, parameters)
} | javascript | function reapply (parameters) {
return (arguments.length > 1)
? reapplyer(parameters, arguments[1])
: reapplyer.bind(null, parameters)
} | [
"function",
"reapply",
"(",
"parameters",
")",
"{",
"return",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"?",
"reapplyer",
"(",
"parameters",
",",
"arguments",
"[",
"1",
"]",
")",
":",
"reapplyer",
".",
"bind",
"(",
"null",
",",
"parameters",
")",... | Curried wrapper.
@param {String} parameters
parameters to pass to applied function.
@return {Function|*}
result of partial or full function application. | [
"Curried",
"wrapper",
"."
] | 77b558bb4a1d9d623bc32a0280e2de5f43a144b7 | https://github.com/wilmoore/reapply.js/blob/77b558bb4a1d9d623bc32a0280e2de5f43a144b7/index.js#L25-L29 | train |
grappler-ci/grappler-hook-github | index.js | handlePush | function handlePush(key, req, log, fn) {
var body = req.body;
var repo = body.repository;
if (!body || !repo) return fn(new Error('missing body'));
var url = repo.url;
var name = repo.name;
var ref = body.ref;
var branch = ref.replace('refs/heads/', '');
var sha = body.after;
var info = {
repo: ... | javascript | function handlePush(key, req, log, fn) {
var body = req.body;
var repo = body.repository;
if (!body || !repo) return fn(new Error('missing body'));
var url = repo.url;
var name = repo.name;
var ref = body.ref;
var branch = ref.replace('refs/heads/', '');
var sha = body.after;
var info = {
repo: ... | [
"function",
"handlePush",
"(",
"key",
",",
"req",
",",
"log",
",",
"fn",
")",
"{",
"var",
"body",
"=",
"req",
".",
"body",
";",
"var",
"repo",
"=",
"body",
".",
"repository",
";",
"if",
"(",
"!",
"body",
"||",
"!",
"repo",
")",
"return",
"fn",
... | Handle a push event
steps:
* git clone sha
* deploy the sha
* listen for success/failure and update the repo status (https://developer.github.com/v3/repos/statuses/)
* create a deployment (https://developer.github.com/v3/repos/deployments/#create-a-deployment) | [
"Handle",
"a",
"push",
"event"
] | acb9a268ee51fd3575739a682ef2ec0ac8403e27 | https://github.com/grappler-ci/grappler-hook-github/blob/acb9a268ee51fd3575739a682ef2ec0ac8403e27/index.js#L75-L98 | train |
grappler-ci/grappler-hook-github | index.js | clone | function clone(url, target, ref, key, log, fn) {
var urlObj = parseurl(url);
urlObj.auth = key + ':x-oauth-basic';
var authurl = formaturl(urlObj) + '.git';
var dir = target + '/.git';
log('creating dir ' + dir);
mkdirp(dir, function(err) {
if (err) return fn(err);
var remote = git.remote(authurl... | javascript | function clone(url, target, ref, key, log, fn) {
var urlObj = parseurl(url);
urlObj.auth = key + ':x-oauth-basic';
var authurl = formaturl(urlObj) + '.git';
var dir = target + '/.git';
log('creating dir ' + dir);
mkdirp(dir, function(err) {
if (err) return fn(err);
var remote = git.remote(authurl... | [
"function",
"clone",
"(",
"url",
",",
"target",
",",
"ref",
",",
"key",
",",
"log",
",",
"fn",
")",
"{",
"var",
"urlObj",
"=",
"parseurl",
"(",
"url",
")",
";",
"urlObj",
".",
"auth",
"=",
"key",
"+",
"':x-oauth-basic'",
";",
"var",
"authurl",
"=",... | Clone a repo
@param {String} url
@param {String} target
@param {String} ref
@param {String} key
@param {Function} log
@param {Function} fn | [
"Clone",
"a",
"repo"
] | acb9a268ee51fd3575739a682ef2ec0ac8403e27 | https://github.com/grappler-ci/grappler-hook-github/blob/acb9a268ee51fd3575739a682ef2ec0ac8403e27/index.js#L149-L180 | train |
yoshuawuyts/base-package-json | index.js | basePackageJson | function basePackageJson (opts) {
opts = opts || {}
const _name = opts.name || '<name>'
const _version = opts.version || '1.0.0'
const _private = opts.private || false
var called = false
return from({ objectMode: true }, function (size, next) {
if (called) return next(null, null)
const res = { na... | javascript | function basePackageJson (opts) {
opts = opts || {}
const _name = opts.name || '<name>'
const _version = opts.version || '1.0.0'
const _private = opts.private || false
var called = false
return from({ objectMode: true }, function (size, next) {
if (called) return next(null, null)
const res = { na... | [
"function",
"basePackageJson",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
"const",
"_name",
"=",
"opts",
".",
"name",
"||",
"'<name>'",
"const",
"_version",
"=",
"opts",
".",
"version",
"||",
"'1.0.0'",
"const",
"_private",
"=",
"opts",
... | Basic package.json readable stream obj -> stream | [
"Basic",
"package",
".",
"json",
"readable",
"stream",
"obj",
"-",
">",
"stream"
] | 314a6c830880fd63347775ff4daf33d0eff972e5 | https://github.com/yoshuawuyts/base-package-json/blob/314a6c830880fd63347775ff4daf33d0eff972e5/index.js#L7-L27 | train |
garyns/OneLineLogger | onelinelogger.js | padLeft | function padLeft(width, string, padding) {
return (width <= string.length) ? string : padLeft(width, string + padding, padding);
} | javascript | function padLeft(width, string, padding) {
return (width <= string.length) ? string : padLeft(width, string + padding, padding);
} | [
"function",
"padLeft",
"(",
"width",
",",
"string",
",",
"padding",
")",
"{",
"return",
"(",
"width",
"<=",
"string",
".",
"length",
")",
"?",
"string",
":",
"padLeft",
"(",
"width",
",",
"string",
"+",
"padding",
",",
"padding",
")",
";",
"}"
] | Pad a string. | [
"Pad",
"a",
"string",
"."
] | 92965144fcc87fa54b15b82843b651af4b980c0d | https://github.com/garyns/OneLineLogger/blob/92965144fcc87fa54b15b82843b651af4b980c0d/onelinelogger.js#L227-L229 | train |
garyns/OneLineLogger | onelinelogger.js | writeLogFile | function writeLogFile(file, line) {
if (file === undefined || file === null) {
return;
}
fs.appendFile(file, line + os.EOL, {}, function() {
//
});
} | javascript | function writeLogFile(file, line) {
if (file === undefined || file === null) {
return;
}
fs.appendFile(file, line + os.EOL, {}, function() {
//
});
} | [
"function",
"writeLogFile",
"(",
"file",
",",
"line",
")",
"{",
"if",
"(",
"file",
"===",
"undefined",
"||",
"file",
"===",
"null",
")",
"{",
"return",
";",
"}",
"fs",
".",
"appendFile",
"(",
"file",
",",
"line",
"+",
"os",
".",
"EOL",
",",
"{",
... | Appends line to a file if Logger.file is specified. | [
"Appends",
"line",
"to",
"a",
"file",
"if",
"Logger",
".",
"file",
"is",
"specified",
"."
] | 92965144fcc87fa54b15b82843b651af4b980c0d | https://github.com/garyns/OneLineLogger/blob/92965144fcc87fa54b15b82843b651af4b980c0d/onelinelogger.js#L234-L243 | train |
yoshuawuyts/linkstash | index.js | Stash | function Stash(nlz) {
if (!(this instanceof Stash)) return new Stash(nlz);
nlz = nlz || function(val) {return val};
assert.equal(typeof nlz, 'function', 'linkstash: nlz should be a function');
this._prev = null;
this._next = null;
this._nlz = nlz;
return this;
} | javascript | function Stash(nlz) {
if (!(this instanceof Stash)) return new Stash(nlz);
nlz = nlz || function(val) {return val};
assert.equal(typeof nlz, 'function', 'linkstash: nlz should be a function');
this._prev = null;
this._next = null;
this._nlz = nlz;
return this;
} | [
"function",
"Stash",
"(",
"nlz",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Stash",
")",
")",
"return",
"new",
"Stash",
"(",
"nlz",
")",
";",
"nlz",
"=",
"nlz",
"||",
"function",
"(",
"val",
")",
"{",
"return",
"val",
"}",
";",
"assert... | Update the API links object. Diffs the prev
timestamp in links and updates if
it exceeds the timestamp threshold.
@param {String} prev
@param {String} next
@api private | [
"Update",
"the",
"API",
"links",
"object",
".",
"Diffs",
"the",
"prev",
"timestamp",
"in",
"links",
"and",
"updates",
"if",
"it",
"exceeds",
"the",
"timestamp",
"threshold",
"."
] | 232f576893f7311e2541c5aa5e7d1d5b78eed500 | https://github.com/yoshuawuyts/linkstash/blob/232f576893f7311e2541c5aa5e7d1d5b78eed500/index.js#L29-L40 | train |
raincatcher-beta/raincatcher-sync | lib/client/mediator-subscribers/create-spec.js | checkMocksCalled | function checkMocksCalled(createResult) {
expect(createResult).to.deep.equal(createResult);
sinon.assert.calledOnce(mockDatasetManager.create);
sinon.assert.calledWith(mockDatasetManager.create, sinon.match(mockDataToCreate));
} | javascript | function checkMocksCalled(createResult) {
expect(createResult).to.deep.equal(createResult);
sinon.assert.calledOnce(mockDatasetManager.create);
sinon.assert.calledWith(mockDatasetManager.create, sinon.match(mockDataToCreate));
} | [
"function",
"checkMocksCalled",
"(",
"createResult",
")",
"{",
"expect",
"(",
"createResult",
")",
".",
"to",
".",
"deep",
".",
"equal",
"(",
"createResult",
")",
";",
"sinon",
".",
"assert",
".",
"calledOnce",
"(",
"mockDatasetManager",
".",
"create",
")",
... | Verifying the mocks were called with the correct parameters. | [
"Verifying",
"the",
"mocks",
"were",
"called",
"with",
"the",
"correct",
"parameters",
"."
] | a51eeb8fdea30a6afdcd0587019bd1148bf30468 | https://github.com/raincatcher-beta/raincatcher-sync/blob/a51eeb8fdea30a6afdcd0587019bd1148bf30468/lib/client/mediator-subscribers/create-spec.js#L52-L57 | train |
jldec/pub-preview | jqueryview.js | nav | function nav(path, query, hash, forceReload) {
var reload = forceReload || !path;
path = path || location.pathname;
query = query || (reload && location.search) || '';
hash = hash || (reload && location.hash) || '';
var newpage = generator.findPage(path);
if (!newpage) return generator.... | javascript | function nav(path, query, hash, forceReload) {
var reload = forceReload || !path;
path = path || location.pathname;
query = query || (reload && location.search) || '';
hash = hash || (reload && location.hash) || '';
var newpage = generator.findPage(path);
if (!newpage) return generator.... | [
"function",
"nav",
"(",
"path",
",",
"query",
",",
"hash",
",",
"forceReload",
")",
"{",
"var",
"reload",
"=",
"forceReload",
"||",
"!",
"path",
";",
"path",
"=",
"path",
"||",
"location",
".",
"pathname",
";",
"query",
"=",
"query",
"||",
"(",
"relo... | navigate or reload by regenerating just the page or the whole layout | [
"navigate",
"or",
"reload",
"by",
"regenerating",
"just",
"the",
"page",
"or",
"the",
"whole",
"layout"
] | 55df6500200cbad4a4a03d8da86fef5b3ea9342c | https://github.com/jldec/pub-preview/blob/55df6500200cbad4a4a03d8da86fef5b3ea9342c/jqueryview.js#L49-L106 | train |
jldec/pub-preview | jqueryview.js | layoutChanged | function layoutChanged(oldpage, newpage) {
if (oldpage && oldpage.fixlayout) return true;
if (lang(oldpage) !== lang(newpage)) return true;
var currentlayout = $layout.attr('data-render-layout') || 'main-layout';
var newlayout = generator.layoutTemplate(newpage);
return (newlayout !== curr... | javascript | function layoutChanged(oldpage, newpage) {
if (oldpage && oldpage.fixlayout) return true;
if (lang(oldpage) !== lang(newpage)) return true;
var currentlayout = $layout.attr('data-render-layout') || 'main-layout';
var newlayout = generator.layoutTemplate(newpage);
return (newlayout !== curr... | [
"function",
"layoutChanged",
"(",
"oldpage",
",",
"newpage",
")",
"{",
"if",
"(",
"oldpage",
"&&",
"oldpage",
".",
"fixlayout",
")",
"return",
"true",
";",
"if",
"(",
"lang",
"(",
"oldpage",
")",
"!==",
"lang",
"(",
"newpage",
")",
")",
"return",
"true... | return true if newpage layout is different from current layout | [
"return",
"true",
"if",
"newpage",
"layout",
"is",
"different",
"from",
"current",
"layout"
] | 55df6500200cbad4a4a03d8da86fef5b3ea9342c | https://github.com/jldec/pub-preview/blob/55df6500200cbad4a4a03d8da86fef5b3ea9342c/jqueryview.js#L98-L104 | train |
jldec/pub-preview | jqueryview.js | updateHtml | function updateHtml(href) {
var fragment = generator.fragment$[href];
if (!fragment) return generator.emit('notify', 'Oops, jqueryview cannot find fragment: ' + href);
var $html = $('[data-render-html="' + href + '"]');
if (!$html.length) return generator.emit('notify', 'Oops, jqueryview cannot update ... | javascript | function updateHtml(href) {
var fragment = generator.fragment$[href];
if (!fragment) return generator.emit('notify', 'Oops, jqueryview cannot find fragment: ' + href);
var $html = $('[data-render-html="' + href + '"]');
if (!$html.length) return generator.emit('notify', 'Oops, jqueryview cannot update ... | [
"function",
"updateHtml",
"(",
"href",
")",
"{",
"var",
"fragment",
"=",
"generator",
".",
"fragment$",
"[",
"href",
"]",
";",
"if",
"(",
"!",
"fragment",
")",
"return",
"generator",
".",
"emit",
"(",
"'notify'",
",",
"'Oops, jqueryview cannot find fragment: '... | this won't work if the href of a fragment is edited | [
"this",
"won",
"t",
"work",
"if",
"the",
"href",
"of",
"a",
"fragment",
"is",
"edited"
] | 55df6500200cbad4a4a03d8da86fef5b3ea9342c | https://github.com/jldec/pub-preview/blob/55df6500200cbad4a4a03d8da86fef5b3ea9342c/jqueryview.js#L109-L119 | train |
diggerio/digger-level | db/append.js | appendModel | function appendModel(url, model, done){
var list = utils.flatten_tree(JSON.parse(JSON.stringify(model)))
var errormodel = null
list = list.filter(function(model){
if(!model._digger.path || !model._digger.inode){
errormodel = model;
return false;
}
return true
})
if(errormodel){
return d... | javascript | function appendModel(url, model, done){
var list = utils.flatten_tree(JSON.parse(JSON.stringify(model)))
var errormodel = null
list = list.filter(function(model){
if(!model._digger.path || !model._digger.inode){
errormodel = model;
return false;
}
return true
})
if(errormodel){
return d... | [
"function",
"appendModel",
"(",
"url",
",",
"model",
",",
"done",
")",
"{",
"var",
"list",
"=",
"utils",
".",
"flatten_tree",
"(",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"model",
")",
")",
")",
"var",
"errormodel",
"=",
"null",
"li... | append a single model | [
"append",
"a",
"single",
"model"
] | 5ec947f28dd781171aa9db3fe457aee6b7b8c27d | https://github.com/diggerio/digger-level/blob/5ec947f28dd781171aa9db3fe457aee6b7b8c27d/db/append.js#L13-L42 | train |
wilmoore/string-prepend.js | index.js | prepend | function prepend(pre) {
function prepender(string) { return pre + string; }
return arguments.length > 1
? prepender(arguments[1])
: prepender;
} | javascript | function prepend(pre) {
function prepender(string) { return pre + string; }
return arguments.length > 1
? prepender(arguments[1])
: prepender;
} | [
"function",
"prepend",
"(",
"pre",
")",
"{",
"function",
"prepender",
"(",
"string",
")",
"{",
"return",
"pre",
"+",
"string",
";",
"}",
"return",
"arguments",
".",
"length",
">",
"1",
"?",
"prepender",
"(",
"arguments",
"[",
"1",
"]",
")",
":",
"pre... | Curried `String.prototype.prepend`.
@param {String} pre
String to prepend to original string.
@param {String} string
Original string.
@return {String}
String consisting of prepended and original string. | [
"Curried",
"String",
".",
"prototype",
".",
"prepend",
"."
] | 00089b79d75edb76db27a5750682c418b86218c0 | https://github.com/wilmoore/string-prepend.js/blob/00089b79d75edb76db27a5750682c418b86218c0/index.js#L22-L28 | train |
nwoltman/pro-array | pro-array.js | function(value, compareFunction) {
var low = 0;
var high = this.length;
var mid;
if (compareFunction) {
while (low < high) {
mid = low + high >>> 1;
var direction = compareFunction(this[mid], value);
if (!direction) {
return mid;
}
if (direction <... | javascript | function(value, compareFunction) {
var low = 0;
var high = this.length;
var mid;
if (compareFunction) {
while (low < high) {
mid = low + high >>> 1;
var direction = compareFunction(this[mid], value);
if (!direction) {
return mid;
}
if (direction <... | [
"function",
"(",
"value",
",",
"compareFunction",
")",
"{",
"var",
"low",
"=",
"0",
";",
"var",
"high",
"=",
"this",
".",
"length",
";",
"var",
"mid",
";",
"if",
"(",
"compareFunction",
")",
"{",
"while",
"(",
"low",
"<",
"high",
")",
"{",
"mid",
... | Finds the index of a value in a sorted array using a binary search algorithm.
If no `compareFunction` is supplied, the `>` and `<` relational operators are used to compare values,
which provides optimal performance for arrays of numbers and simple strings.
@function Array#bsearch
@param {*} value - The value to searc... | [
"Finds",
"the",
"index",
"of",
"a",
"value",
"in",
"a",
"sorted",
"array",
"using",
"a",
"binary",
"search",
"algorithm",
"."
] | c61a7be99e932912f95e553b57bf1bca16e3c709 | https://github.com/nwoltman/pro-array/blob/c61a7be99e932912f95e553b57bf1bca16e3c709/pro-array.js#L136-L169 | 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.