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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
mesmotronic/conbo | src/conbo/binding/BindingUtils.js | function(source, propertyName)
{
if (!conbo.isAccessor(source, propertyName) && !conbo.isFunc(source, propertyName))
{
if (source instanceof conbo.EventDispatcher)
{
conbo.makeBindable(source, [propertyName]);
}
else
{
conbo.warn('It will not be possible to detect changes to "'+pro... | javascript | function(source, propertyName)
{
if (!conbo.isAccessor(source, propertyName) && !conbo.isFunc(source, propertyName))
{
if (source instanceof conbo.EventDispatcher)
{
conbo.makeBindable(source, [propertyName]);
}
else
{
conbo.warn('It will not be possible to detect changes to "'+pro... | [
"function",
"(",
"source",
",",
"propertyName",
")",
"{",
"if",
"(",
"!",
"conbo",
".",
"isAccessor",
"(",
"source",
",",
"propertyName",
")",
"&&",
"!",
"conbo",
".",
"isFunc",
"(",
"source",
",",
"propertyName",
")",
")",
"{",
"if",
"(",
"source",
... | Attempt to make a property bindable if it isn't already
@private
@param {string} value
@returns {Boolean} | [
"Attempt",
"to",
"make",
"a",
"property",
"bindable",
"if",
"it",
"isn",
"t",
"already"
] | 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/BindingUtils.js#L56-L69 | train | |
mesmotronic/conbo | src/conbo/binding/BindingUtils.js | function(element, attributeName)
{
if (this.attributeExists(attributeName))
{
var camelCase = conbo.toCamelCase(attributeName),
ns = attributeName.split('-')[0],
attrFuncs = (ns == 'cb') ? BindingUtils__cbAttrs : BindingUtils__customAttrs,
fn = attrFuncs[camelCase]
;
i... | javascript | function(element, attributeName)
{
if (this.attributeExists(attributeName))
{
var camelCase = conbo.toCamelCase(attributeName),
ns = attributeName.split('-')[0],
attrFuncs = (ns == 'cb') ? BindingUtils__cbAttrs : BindingUtils__customAttrs,
fn = attrFuncs[camelCase]
;
i... | [
"function",
"(",
"element",
",",
"attributeName",
")",
"{",
"if",
"(",
"this",
".",
"attributeExists",
"(",
"attributeName",
")",
")",
"{",
"var",
"camelCase",
"=",
"conbo",
".",
"toCamelCase",
"(",
"attributeName",
")",
",",
"ns",
"=",
"attributeName",
".... | Applies the specified read-only Conbo or custom attribute to the specified element
@param {HTMLElement} element - DOM element to bind value to (two-way bind on input/form elements)
@param {string} attributeName - The attribute to bind as it appears in HTML, e.g. "cb-prop-name"
@returns {conbo.BindingUtils} A re... | [
"Applies",
"the",
"specified",
"read",
"-",
"only",
"Conbo",
"or",
"custom",
"attribute",
"to",
"the",
"specified",
"element"
] | 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/BindingUtils.js#L512-L537 | train | |
mesmotronic/conbo | src/conbo/binding/BindingUtils.js | function(view)
{
if (!view)
{
throw new Error('view is undefined');
}
if (!view.__bindings || !view.__bindings.length)
{
return this;
}
var bindings = view.__bindings;
while (bindings.length)
{
var binding = bindings.pop();
try
{
... | javascript | function(view)
{
if (!view)
{
throw new Error('view is undefined');
}
if (!view.__bindings || !view.__bindings.length)
{
return this;
}
var bindings = view.__bindings;
while (bindings.length)
{
var binding = bindings.pop();
try
{
... | [
"function",
"(",
"view",
")",
"{",
"if",
"(",
"!",
"view",
")",
"{",
"throw",
"new",
"Error",
"(",
"'view is undefined'",
")",
";",
"}",
"if",
"(",
"!",
"view",
".",
"__bindings",
"||",
"!",
"view",
".",
"__bindings",
".",
"length",
")",
"{",
"retu... | Removes all data binding from the specified View instance
@param {conbo.View} view
@returns {conbo.BindingUtils} A reference to this object | [
"Removes",
"all",
"data",
"binding",
"from",
"the",
"specified",
"View",
"instance"
] | 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/BindingUtils.js#L712-L740 | train | |
mesmotronic/conbo | src/conbo/binding/BindingUtils.js | function(rootView, namespace, type)
{
type || (type = 'view');
if (['view', 'glimpse'].indexOf(type) == -1)
{
throw new Error(type+' is not a valid type parameter for applyView');
}
var typeClass = conbo[type.charAt(0).toUpperCase()+type.slice(1)],
scope = this
;
... | javascript | function(rootView, namespace, type)
{
type || (type = 'view');
if (['view', 'glimpse'].indexOf(type) == -1)
{
throw new Error(type+' is not a valid type parameter for applyView');
}
var typeClass = conbo[type.charAt(0).toUpperCase()+type.slice(1)],
scope = this
;
... | [
"function",
"(",
"rootView",
",",
"namespace",
",",
"type",
")",
"{",
"type",
"||",
"(",
"type",
"=",
"'view'",
")",
";",
"if",
"(",
"[",
"'view'",
",",
"'glimpse'",
"]",
".",
"indexOf",
"(",
"type",
")",
"==",
"-",
"1",
")",
"{",
"throw",
"new",... | Applies View and Glimpse classes DOM elements based on their cb-view
attribute or tag name
@param {HTMLElement} rootView - DOM element, View or Application class instance
@param {conbo.Namespace} namespace - The current namespace
@param {string} [type=view] - View type, 'view' or 'glimpse'
@returns {conbo.Bin... | [
"Applies",
"View",
"and",
"Glimpse",
"classes",
"DOM",
"elements",
"based",
"on",
"their",
"cb",
"-",
"view",
"attribute",
"or",
"tag",
"name"
] | 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/BindingUtils.js#L751-L794 | train | |
mesmotronic/conbo | src/conbo/binding/BindingUtils.js | function(className, namespace)
{
if (!className || !namespace) return;
try
{
var classReference = namespace[className];
if (conbo.isClass(classReference))
{
return classReference;
}
}
catch (e) {}
} | javascript | function(className, namespace)
{
if (!className || !namespace) return;
try
{
var classReference = namespace[className];
if (conbo.isClass(classReference))
{
return classReference;
}
}
catch (e) {}
} | [
"function",
"(",
"className",
",",
"namespace",
")",
"{",
"if",
"(",
"!",
"className",
"||",
"!",
"namespace",
")",
"return",
";",
"try",
"{",
"var",
"classReference",
"=",
"namespace",
"[",
"className",
"]",
";",
"if",
"(",
"conbo",
".",
"isClass",
"(... | Attempt to convert string into a conbo.Class in the specified namespace
@param {string} className - The name of the class
@param {conbo.Namespace} namespace - The namespace containing the class
@returns {*} | [
"Attempt",
"to",
"convert",
"string",
"into",
"a",
"conbo",
".",
"Class",
"in",
"the",
"specified",
"namespace"
] | 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/BindingUtils.js#L892-L906 | train | |
mesmotronic/conbo | src/conbo/binding/BindingUtils.js | function(name, handler, readOnly, raw)
{
if (!conbo.isString(name) || !conbo.isFunction(handler))
{
conbo.warn("registerAttribute: both 'name' and 'handler' parameters are required");
return this;
}
var split = conbo.toUnderscoreCase(name).split('_');
if (split.length < 2)
... | javascript | function(name, handler, readOnly, raw)
{
if (!conbo.isString(name) || !conbo.isFunction(handler))
{
conbo.warn("registerAttribute: both 'name' and 'handler' parameters are required");
return this;
}
var split = conbo.toUnderscoreCase(name).split('_');
if (split.length < 2)
... | [
"function",
"(",
"name",
",",
"handler",
",",
"readOnly",
",",
"raw",
")",
"{",
"if",
"(",
"!",
"conbo",
".",
"isString",
"(",
"name",
")",
"||",
"!",
"conbo",
".",
"isFunction",
"(",
"handler",
")",
")",
"{",
"conbo",
".",
"warn",
"(",
"\"register... | Register a custom attribute handler
@param {string} name - camelCase version of the attribute name (must include a namespace prefix)
@param {Function} handler - function that will handle the data bound to the element
@param {boolean} readOnly - Whether or not the attribute is read-only (default: false)
@param {b... | [
"Register",
"a",
"custom",
"attribute",
"handler"
] | 339df613eefc48e054e115337079573ad842f717 | https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/src/conbo/binding/BindingUtils.js#L924-L959 | train | |
invercity/easy-report | lib.js | function(mask) {
var borders = ['border-top','border-right', 'border-bottom', 'border-left'];
var res = {};
for (var i = 0; i < 4; i++) {
if (!(mask & bin(i))) res[borders[i]] = 'none';
}
return res;
} | javascript | function(mask) {
var borders = ['border-top','border-right', 'border-bottom', 'border-left'];
var res = {};
for (var i = 0; i < 4; i++) {
if (!(mask & bin(i))) res[borders[i]] = 'none';
}
return res;
} | [
"function",
"(",
"mask",
")",
"{",
"var",
"borders",
"=",
"[",
"'border-top'",
",",
"'border-right'",
",",
"'border-bottom'",
",",
"'border-left'",
"]",
";",
"var",
"res",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";... | Exclude borders with 'none-border
@param mask
@return {{}} | [
"Exclude",
"borders",
"with",
"none",
"-",
"border"
] | 92e56a1fd98e6f07d31d5c91149eda9981d3b4b3 | https://github.com/invercity/easy-report/blob/92e56a1fd98e6f07d31d5c91149eda9981d3b4b3/lib.js#L50-L57 | train | |
invercity/easy-report | lib.js | function (obj) {
var clone = _.clone(obj);
if (obj.style) {
var style = obj.style;
clone.style = {
"font-family": style.fontFamily,
"font-size": style.fontSize + "px",
"font-weight": (style.mask & bin(4)) ? "bold" : "normal",
... | javascript | function (obj) {
var clone = _.clone(obj);
if (obj.style) {
var style = obj.style;
clone.style = {
"font-family": style.fontFamily,
"font-size": style.fontSize + "px",
"font-weight": (style.mask & bin(4)) ? "bold" : "normal",
... | [
"function",
"(",
"obj",
")",
"{",
"var",
"clone",
"=",
"_",
".",
"clone",
"(",
"obj",
")",
";",
"if",
"(",
"obj",
".",
"style",
")",
"{",
"var",
"style",
"=",
"obj",
".",
"style",
";",
"clone",
".",
"style",
"=",
"{",
"\"font-family\"",
":",
"s... | Replace object.style with real style
@param obj
@return {*} | [
"Replace",
"object",
".",
"style",
"with",
"real",
"style"
] | 92e56a1fd98e6f07d31d5c91149eda9981d3b4b3 | https://github.com/invercity/easy-report/blob/92e56a1fd98e6f07d31d5c91149eda9981d3b4b3/lib.js#L64-L85 | train | |
AlexisNo/pebo | index.js | callListenersSequentially | function callListenersSequentially(i, args) {
if (!this.events[eventName][i]) {
// If there is no more listener to execute, we return a promise of the event arguments/result
// So we are getting out of the recursive function
return new Promise((resolve, reject) => {
resolve(args);
})... | javascript | function callListenersSequentially(i, args) {
if (!this.events[eventName][i]) {
// If there is no more listener to execute, we return a promise of the event arguments/result
// So we are getting out of the recursive function
return new Promise((resolve, reject) => {
resolve(args);
})... | [
"function",
"callListenersSequentially",
"(",
"i",
",",
"args",
")",
"{",
"if",
"(",
"!",
"this",
".",
"events",
"[",
"eventName",
"]",
"[",
"i",
"]",
")",
"{",
"// If there is no more listener to execute, we return a promise of the event arguments/result",
"// So we ar... | Define a recusive function that will check if a plugin implements the hook, execute it and pass the eventually transformed arguments to the next one | [
"Define",
"a",
"recusive",
"function",
"that",
"will",
"check",
"if",
"a",
"plugin",
"implements",
"the",
"hook",
"execute",
"it",
"and",
"pass",
"the",
"eventually",
"transformed",
"arguments",
"to",
"the",
"next",
"one"
] | 59fe7698a099a12c469b09d3c1cda2a9e334f87e | https://github.com/AlexisNo/pebo/blob/59fe7698a099a12c469b09d3c1cda2a9e334f87e/index.js#L57-L80 | train |
xudafeng/passme | demo/editor/kissy.js | function (arr, callback, initialValue) {
var len = arr.length;
if (typeof callback !== 'function') {
throw new TypeError('callback is not function!');
}
// no value to return if no initial value and an empty array
if (len === 0 && arguments.le... | javascript | function (arr, callback, initialValue) {
var len = arr.length;
if (typeof callback !== 'function') {
throw new TypeError('callback is not function!');
}
// no value to return if no initial value and an empty array
if (len === 0 && arguments.le... | [
"function",
"(",
"arr",
",",
"callback",
",",
"initialValue",
")",
"{",
"var",
"len",
"=",
"arr",
".",
"length",
";",
"if",
"(",
"typeof",
"callback",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'callback is not function!'",
")",
";",... | Executes the supplied function on each item in the array.
Returns a value which is accumulation of the value that the supplied
function returned.
@param arr {Array} the array to iterate
@param callback {Function} the function to execute on each item
@param initialValue {number} optional context object
refer: https://d... | [
"Executes",
"the",
"supplied",
"function",
"on",
"each",
"item",
"in",
"the",
"array",
".",
"Returns",
"a",
"value",
"which",
"is",
"accumulation",
"of",
"the",
"value",
"that",
"the",
"supplied",
"function",
"returned",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L906-L946 | train | |
xudafeng/passme | demo/editor/kissy.js | function (o) {
if (o == null) {
return [];
}
if (S.isArray(o)) {
return o;
}
var lengthType = typeof o.length,
oType = typeof o;
// The strings and functions also have 'length'
if (lengthT... | javascript | function (o) {
if (o == null) {
return [];
}
if (S.isArray(o)) {
return o;
}
var lengthType = typeof o.length,
oType = typeof o;
// The strings and functions also have 'length'
if (lengthT... | [
"function",
"(",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"S",
".",
"isArray",
"(",
"o",
")",
")",
"{",
"return",
"o",
";",
"}",
"var",
"lengthType",
"=",
"typeof",
"o",
".",
"length",
... | Converts object to a TRUE array.
@param o {object|Array} array like object or array
@return {Array} native Array
@member KISSY | [
"Converts",
"object",
"to",
"a",
"TRUE",
"array",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L999-L1025 | train | |
xudafeng/passme | demo/editor/kissy.js | function (path, ext) {
var result = path.match(splitPathRe) || [],
basename;
basename = result[3] || '';
if (ext && basename && basename.slice(-1 * ext.length) == ext) {
basename = basename.slice(0, -1 * ext.length);
}
return ba... | javascript | function (path, ext) {
var result = path.match(splitPathRe) || [],
basename;
basename = result[3] || '';
if (ext && basename && basename.slice(-1 * ext.length) == ext) {
basename = basename.slice(0, -1 * ext.length);
}
return ba... | [
"function",
"(",
"path",
",",
"ext",
")",
"{",
"var",
"result",
"=",
"path",
".",
"match",
"(",
"splitPathRe",
")",
"||",
"[",
"]",
",",
"basename",
";",
"basename",
"=",
"result",
"[",
"3",
"]",
"||",
"''",
";",
"if",
"(",
"ext",
"&&",
"basename... | Get base name of path
@param {String} path
@param {String} [ext] ext to be stripped from result returned.
@return {String} | [
"Get",
"base",
"name",
"of",
"path"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L2180-L2188 | train | |
xudafeng/passme | demo/editor/kissy.js | function (key, value) {
var self = this,
_queryMap,
currentValue;
if (typeof key == 'string') {
parseQuery(self);
_queryMap = self._queryMap;
currentValue = _queryMap[key];
if (currentValue === undefi... | javascript | function (key, value) {
var self = this,
_queryMap,
currentValue;
if (typeof key == 'string') {
parseQuery(self);
_queryMap = self._queryMap;
currentValue = _queryMap[key];
if (currentValue === undefi... | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"var",
"self",
"=",
"this",
",",
"_queryMap",
",",
"currentValue",
";",
"if",
"(",
"typeof",
"key",
"==",
"'string'",
")",
"{",
"parseQuery",
"(",
"self",
")",
";",
"_queryMap",
"=",
"self",
".",
"_quer... | Add parameter value corresponding to current key
@param {String} key
@param value
@chainable | [
"Add",
"parameter",
"value",
"corresponding",
"to",
"current",
"key"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L2450-L2473 | train | |
xudafeng/passme | demo/editor/kissy.js | function (other) {
var self = this;
// port and hostname has to be same
return equalsIgnoreCase(self.hostname, other['hostname']) &&
equalsIgnoreCase(self.scheme, other['scheme']) &&
equalsIgnoreCase(self.port, other['port']);
} | javascript | function (other) {
var self = this;
// port and hostname has to be same
return equalsIgnoreCase(self.hostname, other['hostname']) &&
equalsIgnoreCase(self.scheme, other['scheme']) &&
equalsIgnoreCase(self.port, other['port']);
} | [
"function",
"(",
"other",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// port and hostname has to be same",
"return",
"equalsIgnoreCase",
"(",
"self",
".",
"hostname",
",",
"other",
"[",
"'hostname'",
"]",
")",
"&&",
"equalsIgnoreCase",
"(",
"self",
".",
"sche... | Judge whether two uri has same domain.
@param {KISSY.Uri} other
@return {Boolean} | [
"Judge",
"whether",
"two",
"uri",
"has",
"same",
"domain",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L2809-L2815 | train | |
xudafeng/passme | demo/editor/kissy.js | function (serializeArray) {
var out = [],
self = this,
scheme,
hostname,
path,
port,
fragment,
query,
userInfo;
if (scheme = self.scheme) {
out.push(e... | javascript | function (serializeArray) {
var out = [],
self = this,
scheme,
hostname,
path,
port,
fragment,
query,
userInfo;
if (scheme = self.scheme) {
out.push(e... | [
"function",
"(",
"serializeArray",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"self",
"=",
"this",
",",
"scheme",
",",
"hostname",
",",
"path",
",",
"port",
",",
"fragment",
",",
"query",
",",
"userInfo",
";",
"if",
"(",
"scheme",
"=",
"self",
"."... | Serialize to string.
See rfc 5.3 Component Recomposition.
But kissy does not differentiate between undefined and empty.
@param {Boolean} [serializeArray=true]
whether append [] to key name when value 's type is array
@return {String} | [
"Serialize",
"to",
"string",
".",
"See",
"rfc",
"5",
".",
"3",
"Component",
"Recomposition",
".",
"But",
"kissy",
"does",
"not",
"differentiate",
"between",
"undefined",
"and",
"empty",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L2825-L2876 | train | |
xudafeng/passme | demo/editor/kissy.js | function (runtime, modNames) {
S.each(modNames, function (m) {
Utils.createModuleInfo(runtime, m);
});
} | javascript | function (runtime, modNames) {
S.each(modNames, function (m) {
Utils.createModuleInfo(runtime, m);
});
} | [
"function",
"(",
"runtime",
",",
"modNames",
")",
"{",
"S",
".",
"each",
"(",
"modNames",
",",
"function",
"(",
"m",
")",
"{",
"Utils",
".",
"createModuleInfo",
"(",
"runtime",
",",
"m",
")",
";",
"}",
")",
";",
"}"
] | create modules info
@param runtime Module container, such as KISSY
@param {String[]} modNames to be created module names | [
"create",
"modules",
"info"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L3619-L3623 | train | |
xudafeng/passme | demo/editor/kissy.js | function (runtime, modNames) {
var mods = [runtime], mod,
unalias,
allOk,
m,
runtimeMods = runtime.Env.mods;
S.each(modNames, function (modName) {
mod = runtimeMods[modName];
if (!mod || mod.getType(... | javascript | function (runtime, modNames) {
var mods = [runtime], mod,
unalias,
allOk,
m,
runtimeMods = runtime.Env.mods;
S.each(modNames, function (modName) {
mod = runtimeMods[modName];
if (!mod || mod.getType(... | [
"function",
"(",
"runtime",
",",
"modNames",
")",
"{",
"var",
"mods",
"=",
"[",
"runtime",
"]",
",",
"mod",
",",
"unalias",
",",
"allOk",
",",
"m",
",",
"runtimeMods",
"=",
"runtime",
".",
"Env",
".",
"mods",
";",
"S",
".",
"each",
"(",
"modNames",... | Get module values
@param runtime Module container, such as KISSY
@param {String[]} modNames module names
@return {Array} module values | [
"Get",
"module",
"values"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L3667-L3691 | train | |
xudafeng/passme | demo/editor/kissy.js | function (runtime, mod) {
if (mod.status != LOADED) {
return;
}
var fn = mod.fn;
if (typeof fn === 'function') {
// 需要解开 index,相对路径
// 但是需要保留 alias,防止值不对应
mod.value = fn.apply(mod, Utils.getModules(runtime,... | javascript | function (runtime, mod) {
if (mod.status != LOADED) {
return;
}
var fn = mod.fn;
if (typeof fn === 'function') {
// 需要解开 index,相对路径
// 但是需要保留 alias,防止值不对应
mod.value = fn.apply(mod, Utils.getModules(runtime,... | [
"function",
"(",
"runtime",
",",
"mod",
")",
"{",
"if",
"(",
"mod",
".",
"status",
"!=",
"LOADED",
")",
"{",
"return",
";",
"}",
"var",
"fn",
"=",
"mod",
".",
"fn",
";",
"if",
"(",
"typeof",
"fn",
"===",
"'function'",
")",
"{",
"// 需要解开 index,相对路径"... | Attach specified mod.
@param runtime Module container, such as KISSY
@param {KISSY.Loader.Module} mod module instance | [
"Attach",
"specified",
"mod",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L3768-L3784 | train | |
xudafeng/passme | demo/editor/kissy.js | function (runtime, path, rules) {
var mappedRules = rules ||
runtime.Config.mappedRules ||
[],
i,
m,
rule;
for (i = 0; i < mappedRules.length; i++) {
rule = mappedRules[i];
if ... | javascript | function (runtime, path, rules) {
var mappedRules = rules ||
runtime.Config.mappedRules ||
[],
i,
m,
rule;
for (i = 0; i < mappedRules.length; i++) {
rule = mappedRules[i];
if ... | [
"function",
"(",
"runtime",
",",
"path",
",",
"rules",
")",
"{",
"var",
"mappedRules",
"=",
"rules",
"||",
"runtime",
".",
"Config",
".",
"mappedRules",
"||",
"[",
"]",
",",
"i",
",",
"m",
",",
"rule",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
... | Get mapped path.
@param runtime Module container, such as KISSY
@param {String} path module path
@param [rules] map rules
@return {String} mapped path | [
"Get",
"mapped",
"path",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L3912-L3926 | train | |
xudafeng/passme | demo/editor/kissy.js | function () {
var self = this;
if (self.packageUri) {
return self.packageUri;
}
return self.packageUri = new S.Uri(this.getPrefixUriForCombo());
} | javascript | function () {
var self = this;
if (self.packageUri) {
return self.packageUri;
}
return self.packageUri = new S.Uri(this.getPrefixUriForCombo());
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"packageUri",
")",
"{",
"return",
"self",
".",
"packageUri",
";",
"}",
"return",
"self",
".",
"packageUri",
"=",
"new",
"S",
".",
"Uri",
"(",
"this",
".",
"getPrefi... | get package uri | [
"get",
"package",
"uri"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L4011-L4017 | train | |
xudafeng/passme | demo/editor/kissy.js | function () {
var self = this,
t,
fullPathUri,
packageBaseUri,
packageInfo,
packageName,
path;
if (!self.fullPathUri) {
if (self.fullpath) {
fullPathUri = new S.Uri... | javascript | function () {
var self = this,
t,
fullPathUri,
packageBaseUri,
packageInfo,
packageName,
path;
if (!self.fullPathUri) {
if (self.fullpath) {
fullPathUri = new S.Uri... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"t",
",",
"fullPathUri",
",",
"packageBaseUri",
",",
"packageInfo",
",",
"packageName",
",",
"path",
";",
"if",
"(",
"!",
"self",
".",
"fullPathUri",
")",
"{",
"if",
"(",
"self",
".",
"fullp... | Get the fullpath uri of current module if load dynamically
@return {KISSY.Uri} | [
"Get",
"the",
"fullpath",
"uri",
"of",
"current",
"module",
"if",
"load",
"dynamically"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L4133-L4163 | train | |
xudafeng/passme | demo/editor/kissy.js | function () {
var self = this,
fullPathUri;
if (!self.fullpath) {
fullPathUri = self.getFullPathUri();
self.fullpath = Utils.getMappedPath(self.runtime, fullPathUri.toString());
}
return self.fullpath;
} | javascript | function () {
var self = this,
fullPathUri;
if (!self.fullpath) {
fullPathUri = self.getFullPathUri();
self.fullpath = Utils.getMappedPath(self.runtime, fullPathUri.toString());
}
return self.fullpath;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"fullPathUri",
";",
"if",
"(",
"!",
"self",
".",
"fullpath",
")",
"{",
"fullPathUri",
"=",
"self",
".",
"getFullPathUri",
"(",
")",
";",
"self",
".",
"fullpath",
"=",
"Utils",
".",
"getMappe... | Get the fullpath of current module if load dynamically
@return {String} | [
"Get",
"the",
"fullpath",
"of",
"current",
"module",
"if",
"load",
"dynamically"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L4169-L4177 | train | |
xudafeng/passme | demo/editor/kissy.js | function () {
var self = this,
runtime = self.runtime;
return S.map(self.getNormalizedRequires(), function (r) {
return Utils.createModuleInfo(runtime, r);
});
} | javascript | function () {
var self = this,
runtime = self.runtime;
return S.map(self.getNormalizedRequires(), function (r) {
return Utils.createModuleInfo(runtime, r);
});
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"runtime",
"=",
"self",
".",
"runtime",
";",
"return",
"S",
".",
"map",
"(",
"self",
".",
"getNormalizedRequires",
"(",
")",
",",
"function",
"(",
"r",
")",
"{",
"return",
"Utils",
".",
"c... | Get module objects required by this module
@return {KISSY.Loader.Module[]} | [
"Get",
"module",
"objects",
"required",
"by",
"this",
"module"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L4238-L4244 | train | |
xudafeng/passme | demo/editor/kissy.js | function () {
var self = this,
normalizedRequires,
normalizedRequiresStatus = self.normalizedRequiresStatus,
status = self.status,
requires = self.requires;
if (!requires || requires.length == 0) {
return requires ||... | javascript | function () {
var self = this,
normalizedRequires,
normalizedRequiresStatus = self.normalizedRequiresStatus,
status = self.status,
requires = self.requires;
if (!requires || requires.length == 0) {
return requires ||... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"normalizedRequires",
",",
"normalizedRequiresStatus",
"=",
"self",
".",
"normalizedRequiresStatus",
",",
"status",
"=",
"self",
".",
"status",
",",
"requires",
"=",
"self",
".",
"requires",
";",
"i... | Get module names required by this module
@return {KISSY.Loader.Module[]} | [
"Get",
"module",
"names",
"required",
"by",
"this",
"module"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L4263-L4280 | train | |
xudafeng/passme | demo/editor/kissy.js | function (moduleName) {
var moduleNames = Utils.unalias(S, Utils.normalizeModNamesWithAlias(S, [moduleName]));
if (Utils.attachModsRecursively(moduleNames, S)) {
return Utils.getModules(S, moduleNames)[1];
}
return undefined;
} | javascript | function (moduleName) {
var moduleNames = Utils.unalias(S, Utils.normalizeModNamesWithAlias(S, [moduleName]));
if (Utils.attachModsRecursively(moduleNames, S)) {
return Utils.getModules(S, moduleNames)[1];
}
return undefined;
} | [
"function",
"(",
"moduleName",
")",
"{",
"var",
"moduleNames",
"=",
"Utils",
".",
"unalias",
"(",
"S",
",",
"Utils",
".",
"normalizeModNamesWithAlias",
"(",
"S",
",",
"[",
"moduleName",
"]",
")",
")",
";",
"if",
"(",
"Utils",
".",
"attachModsRecursively",
... | get module value from KISSY module cache
@param {String} moduleName module name
@member KISSY
@return {*} value of module which name is moduleName | [
"get",
"module",
"value",
"from",
"KISSY",
"module",
"cache"
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L5349-L5355 | train | |
xudafeng/passme | demo/editor/kissy.js | function (data) {
if (data && RE_NOT_WHITESPACE.test(data)) {
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
// http://msdn.microsoft.com/en-us/library/ie/ms536420(v=vs.85).aspx always return null
( win.execScript ||... | javascript | function (data) {
if (data && RE_NOT_WHITESPACE.test(data)) {
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
// http://msdn.microsoft.com/en-us/library/ie/ms536420(v=vs.85).aspx always return null
( win.execScript ||... | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
"&&",
"RE_NOT_WHITESPACE",
".",
"test",
"(",
"data",
")",
")",
"{",
"// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context",
"// http://msdn.microsoft.com/en-us/library/ie/ms536420(v=vs.85)... | Evaluates a script in a global context.
@member KISSY | [
"Evaluates",
"a",
"script",
"in",
"a",
"global",
"context",
"."
] | 14c5a9d76569fc67101b35284ea2f049bcc9896e | https://github.com/xudafeng/passme/blob/14c5a9d76569fc67101b35284ea2f049bcc9896e/demo/editor/kissy.js#L5570-L5578 | train | |
nodejitsu/contour | pagelets/pills.js | links | function links(options) {
var page = this.page;
return this.navigation.reduce(function reduce(menu, item) {
if (page === item.page) item.class = (item.class || '') + ' active';
if (item.class) item.class = ' class="' + item.class + '"';
if (item.swap) item.swap = ' data-swap="' + item.swap.h... | javascript | function links(options) {
var page = this.page;
return this.navigation.reduce(function reduce(menu, item) {
if (page === item.page) item.class = (item.class || '') + ' active';
if (item.class) item.class = ' class="' + item.class + '"';
if (item.swap) item.swap = ' data-swap="' + item.swap.h... | [
"function",
"links",
"(",
"options",
")",
"{",
"var",
"page",
"=",
"this",
".",
"page",
";",
"return",
"this",
".",
"navigation",
".",
"reduce",
"(",
"function",
"reduce",
"(",
"menu",
",",
"item",
")",
"{",
"if",
"(",
"page",
"===",
"item",
".",
"... | Handblebar helper to generate each pill. The base is defined by
the active page and should match the page defined in the navigation.
@param {Object} options
@return {String} generated template
@api private | [
"Handblebar",
"helper",
"to",
"generate",
"each",
"pill",
".",
"The",
"base",
"is",
"defined",
"by",
"the",
"active",
"page",
"and",
"should",
"match",
"the",
"page",
"defined",
"in",
"the",
"navigation",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/pills.js#L46-L59 | train |
vid/SenseBase | lib/pubsub-client.js | publish | function publish(loc, data) {
data = data || {};
data.clientID = clientID;
fayeClient.publish(loc, data);
} | javascript | function publish(loc, data) {
data = data || {};
data.clientID = clientID;
fayeClient.publish(loc, data);
} | [
"function",
"publish",
"(",
"loc",
",",
"data",
")",
"{",
"data",
"=",
"data",
"||",
"{",
"}",
";",
"data",
".",
"clientID",
"=",
"clientID",
";",
"fayeClient",
".",
"publish",
"(",
"loc",
",",
"data",
")",
";",
"}"
] | send clientID with publish | [
"send",
"clientID",
"with",
"publish"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub-client.js#L16-L20 | train |
vid/SenseBase | lib/pubsub-client.js | function(title, content, callback) {
console.log('mltc');
publish('/query/moreLikeThisContent', { title: title, content: content });
results(callback);
} | javascript | function(title, content, callback) {
console.log('mltc');
publish('/query/moreLikeThisContent', { title: title, content: content });
results(callback);
} | [
"function",
"(",
"title",
",",
"content",
",",
"callback",
")",
"{",
"console",
".",
"log",
"(",
"'mltc'",
")",
";",
"publish",
"(",
"'/query/moreLikeThisContent'",
",",
"{",
"title",
":",
"title",
",",
"content",
":",
"content",
"}",
")",
";",
"results"... | Perform a moreLikeThis query for text | [
"Perform",
"a",
"moreLikeThis",
"query",
"for",
"text"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub-client.js#L93-L97 | train | |
vid/SenseBase | lib/pubsub-client.js | function(options, cb) {
console.log('/watch/request', options);
publish('/watch/request', options);
fayeClient.subscribe('/watch/results/' + clientID, cb);
} | javascript | function(options, cb) {
console.log('/watch/request', options);
publish('/watch/request', options);
fayeClient.subscribe('/watch/results/' + clientID, cb);
} | [
"function",
"(",
"options",
",",
"cb",
")",
"{",
"console",
".",
"log",
"(",
"'/watch/request'",
",",
"options",
")",
";",
"publish",
"(",
"'/watch/request'",
",",
"options",
")",
";",
"fayeClient",
".",
"subscribe",
"(",
"'/watch/results/'",
"+",
"clientID"... | Request subscriptions for user. | [
"Request",
"subscriptions",
"for",
"user",
"."
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub-client.js#L213-L217 | train | |
folkelib/folke-ko-infinite-scroll | dist/index.js | isElementInViewport | function isElementInViewport(el) {
var eap;
var rect = el.getBoundingClientRect();
var docEl = document.documentElement;
var vWidth = window.innerWidth || docEl.clientWidth;
var vHeight = window.innerHeight || docEl.clientHeight;
var efp = function (x, y) { return document.elementFromPoint(x, y)... | javascript | function isElementInViewport(el) {
var eap;
var rect = el.getBoundingClientRect();
var docEl = document.documentElement;
var vWidth = window.innerWidth || docEl.clientWidth;
var vHeight = window.innerHeight || docEl.clientHeight;
var efp = function (x, y) { return document.elementFromPoint(x, y)... | [
"function",
"isElementInViewport",
"(",
"el",
")",
"{",
"var",
"eap",
";",
"var",
"rect",
"=",
"el",
".",
"getBoundingClientRect",
"(",
")",
";",
"var",
"docEl",
"=",
"document",
".",
"documentElement",
";",
"var",
"vWidth",
"=",
"window",
".",
"innerWidth... | Checks if an element is in the viewport | [
"Checks",
"if",
"an",
"element",
"is",
"in",
"the",
"viewport"
] | 49aa555139b4f5cc7f75d47553b2b9b50b87bdf4 | https://github.com/folkelib/folke-ko-infinite-scroll/blob/49aa555139b4f5cc7f75d47553b2b9b50b87bdf4/dist/index.js#L17-L34 | train |
canvaspop/grunt-static-versioning | tasks/versioning.js | versioningJSON | function versioningJSON ( obj, dest, ns ) {
var content = {};
content[ ns ] = obj;
var json = JSON.stringify( content, null, 2 );
grunt.log.subhead( 'Generating JSON config file' );
grunt.file.write( dest + '/assets.config.json', json );
grunt.log.ok( 'File "' + dest + '/... | javascript | function versioningJSON ( obj, dest, ns ) {
var content = {};
content[ ns ] = obj;
var json = JSON.stringify( content, null, 2 );
grunt.log.subhead( 'Generating JSON config file' );
grunt.file.write( dest + '/assets.config.json', json );
grunt.log.ok( 'File "' + dest + '/... | [
"function",
"versioningJSON",
"(",
"obj",
",",
"dest",
",",
"ns",
")",
"{",
"var",
"content",
"=",
"{",
"}",
";",
"content",
"[",
"ns",
"]",
"=",
"obj",
";",
"var",
"json",
"=",
"JSON",
".",
"stringify",
"(",
"content",
",",
"null",
",",
"2",
")"... | Generate a JSON config file
@todo Determine if keeping these in this file is the right approach
@param {Object} obj Versioning object created by the task
@param {String} dest Location to save the generated config file
@param {String} ns Namespace to wrap config content
@return {undefined} | [
"Generate",
"a",
"JSON",
"config",
"file"
] | f347fd40e86aee639ba0e3502ae3828705ed9434 | https://github.com/canvaspop/grunt-static-versioning/blob/f347fd40e86aee639ba0e3502ae3828705ed9434/tasks/versioning.js#L134-L141 | train |
canvaspop/grunt-static-versioning | tasks/versioning.js | versioningPHP | function versioningPHP ( obj, dest, ns ) {
var contents = '<?php\n';
contents += 'return array(\n';
contents += ' \'' + ns + '\' => array(\n';
for ( var key in obj ) {
if ( obj.hasOwnProperty( key ) ) {
contents += ' \'' + key + '\' => array(\n';
... | javascript | function versioningPHP ( obj, dest, ns ) {
var contents = '<?php\n';
contents += 'return array(\n';
contents += ' \'' + ns + '\' => array(\n';
for ( var key in obj ) {
if ( obj.hasOwnProperty( key ) ) {
contents += ' \'' + key + '\' => array(\n';
... | [
"function",
"versioningPHP",
"(",
"obj",
",",
"dest",
",",
"ns",
")",
"{",
"var",
"contents",
"=",
"'<?php\\n'",
";",
"contents",
"+=",
"'return array(\\n'",
";",
"contents",
"+=",
"' \\''",
"+",
"ns",
"+",
"'\\' => array(\\n'",
";",
"for",
"(",
"var",
... | Generate a PHP config file
@todo Determine if keeping these in this file is the right approach
@param {Object} obj Versioning object created by the task
@param {String} dest Location to save the generated config file
@param {String} ns Namespace to wrap config content
@return {undefined} | [
"Generate",
"a",
"PHP",
"config",
"file"
] | f347fd40e86aee639ba0e3502ae3828705ed9434 | https://github.com/canvaspop/grunt-static-versioning/blob/f347fd40e86aee639ba0e3502ae3828705ed9434/tasks/versioning.js#L153-L175 | train |
Stitchuuuu/thread-promisify | index.js | ParseMessageFromThread | function ParseMessageFromThread(o) {
var o = UnserializeFromProcess(o);
if (typeof(o) == "object" && o.name && o.args) {
// Process response from the thread
// Electron: If we are in the Main Process, and it is not a global message, we executed it too
if (!isElectron || electron.ipcRend... | javascript | function ParseMessageFromThread(o) {
var o = UnserializeFromProcess(o);
if (typeof(o) == "object" && o.name && o.args) {
// Process response from the thread
// Electron: If we are in the Main Process, and it is not a global message, we executed it too
if (!isElectron || electron.ipcRend... | [
"function",
"ParseMessageFromThread",
"(",
"o",
")",
"{",
"var",
"o",
"=",
"UnserializeFromProcess",
"(",
"o",
")",
";",
"if",
"(",
"typeof",
"(",
"o",
")",
"==",
"\"object\"",
"&&",
"o",
".",
"name",
"&&",
"o",
".",
"args",
")",
"{",
"// Process respo... | Parse the message from the thread or just passthrough to the Electron Renderer Process concerned | [
"Parse",
"the",
"message",
"from",
"the",
"thread",
"or",
"just",
"passthrough",
"to",
"the",
"Electron",
"Renderer",
"Process",
"concerned"
] | 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/index.js#L159-L175 | train |
Stitchuuuu/thread-promisify | index.js | CheckPendingThreadRequests | function CheckPendingThreadRequests() {
while (PendingThreadRequests.length) {
var tq = PendingThreadRequests.shift();
if (!SendThreadRequest(tq)) {
// No available thread, we queue the request, again
PendingThreadRequests.unshift(tq);
break;
}
}
} | javascript | function CheckPendingThreadRequests() {
while (PendingThreadRequests.length) {
var tq = PendingThreadRequests.shift();
if (!SendThreadRequest(tq)) {
// No available thread, we queue the request, again
PendingThreadRequests.unshift(tq);
break;
}
}
} | [
"function",
"CheckPendingThreadRequests",
"(",
")",
"{",
"while",
"(",
"PendingThreadRequests",
".",
"length",
")",
"{",
"var",
"tq",
"=",
"PendingThreadRequests",
".",
"shift",
"(",
")",
";",
"if",
"(",
"!",
"SendThreadRequest",
"(",
"tq",
")",
")",
"{",
... | Check if there is a request waiting and execute it on an inactive thread available | [
"Check",
"if",
"there",
"is",
"a",
"request",
"waiting",
"and",
"execute",
"it",
"on",
"an",
"inactive",
"thread",
"available"
] | 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/index.js#L183-L192 | train |
Stitchuuuu/thread-promisify | index.js | findObject | function findObject(c, obj, path, alreadyParsed) {
if (!path) {
path = [];
}
// Recursive reference : boooh, very wrong
if (!alreadyParsed) {
alreadyParsed = [];
}
var keys = Object.keys(obj);
alreadyParsed.push(obj);
for (var key = 0; key < keys.length; key++) {
... | javascript | function findObject(c, obj, path, alreadyParsed) {
if (!path) {
path = [];
}
// Recursive reference : boooh, very wrong
if (!alreadyParsed) {
alreadyParsed = [];
}
var keys = Object.keys(obj);
alreadyParsed.push(obj);
for (var key = 0; key < keys.length; key++) {
... | [
"function",
"findObject",
"(",
"c",
",",
"obj",
",",
"path",
",",
"alreadyParsed",
")",
"{",
"if",
"(",
"!",
"path",
")",
"{",
"path",
"=",
"[",
"]",
";",
"}",
"// Recursive reference : boooh, very wrong",
"if",
"(",
"!",
"alreadyParsed",
")",
"{",
"alre... | Find an object recursively and return the path where it was founded
Use in Threadify function to find the module and the path to the object
so we can clone it in the thread | [
"Find",
"an",
"object",
"recursively",
"and",
"return",
"the",
"path",
"where",
"it",
"was",
"founded",
"Use",
"in",
"Threadify",
"function",
"to",
"find",
"the",
"module",
"and",
"the",
"path",
"to",
"the",
"object",
"so",
"we",
"can",
"clone",
"it",
"i... | 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/index.js#L414-L444 | train |
Stitchuuuu/thread-promisify | index.js | Threadify | function Threadify(options) {
if (typeof(options) == "string") {
options = {methods: [options]};
} else if (Array.isArray(options)) {
options = {methods: options};
} else {
if (options !== undefined && typeof(options) != "object") {
throw new Error("[Threadify] You must s... | javascript | function Threadify(options) {
if (typeof(options) == "string") {
options = {methods: [options]};
} else if (Array.isArray(options)) {
options = {methods: options};
} else {
if (options !== undefined && typeof(options) != "object") {
throw new Error("[Threadify] You must s... | [
"function",
"Threadify",
"(",
"options",
")",
"{",
"if",
"(",
"typeof",
"(",
"options",
")",
"==",
"\"string\"",
")",
"{",
"options",
"=",
"{",
"methods",
":",
"[",
"options",
"]",
"}",
";",
"}",
"else",
"if",
"(",
"Array",
".",
"isArray",
"(",
"op... | Threadify a class or an object defined in a separate uncore module
Cored module like fs, path, and others can't be threadified
Options can be:
- Nothing: all functions are threadified
- A String: the specific function is threadified
- An array of string: all the functions specified are threadified
For class only:
The... | [
"Threadify",
"a",
"class",
"or",
"an",
"object",
"defined",
"in",
"a",
"separate",
"uncore",
"module",
"Cored",
"module",
"like",
"fs",
"path",
"and",
"others",
"can",
"t",
"be",
"threadified"
] | 5c6fc0b481520049e2078461693ceee7c27ddd53 | https://github.com/Stitchuuuu/thread-promisify/blob/5c6fc0b481520049e2078461693ceee7c27ddd53/index.js#L461-L512 | train |
fullcube/loopback-component-meta | index.js | getSettings | function getSettings (def) {
var settings = {}
for (var s in def) {
if (def.hasOwnProperty(s)) {
if (s !== 'name' || s !== 'properties') {
settings[ s ] = def[ s ]
}
}
}
return settings
} | javascript | function getSettings (def) {
var settings = {}
for (var s in def) {
if (def.hasOwnProperty(s)) {
if (s !== 'name' || s !== 'properties') {
settings[ s ] = def[ s ]
}
}
}
return settings
} | [
"function",
"getSettings",
"(",
"def",
")",
"{",
"var",
"settings",
"=",
"{",
"}",
"for",
"(",
"var",
"s",
"in",
"def",
")",
"{",
"if",
"(",
"def",
".",
"hasOwnProperty",
"(",
"s",
")",
")",
"{",
"if",
"(",
"s",
"!==",
"'name'",
"||",
"s",
"!==... | Remove properties that will confuse LB | [
"Remove",
"properties",
"that",
"will",
"confuse",
"LB"
] | b91bc0e93881f8e47ac88a77d4a91231053b219a | https://github.com/fullcube/loopback-component-meta/blob/b91bc0e93881f8e47ac88a77d4a91231053b219a/index.js#L5-L15 | train |
vid/SenseBase | services/annotators/annotateLib.js | instancesFromMatches | function instancesFromMatches(word, text, selector) {
var match, ret = [];
var re = new RegExp('\\b'+utils.escapeRegex(word)+'\\b', 'gi');
var instance = 1;
while ((match = re.exec(text)) !== null) {
GLOBAL.debug(text.length, text.substring(0, 10), word, match.index, text.substr(match.index, word.length));
... | javascript | function instancesFromMatches(word, text, selector) {
var match, ret = [];
var re = new RegExp('\\b'+utils.escapeRegex(word)+'\\b', 'gi');
var instance = 1;
while ((match = re.exec(text)) !== null) {
GLOBAL.debug(text.length, text.substring(0, 10), word, match.index, text.substr(match.index, word.length));
... | [
"function",
"instancesFromMatches",
"(",
"word",
",",
"text",
",",
"selector",
")",
"{",
"var",
"match",
",",
"ret",
"=",
"[",
"]",
";",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"'\\\\b'",
"+",
"utils",
".",
"escapeRegex",
"(",
"word",
")",
"+",
"'\\\... | convert instances of a match to instances | [
"convert",
"instances",
"of",
"a",
"match",
"to",
"instances"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/services/annotators/annotateLib.js#L40-L53 | train |
vid/SenseBase | services/annotators/annotateLib.js | rangesFromMatches | function rangesFromMatches(word, text, selector) {
var ret = [], match;
var re = new RegExp('\\b'+word+'\\b', 'gi');
while ((match = re.exec(text)) !== null) {
GLOBAL.debug(text.length, text.substring(0, 10), word, match.index, text.substr(match.index, word.length));
ret.push(annoLib.createRange({exact: ... | javascript | function rangesFromMatches(word, text, selector) {
var ret = [], match;
var re = new RegExp('\\b'+word+'\\b', 'gi');
while ((match = re.exec(text)) !== null) {
GLOBAL.debug(text.length, text.substring(0, 10), word, match.index, text.substr(match.index, word.length));
ret.push(annoLib.createRange({exact: ... | [
"function",
"rangesFromMatches",
"(",
"word",
",",
"text",
",",
"selector",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
",",
"match",
";",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"'\\\\b'",
"+",
"word",
"+",
"'\\\\b'",
",",
"'gi'",
")",
";",
"while",
"(... | convert instances of a match to ranges | [
"convert",
"instances",
"of",
"a",
"match",
"to",
"ranges"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/services/annotators/annotateLib.js#L55-L63 | train |
jrmerz/node-ckan | lib/ckan-importer.js | setVocabIds | function setVocabIds(index, pkg, callback) {
if(!pkg.tags) return callback();
if( index == pkg.tags.length ) {
callback();
} else {
getVocabId(pkg.tags[index].vocabulary_id, function(id) {
pkg.tags[index].vocabulary_id = id;
index++;
setVocabIds(index, pkg, callback);
});
}
} | javascript | function setVocabIds(index, pkg, callback) {
if(!pkg.tags) return callback();
if( index == pkg.tags.length ) {
callback();
} else {
getVocabId(pkg.tags[index].vocabulary_id, function(id) {
pkg.tags[index].vocabulary_id = id;
index++;
setVocabIds(index, pkg, callback);
});
}
} | [
"function",
"setVocabIds",
"(",
"index",
",",
"pkg",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"pkg",
".",
"tags",
")",
"return",
"callback",
"(",
")",
";",
"if",
"(",
"index",
"==",
"pkg",
".",
"tags",
".",
"length",
")",
"{",
"callback",
"(",
... | we are going to assume people pass names in the vocabulary_id column to which point we need to look up the id from the name so package_create does the correct association | [
"we",
"are",
"going",
"to",
"assume",
"people",
"pass",
"names",
"in",
"the",
"vocabulary_id",
"column",
"to",
"which",
"point",
"we",
"need",
"to",
"look",
"up",
"the",
"id",
"from",
"the",
"name",
"so",
"package_create",
"does",
"the",
"correct",
"associ... | 55f6bb1ece7f57ccd5ba57be7888e4d3941bc659 | https://github.com/jrmerz/node-ckan/blob/55f6bb1ece7f57ccd5ba57be7888e4d3941bc659/lib/ckan-importer.js#L158-L170 | train |
jrmerz/node-ckan | lib/ckan-importer.js | getVocabId | function getVocabId(name, callback) {
if( vocabMap[name] ) return callback(vocabMap[name]);
ckan.exec("vocabulary_show", {id: name}, function(err, resp) {
if( err && JSON.parse(err.body).error.__type == 'Not Found Error' ) {
create("vocabulary", {name: name, tags: []}, function(err, resp){
if( err ) error(... | javascript | function getVocabId(name, callback) {
if( vocabMap[name] ) return callback(vocabMap[name]);
ckan.exec("vocabulary_show", {id: name}, function(err, resp) {
if( err && JSON.parse(err.body).error.__type == 'Not Found Error' ) {
create("vocabulary", {name: name, tags: []}, function(err, resp){
if( err ) error(... | [
"function",
"getVocabId",
"(",
"name",
",",
"callback",
")",
"{",
"if",
"(",
"vocabMap",
"[",
"name",
"]",
")",
"return",
"callback",
"(",
"vocabMap",
"[",
"name",
"]",
")",
";",
"ckan",
".",
"exec",
"(",
"\"vocabulary_show\"",
",",
"{",
"id",
":",
"... | if the id doesn't exist, create it | [
"if",
"the",
"id",
"doesn",
"t",
"exist",
"create",
"it"
] | 55f6bb1ece7f57ccd5ba57be7888e4d3941bc659 | https://github.com/jrmerz/node-ckan/blob/55f6bb1ece7f57ccd5ba57be7888e4d3941bc659/lib/ckan-importer.js#L173-L203 | train |
AsceticBoy/chilli-toolkit | tools/build/bundle.js | format | function format() {
var format = 'es' // default
var args = process.argv.slice(2)
outer:
for (var i = 0; i < formats.length; i++) {
for (var j = 0; j < args.length; j++) {
if (args[j].slice(0, 2) !== '--') { throw new TypeError('process args usage error'); break outer }
if (args[j].toLocaleLowe... | javascript | function format() {
var format = 'es' // default
var args = process.argv.slice(2)
outer:
for (var i = 0; i < formats.length; i++) {
for (var j = 0; j < args.length; j++) {
if (args[j].slice(0, 2) !== '--') { throw new TypeError('process args usage error'); break outer }
if (args[j].toLocaleLowe... | [
"function",
"format",
"(",
")",
"{",
"var",
"format",
"=",
"'es'",
"// default",
"var",
"args",
"=",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
"outer",
":",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"formats",
".",
"length",
";"... | output format type | [
"output",
"format",
"type"
] | a4f5f03ce55187a8c91b847e84d767357f347839 | https://github.com/AsceticBoy/chilli-toolkit/blob/a4f5f03ce55187a8c91b847e84d767357f347839/tools/build/bundle.js#L95-L107 | train |
AsceticBoy/chilli-toolkit | tools/build/bundle.js | write | function write(dir, code) {
return new Promise(function (resolve, reject) {
fse.ensureFile(dir, (err) => {
if (err) return reject(err)
fs.writeFile(dir, code, 'utf-8', (err) => {
if (err) {
return reject(err)
}
console.info(chalk.red(dir) + ' ' + chalk.green(getSize(c... | javascript | function write(dir, code) {
return new Promise(function (resolve, reject) {
fse.ensureFile(dir, (err) => {
if (err) return reject(err)
fs.writeFile(dir, code, 'utf-8', (err) => {
if (err) {
return reject(err)
}
console.info(chalk.red(dir) + ' ' + chalk.green(getSize(c... | [
"function",
"write",
"(",
"dir",
",",
"code",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"fse",
".",
"ensureFile",
"(",
"dir",
",",
"(",
"err",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"return",
... | Write code in dir path
@param { String } dir file path dir
@param { String | Buffer } code code | [
"Write",
"code",
"in",
"dir",
"path"
] | a4f5f03ce55187a8c91b847e84d767357f347839 | https://github.com/AsceticBoy/chilli-toolkit/blob/a4f5f03ce55187a8c91b847e84d767357f347839/tools/build/bundle.js#L115-L128 | train |
verekia/remark-lint-no-leading-spaces | index.js | noLeadingSpaces | function noLeadingSpaces(ast, file) {
var lines = file.toString().split('\n');
for (var i = 0; i < lines.length; i++) {
var currentLine = lines[i];
var lineIndex = i + 1;
if (/^\s/.test(currentLine)) {
file.message('Remove leading whitespace', {
position: {
start: { line: lineInd... | javascript | function noLeadingSpaces(ast, file) {
var lines = file.toString().split('\n');
for (var i = 0; i < lines.length; i++) {
var currentLine = lines[i];
var lineIndex = i + 1;
if (/^\s/.test(currentLine)) {
file.message('Remove leading whitespace', {
position: {
start: { line: lineInd... | [
"function",
"noLeadingSpaces",
"(",
"ast",
",",
"file",
")",
"{",
"var",
"lines",
"=",
"file",
".",
"toString",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"lines",
".",
"length",
";",
"i",
"... | Lines that are just space characters are not present in
the AST, which is why we loop through lines manually. | [
"Lines",
"that",
"are",
"just",
"space",
"characters",
"are",
"not",
"present",
"in",
"the",
"AST",
"which",
"is",
"why",
"we",
"loop",
"through",
"lines",
"manually",
"."
] | d6ff6dcb8f1a3c6614deec9d54ed78a224b15e28 | https://github.com/verekia/remark-lint-no-leading-spaces/blob/d6ff6dcb8f1a3c6614deec9d54ed78a224b15e28/index.js#L8-L22 | train |
DScheglov/merest | lib/controllers/static-method.js | callStaticMethod | function callStaticMethod(methodName, req, res, next) {
res.__apiMethod = 'staticMethod';
res.__apiStaticMethod = methodName;
var self = this;
var methodOptions = this.apiOptions.exposeStatic[methodName] || {};
var wrapper = methodOptions.exec;
if (!(wrapper instanceof Function)) wrapper = null;
... | javascript | function callStaticMethod(methodName, req, res, next) {
res.__apiMethod = 'staticMethod';
res.__apiStaticMethod = methodName;
var self = this;
var methodOptions = this.apiOptions.exposeStatic[methodName] || {};
var wrapper = methodOptions.exec;
if (!(wrapper instanceof Function)) wrapper = null;
... | [
"function",
"callStaticMethod",
"(",
"methodName",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"__apiMethod",
"=",
"'staticMethod'",
";",
"res",
".",
"__apiStaticMethod",
"=",
"methodName",
";",
"var",
"self",
"=",
"this",
";",
"var",
"metho... | callStaticMethod - controller that calls a static method of model
@param {String} methodName the name of method that should be called
@param {express.Request} req the http(s) request
@param {express.Response} res the http(s) response
@param {Function} next the callback should... | [
"callStaticMethod",
"-",
"controller",
"that",
"calls",
"a",
"static",
"method",
"of",
"model"
] | d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/controllers/static-method.js#L12-L30 | train |
cfpb/AtomicComponent | src/utilities/dom-class-list/index.js | addClass | function addClass( element ) {
const addClassNamesArray = _sliceArgs( arguments );
if ( hasClassList ) {
element.classList.add.apply( element.classList, addClassNamesArray );
} else {
var classes = element.className.split( ' ' );
addClassNamesArray.forEach( function( name ) {
if ( classes.indexO... | javascript | function addClass( element ) {
const addClassNamesArray = _sliceArgs( arguments );
if ( hasClassList ) {
element.classList.add.apply( element.classList, addClassNamesArray );
} else {
var classes = element.className.split( ' ' );
addClassNamesArray.forEach( function( name ) {
if ( classes.indexO... | [
"function",
"addClass",
"(",
"element",
")",
"{",
"const",
"addClassNamesArray",
"=",
"_sliceArgs",
"(",
"arguments",
")",
";",
"if",
"(",
"hasClassList",
")",
"{",
"element",
".",
"classList",
".",
"add",
".",
"apply",
"(",
"element",
".",
"classList",
",... | Add CSS class from an element.
@param {HTMLNode} element - A DOM element.
@param {string} className - CSS selector.
@returns {HTMLNode} element - A DOM element. | [
"Add",
"CSS",
"class",
"from",
"an",
"element",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/dom-class-list/index.js#L34-L49 | train |
cfpb/AtomicComponent | src/utilities/dom-class-list/index.js | contains | function contains( element, className ) {
className = className.replace( '.', '' );
if ( hasClassList ) {
return element.classList.contains( className );
}
return element.className.indexOf( className ) > -1;
} | javascript | function contains( element, className ) {
className = className.replace( '.', '' );
if ( hasClassList ) {
return element.classList.contains( className );
}
return element.className.indexOf( className ) > -1;
} | [
"function",
"contains",
"(",
"element",
",",
"className",
")",
"{",
"className",
"=",
"className",
".",
"replace",
"(",
"'.'",
",",
"''",
")",
";",
"if",
"(",
"hasClassList",
")",
"{",
"return",
"element",
".",
"classList",
".",
"contains",
"(",
"classNa... | Determine if element has particular CSS class.
@param {HTMLNode} element - A DOM element.
@param {string} className - CSS selector.
@returns {boolean} True if `element` contains class `className`. | [
"Determine",
"if",
"element",
"has",
"particular",
"CSS",
"class",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/dom-class-list/index.js#L58-L65 | train |
cfpb/AtomicComponent | src/utilities/dom-class-list/index.js | removeClass | function removeClass( element ) {
const removeClassNamesArray = _sliceArgs( arguments );
if ( hasClassList ) {
element.classList.remove
.apply( element.classList, removeClassNamesArray );
} else {
var classes = element.className.split( ' ' );
removeClassNamesArray.forEach( function( className ) {
... | javascript | function removeClass( element ) {
const removeClassNamesArray = _sliceArgs( arguments );
if ( hasClassList ) {
element.classList.remove
.apply( element.classList, removeClassNamesArray );
} else {
var classes = element.className.split( ' ' );
removeClassNamesArray.forEach( function( className ) {
... | [
"function",
"removeClass",
"(",
"element",
")",
"{",
"const",
"removeClassNamesArray",
"=",
"_sliceArgs",
"(",
"arguments",
")",
";",
"if",
"(",
"hasClassList",
")",
"{",
"element",
".",
"classList",
".",
"remove",
".",
"apply",
"(",
"element",
".",
"classLi... | Remove CSS class from an element.
@param {HTMLNode} element - A DOM element.
@param {string} className - CSS selector. | [
"Remove",
"CSS",
"class",
"from",
"an",
"element",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/dom-class-list/index.js#L73-L87 | train |
cfpb/AtomicComponent | src/utilities/dom-class-list/index.js | toggleClass | function toggleClass( element, className, forceFlag ) {
let hasClass = false;
if ( hasClassList ) {
hasClass = element.classList.toggle( className );
} else if ( forceFlag === false || contains( element, className ) ) {
removeClass( element, forceFlag );
} else {
addClass( element, className );
... | javascript | function toggleClass( element, className, forceFlag ) {
let hasClass = false;
if ( hasClassList ) {
hasClass = element.classList.toggle( className );
} else if ( forceFlag === false || contains( element, className ) ) {
removeClass( element, forceFlag );
} else {
addClass( element, className );
... | [
"function",
"toggleClass",
"(",
"element",
",",
"className",
",",
"forceFlag",
")",
"{",
"let",
"hasClass",
"=",
"false",
";",
"if",
"(",
"hasClassList",
")",
"{",
"hasClass",
"=",
"element",
".",
"classList",
".",
"toggle",
"(",
"className",
")",
";",
"... | Toggle CSS class on an element.
@param {HTMLNode} element - A DOM element.
@param {string} className - CSS selector.
@param {boolean} forceFlag - True if `className` class
should be forcibly removed.
@returns {boolean} True if the flag existed, false otherwise. | [
"Toggle",
"CSS",
"class",
"on",
"an",
"element",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/dom-class-list/index.js#L98-L110 | train |
WISEPLAT/solc-js | wrapper.js | function (versionString, cb) {
var mem = new MemoryStream(null, {readable: false});
var url = 'https://wiseplat.github.io/solc-bin/bin/soljson-' + versionString + '.js';
https.get(url, function (response) {
if (response.statusCode !== 200) {
cb(new Error('Error retrieving binary: ' +... | javascript | function (versionString, cb) {
var mem = new MemoryStream(null, {readable: false});
var url = 'https://wiseplat.github.io/solc-bin/bin/soljson-' + versionString + '.js';
https.get(url, function (response) {
if (response.statusCode !== 200) {
cb(new Error('Error retrieving binary: ' +... | [
"function",
"(",
"versionString",
",",
"cb",
")",
"{",
"var",
"mem",
"=",
"new",
"MemoryStream",
"(",
"null",
",",
"{",
"readable",
":",
"false",
"}",
")",
";",
"var",
"url",
"=",
"'https://wiseplat.github.io/solc-bin/bin/soljson-'",
"+",
"versionString",
"+",... | Loads the compiler of the given version from the github repository instead of from the local filesystem. | [
"Loads",
"the",
"compiler",
"of",
"the",
"given",
"version",
"from",
"the",
"github",
"repository",
"instead",
"of",
"from",
"the",
"local",
"filesystem",
"."
] | edabdd02fb0a9385851b92fcf10dee0b8af8e766 | https://github.com/WISEPLAT/solc-js/blob/edabdd02fb0a9385851b92fcf10dee0b8af8e766/wrapper.js#L179-L194 | train | |
Rafflecopter/deetoo | index.js | function($done) {
function procType(kv, $_done) {
var jobType=kv[0], func=kv[1]
JOBS.process(jobType, func._concurrent, func)
$_done()
}
// TODO: wouldn't need to do this if async.forEach() took an object
var _procs = _.zip(_.keys(__processors), _.values(__processors))
async.forEach(_procs, proc... | javascript | function($done) {
function procType(kv, $_done) {
var jobType=kv[0], func=kv[1]
JOBS.process(jobType, func._concurrent, func)
$_done()
}
// TODO: wouldn't need to do this if async.forEach() took an object
var _procs = _.zip(_.keys(__processors), _.values(__processors))
async.forEach(_procs, proc... | [
"function",
"(",
"$done",
")",
"{",
"function",
"procType",
"(",
"kv",
",",
"$_done",
")",
"{",
"var",
"jobType",
"=",
"kv",
"[",
"0",
"]",
",",
"func",
"=",
"kv",
"[",
"1",
"]",
"JOBS",
".",
"process",
"(",
"jobType",
",",
"func",
".",
"_concurr... | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ Util Functions | [
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
"~~",
"Util",
"Functions"
] | 4d7932efeab35e01fa3a584b6c1253b21f0c4515 | https://github.com/Rafflecopter/deetoo/blob/4d7932efeab35e01fa3a584b6c1253b21f0c4515/index.js#L55-L70 | train | |
Rafflecopter/deetoo | index.js | function(config) {
INIT(config)
this.__init__()
this.log = LOG
this.jobs = JOBS
MEM = new MemChecker(this, CONF.memChecker)
this._ = {
www: WWW
,redis: JOBS._rawQueue.client
}
} | javascript | function(config) {
INIT(config)
this.__init__()
this.log = LOG
this.jobs = JOBS
MEM = new MemChecker(this, CONF.memChecker)
this._ = {
www: WWW
,redis: JOBS._rawQueue.client
}
} | [
"function",
"(",
"config",
")",
"{",
"INIT",
"(",
"config",
")",
"this",
".",
"__init__",
"(",
")",
"this",
".",
"log",
"=",
"LOG",
"this",
".",
"jobs",
"=",
"JOBS",
"MEM",
"=",
"new",
"MemChecker",
"(",
"this",
",",
"CONF",
".",
"memChecker",
")",... | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ Worker | [
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
"~~",
"Worker"
] | 4d7932efeab35e01fa3a584b6c1253b21f0c4515 | https://github.com/Rafflecopter/deetoo/blob/4d7932efeab35e01fa3a584b6c1253b21f0c4515/index.js#L123-L136 | train | |
berkeleybop/class-expression | lib/class_expression.js | function(in_type){
this._is_a = 'class_expression';
var anchor = this;
///
/// Initialize.
///
// in_type is always a JSON object, trivial catch of attempt to
// use just a string as a class identifier.
if( in_type ){
if( what_is(in_type) === 'class_expression' ){
// Unf... | javascript | function(in_type){
this._is_a = 'class_expression';
var anchor = this;
///
/// Initialize.
///
// in_type is always a JSON object, trivial catch of attempt to
// use just a string as a class identifier.
if( in_type ){
if( what_is(in_type) === 'class_expression' ){
// Unf... | [
"function",
"(",
"in_type",
")",
"{",
"this",
".",
"_is_a",
"=",
"'class_expression'",
";",
"var",
"anchor",
"=",
"this",
";",
"///",
"/// Initialize.",
"///",
"// in_type is always a JSON object, trivial catch of attempt to",
"// use just a string as a class identifier.",
... | Core constructor.
The argument "in_type" may be:
- a class id (string)
- a JSON blob as described from Minerva
- another <class_expression>
- null (user will load or interactively create one)
@constructor
@param {String|Object|class_expression|null} - the raw type description (see above) | [
"Core",
"constructor",
"."
] | 47dc5dffe8aedd1c1be92f223715c27c7d67fa76 | https://github.com/berkeleybop/class-expression/blob/47dc5dffe8aedd1c1be92f223715c27c7d67fa76/lib/class_expression.js#L44-L91 | train | |
berkeleybop/class-expression | lib/class_expression.js | _class_labeler | function _class_labeler(ce){
var ret = ce.class_label();
// Optional ID.
var cid = ce.class_id();
if( cid && cid !== ret ){
ret = '[' + cid + '] ' + ret;
}
return ret;
} | javascript | function _class_labeler(ce){
var ret = ce.class_label();
// Optional ID.
var cid = ce.class_id();
if( cid && cid !== ret ){
ret = '[' + cid + '] ' + ret;
}
return ret;
} | [
"function",
"_class_labeler",
"(",
"ce",
")",
"{",
"var",
"ret",
"=",
"ce",
".",
"class_label",
"(",
")",
";",
"// Optional ID.",
"var",
"cid",
"=",
"ce",
".",
"class_id",
"(",
")",
";",
"if",
"(",
"cid",
"&&",
"cid",
"!==",
"ret",
")",
"{",
"ret",... | Class label is main, but prepend class ID if available and different. | [
"Class",
"label",
"is",
"main",
"but",
"prepend",
"class",
"ID",
"if",
"available",
"and",
"different",
"."
] | 47dc5dffe8aedd1c1be92f223715c27c7d67fa76 | https://github.com/berkeleybop/class-expression/blob/47dc5dffe8aedd1c1be92f223715c27c7d67fa76/lib/class_expression.js#L584-L592 | train |
chapmanu/hb | lib/adapter.js | function(config) {
this._config = this._defaultConfig();
if (!config) return true;
var datastore;
switch(config.adapter) {
case 'disk':
datastore = this._adapters.disk.connection();
break;
case 'redis':
datastore = this._adapters.redis.connection(config.redis);... | javascript | function(config) {
this._config = this._defaultConfig();
if (!config) return true;
var datastore;
switch(config.adapter) {
case 'disk':
datastore = this._adapters.disk.connection();
break;
case 'redis':
datastore = this._adapters.redis.connection(config.redis);... | [
"function",
"(",
"config",
")",
"{",
"this",
".",
"_config",
"=",
"this",
".",
"_defaultConfig",
"(",
")",
";",
"if",
"(",
"!",
"config",
")",
"return",
"true",
";",
"var",
"datastore",
";",
"switch",
"(",
"config",
".",
"adapter",
")",
"{",
"case",
... | Configure adapter connection
@param {object} config - Adapter configuration | [
"Configure",
"adapter",
"connection"
] | 5edd8de89c7c5fdffc3df0c627513889220f7d51 | https://github.com/chapmanu/hb/blob/5edd8de89c7c5fdffc3df0c627513889220f7d51/lib/adapter.js#L39-L62 | train | |
chapmanu/hb | lib/adapter.js | function(cb) {
this._loadCollections();
// Start Waterline
var self = this;
this._waterline.initialize(self.config, function(err, waterline) {
if(err) throw err;
hb.addModel('Account', waterline.collections['accounts-'+hb.env]);
hb.addModel('Keyword', waterline.collections[... | javascript | function(cb) {
this._loadCollections();
// Start Waterline
var self = this;
this._waterline.initialize(self.config, function(err, waterline) {
if(err) throw err;
hb.addModel('Account', waterline.collections['accounts-'+hb.env]);
hb.addModel('Keyword', waterline.collections[... | [
"function",
"(",
"cb",
")",
"{",
"this",
".",
"_loadCollections",
"(",
")",
";",
"// Start Waterline",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_waterline",
".",
"initialize",
"(",
"self",
".",
"config",
",",
"function",
"(",
"err",
",",
"waterline... | Initialize the connection | [
"Initialize",
"the",
"connection"
] | 5edd8de89c7c5fdffc3df0c627513889220f7d51 | https://github.com/chapmanu/hb/blob/5edd8de89c7c5fdffc3df0c627513889220f7d51/lib/adapter.js#L68-L81 | train | |
bjarneo/mini-template-engine | src/mini-template-engine.js | miniTemplateEngine | function miniTemplateEngine(str, props, callback) {
var isCallback = false,
errorString = 'The first parameter must be a string';
if (callback && isFunction(callback)) {
isCallback = true;
}
if (!str || !isString(str)) {
if (isCallback) {
callback(null, errorString)... | javascript | function miniTemplateEngine(str, props, callback) {
var isCallback = false,
errorString = 'The first parameter must be a string';
if (callback && isFunction(callback)) {
isCallback = true;
}
if (!str || !isString(str)) {
if (isCallback) {
callback(null, errorString)... | [
"function",
"miniTemplateEngine",
"(",
"str",
",",
"props",
",",
"callback",
")",
"{",
"var",
"isCallback",
"=",
"false",
",",
"errorString",
"=",
"'The first parameter must be a string'",
";",
"if",
"(",
"callback",
"&&",
"isFunction",
"(",
"callback",
")",
")"... | This is a small easy template engine.
It just replaces variable placeholders with objects passed to the function.
@param {string} the string with placeholders
@param {object} the properties to replace the placeholders
@throws {Error} Throws an error if the first parameter is not a string
@returns {string} | [
"This",
"is",
"a",
"small",
"easy",
"template",
"engine",
".",
"It",
"just",
"replaces",
"variable",
"placeholders",
"with",
"objects",
"passed",
"to",
"the",
"function",
"."
] | 22a0d71205cf04d5edb9d96cb5d4725530ef0c63 | https://github.com/bjarneo/mini-template-engine/blob/22a0d71205cf04d5edb9d96cb5d4725530ef0c63/src/mini-template-engine.js#L17-L48 | train |
odogono/elsinore-js | src/query/dsl.js | rpnToTree | function rpnToTree(values) {
let ii, len, op, stack, slice, count;
stack = [];
// result = [];
for (ii = 0, len = values.length; ii < len; ii++) {
op = values[ii];
if (op === LEFT_PAREN) {
// cut out this sub and convert it to a tree
slice = findMatchingRightPar... | javascript | function rpnToTree(values) {
let ii, len, op, stack, slice, count;
stack = [];
// result = [];
for (ii = 0, len = values.length; ii < len; ii++) {
op = values[ii];
if (op === LEFT_PAREN) {
// cut out this sub and convert it to a tree
slice = findMatchingRightPar... | [
"function",
"rpnToTree",
"(",
"values",
")",
"{",
"let",
"ii",
",",
"len",
",",
"op",
",",
"stack",
",",
"slice",
",",
"count",
";",
"stack",
"=",
"[",
"]",
";",
"// result = [];",
"for",
"(",
"ii",
"=",
"0",
",",
"len",
"=",
"values",
".",
"leng... | Converts an RPN expression into an AST | [
"Converts",
"an",
"RPN",
"expression",
"into",
"an",
"AST"
] | 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/query/dsl.js#L81-L128 | train |
warehouseai/warehouse-models | lib/common.js | strip | function strip(file) {
file.fingerprint = file.fingerprint.slice(0, -3);
delete file.source;
delete file.sourcemap;
delete file.shrinkwrap;
return file;
} | javascript | function strip(file) {
file.fingerprint = file.fingerprint.slice(0, -3);
delete file.source;
delete file.sourcemap;
delete file.shrinkwrap;
return file;
} | [
"function",
"strip",
"(",
"file",
")",
"{",
"file",
".",
"fingerprint",
"=",
"file",
".",
"fingerprint",
".",
"slice",
"(",
"0",
",",
"-",
"3",
")",
";",
"delete",
"file",
".",
"source",
";",
"delete",
"file",
".",
"sourcemap",
";",
"delete",
"file",... | Cleanup the heavyweight stuff and meta data | [
"Cleanup",
"the",
"heavyweight",
"stuff",
"and",
"meta",
"data"
] | ee65aa759adc6a7f83f4b02608a4e74fe562aa89 | https://github.com/warehouseai/warehouse-models/blob/ee65aa759adc6a7f83f4b02608a4e74fe562aa89/lib/common.js#L24-L30 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | validateParamsPresent | function validateParamsPresent(expectedKeys, params) {
params = params || {};
var paramKeys = _.keys(params);
return _.first(_.difference(expectedKeys, _.intersection(paramKeys, expectedKeys)));
} | javascript | function validateParamsPresent(expectedKeys, params) {
params = params || {};
var paramKeys = _.keys(params);
return _.first(_.difference(expectedKeys, _.intersection(paramKeys, expectedKeys)));
} | [
"function",
"validateParamsPresent",
"(",
"expectedKeys",
",",
"params",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"var",
"paramKeys",
"=",
"_",
".",
"keys",
"(",
"params",
")",
";",
"return",
"_",
".",
"first",
"(",
"_",
".",
"difference... | Validating Params Have Expected Key Values
@param expectedKeys
@param params
@private | [
"Validating",
"Params",
"Have",
"Expected",
"Key",
"Values"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L16-L20 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | validateCommonParams | function validateCommonParams(params) {
log.logger.debug({params: params}, "FH-MBAAS-CLIENT: validateCommonParams");
var expectedParams = ["method", "data", "resourcePath", "environment", "domain"];
var missingParam = validateParamsPresent(expectedParams, params);
if (missingParam) {
return missingParam;
... | javascript | function validateCommonParams(params) {
log.logger.debug({params: params}, "FH-MBAAS-CLIENT: validateCommonParams");
var expectedParams = ["method", "data", "resourcePath", "environment", "domain"];
var missingParam = validateParamsPresent(expectedParams, params);
if (missingParam) {
return missingParam;
... | [
"function",
"validateCommonParams",
"(",
"params",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"{",
"params",
":",
"params",
"}",
",",
"\"FH-MBAAS-CLIENT: validateCommonParams\"",
")",
";",
"var",
"expectedParams",
"=",
"[",
"\"method\"",
",",
"\"data\"",... | Validating Common Params Between Admin and App MbaaS Requests
@param params
@private | [
"Validating",
"Common",
"Params",
"Between",
"Admin",
"and",
"App",
"MbaaS",
"Requests"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L28-L52 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | validateAppParams | function validateAppParams(params) {
params = params || {};
var expectedAppParams = ["project", "app", "accessKey", "appApiKey", "url"];
var missingParam = validateCommonParams(params);
if (missingParam) {
return new Error("Missing Param " + missingParam);
}
missingParam = validateParamsPresent(expe... | javascript | function validateAppParams(params) {
params = params || {};
var expectedAppParams = ["project", "app", "accessKey", "appApiKey", "url"];
var missingParam = validateCommonParams(params);
if (missingParam) {
return new Error("Missing Param " + missingParam);
}
missingParam = validateParamsPresent(expe... | [
"function",
"validateAppParams",
"(",
"params",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"var",
"expectedAppParams",
"=",
"[",
"\"project\"",
",",
"\"app\"",
",",
"\"accessKey\"",
",",
"\"appApiKey\"",
",",
"\"url\"",
"]",
";",
"var",
"missing... | App API Requests To An MbaaS Require
@param params
@returns {*}
@private | [
"App",
"API",
"Requests",
"To",
"An",
"MbaaS",
"Require"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L60-L78 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | validateAdminParams | function validateAdminParams(params) {
log.logger.debug({params: params}, "FH-MBAAS-CLIENT: validateAdminParams");
var missingParam = validateCommonParams(params);
var expectedAdminMbaasConfig = ["url", "username", "password"];
if (missingParam) {
return new Error("Missing Param " + missingParam);
}
... | javascript | function validateAdminParams(params) {
log.logger.debug({params: params}, "FH-MBAAS-CLIENT: validateAdminParams");
var missingParam = validateCommonParams(params);
var expectedAdminMbaasConfig = ["url", "username", "password"];
if (missingParam) {
return new Error("Missing Param " + missingParam);
}
... | [
"function",
"validateAdminParams",
"(",
"params",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"{",
"params",
":",
"params",
"}",
",",
"\"FH-MBAAS-CLIENT: validateAdminParams\"",
")",
";",
"var",
"missingParam",
"=",
"validateCommonParams",
"(",
"params",
... | Administration API Requests To An MbaaS Require The Username And Password Of The MbaaS.
@param params
@returns {*}
@private | [
"Administration",
"API",
"Requests",
"To",
"An",
"MbaaS",
"Require",
"The",
"Username",
"And",
"Password",
"Of",
"The",
"MbaaS",
"."
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L86-L102 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | _buildAdminMbaasParams | function _buildAdminMbaasParams(params) {
log.logger.debug({params: params}, "FH-MBAAS-CLIENT: _buildAdminMbaasParams");
var basePath;
basePath = config.addURIParams(constants.ADMIN_API_PATH, params);
params = params || {};
var method, resourcePath;
method = params.method;
resourcePath = params.resourc... | javascript | function _buildAdminMbaasParams(params) {
log.logger.debug({params: params}, "FH-MBAAS-CLIENT: _buildAdminMbaasParams");
var basePath;
basePath = config.addURIParams(constants.ADMIN_API_PATH, params);
params = params || {};
var method, resourcePath;
method = params.method;
resourcePath = params.resourc... | [
"function",
"_buildAdminMbaasParams",
"(",
"params",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"{",
"params",
":",
"params",
"}",
",",
"\"FH-MBAAS-CLIENT: _buildAdminMbaasParams\"",
")",
";",
"var",
"basePath",
";",
"basePath",
"=",
"config",
".",
"ad... | Building Request Params For A Call To Administration APIs In An MbaaS
@param params
@returns {{url: *, json: boolean, method: (method|*|string), auth: {user: *, pass: *}, headers: {host: string}, body: *}}
@private | [
"Building",
"Request",
"Params",
"For",
"A",
"Call",
"To",
"Administration",
"APIs",
"In",
"An",
"MbaaS"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L110-L149 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | responseHandler | function responseHandler(params, cb) {
return function handleResponse(err, httpResponse, body) {
body = body || "{}";
httpResponse = httpResponse || {};
//The response should be JSON. If it is a string, then the response should be parsed.
if (_.isString(body)) {
try {
body = JSON.parse... | javascript | function responseHandler(params, cb) {
return function handleResponse(err, httpResponse, body) {
body = body || "{}";
httpResponse = httpResponse || {};
//The response should be JSON. If it is a string, then the response should be parsed.
if (_.isString(body)) {
try {
body = JSON.parse... | [
"function",
"responseHandler",
"(",
"params",
",",
"cb",
")",
"{",
"return",
"function",
"handleResponse",
"(",
"err",
",",
"httpResponse",
",",
"body",
")",
"{",
"body",
"=",
"body",
"||",
"\"{}\"",
";",
"httpResponse",
"=",
"httpResponse",
"||",
"{",
"}"... | Create a response handler from a request to the MBaaS.
@param params
@param cb
@returns {handleResponse} | [
"Create",
"a",
"response",
"handler",
"from",
"a",
"request",
"to",
"the",
"MBaaS",
"."
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L158-L208 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | doFHMbaaSRequest | function doFHMbaaSRequest(params, cb) {
//Preventing multiple callbacks.
// _.defaults(undefined, ...) === undefined, so we still need to OR with an empty object
params = _.defaults(params || {}, {
headers: {}
});
//Adding pagination parameters if required
params.url = addPaginationUrlParams(params.url... | javascript | function doFHMbaaSRequest(params, cb) {
//Preventing multiple callbacks.
// _.defaults(undefined, ...) === undefined, so we still need to OR with an empty object
params = _.defaults(params || {}, {
headers: {}
});
//Adding pagination parameters if required
params.url = addPaginationUrlParams(params.url... | [
"function",
"doFHMbaaSRequest",
"(",
"params",
",",
"cb",
")",
"{",
"//Preventing multiple callbacks.",
"// _.defaults(undefined, ...) === undefined, so we still need to OR with an empty object",
"params",
"=",
"_",
".",
"defaults",
"(",
"params",
"||",
"{",
"}",
",",
"{",
... | Perform A Request To An MbaaS
@private | [
"Perform",
"A",
"Request",
"To",
"An",
"MbaaS"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L217-L284 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | _buildAppRequestParams | function _buildAppRequestParams(params) {
params = params || {};
var basePath = config.addURIParams(constants.APP_API_PATH, params);
var fullPath = basePath + params.resourcePath;
var mbaasUrl = url.parse(params.url);
mbaasUrl.pathname = fullPath;
var headers = {
'x-fh-env-access-key': params.acces... | javascript | function _buildAppRequestParams(params) {
params = params || {};
var basePath = config.addURIParams(constants.APP_API_PATH, params);
var fullPath = basePath + params.resourcePath;
var mbaasUrl = url.parse(params.url);
mbaasUrl.pathname = fullPath;
var headers = {
'x-fh-env-access-key': params.acces... | [
"function",
"_buildAppRequestParams",
"(",
"params",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"var",
"basePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"APP_API_PATH",
",",
"params",
")",
";",
"var",
"fullPath",
"=",
"bas... | Building Request Params For An App Request To An Mbaas
@param params
@returns {{url: string, body: *, method: (method|*|string), json: boolean, headers: {fh-app-env-access-key: *}}}
@private | [
"Building",
"Request",
"Params",
"For",
"An",
"App",
"Request",
"To",
"An",
"Mbaas"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L293-L318 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | adminRequest | function adminRequest(params, cb) {
params = params || {};
var mbaasConf = params[constants.MBAAS_CONF_KEY];
params[constants.MBAAS_CONF_KEY] = undefined;
log.logger.debug({params: params}, "FH-MBAAS-CLIENT: adminRequest ");
var fullParams = _.extend(_.clone(params), mbaasConf);
log.logger.info({
env: p... | javascript | function adminRequest(params, cb) {
params = params || {};
var mbaasConf = params[constants.MBAAS_CONF_KEY];
params[constants.MBAAS_CONF_KEY] = undefined;
log.logger.debug({params: params}, "FH-MBAAS-CLIENT: adminRequest ");
var fullParams = _.extend(_.clone(params), mbaasConf);
log.logger.info({
env: p... | [
"function",
"adminRequest",
"(",
"params",
",",
"cb",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"var",
"mbaasConf",
"=",
"params",
"[",
"constants",
".",
"MBAAS_CONF_KEY",
"]",
";",
"params",
"[",
"constants",
".",
"MBAAS_CONF_KEY",
"]",
"=... | Performing A Request Against The Admin MBaaS API
@param params
@param cb | [
"Performing",
"A",
"Request",
"Against",
"The",
"Admin",
"MBaaS",
"API"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L326-L350 | train |
feedhenry/fh-mbaas-client | lib/mbaasRequest/mbaasRequest.js | appRequest | function appRequest(params, cb) {
params = params || {};
var mbaasConf = params[constants.MBAAS_CONF_KEY];
params[constants.MBAAS_CONF_KEY] = undefined;
//Adding Mbaas Config Params
var fullParams = _.extend(_.clone(params), mbaasConf);
var invalidParamError = validateAppParams(fullParams);
if (invalidP... | javascript | function appRequest(params, cb) {
params = params || {};
var mbaasConf = params[constants.MBAAS_CONF_KEY];
params[constants.MBAAS_CONF_KEY] = undefined;
//Adding Mbaas Config Params
var fullParams = _.extend(_.clone(params), mbaasConf);
var invalidParamError = validateAppParams(fullParams);
if (invalidP... | [
"function",
"appRequest",
"(",
"params",
",",
"cb",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"var",
"mbaasConf",
"=",
"params",
"[",
"constants",
".",
"MBAAS_CONF_KEY",
"]",
";",
"params",
"[",
"constants",
".",
"MBAAS_CONF_KEY",
"]",
"=",... | Performing A Request Against The App MBaaS API
@param params
@param cb | [
"Performing",
"A",
"Request",
"Against",
"The",
"App",
"MBaaS",
"API"
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/mbaasRequest/mbaasRequest.js#L359-L375 | train |
node-ffi-napi/ref-union-di | lib/union.js | Union | function Union () {
debug('defining new union "type"')
function UnionType (arg, data) {
if (!(this instanceof UnionType)) {
return new UnionType(arg, data)
}
debug('creating new union instance')
var store
if (Buffer.isBuffer(arg)) {
debug('using passed-in Buffer instance to back the... | javascript | function Union () {
debug('defining new union "type"')
function UnionType (arg, data) {
if (!(this instanceof UnionType)) {
return new UnionType(arg, data)
}
debug('creating new union instance')
var store
if (Buffer.isBuffer(arg)) {
debug('using passed-in Buffer instance to back the... | [
"function",
"Union",
"(",
")",
"{",
"debug",
"(",
"'defining new union \"type\"'",
")",
"function",
"UnionType",
"(",
"arg",
",",
"data",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"UnionType",
")",
")",
"{",
"return",
"new",
"UnionType",
"(",
... | The "Union" type constructor. | [
"The",
"Union",
"type",
"constructor",
"."
] | 858792be59a2c75f4a8d8958b1c59c3bb7483671 | https://github.com/node-ffi-napi/ref-union-di/blob/858792be59a2c75f4a8d8958b1c59c3bb7483671/lib/union.js#L20-L86 | train |
node-ffi-napi/ref-union-di | lib/union.js | defineProperty | function defineProperty (name, type) {
debug('defining new union type field', name)
// allow string types for convenience
type = ref.coerceType(type)
assert(!this._instanceCreated, 'an instance of this Union type has already '
+ 'been created, cannot add new data members anymore')
assert.equal('string... | javascript | function defineProperty (name, type) {
debug('defining new union type field', name)
// allow string types for convenience
type = ref.coerceType(type)
assert(!this._instanceCreated, 'an instance of this Union type has already '
+ 'been created, cannot add new data members anymore')
assert.equal('string... | [
"function",
"defineProperty",
"(",
"name",
",",
"type",
")",
"{",
"debug",
"(",
"'defining new union type field'",
",",
"name",
")",
"// allow string types for convenience",
"type",
"=",
"ref",
".",
"coerceType",
"(",
"type",
")",
"assert",
"(",
"!",
"this",
"."... | Adds a new field to the union instance with the given name and type.
Note that this function will throw an Error if any instances of the union
type have already been created, therefore this function must be called at the
beginning, before any instances are created. | [
"Adds",
"a",
"new",
"field",
"to",
"the",
"union",
"instance",
"with",
"the",
"given",
"name",
"and",
"type",
".",
"Note",
"that",
"this",
"function",
"will",
"throw",
"an",
"Error",
"if",
"any",
"instances",
"of",
"the",
"union",
"type",
"have",
"alread... | 858792be59a2c75f4a8d8958b1c59c3bb7483671 | https://github.com/node-ffi-napi/ref-union-di/blob/858792be59a2c75f4a8d8958b1c59c3bb7483671/lib/union.js#L128-L168 | train |
brianbrunner/yowl | lib/yowl.js | createBot | function createBot() {
var bot = function(platform, context, event, next) {
context.platform = platform;
bot.handle(context, event, next);
};
mixin(bot, EventEmitter.prototype, false);
mixin(bot, proto, false);
bot.context = { __proto__: context, bot: bot };
bot.event = { __proto__: event, bot: bo... | javascript | function createBot() {
var bot = function(platform, context, event, next) {
context.platform = platform;
bot.handle(context, event, next);
};
mixin(bot, EventEmitter.prototype, false);
mixin(bot, proto, false);
bot.context = { __proto__: context, bot: bot };
bot.event = { __proto__: event, bot: bo... | [
"function",
"createBot",
"(",
")",
"{",
"var",
"bot",
"=",
"function",
"(",
"platform",
",",
"context",
",",
"event",
",",
"next",
")",
"{",
"context",
".",
"platform",
"=",
"platform",
";",
"bot",
".",
"handle",
"(",
"context",
",",
"event",
",",
"n... | Creates a bot.
@return {Function}
@api public | [
"Creates",
"a",
"bot",
"."
] | 35d6764f4cc6c4a3487eca18a12fd8ca567d4293 | https://github.com/brianbrunner/yowl/blob/35d6764f4cc6c4a3487eca18a12fd8ca567d4293/lib/yowl.js#L34-L48 | train |
vid/SenseBase | lib/indexer.js | resultToContentItem | function resultToContentItem(esDoc) {
var annoDoc = {_source : {}};
publishFields.forEach(function(f) {
annoDoc._source[f] = esDoc[f];
});
return annoDoc;
} | javascript | function resultToContentItem(esDoc) {
var annoDoc = {_source : {}};
publishFields.forEach(function(f) {
annoDoc._source[f] = esDoc[f];
});
return annoDoc;
} | [
"function",
"resultToContentItem",
"(",
"esDoc",
")",
"{",
"var",
"annoDoc",
"=",
"{",
"_source",
":",
"{",
"}",
"}",
";",
"publishFields",
".",
"forEach",
"(",
"function",
"(",
"f",
")",
"{",
"annoDoc",
".",
"_source",
"[",
"f",
"]",
"=",
"esDoc",
"... | copy a cItem to elasticsearch field result format | [
"copy",
"a",
"cItem",
"to",
"elasticsearch",
"field",
"result",
"format"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/indexer.js#L50-L56 | train |
vid/SenseBase | lib/indexer.js | retrieveByURI | function retrieveByURI(uri, callback) {
var query = {
query: {
term: {
uri : uri
}
}
};
getEs().search({ _index : GLOBAL.config.ESEARCH._index, _type : 'contentItem'}, query, function(err, res) {
if (!err && res && res.hits.total) {
if (res.hits.total > 1) {
// That w... | javascript | function retrieveByURI(uri, callback) {
var query = {
query: {
term: {
uri : uri
}
}
};
getEs().search({ _index : GLOBAL.config.ESEARCH._index, _type : 'contentItem'}, query, function(err, res) {
if (!err && res && res.hits.total) {
if (res.hits.total > 1) {
// That w... | [
"function",
"retrieveByURI",
"(",
"uri",
",",
"callback",
")",
"{",
"var",
"query",
"=",
"{",
"query",
":",
"{",
"term",
":",
"{",
"uri",
":",
"uri",
"}",
"}",
"}",
";",
"getEs",
"(",
")",
".",
"search",
"(",
"{",
"_index",
":",
"GLOBAL",
".",
... | Retrieves a complete contentItem by URI. | [
"Retrieves",
"a",
"complete",
"contentItem",
"by",
"URI",
"."
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/indexer.js#L85-L103 | train |
vid/SenseBase | lib/indexer.js | deleteRecord | function deleteRecord(rType, idFun) {
return function(item, callback) {
GLOBAL.debug('deleting', item, rType);
var tc = [];
getEs().delete({ _type: rType, _id : encodeURIComponent(idFun(item))}, function(err, deleteRes) {
callback(err, deleteRes);
});
};
} | javascript | function deleteRecord(rType, idFun) {
return function(item, callback) {
GLOBAL.debug('deleting', item, rType);
var tc = [];
getEs().delete({ _type: rType, _id : encodeURIComponent(idFun(item))}, function(err, deleteRes) {
callback(err, deleteRes);
});
};
} | [
"function",
"deleteRecord",
"(",
"rType",
",",
"idFun",
")",
"{",
"return",
"function",
"(",
"item",
",",
"callback",
")",
"{",
"GLOBAL",
".",
"debug",
"(",
"'deleting'",
",",
"item",
",",
"rType",
")",
";",
"var",
"tc",
"=",
"[",
"]",
";",
"getEs",
... | delete member record partial | [
"delete",
"member",
"record",
"partial"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/indexer.js#L106-L114 | train |
vid/SenseBase | lib/indexer.js | saveRecord | function saveRecord(rType, idFun) {
return function(records, callback) {
GLOBAL.debug('inserting', records.length, rType);
if (!_.isArray(records)) {
records = [records];
}
var tc = [];
records.forEach(function(d) {
var meta = {_index : GLOBAL.config.ESEARCH._index, _type : rType};
... | javascript | function saveRecord(rType, idFun) {
return function(records, callback) {
GLOBAL.debug('inserting', records.length, rType);
if (!_.isArray(records)) {
records = [records];
}
var tc = [];
records.forEach(function(d) {
var meta = {_index : GLOBAL.config.ESEARCH._index, _type : rType};
... | [
"function",
"saveRecord",
"(",
"rType",
",",
"idFun",
")",
"{",
"return",
"function",
"(",
"records",
",",
"callback",
")",
"{",
"GLOBAL",
".",
"debug",
"(",
"'inserting'",
",",
"records",
".",
"length",
",",
"rType",
")",
";",
"if",
"(",
"!",
"_",
"... | save member record partial | [
"save",
"member",
"record",
"partial"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/indexer.js#L117-L136 | train |
vid/SenseBase | lib/indexer.js | formQuery | function formQuery(params, callback) {
params = params || { query: {}};
var query = formQueryLib.createFormQuery(params);
var q = {
_source : params.sourceFields || sourceFields,
sort : params.sort || [
{ "timestamp" : {"order" : "desc"}},
],
from: params.from || 0,
size : querySize(par... | javascript | function formQuery(params, callback) {
params = params || { query: {}};
var query = formQueryLib.createFormQuery(params);
var q = {
_source : params.sourceFields || sourceFields,
sort : params.sort || [
{ "timestamp" : {"order" : "desc"}},
],
from: params.from || 0,
size : querySize(par... | [
"function",
"formQuery",
"(",
"params",
",",
"callback",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"query",
":",
"{",
"}",
"}",
";",
"var",
"query",
"=",
"formQueryLib",
".",
"createFormQuery",
"(",
"params",
")",
";",
"var",
"q",
"=",
"{",
"_sou... | Executes form params, returning results | [
"Executes",
"form",
"params",
"returning",
"results"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/indexer.js#L182-L213 | train |
vid/SenseBase | lib/indexer.js | formCluster | function formCluster(params, callback) {
var query = formQueryLib.createFormQuery(params);
var q = {
"search_request" : {
_source : sourceFields.concat(['text']),
sort : [
{ "visitors.@timestamp" : {"order" : "desc"}},
],
size : querySize(params),
query: query
},
"q... | javascript | function formCluster(params, callback) {
var query = formQueryLib.createFormQuery(params);
var q = {
"search_request" : {
_source : sourceFields.concat(['text']),
sort : [
{ "visitors.@timestamp" : {"order" : "desc"}},
],
size : querySize(params),
query: query
},
"q... | [
"function",
"formCluster",
"(",
"params",
",",
"callback",
")",
"{",
"var",
"query",
"=",
"formQueryLib",
".",
"createFormQuery",
"(",
"params",
")",
";",
"var",
"q",
"=",
"{",
"\"search_request\"",
":",
"{",
"_source",
":",
"sourceFields",
".",
"concat",
... | Executes carrot2 cluster query | [
"Executes",
"carrot2",
"cluster",
"query"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/indexer.js#L216-L249 | train |
vid/SenseBase | lib/indexer.js | doPost | function doPost(path, data, callback) {
var options = {
host: GLOBAL.config.ESEARCH.server.host,
port: GLOBAL.config.ESEARCH.server.port,
path: GLOBAL.config.ESEARCH._index + path,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.... | javascript | function doPost(path, data, callback) {
var options = {
host: GLOBAL.config.ESEARCH.server.host,
port: GLOBAL.config.ESEARCH.server.port,
path: GLOBAL.config.ESEARCH._index + path,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.... | [
"function",
"doPost",
"(",
"path",
",",
"data",
",",
"callback",
")",
"{",
"var",
"options",
"=",
"{",
"host",
":",
"GLOBAL",
".",
"config",
".",
"ESEARCH",
".",
"server",
".",
"host",
",",
"port",
":",
"GLOBAL",
".",
"config",
".",
"ESEARCH",
".",
... | POST for es functions that aren't locally supported | [
"POST",
"for",
"es",
"functions",
"that",
"aren",
"t",
"locally",
"supported"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/indexer.js#L297-L309 | train |
Whitebolt/require-extra | src/require.js | _getResolve | function _getResolve(obj) {
if (!obj) return settings.get('resolver');
if (obj instanceof Resolver) return obj;
if (obj.resolver) return obj.resolver;
let pass = true;
Resolver.resolveLike.forEach(property=>{pass &= (property in obj);});
if (pass) return obj;
return new Resolver(obj);
} | javascript | function _getResolve(obj) {
if (!obj) return settings.get('resolver');
if (obj instanceof Resolver) return obj;
if (obj.resolver) return obj.resolver;
let pass = true;
Resolver.resolveLike.forEach(property=>{pass &= (property in obj);});
if (pass) return obj;
return new Resolver(obj);
} | [
"function",
"_getResolve",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"return",
"settings",
".",
"get",
"(",
"'resolver'",
")",
";",
"if",
"(",
"obj",
"instanceof",
"Resolver",
")",
"return",
"obj",
";",
"if",
"(",
"obj",
".",
"resolver",
")",... | Get the resolver object from a given object. Assumes it has received
either an actual resolver or an options object with resolver in it. If this
is not true then return the default resolver.
@private
@param {Object} obj Object to get resolver from.
@returns {Object} The resolver object. | [
"Get",
"the",
"resolver",
"object",
"from",
"a",
"given",
"object",
".",
"Assumes",
"it",
"has",
"received",
"either",
"an",
"actual",
"resolver",
"or",
"an",
"options",
"object",
"with",
"resolver",
"in",
"it",
".",
"If",
"this",
"is",
"not",
"true",
"t... | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L52-L60 | train |
Whitebolt/require-extra | src/require.js | _getRoot | function _getRoot(obj) {
return (getCallingDir(((obj && obj.basedir) ? obj.basedir : undefined)) || (obj?obj.basedir:undefined));
} | javascript | function _getRoot(obj) {
return (getCallingDir(((obj && obj.basedir) ? obj.basedir : undefined)) || (obj?obj.basedir:undefined));
} | [
"function",
"_getRoot",
"(",
"obj",
")",
"{",
"return",
"(",
"getCallingDir",
"(",
"(",
"(",
"obj",
"&&",
"obj",
".",
"basedir",
")",
"?",
"obj",
".",
"basedir",
":",
"undefined",
")",
")",
"||",
"(",
"obj",
"?",
"obj",
".",
"basedir",
":",
"undefi... | Get the root directory to use from the supplied object or calculate it.
@private
@param {Object} obj The options object containing a 'dir' property.
@returns {string} The directory path. | [
"Get",
"the",
"root",
"directory",
"to",
"use",
"from",
"the",
"supplied",
"object",
"or",
"calculate",
"it",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L69-L71 | train |
Whitebolt/require-extra | src/require.js | _loadModuleText | function _loadModuleText(target, source, sync=false) {
const time = process.hrtime();
const loadEventEvent = new emitter.Load({target, source, sync});
const loadEvent = emitter.emit('load', loadEventEvent);
const loaded = txtBuffer=>{
try {
const loadedEvent = emitter.emit('loaded', new emitter.Loade... | javascript | function _loadModuleText(target, source, sync=false) {
const time = process.hrtime();
const loadEventEvent = new emitter.Load({target, source, sync});
const loadEvent = emitter.emit('load', loadEventEvent);
const loaded = txtBuffer=>{
try {
const loadedEvent = emitter.emit('loaded', new emitter.Loade... | [
"function",
"_loadModuleText",
"(",
"target",
",",
"source",
",",
"sync",
"=",
"false",
")",
"{",
"const",
"time",
"=",
"process",
".",
"hrtime",
"(",
")",
";",
"const",
"loadEventEvent",
"=",
"new",
"emitter",
".",
"Load",
"(",
"{",
"target",
",",
"so... | Read text from a file and handle any errors.
@private
@param {string} target The target to load.
@param {string} source The loading source path.
@param {boolean} [sync=false] Use sync method?
@returns {Promise.<string>|string} The results. | [
"Read",
"text",
"from",
"a",
"file",
"and",
"handle",
"any",
"errors",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L110-L144 | train |
Whitebolt/require-extra | src/require.js | _evalModuleText | function _evalModuleText(filename, content, userResolver, sync=true) {
if (content === undefined) return;
const ext = path.extname(filename);
const config = _createModuleConfig(filename, content, _getResolve(userResolver));
let module = _runEval(config, settings.get(ext) || function(){}, userResolver.options |... | javascript | function _evalModuleText(filename, content, userResolver, sync=true) {
if (content === undefined) return;
const ext = path.extname(filename);
const config = _createModuleConfig(filename, content, _getResolve(userResolver));
let module = _runEval(config, settings.get(ext) || function(){}, userResolver.options |... | [
"function",
"_evalModuleText",
"(",
"filename",
",",
"content",
",",
"userResolver",
",",
"sync",
"=",
"true",
")",
"{",
"if",
"(",
"content",
"===",
"undefined",
")",
"return",
";",
"const",
"ext",
"=",
"path",
".",
"extname",
"(",
"filename",
")",
";",... | Evaluate module text in similar fashion to require evaluations, returning the module.
@private
@param {string} filename The path of the evaluated module.
@param {string} content The text content of the module.
@param {Resolver|Object} [userResolver] Resolver to use, if not a res... | [
"Evaluate",
"module",
"text",
"in",
"similar",
"fashion",
"to",
"require",
"evaluations",
"returning",
"the",
"module",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L155-L164 | train |
Whitebolt/require-extra | src/require.js | _runEval | function _runEval(config, parser, options, sync=true) {
const time = process.hrtime();
const evalEvent = new emitter.Evaluate({
target:config.filename,
source:(config.parent || {}).filename,
moduleConfig: config,
parserOptions: options,
sync
});
const evaluateEvent = emitter.emit('evaluate'... | javascript | function _runEval(config, parser, options, sync=true) {
const time = process.hrtime();
const evalEvent = new emitter.Evaluate({
target:config.filename,
source:(config.parent || {}).filename,
moduleConfig: config,
parserOptions: options,
sync
});
const evaluateEvent = emitter.emit('evaluate'... | [
"function",
"_runEval",
"(",
"config",
",",
"parser",
",",
"options",
",",
"sync",
"=",
"true",
")",
"{",
"const",
"time",
"=",
"process",
".",
"hrtime",
"(",
")",
";",
"const",
"evalEvent",
"=",
"new",
"emitter",
".",
"Evaluate",
"(",
"{",
"target",
... | Run the parser with the given configuration and deal with events, returning the module.
@private
@param {Object} config
@param {Function} parser
@returns {Module} | [
"Run",
"the",
"parser",
"with",
"the",
"given",
"configuration",
"and",
"deal",
"with",
"events",
"returning",
"the",
"module",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L174-L203 | train |
Whitebolt/require-extra | src/require.js | _createModuleConfig | function _createModuleConfig(filename, content, userResolver) {
return Object.assign({
content,
filename,
includeGlobals:true,
syncRequire:_syncRequire(_syncRequire),
resolveModulePath,
resolveModulePathSync,
basedir: path.dirname(filename),
resolver: userResolver
}, userResolver.exp... | javascript | function _createModuleConfig(filename, content, userResolver) {
return Object.assign({
content,
filename,
includeGlobals:true,
syncRequire:_syncRequire(_syncRequire),
resolveModulePath,
resolveModulePathSync,
basedir: path.dirname(filename),
resolver: userResolver
}, userResolver.exp... | [
"function",
"_createModuleConfig",
"(",
"filename",
",",
"content",
",",
"userResolver",
")",
"{",
"return",
"Object",
".",
"assign",
"(",
"{",
"content",
",",
"filename",
",",
"includeGlobals",
":",
"true",
",",
"syncRequire",
":",
"_syncRequire",
"(",
"_sync... | Create a config object to pass to _eval or Module constructor using supplied filename, content and Resolver.
@private
@param {string} filename The filename to create for.
@param {string|Buffer} content The content of the file.
@param {Resolver} userResolver The Resolver being used.
@returns {Object} ... | [
"Create",
"a",
"config",
"object",
"to",
"pass",
"to",
"_eval",
"or",
"Module",
"constructor",
"using",
"supplied",
"filename",
"content",
"and",
"Resolver",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L249-L260 | train |
Whitebolt/require-extra | src/require.js | _loadModuleSyncAsync | async function _loadModuleSyncAsync(filename, userResolver) {
const localRequire = requireLike(_getResolve(userResolver).parent || settings.get('parent').filename);
await promisify(setImmediate)();
return localRequire(filename);
} | javascript | async function _loadModuleSyncAsync(filename, userResolver) {
const localRequire = requireLike(_getResolve(userResolver).parent || settings.get('parent').filename);
await promisify(setImmediate)();
return localRequire(filename);
} | [
"async",
"function",
"_loadModuleSyncAsync",
"(",
"filename",
",",
"userResolver",
")",
"{",
"const",
"localRequire",
"=",
"requireLike",
"(",
"_getResolve",
"(",
"userResolver",
")",
".",
"parent",
"||",
"settings",
".",
"get",
"(",
"'parent'",
")",
".",
"fil... | This is a sychronous version of loadModule. The module is still resolved
using async methods but the actual loading is done using the native require
from node.
Load and evaluate a module returning undefined to promise resolve
on failure.
@private
@param {string} filename The path of the evaluated mod... | [
"This",
"is",
"a",
"sychronous",
"version",
"of",
"loadModule",
".",
"The",
"module",
"is",
"still",
"resolved",
"using",
"async",
"methods",
"but",
"the",
"actual",
"loading",
"is",
"done",
"using",
"the",
"native",
"require",
"from",
"node",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L314-L318 | train |
Whitebolt/require-extra | src/require.js | _parseRequireParams | function _parseRequireParams([userResolver, moduleId, callback], useSyncResolve=false) {
if(isString(userResolver) || Array.isArray(userResolver)) {
return [settings.get('resolver'), userResolver, moduleId, useSyncResolve];
}else {
return [_getResolve(userResolver), moduleId, callback, useSyncResolve];
}
... | javascript | function _parseRequireParams([userResolver, moduleId, callback], useSyncResolve=false) {
if(isString(userResolver) || Array.isArray(userResolver)) {
return [settings.get('resolver'), userResolver, moduleId, useSyncResolve];
}else {
return [_getResolve(userResolver), moduleId, callback, useSyncResolve];
}
... | [
"function",
"_parseRequireParams",
"(",
"[",
"userResolver",
",",
"moduleId",
",",
"callback",
"]",
",",
"useSyncResolve",
"=",
"false",
")",
"{",
"if",
"(",
"isString",
"(",
"userResolver",
")",
"||",
"Array",
".",
"isArray",
"(",
"userResolver",
")",
")",
... | Take arguments supplied to the different require function and parse ready for internal use.
@private
@param {Resolver} [userResolver] Resolver to use.
@param {string} moduleId The module to load.
@param {Function} [callback] ... | [
"Take",
"arguments",
"supplied",
"to",
"the",
"different",
"require",
"function",
"and",
"parse",
"ready",
"for",
"internal",
"use",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L379-L385 | train |
Whitebolt/require-extra | src/require.js | syncRequire | function syncRequire(...params) {
const [userResolver, moduleId] = _parseRequireParams(params);
if (userResolver.isCoreModule(moduleId)) return getRequire()(moduleId);
userResolver.basedir = userResolver.basedir || userResolver.dir;
const filename = resolveModulePathSync(userResolver, moduleId, true);
return ... | javascript | function syncRequire(...params) {
const [userResolver, moduleId] = _parseRequireParams(params);
if (userResolver.isCoreModule(moduleId)) return getRequire()(moduleId);
userResolver.basedir = userResolver.basedir || userResolver.dir;
const filename = resolveModulePathSync(userResolver, moduleId, true);
return ... | [
"function",
"syncRequire",
"(",
"...",
"params",
")",
"{",
"const",
"[",
"userResolver",
",",
"moduleId",
"]",
"=",
"_parseRequireParams",
"(",
"params",
")",
";",
"if",
"(",
"userResolver",
".",
"isCoreModule",
"(",
"moduleId",
")",
")",
"return",
"getRequi... | CommonJs require function, similar to node.js native version but with extra features of this module.
@param {Resolver} [userResolver] Resolver to use in requiring.
@param {string} moduleId Module to load.
@returns {*} Module exports | [
"CommonJs",
"require",
"function",
"similar",
"to",
"node",
".",
"js",
"native",
"version",
"but",
"with",
"extra",
"features",
"of",
"this",
"module",
"."
] | 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/require.js#L428-L434 | train |
ciena-frost/ember-frost-page-title | index.js | function (type, config) {
// fail if we don't have a default for frost-page-title in the config
if (!config.APP || !config.APP['frost-page-title'].defaultTitle) {
return
}
// insert default page title
if (type === 'page-title') {
return config.APP['frost-page-title'].defaultTitle
}
... | javascript | function (type, config) {
// fail if we don't have a default for frost-page-title in the config
if (!config.APP || !config.APP['frost-page-title'].defaultTitle) {
return
}
// insert default page title
if (type === 'page-title') {
return config.APP['frost-page-title'].defaultTitle
}
... | [
"function",
"(",
"type",
",",
"config",
")",
"{",
"// fail if we don't have a default for frost-page-title in the config",
"if",
"(",
"!",
"config",
".",
"APP",
"||",
"!",
"config",
".",
"APP",
"[",
"'frost-page-title'",
"]",
".",
"defaultTitle",
")",
"{",
"return... | sets the default page title on build
@param {string} type - type of content in which to be included
@param {object} config - the app config object
@returns {string|undefined} - string for content | [
"sets",
"the",
"default",
"page",
"title",
"on",
"build"
] | a8c85180f522ad7fb6a2836122867bc8178d69c8 | https://github.com/ciena-frost/ember-frost-page-title/blob/a8c85180f522ad7fb6a2836122867bc8178d69c8/index.js#L13-L23 | train | |
jonschlinkert/file-contents | index.js | contentsAsync | function contentsAsync(file, options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
}
if (typeof cb !== 'function') {
throw new TypeError('expected a callback function');
}
if (!utils.isObject(file)) {
cb(new TypeError('expected file to be an object'));
return;
... | javascript | function contentsAsync(file, options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
}
if (typeof cb !== 'function') {
throw new TypeError('expected a callback function');
}
if (!utils.isObject(file)) {
cb(new TypeError('expected file to be an object'));
return;
... | [
"function",
"contentsAsync",
"(",
"file",
",",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"cb",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"typeof",
"cb",
"!==",
"'function'... | Async method for getting `file.contents`.
@param {Object} `file`
@param {Object} `options`
@param {Function} `cb`
@return {Object} | [
"Async",
"method",
"for",
"getting",
"file",
".",
"contents",
"."
] | a53dcc62a1a529fc5f8b1dc0fa2a76a3196236fa | https://github.com/jonschlinkert/file-contents/blob/a53dcc62a1a529fc5f8b1dc0fa2a76a3196236fa/index.js#L29-L46 | train |
jonschlinkert/file-contents | index.js | contentsSync | function contentsSync(file, options) {
if (!utils.isObject(file)) {
throw new TypeError('expected file to be an object');
}
try {
// ideally we want to stat the real, initial filepath
file.stat = fs.lstatSync(file.history[0]);
} catch (err) {
try {
// if that doesn't work, try again
... | javascript | function contentsSync(file, options) {
if (!utils.isObject(file)) {
throw new TypeError('expected file to be an object');
}
try {
// ideally we want to stat the real, initial filepath
file.stat = fs.lstatSync(file.history[0]);
} catch (err) {
try {
// if that doesn't work, try again
... | [
"function",
"contentsSync",
"(",
"file",
",",
"options",
")",
"{",
"if",
"(",
"!",
"utils",
".",
"isObject",
"(",
"file",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'expected file to be an object'",
")",
";",
"}",
"try",
"{",
"// ideally we want to st... | Sync method for getting `file.contents`.
@param {Object} `file`
@param {Object} `options`
@return {Object} | [
"Sync",
"method",
"for",
"getting",
"file",
".",
"contents",
"."
] | a53dcc62a1a529fc5f8b1dc0fa2a76a3196236fa | https://github.com/jonschlinkert/file-contents/blob/a53dcc62a1a529fc5f8b1dc0fa2a76a3196236fa/index.js#L56-L75 | train |
vid/SenseBase | lib/utils.js | retrieve | function retrieve(uri, callback) {
var buffer = '';
http.get(uri, function(res) {
res.on('data', function (chunk) {
buffer += chunk;
});
res.on('end', function() {
callback(null, buffer);
});
}).on('error', function(e) {
callback(e);
});
} | javascript | function retrieve(uri, callback) {
var buffer = '';
http.get(uri, function(res) {
res.on('data', function (chunk) {
buffer += chunk;
});
res.on('end', function() {
callback(null, buffer);
});
}).on('error', function(e) {
callback(e);
});
} | [
"function",
"retrieve",
"(",
"uri",
",",
"callback",
")",
"{",
"var",
"buffer",
"=",
"''",
";",
"http",
".",
"get",
"(",
"uri",
",",
"function",
"(",
"res",
")",
"{",
"res",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{",
"buff... | perform a GET then callback content | [
"perform",
"a",
"GET",
"then",
"callback",
"content"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/utils.js#L82-L94 | train |
vid/SenseBase | lib/utils.js | doPost | function doPost(options, data, callback) {
var buffer = '';
var req = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
buffer += chunk;
});
res.on('end', function(err) {
callback(err, buffer);
});
}).on('error', function(e) {
call... | javascript | function doPost(options, data, callback) {
var buffer = '';
var req = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
buffer += chunk;
});
res.on('end', function(err) {
callback(err, buffer);
});
}).on('error', function(e) {
call... | [
"function",
"doPost",
"(",
"options",
",",
"data",
",",
"callback",
")",
"{",
"var",
"buffer",
"=",
"''",
";",
"var",
"req",
"=",
"http",
".",
"request",
"(",
"options",
",",
"function",
"(",
"res",
")",
"{",
"res",
".",
"setEncoding",
"(",
"'utf8'",... | perform a POST then callback contents | [
"perform",
"a",
"POST",
"then",
"callback",
"contents"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/utils.js#L97-L115 | train |
wunderbyte/grunt-spiritual-build | trash/super.NOTUSED.js | checkextension | function checkextension(subword) {
var checknext = true;
if(findbehind(subword) && endshere(subword)) {
wordindex = startindex(subword);
prototype = getprototypeat(wordindex);
curlcount = 0;
prencount = 0;
checknext = false;
}
return checknext;
} | javascript | function checkextension(subword) {
var checknext = true;
if(findbehind(subword) && endshere(subword)) {
wordindex = startindex(subword);
prototype = getprototypeat(wordindex);
curlcount = 0;
prencount = 0;
checknext = false;
}
return checknext;
} | [
"function",
"checkextension",
"(",
"subword",
")",
"{",
"var",
"checknext",
"=",
"true",
";",
"if",
"(",
"findbehind",
"(",
"subword",
")",
"&&",
"endshere",
"(",
"subword",
")",
")",
"{",
"wordindex",
"=",
"startindex",
"(",
"subword",
")",
";",
"protot... | Did the code just itend to extend or mixin something?
If so, we switch to super keyword replacement modus.
@param {string} subword
@returns {boolean} True if no match (so check another match) | [
"Did",
"the",
"code",
"just",
"itend",
"to",
"extend",
"or",
"mixin",
"something?",
"If",
"so",
"we",
"switch",
"to",
"super",
"keyword",
"replacement",
"modus",
"."
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/trash/super.NOTUSED.js#L61-L71 | train |
wunderbyte/grunt-spiritual-build | trash/super.NOTUSED.js | checksupercall | function checksupercall() {
keywords.every(function(keyword) {
if (findbehind(keyword)) {
supercall = true;
methodname = true;
buffer = buffer.substr(0, startindex(keyword));
buffer += prototype;
return false;
}
return true;
});
} | javascript | function checksupercall() {
keywords.every(function(keyword) {
if (findbehind(keyword)) {
supercall = true;
methodname = true;
buffer = buffer.substr(0, startindex(keyword));
buffer += prototype;
return false;
}
return true;
});
} | [
"function",
"checksupercall",
"(",
")",
"{",
"keywords",
".",
"every",
"(",
"function",
"(",
"keyword",
")",
"{",
"if",
"(",
"findbehind",
"(",
"keyword",
")",
")",
"{",
"supercall",
"=",
"true",
";",
"methodname",
"=",
"true",
";",
"buffer",
"=",
"buf... | Did the code just intend a supercall? | [
"Did",
"the",
"code",
"just",
"intend",
"a",
"supercall?"
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/trash/super.NOTUSED.js#L76-L87 | train |
wunderbyte/grunt-spiritual-build | trash/super.NOTUSED.js | endshere | function endshere(subword) {
var nextindex = charindex + 1;
return input.length === nextindex ||
!input[nextindex].match(METHODNAME);
} | javascript | function endshere(subword) {
var nextindex = charindex + 1;
return input.length === nextindex ||
!input[nextindex].match(METHODNAME);
} | [
"function",
"endshere",
"(",
"subword",
")",
"{",
"var",
"nextindex",
"=",
"charindex",
"+",
"1",
";",
"return",
"input",
".",
"length",
"===",
"nextindex",
"||",
"!",
"input",
"[",
"nextindex",
"]",
".",
"match",
"(",
"METHODNAME",
")",
";",
"}"
] | Magic word is not a substring of a longer word?
@param {string} subword
@returns {booleans} | [
"Magic",
"word",
"is",
"not",
"a",
"substring",
"of",
"a",
"longer",
"word?"
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/trash/super.NOTUSED.js#L122-L126 | train |
wunderbyte/grunt-spiritual-build | trash/super.NOTUSED.js | flush | function flush() {
output += buffer;
output += character;
buffer = '';
supercall = false;
methodname = false;
superargs = false;
} | javascript | function flush() {
output += buffer;
output += character;
buffer = '';
supercall = false;
methodname = false;
superargs = false;
} | [
"function",
"flush",
"(",
")",
"{",
"output",
"+=",
"buffer",
";",
"output",
"+=",
"character",
";",
"buffer",
"=",
"''",
";",
"supercall",
"=",
"false",
";",
"methodname",
"=",
"false",
";",
"superargs",
"=",
"false",
";",
"}"
] | Flush buffer to output. | [
"Flush",
"buffer",
"to",
"output",
"."
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/trash/super.NOTUSED.js#L175-L182 | train |
wunderbyte/grunt-spiritual-build | trash/super.NOTUSED.js | morechars | function morechars() {
switch (character) {
case ';':
flush();
break;
case '=':
case '\'':
case '"':
if(!supercall) {
flush();
}
break;
default:
if (supercall) {
processsupercall();
}
buffer += character;
if (prototype && !supercall) {
checksupercall()... | javascript | function morechars() {
switch (character) {
case ';':
flush();
break;
case '=':
case '\'':
case '"':
if(!supercall) {
flush();
}
break;
default:
if (supercall) {
processsupercall();
}
buffer += character;
if (prototype && !supercall) {
checksupercall()... | [
"function",
"morechars",
"(",
")",
"{",
"switch",
"(",
"character",
")",
"{",
"case",
"';'",
":",
"flush",
"(",
")",
";",
"break",
";",
"case",
"'='",
":",
"case",
"'\\''",
":",
"case",
"'\"'",
":",
"if",
"(",
"!",
"supercall",
")",
"{",
"flush",
... | Process chars in another way. | [
"Process",
"chars",
"in",
"another",
"way",
"."
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/trash/super.NOTUSED.js#L221-L246 | train |
feedhenry/fh-reportingclient | lib/sync.js | reqeueBatch | function reqeueBatch(times,interval,batch) {
async.retry({times: times, interval: interval}, function(cb) {
syncBatch(batch,cb);
}, function done(err) {
if (err) {
log.error("failed to sync message batch", {err: err, data: batch});
}
});
} | javascript | function reqeueBatch(times,interval,batch) {
async.retry({times: times, interval: interval}, function(cb) {
syncBatch(batch,cb);
}, function done(err) {
if (err) {
log.error("failed to sync message batch", {err: err, data: batch});
}
});
} | [
"function",
"reqeueBatch",
"(",
"times",
",",
"interval",
",",
"batch",
")",
"{",
"async",
".",
"retry",
"(",
"{",
"times",
":",
"times",
",",
"interval",
":",
"interval",
"}",
",",
"function",
"(",
"cb",
")",
"{",
"syncBatch",
"(",
"batch",
",",
"cb... | requeue the send of messages on failure. stopping after times or first success | [
"requeue",
"the",
"send",
"of",
"messages",
"on",
"failure",
".",
"stopping",
"after",
"times",
"or",
"first",
"success"
] | a0e2c959ce73addbf138d48f3ed46ef87229ae1a | https://github.com/feedhenry/fh-reportingclient/blob/a0e2c959ce73addbf138d48f3ed46ef87229ae1a/lib/sync.js#L18-L26 | 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.