id int32 0 58k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
38,000 | jgable/react-native-fluxbone | lib/dispatcher.js | function (events, context) {
if (!_.isObject(events)) {
console.warn('Only registration objects can be passed to dispatcher.register()');
return;
}
return this.dispatcher.register(function (payload) {
// Switch statements be damned...
if (events[payload.type]) {
events[paylo... | javascript | function (events, context) {
if (!_.isObject(events)) {
console.warn('Only registration objects can be passed to dispatcher.register()');
return;
}
return this.dispatcher.register(function (payload) {
// Switch statements be damned...
if (events[payload.type]) {
events[paylo... | [
"function",
"(",
"events",
",",
"context",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"events",
")",
")",
"{",
"console",
".",
"warn",
"(",
"'Only registration objects can be passed to dispatcher.register()'",
")",
";",
"return",
";",
"}",
"return",
... | Register a collection of callbacks to action types
@param {Object} events - A mapping of action types to callbacks
@param {Object} [context=null] - The context applied to the callback
@returns {string} The dispatcher token to use for unregister or waitFor | [
"Register",
"a",
"collection",
"of",
"callbacks",
"to",
"action",
"types"
] | 9847a598da0cc72f056c6bd4d2e21909b146f530 | https://github.com/jgable/react-native-fluxbone/blob/9847a598da0cc72f056c6bd4d2e21909b146f530/lib/dispatcher.js#L25-L37 | |
38,001 | jgable/react-native-fluxbone | lib/dispatcher.js | function (type, data) {
if (!_.isString(type)) {
console.warn('Action types are required when calling dispatcher.dispatch()');
return;
}
this.dispatcher.dispatch({
type: type,
data: data
});
} | javascript | function (type, data) {
if (!_.isString(type)) {
console.warn('Action types are required when calling dispatcher.dispatch()');
return;
}
this.dispatcher.dispatch({
type: type,
data: data
});
} | [
"function",
"(",
"type",
",",
"data",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"type",
")",
")",
"{",
"console",
".",
"warn",
"(",
"'Action types are required when calling dispatcher.dispatch()'",
")",
";",
"return",
";",
"}",
"this",
".",
"dis... | Dispatch an action by name
@param {string} type - Name of the action
@param {Object|string|number|boolean} data - The payload of the action | [
"Dispatch",
"an",
"action",
"by",
"name"
] | 9847a598da0cc72f056c6bd4d2e21909b146f530 | https://github.com/jgable/react-native-fluxbone/blob/9847a598da0cc72f056c6bd4d2e21909b146f530/lib/dispatcher.js#L62-L72 | |
38,002 | jgable/react-native-fluxbone | lib/dispatcher.js | function (token) {
var tokens = token;
if (!_.isArray(tokens)) {
tokens = [tokens];
}
tokens = tokens.map(function (token) {
// Allow passing stores straight and we grab the dispatcherToken
return token.dispatcherToken || token;
});
return this.dispatcher.waitFor(tokens);
} | javascript | function (token) {
var tokens = token;
if (!_.isArray(tokens)) {
tokens = [tokens];
}
tokens = tokens.map(function (token) {
// Allow passing stores straight and we grab the dispatcherToken
return token.dispatcherToken || token;
});
return this.dispatcher.waitFor(tokens);
} | [
"function",
"(",
"token",
")",
"{",
"var",
"tokens",
"=",
"token",
";",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"tokens",
")",
")",
"{",
"tokens",
"=",
"[",
"tokens",
"]",
";",
"}",
"tokens",
"=",
"tokens",
".",
"map",
"(",
"function",
"(",
"... | Wait for another callback to occur before continuing
@param {string|string[]|Store} token - The collection of dispatch tokens to wait on | [
"Wait",
"for",
"another",
"callback",
"to",
"occur",
"before",
"continuing"
] | 9847a598da0cc72f056c6bd4d2e21909b146f530 | https://github.com/jgable/react-native-fluxbone/blob/9847a598da0cc72f056c6bd4d2e21909b146f530/lib/dispatcher.js#L79-L91 | |
38,003 | fashion-js/fashion-model | Model.js | _ensureArray | function _ensureArray (model, property) {
const propertyKey = property.getKey();
let array = model.data[propertyKey];
if (!array) {
model.data[propertyKey] = array = [];
ArrayType.flagAsArrayType(array);
}
return array;
} | javascript | function _ensureArray (model, property) {
const propertyKey = property.getKey();
let array = model.data[propertyKey];
if (!array) {
model.data[propertyKey] = array = [];
ArrayType.flagAsArrayType(array);
}
return array;
} | [
"function",
"_ensureArray",
"(",
"model",
",",
"property",
")",
"{",
"const",
"propertyKey",
"=",
"property",
".",
"getKey",
"(",
")",
";",
"let",
"array",
"=",
"model",
".",
"data",
"[",
"propertyKey",
"]",
";",
"if",
"(",
"!",
"array",
")",
"{",
"m... | This function will be used to make sure an array value exists for the given property | [
"This",
"function",
"will",
"be",
"used",
"to",
"make",
"sure",
"an",
"array",
"value",
"exists",
"for",
"the",
"given",
"property"
] | 75a4090527ecf8b5075837a18f3d4216ccb561de | https://github.com/fashion-js/fashion-model/blob/75a4090527ecf8b5075837a18f3d4216ccb561de/Model.js#L112-L121 |
38,004 | danShumway/serverboy.js | examples/streaming/video/index.js | function() {
//io = socket(process.env.PORT || process.env.NODE_PORT || 3333);
io = socket(http);
io.on('connection', function(socket){
console.log('connection happened');
//Logic for handeling a new connection here.
//ie. registering a user or something similar.
... | javascript | function() {
//io = socket(process.env.PORT || process.env.NODE_PORT || 3333);
io = socket(http);
io.on('connection', function(socket){
console.log('connection happened');
//Logic for handeling a new connection here.
//ie. registering a user or something similar.
... | [
"function",
"(",
")",
"{",
"//io = socket(process.env.PORT || process.env.NODE_PORT || 3333);",
"io",
"=",
"socket",
"(",
"http",
")",
";",
"io",
".",
"on",
"(",
"'connection'",
",",
"function",
"(",
"socket",
")",
"{",
"console",
".",
"log",
"(",
"'connection h... | What keys we want pressed. | [
"What",
"keys",
"we",
"want",
"pressed",
"."
] | 68f0ac88b5b280f64de2c8ae6d57d8a84cbe3628 | https://github.com/danShumway/serverboy.js/blob/68f0ac88b5b280f64de2c8ae6d57d8a84cbe3628/examples/streaming/video/index.js#L17-L46 | |
38,005 | byron-dupreez/aws-core-utils | api-lambdas.js | configureHandlerContext | function configureHandlerContext(createContext, createSettings, createOptions, event, awsContext) {
// Configure the context as a standard context
let context = typeof createContext === 'function' ? createContext() :
createContext && typeof createContext === 'object' ? copy(createContext, deep) : {};
if (!con... | javascript | function configureHandlerContext(createContext, createSettings, createOptions, event, awsContext) {
// Configure the context as a standard context
let context = typeof createContext === 'function' ? createContext() :
createContext && typeof createContext === 'object' ? copy(createContext, deep) : {};
if (!con... | [
"function",
"configureHandlerContext",
"(",
"createContext",
",",
"createSettings",
",",
"createOptions",
",",
"event",
",",
"awsContext",
")",
"{",
"// Configure the context as a standard context",
"let",
"context",
"=",
"typeof",
"createContext",
"===",
"'function'",
"?... | Configures a standard handler context to use.
@param {(function(): (Object|HandlerContext))|undefined|Object|HandlerContext} [createContext] - an optional function
that will be used to create the initial context to be configured & used (OR or an optional LEGACY module-scope
context from which to copy an initial standar... | [
"Configures",
"a",
"standard",
"handler",
"context",
"to",
"use",
"."
] | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/api-lambdas.js#L166-L188 |
38,006 | byron-dupreez/aws-core-utils | api-lambdas.js | succeedLambdaCallback | function succeedLambdaCallback(callback, response, event, context) {
return Promises.try(() => {
const handler = context && context.handler;
if (handler && handler.useLambdaProxy) {
const statusCode = response && isNotBlank(response.statusCode) ? response.statusCode : 200;
const body = (response &... | javascript | function succeedLambdaCallback(callback, response, event, context) {
return Promises.try(() => {
const handler = context && context.handler;
if (handler && handler.useLambdaProxy) {
const statusCode = response && isNotBlank(response.statusCode) ? response.statusCode : 200;
const body = (response &... | [
"function",
"succeedLambdaCallback",
"(",
"callback",
",",
"response",
",",
"event",
",",
"context",
")",
"{",
"return",
"Promises",
".",
"try",
"(",
"(",
")",
"=>",
"{",
"const",
"handler",
"=",
"context",
"&&",
"context",
".",
"handler",
";",
"if",
"("... | Succeeds the given callback of an API Gateway exposed AWS Lambda, by invoking the given callback with the given
response.
@param {Function} callback - the callback function passed as the last argument to your Lambda function on invocation.
@param {Object} response - a normal or Lambda Proxy integration response to be r... | [
"Succeeds",
"the",
"given",
"callback",
"of",
"an",
"API",
"Gateway",
"exposed",
"AWS",
"Lambda",
"by",
"invoking",
"the",
"given",
"callback",
"with",
"the",
"given",
"response",
"."
] | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/api-lambdas.js#L293-L318 |
38,007 | byron-dupreez/aws-core-utils | api-lambdas.js | toLambdaProxyResponse | function toLambdaProxyResponse(statusCode, headers, body, defaultHeaders) {
const proxyResponse = {statusCode: statusCode};
const headersWithDefaults = headers && defaultHeaders ? merge(defaultHeaders, copy(headers)) :
headers || (defaultHeaders && copy(defaultHeaders));
if (headersWithDefaults) {
proxyR... | javascript | function toLambdaProxyResponse(statusCode, headers, body, defaultHeaders) {
const proxyResponse = {statusCode: statusCode};
const headersWithDefaults = headers && defaultHeaders ? merge(defaultHeaders, copy(headers)) :
headers || (defaultHeaders && copy(defaultHeaders));
if (headersWithDefaults) {
proxyR... | [
"function",
"toLambdaProxyResponse",
"(",
"statusCode",
",",
"headers",
",",
"body",
",",
"defaultHeaders",
")",
"{",
"const",
"proxyResponse",
"=",
"{",
"statusCode",
":",
"statusCode",
"}",
";",
"const",
"headersWithDefaults",
"=",
"headers",
"&&",
"defaultHeade... | Builds & returns a Lambda Proxy integration compatible response.
@param {number|string} statusCode - the HTTP status code to return
@param {Object|undefined} [headers] - optional response headers to use
@param {Object|string|undefined} [body] - an optional response body to use
@param {Object|undefined} [defaultHeaders]... | [
"Builds",
"&",
"returns",
"a",
"Lambda",
"Proxy",
"integration",
"compatible",
"response",
"."
] | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/api-lambdas.js#L385-L397 |
38,008 | byron-dupreez/aws-core-utils | api-lambdas.js | toDefaultErrorResponseBody | function toDefaultErrorResponseBody(error) {
const json = error && error.toJSON();
if (json) {
if (json.httpStatus) {
delete json.httpStatus; // don't really need `httpStatus` inside `body` too, since have it in response as `statusCode`
}
if (json.headers) {
delete json.headers; // don't wan... | javascript | function toDefaultErrorResponseBody(error) {
const json = error && error.toJSON();
if (json) {
if (json.httpStatus) {
delete json.httpStatus; // don't really need `httpStatus` inside `body` too, since have it in response as `statusCode`
}
if (json.headers) {
delete json.headers; // don't wan... | [
"function",
"toDefaultErrorResponseBody",
"(",
"error",
")",
"{",
"const",
"json",
"=",
"error",
"&&",
"error",
".",
"toJSON",
"(",
")",
";",
"if",
"(",
"json",
")",
"{",
"if",
"(",
"json",
".",
"httpStatus",
")",
"{",
"delete",
"json",
".",
"httpStatu... | A default conversion from an error to an error response body for a Lambda Proxy error response
@param {AppError} error - an error to convert
@return {Object} an error response body | [
"A",
"default",
"conversion",
"from",
"an",
"error",
"to",
"an",
"error",
"response",
"body",
"for",
"a",
"Lambda",
"Proxy",
"error",
"response"
] | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/api-lambdas.js#L452-L463 |
38,009 | ninejs/ninejs | ui/logic/FilterBuilder/DefaultClipboardStrategy.js | function(expression) {
if (this.hasClipboard()) {
var key = this._getKey();
localStorage[key] = json.stringify(expression.toJson());
}
} | javascript | function(expression) {
if (this.hasClipboard()) {
var key = this._getKey();
localStorage[key] = json.stringify(expression.toJson());
}
} | [
"function",
"(",
"expression",
")",
"{",
"if",
"(",
"this",
".",
"hasClipboard",
"(",
")",
")",
"{",
"var",
"key",
"=",
"this",
".",
"_getKey",
"(",
")",
";",
"localStorage",
"[",
"key",
"]",
"=",
"json",
".",
"stringify",
"(",
"expression",
".",
"... | Copies the expression parameter | [
"Copies",
"the",
"expression",
"parameter"
] | 5da252baff42c13f92fa8f45932439993e9f7dd3 | https://github.com/ninejs/ninejs/blob/5da252baff42c13f92fa8f45932439993e9f7dd3/ui/logic/FilterBuilder/DefaultClipboardStrategy.js#L45-L50 | |
38,010 | ninejs/ninejs | ui/logic/FilterBuilder/DefaultClipboardStrategy.js | function(expression) {
var pastedExpression = new Expression();
var key = this._getKey();
pastedExpression.fromJson(json.parse(localStorage[key]));
var newExpression;
if (expression) {
var expressionClone = new Expression({
operator : 'and',
expressionList : [expression, pastedExpression]
... | javascript | function(expression) {
var pastedExpression = new Expression();
var key = this._getKey();
pastedExpression.fromJson(json.parse(localStorage[key]));
var newExpression;
if (expression) {
var expressionClone = new Expression({
operator : 'and',
expressionList : [expression, pastedExpression]
... | [
"function",
"(",
"expression",
")",
"{",
"var",
"pastedExpression",
"=",
"new",
"Expression",
"(",
")",
";",
"var",
"key",
"=",
"this",
".",
"_getKey",
"(",
")",
";",
"pastedExpression",
".",
"fromJson",
"(",
"json",
".",
"parse",
"(",
"localStorage",
"[... | Pastes the copied expression in the same level as the one provided and returns the new Expression If null is provided then it just returns the pasted expression. | [
"Pastes",
"the",
"copied",
"expression",
"in",
"the",
"same",
"level",
"as",
"the",
"one",
"provided",
"and",
"returns",
"the",
"new",
"Expression",
"If",
"null",
"is",
"provided",
"then",
"it",
"just",
"returns",
"the",
"pasted",
"expression",
"."
] | 5da252baff42c13f92fa8f45932439993e9f7dd3 | https://github.com/ninejs/ninejs/blob/5da252baff42c13f92fa8f45932439993e9f7dd3/ui/logic/FilterBuilder/DefaultClipboardStrategy.js#L54-L76 | |
38,011 | recidive/choko | server.js | getArguments | function getArguments() {
var port = 3000;
var path = '.';
var args = process.argv.slice(2);
while (args.length) {
var arg = args.shift();
switch (arg) {
case '-p':
port = args.shift();
break;
default:
path = arg || path;
}
}
return {
port: port,
pat... | javascript | function getArguments() {
var port = 3000;
var path = '.';
var args = process.argv.slice(2);
while (args.length) {
var arg = args.shift();
switch (arg) {
case '-p':
port = args.shift();
break;
default:
path = arg || path;
}
}
return {
port: port,
pat... | [
"function",
"getArguments",
"(",
")",
"{",
"var",
"port",
"=",
"3000",
";",
"var",
"path",
"=",
"'.'",
";",
"var",
"args",
"=",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
";",
"while",
"(",
"args",
".",
"length",
")",
"{",
"var",
"arg",... | Get port and application folder path from command line arguments. Use port from "-p" or fallback to 3000. Default folder is the current folder. | [
"Get",
"port",
"and",
"application",
"folder",
"path",
"from",
"command",
"line",
"arguments",
".",
"Use",
"port",
"from",
"-",
"p",
"or",
"fallback",
"to",
"3000",
".",
"Default",
"folder",
"is",
"the",
"current",
"folder",
"."
] | 7c0576c8c55543ec99d04ea609700765f178f73a | https://github.com/recidive/choko/blob/7c0576c8c55543ec99d04ea609700765f178f73a/server.js#L13-L33 |
38,012 | scott-wyatt/sails-stripe | templates/Discount.template.js | function (discount, cb) {
Discount.destroy(discount.id)
.exec(function (err, destroyedDiscounts){
if (err) return cb(err);
if (!destroyedDiscounts) return cb(null, null);
Discount.afterStripeCustomerDiscountDeleted(destroyedDiscounts[0], function(err, discount){
cb(err, discount);
... | javascript | function (discount, cb) {
Discount.destroy(discount.id)
.exec(function (err, destroyedDiscounts){
if (err) return cb(err);
if (!destroyedDiscounts) return cb(null, null);
Discount.afterStripeCustomerDiscountDeleted(destroyedDiscounts[0], function(err, discount){
cb(err, discount);
... | [
"function",
"(",
"discount",
",",
"cb",
")",
"{",
"Discount",
".",
"destroy",
"(",
"discount",
".",
"id",
")",
".",
"exec",
"(",
"function",
"(",
"err",
",",
"destroyedDiscounts",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";... | Stripe Webhook customer.discount.deleted | [
"Stripe",
"Webhook",
"customer",
".",
"discount",
".",
"deleted"
] | 0766bc04a6893a07c842170f37b37200d6771425 | https://github.com/scott-wyatt/sails-stripe/blob/0766bc04a6893a07c842170f37b37200d6771425/templates/Discount.template.js#L103-L113 | |
38,013 | impromptu/impromptu | lib/cache/ShimCache.js | ShimCache | function ShimCache(state, name, options) {
this._callbacks = []
AbstractCache.call(this, state, name, options)
} | javascript | function ShimCache(state, name, options) {
this._callbacks = []
AbstractCache.call(this, state, name, options)
} | [
"function",
"ShimCache",
"(",
"state",
",",
"name",
",",
"options",
")",
"{",
"this",
".",
"_callbacks",
"=",
"[",
"]",
"AbstractCache",
".",
"call",
"(",
"this",
",",
"state",
",",
"name",
",",
"options",
")",
"}"
] | A shim that runs a function in the context of Impromptu's caching interface.
Does NOT cache the result!
@constructor
@extends {AbstractCache}
@param {State} state
@param {string} name The name of the cache key.
@param {Object} options The options for this instance of the cache. | [
"A",
"shim",
"that",
"runs",
"a",
"function",
"in",
"the",
"context",
"of",
"Impromptu",
"s",
"caching",
"interface",
".",
"Does",
"NOT",
"cache",
"the",
"result!"
] | 829798eda62771d6a6ed971d87eef7a461932704 | https://github.com/impromptu/impromptu/blob/829798eda62771d6a6ed971d87eef7a461932704/lib/cache/ShimCache.js#L16-L19 |
38,014 | recidive/choko | lib/storage.js | function(when, operation) {
return function(values, callback) {
var callbackName = when + operation;
// Call type callback.
if (callbackName in settings) {
return settings[callbackName](settings, values, function() {
// Invoke hook on all extensions.
application.invoke... | javascript | function(when, operation) {
return function(values, callback) {
var callbackName = when + operation;
// Call type callback.
if (callbackName in settings) {
return settings[callbackName](settings, values, function() {
// Invoke hook on all extensions.
application.invoke... | [
"function",
"(",
"when",
",",
"operation",
")",
"{",
"return",
"function",
"(",
"values",
",",
"callback",
")",
"{",
"var",
"callbackName",
"=",
"when",
"+",
"operation",
";",
"// Call type callback.",
"if",
"(",
"callbackName",
"in",
"settings",
")",
"{",
... | Generate callbacks for all Waterline lifecycle callbacks. | [
"Generate",
"callbacks",
"for",
"all",
"Waterline",
"lifecycle",
"callbacks",
"."
] | 7c0576c8c55543ec99d04ea609700765f178f73a | https://github.com/recidive/choko/blob/7c0576c8c55543ec99d04ea609700765f178f73a/lib/storage.js#L115-L130 | |
38,015 | XOP/sass-vars-to-js | src/_collect-declarations.js | collectDeclarations | function collectDeclarations (filePath) {
const declarationRegexp = /(?:\$)([\w-]+)(?:[\s\n\r\t])*(?::)(?:[\s\n\r\t])*(.+)(?:[\s\n\r\t])*(?:;)/gm;
const fileSource = fs.readFileSync(filePath, 'utf8');
return fileSource.match(declarationRegexp);
} | javascript | function collectDeclarations (filePath) {
const declarationRegexp = /(?:\$)([\w-]+)(?:[\s\n\r\t])*(?::)(?:[\s\n\r\t])*(.+)(?:[\s\n\r\t])*(?:;)/gm;
const fileSource = fs.readFileSync(filePath, 'utf8');
return fileSource.match(declarationRegexp);
} | [
"function",
"collectDeclarations",
"(",
"filePath",
")",
"{",
"const",
"declarationRegexp",
"=",
"/",
"(?:\\$)([\\w-]+)(?:[\\s\\n\\r\\t])*(?::)(?:[\\s\\n\\r\\t])*(.+)(?:[\\s\\n\\r\\t])*(?:;)",
"/",
"gm",
";",
"const",
"fileSource",
"=",
"fs",
".",
"readFileSync",
"(",
"file... | Parses file
Returns declarations array
@param filePath
@returns {Array|{index: number, input: string}|*|Array} | [
"Parses",
"file",
"Returns",
"declarations",
"array"
] | 87ad8588701a9c2e69ace75931947d11698f25f0 | https://github.com/XOP/sass-vars-to-js/blob/87ad8588701a9c2e69ace75931947d11698f25f0/src/_collect-declarations.js#L9-L14 |
38,016 | alexlafroscia/postcss-retina-bg-img | lib/utils/media-query.js | queryCoversRange | function queryCoversRange(lessRestrictive, moreRestrictive) {
// Short curcuit if there is an exact match
if (lessRestrictive === moreRestrictive) {
return true;
}
const lessRestrictiveParts = explodeMediaQuery(lessRestrictive);
const moreRestrictiveParts = explodeMediaQuery(moreRestrictive);
return l... | javascript | function queryCoversRange(lessRestrictive, moreRestrictive) {
// Short curcuit if there is an exact match
if (lessRestrictive === moreRestrictive) {
return true;
}
const lessRestrictiveParts = explodeMediaQuery(lessRestrictive);
const moreRestrictiveParts = explodeMediaQuery(moreRestrictive);
return l... | [
"function",
"queryCoversRange",
"(",
"lessRestrictive",
",",
"moreRestrictive",
")",
"{",
"// Short curcuit if there is an exact match",
"if",
"(",
"lessRestrictive",
"===",
"moreRestrictive",
")",
"{",
"return",
"true",
";",
"}",
"const",
"lessRestrictiveParts",
"=",
"... | Determine if the more restrictive media query covers all cases of the less restrictive one
For MQ "A" to contain MQ "B", "A" must be at least as specific as "B".
@example
// returns `true`
queryCoversRange('(min-width: 600px)', '(min-width: 600px) and (max-width: 800px)');
@example
// returns `false`
queryCoversRang... | [
"Determine",
"if",
"the",
"more",
"restrictive",
"media",
"query",
"covers",
"all",
"cases",
"of",
"the",
"less",
"restrictive",
"one"
] | 4ff929815be2f76fe930335e2facc486df3f9dda | https://github.com/alexlafroscia/postcss-retina-bg-img/blob/4ff929815be2f76fe930335e2facc486df3f9dda/lib/utils/media-query.js#L18-L39 |
38,017 | alexlafroscia/postcss-retina-bg-img | lib/utils/media-query.js | explodeMediaQuery | function explodeMediaQuery(query) {
return query
.split(',')
.map(part => part.trim())
.map(orSection => orSection.split('and').map(part => part.trim()));
} | javascript | function explodeMediaQuery(query) {
return query
.split(',')
.map(part => part.trim())
.map(orSection => orSection.split('and').map(part => part.trim()));
} | [
"function",
"explodeMediaQuery",
"(",
"query",
")",
"{",
"return",
"query",
".",
"split",
"(",
"','",
")",
".",
"map",
"(",
"part",
"=>",
"part",
".",
"trim",
"(",
")",
")",
".",
"map",
"(",
"orSection",
"=>",
"orSection",
".",
"split",
"(",
"'and'",... | Break a media query string into parts
@example
const q = '(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)';
explodeMediaQuery(q);
// => ['(-webkit-min-device-pixel-ratio: 2)', '(min-resolution: 192dpi)']
@param {string} query the media query string to break apart
@return {array} the structure of the pr... | [
"Break",
"a",
"media",
"query",
"string",
"into",
"parts"
] | 4ff929815be2f76fe930335e2facc486df3f9dda | https://github.com/alexlafroscia/postcss-retina-bg-img/blob/4ff929815be2f76fe930335e2facc486df3f9dda/lib/utils/media-query.js#L53-L58 |
38,018 | alexlafroscia/postcss-retina-bg-img | lib/utils/media-query.js | arrayContainsAllElementsOfArray | function arrayContainsAllElementsOfArray(smaller, larger) {
return smaller.reduce((prev, element) => {
return prev && larger.indexOf(element) >= 0;
}, true);
} | javascript | function arrayContainsAllElementsOfArray(smaller, larger) {
return smaller.reduce((prev, element) => {
return prev && larger.indexOf(element) >= 0;
}, true);
} | [
"function",
"arrayContainsAllElementsOfArray",
"(",
"smaller",
",",
"larger",
")",
"{",
"return",
"smaller",
".",
"reduce",
"(",
"(",
"prev",
",",
"element",
")",
"=>",
"{",
"return",
"prev",
"&&",
"larger",
".",
"indexOf",
"(",
"element",
")",
">=",
"0",
... | Verify that one array contains all the elements of another
@example
const smaller = ['a'];
const larger = ['b'];
arrayContainsAllElementsOfArray(smaller, larger);
// => true
@param {array} smaller the array to ensure is contained by the other
@param {array} larger the array to ensure contains the other
@return {bool... | [
"Verify",
"that",
"one",
"array",
"contains",
"all",
"the",
"elements",
"of",
"another"
] | 4ff929815be2f76fe930335e2facc486df3f9dda | https://github.com/alexlafroscia/postcss-retina-bg-img/blob/4ff929815be2f76fe930335e2facc486df3f9dda/lib/utils/media-query.js#L74-L78 |
38,019 | alexlafroscia/postcss-retina-bg-img | lib/utils/media-query.js | distributeQueryAcrossQuery | function distributeQueryAcrossQuery(firstQuery, secondQuery) {
const aParts = explodeMediaQuery(firstQuery);
const bParts = explodeMediaQuery(secondQuery);
return aParts
.map(aPart => bParts.map(bPart => `${aPart} and ${bPart}`).join(', '))
.join(', ');
} | javascript | function distributeQueryAcrossQuery(firstQuery, secondQuery) {
const aParts = explodeMediaQuery(firstQuery);
const bParts = explodeMediaQuery(secondQuery);
return aParts
.map(aPart => bParts.map(bPart => `${aPart} and ${bPart}`).join(', '))
.join(', ');
} | [
"function",
"distributeQueryAcrossQuery",
"(",
"firstQuery",
",",
"secondQuery",
")",
"{",
"const",
"aParts",
"=",
"explodeMediaQuery",
"(",
"firstQuery",
")",
";",
"const",
"bParts",
"=",
"explodeMediaQuery",
"(",
"secondQuery",
")",
";",
"return",
"aParts",
".",... | Perform a "logic AND" on the two media queries
@example
const a = '(min-width: 600px)';
const b = '(max-width: 800px)';
distributeQueryAcrossQuery(a, b);
// => '(min-width: 600px), (max-width: 800px)'
@example
const a = '(min-width: 600px)';
const b = '(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)';
... | [
"Perform",
"a",
"logic",
"AND",
"on",
"the",
"two",
"media",
"queries"
] | 4ff929815be2f76fe930335e2facc486df3f9dda | https://github.com/alexlafroscia/postcss-retina-bg-img/blob/4ff929815be2f76fe930335e2facc486df3f9dda/lib/utils/media-query.js#L101-L108 |
38,020 | royalpinto/node-cares | lib/cares.js | Resolver | function Resolver(options) {
if (!(this instanceof Resolver)) {
return new Resolver(options);
}
options = options || {};
if (!isObject(options)) {
throw new Error('options must be an object');
}
this._resolver = new cares.Resolver(options);
if (options.servers) {
... | javascript | function Resolver(options) {
if (!(this instanceof Resolver)) {
return new Resolver(options);
}
options = options || {};
if (!isObject(options)) {
throw new Error('options must be an object');
}
this._resolver = new cares.Resolver(options);
if (options.servers) {
... | [
"function",
"Resolver",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Resolver",
")",
")",
"{",
"return",
"new",
"Resolver",
"(",
"options",
")",
";",
"}",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"isO... | Initialize the resolver with given options.
@param {Object} [options={}] The options to be used with the resolver.
@param {Number} [options.timeout=5000] The number of milliseconds each
name server should be given to respond to a query on the first try.
(After the first try, the timeout algorithm becomes more complicat... | [
"Initialize",
"the",
"resolver",
"with",
"given",
"options",
"."
] | 6a38a49a8baf080d33d4520567f8eee5fb74f249 | https://github.com/royalpinto/node-cares/blob/6a38a49a8baf080d33d4520567f8eee5fb74f249/lib/cares.js#L179-L195 |
38,021 | dominicbarnes/json-string | index.js | format | function format(input, level, options) {
if (util.isArray(input)) {
return array(input, level, options);
} else if (util.isObject(input)) {
return object(input, level, options);
} else {
return stringify(input, options);
}
} | javascript | function format(input, level, options) {
if (util.isArray(input)) {
return array(input, level, options);
} else if (util.isObject(input)) {
return object(input, level, options);
} else {
return stringify(input, options);
}
} | [
"function",
"format",
"(",
"input",
",",
"level",
",",
"options",
")",
"{",
"if",
"(",
"util",
".",
"isArray",
"(",
"input",
")",
")",
"{",
"return",
"array",
"(",
"input",
",",
"level",
",",
"options",
")",
";",
"}",
"else",
"if",
"(",
"util",
"... | Turns the `input` object into a string with options for human-friendly
output.
@param {Object} input
@param {Object} [options]
@returns {String} | [
"Turns",
"the",
"input",
"object",
"into",
"a",
"string",
"with",
"options",
"for",
"human",
"-",
"friendly",
"output",
"."
] | 3c41894b2040b9542f6aedb0d5fd0fbdb54e0a5d | https://github.com/dominicbarnes/json-string/blob/3c41894b2040b9542f6aedb0d5fd0fbdb54e0a5d/index.js#L41-L49 |
38,022 | dominicbarnes/json-string | index.js | object | function object(input, level, options) {
var spaces = options.spaces;
var inner = indent(level, spaces);
var outer = indent(level - 1, spaces);
var keys = Object.keys(input);
if (options.sortKeys) keys.sort(naturalSort());
var str = keys.map(function (key) {
return inner
+ stringify(key) + ': '
... | javascript | function object(input, level, options) {
var spaces = options.spaces;
var inner = indent(level, spaces);
var outer = indent(level - 1, spaces);
var keys = Object.keys(input);
if (options.sortKeys) keys.sort(naturalSort());
var str = keys.map(function (key) {
return inner
+ stringify(key) + ': '
... | [
"function",
"object",
"(",
"input",
",",
"level",
",",
"options",
")",
"{",
"var",
"spaces",
"=",
"options",
".",
"spaces",
";",
"var",
"inner",
"=",
"indent",
"(",
"level",
",",
"spaces",
")",
";",
"var",
"outer",
"=",
"indent",
"(",
"level",
"-",
... | JSON format an object directly.
@param {Object} input
@param {Number} level
@param {Object} options
@returns {String} | [
"JSON",
"format",
"an",
"object",
"directly",
"."
] | 3c41894b2040b9542f6aedb0d5fd0fbdb54e0a5d | https://github.com/dominicbarnes/json-string/blob/3c41894b2040b9542f6aedb0d5fd0fbdb54e0a5d/index.js#L74-L88 |
38,023 | dominicbarnes/json-string | index.js | array | function array(input, level, options) {
var spaces = options.spaces;
var inner = indent(level, spaces);
var outer = indent(level - 1, spaces);
var str = input
.map(function (value) {
return inner + format(value, level + 1, options);
})
.join(',\n');
return [ '[', str, outer + ']' ].join('\... | javascript | function array(input, level, options) {
var spaces = options.spaces;
var inner = indent(level, spaces);
var outer = indent(level - 1, spaces);
var str = input
.map(function (value) {
return inner + format(value, level + 1, options);
})
.join(',\n');
return [ '[', str, outer + ']' ].join('\... | [
"function",
"array",
"(",
"input",
",",
"level",
",",
"options",
")",
"{",
"var",
"spaces",
"=",
"options",
".",
"spaces",
";",
"var",
"inner",
"=",
"indent",
"(",
"level",
",",
"spaces",
")",
";",
"var",
"outer",
"=",
"indent",
"(",
"level",
"-",
... | JSON format an array directly.
@param {Object} input
@param {Number} level
@param {Object} options
@returns {String} | [
"JSON",
"format",
"an",
"array",
"directly",
"."
] | 3c41894b2040b9542f6aedb0d5fd0fbdb54e0a5d | https://github.com/dominicbarnes/json-string/blob/3c41894b2040b9542f6aedb0d5fd0fbdb54e0a5d/index.js#L99-L111 |
38,024 | knee-cola/SphereViewer | src/equi2recti-worker.js | outImgToXYZ | function outImgToXYZ(i, j, faceIdx, faceSize) {
var a = 2 * i / faceSize,
b = 2 * j / faceSize;
switch(faceIdx) {
case 0: // back
return({x:-1, y:1-a, z:1-b});
case 1: // left
return({x:a-1, y:-1, z:1-b});
case 2: // front
return({x: 1, y:a-1, z:1-b});
case 3: // right
return({x:1-a, y:1, z:1-... | javascript | function outImgToXYZ(i, j, faceIdx, faceSize) {
var a = 2 * i / faceSize,
b = 2 * j / faceSize;
switch(faceIdx) {
case 0: // back
return({x:-1, y:1-a, z:1-b});
case 1: // left
return({x:a-1, y:-1, z:1-b});
case 2: // front
return({x: 1, y:a-1, z:1-b});
case 3: // right
return({x:1-a, y:1, z:1-... | [
"function",
"outImgToXYZ",
"(",
"i",
",",
"j",
",",
"faceIdx",
",",
"faceSize",
")",
"{",
"var",
"a",
"=",
"2",
"*",
"i",
"/",
"faceSize",
",",
"b",
"=",
"2",
"*",
"j",
"/",
"faceSize",
";",
"switch",
"(",
"faceIdx",
")",
"{",
"case",
"0",
":",... | get x,y,z coords from out image pixels coords i,j are pixel coords faceIdx is face number faceSize is edge length | [
"get",
"x",
"y",
"z",
"coords",
"from",
"out",
"image",
"pixels",
"coords",
"i",
"j",
"are",
"pixel",
"coords",
"faceIdx",
"is",
"face",
"number",
"faceSize",
"is",
"edge",
"length"
] | e87cded5bd1635334612ac4b22d69355ec3e1d19 | https://github.com/knee-cola/SphereViewer/blob/e87cded5bd1635334612ac4b22d69355ec3e1d19/src/equi2recti-worker.js#L102-L120 |
38,025 | gl-vis/regl-splom | index.js | passId | function passId (trace, i, j) {
let id = (trace.id != null ? trace.id : trace)
let n = i
let m = j
let key = id << 16 | (n & 0xff) << 8 | m & 0xff
return key
} | javascript | function passId (trace, i, j) {
let id = (trace.id != null ? trace.id : trace)
let n = i
let m = j
let key = id << 16 | (n & 0xff) << 8 | m & 0xff
return key
} | [
"function",
"passId",
"(",
"trace",
",",
"i",
",",
"j",
")",
"{",
"let",
"id",
"=",
"(",
"trace",
".",
"id",
"!=",
"null",
"?",
"trace",
".",
"id",
":",
"trace",
")",
"let",
"n",
"=",
"i",
"let",
"m",
"=",
"j",
"let",
"key",
"=",
"id",
"<<"... | return pass corresponding to trace i- j- square | [
"return",
"pass",
"corresponding",
"to",
"trace",
"i",
"-",
"j",
"-",
"square"
] | a98ee4f4da9ca2773b81ed1d066cefc06f7400f1 | https://github.com/gl-vis/regl-splom/blob/a98ee4f4da9ca2773b81ed1d066cefc06f7400f1/index.js#L338-L345 |
38,026 | gl-vis/regl-splom | index.js | getBox | function getBox (items, i, j) {
let ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy
let iitem = items[i], jitem = items[j]
if (iitem.length > 2) {
ilox = iitem[0]
ihix = iitem[2]
iloy = iitem[1]
ihiy = iitem[3]
}
else if (iitem.length) {
ilox = iloy = iitem[0]
ihix = ihiy = iitem[1]
}
else {
ilox =... | javascript | function getBox (items, i, j) {
let ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy
let iitem = items[i], jitem = items[j]
if (iitem.length > 2) {
ilox = iitem[0]
ihix = iitem[2]
iloy = iitem[1]
ihiy = iitem[3]
}
else if (iitem.length) {
ilox = iloy = iitem[0]
ihix = ihiy = iitem[1]
}
else {
ilox =... | [
"function",
"getBox",
"(",
"items",
",",
"i",
",",
"j",
")",
"{",
"let",
"ilox",
",",
"iloy",
",",
"ihix",
",",
"ihiy",
",",
"jlox",
",",
"jloy",
",",
"jhix",
",",
"jhiy",
"let",
"iitem",
"=",
"items",
"[",
"i",
"]",
",",
"jitem",
"=",
"items",... | return bounding box corresponding to a pass | [
"return",
"bounding",
"box",
"corresponding",
"to",
"a",
"pass"
] | a98ee4f4da9ca2773b81ed1d066cefc06f7400f1 | https://github.com/gl-vis/regl-splom/blob/a98ee4f4da9ca2773b81ed1d066cefc06f7400f1/index.js#L349-L388 |
38,027 | glaunay/nslurm | index.js | function(opt) {
var vKeys = ["cancelBin", "queueBin", "submitBin"];
var msg = "Missing engine binaries parameters keys \"cancelBin\", \"queueBin\", \"submitBin\"";
for (var k in vKeys)
if (!opt.hasOwnProperty(k))
throw (msg);
engine.configure(opt);
} | javascript | function(opt) {
var vKeys = ["cancelBin", "queueBin", "submitBin"];
var msg = "Missing engine binaries parameters keys \"cancelBin\", \"queueBin\", \"submitBin\"";
for (var k in vKeys)
if (!opt.hasOwnProperty(k))
throw (msg);
engine.configure(opt);
} | [
"function",
"(",
"opt",
")",
"{",
"var",
"vKeys",
"=",
"[",
"\"cancelBin\"",
",",
"\"queueBin\"",
",",
"\"submitBin\"",
"]",
";",
"var",
"msg",
"=",
"\"Missing engine binaries parameters keys \\\"cancelBin\\\", \\\"queueBin\\\", \\\"submitBin\\\"\"",
";",
"for",
"(",
"v... | Check the existence of the bare minimum set of parameters to configure an engine
@param {Object}managerOptions: Litteral of options
@return null | [
"Check",
"the",
"existence",
"of",
"the",
"bare",
"minimum",
"set",
"of",
"parameters",
"to",
"configure",
"an",
"engine"
] | 002b064a700d3596d82e1c57110c0100a389f792 | https://github.com/glaunay/nslurm/blob/002b064a700d3596d82e1c57110c0100a389f792/index.js#L83-L90 | |
38,028 | glaunay/nslurm | index.js | function() {
var displayString = '###############################\n' + '###### Current jobs pool ######\n' + '###############################\n';
var c = 0;
for (var key in jobsArray) {;
c++;
displayString += '# ' + key + ' : ' + jobsArray[key].status + '\n';
}
if (c === 0)
d... | javascript | function() {
var displayString = '###############################\n' + '###### Current jobs pool ######\n' + '###############################\n';
var c = 0;
for (var key in jobsArray) {;
c++;
displayString += '# ' + key + ' : ' + jobsArray[key].status + '\n';
}
if (c === 0)
d... | [
"function",
"(",
")",
"{",
"var",
"displayString",
"=",
"'###############################\\n'",
"+",
"'###### Current jobs pool ######\\n'",
"+",
"'###############################\\n'",
";",
"var",
"c",
"=",
"0",
";",
"for",
"(",
"var",
"key",
"in",
"jobsArray",
")",
... | Display on console.log the current list of "pushed" jobs and their status
@param None
@return null | [
"Display",
"on",
"console",
".",
"log",
"the",
"current",
"list",
"of",
"pushed",
"jobs",
"and",
"their",
"status"
] | 002b064a700d3596d82e1c57110c0100a389f792 | https://github.com/glaunay/nslurm/blob/002b064a700d3596d82e1c57110c0100a389f792/index.js#L109-L121 | |
38,029 | glaunay/nslurm | index.js | function(opt) {
//console.log(opt)
if (isStarted) return;
var self = this;
if (!opt) {
throw "Options required to start manager : \"cacheDir\", \"tcp\", \"port\"";
}
cacheDir = opt.cacheDir + '/' + scheduler_id;
TCPip = opt.tcp;
TCPport = opt.... | javascript | function(opt) {
//console.log(opt)
if (isStarted) return;
var self = this;
if (!opt) {
throw "Options required to start manager : \"cacheDir\", \"tcp\", \"port\"";
}
cacheDir = opt.cacheDir + '/' + scheduler_id;
TCPip = opt.tcp;
TCPport = opt.... | [
"function",
"(",
"opt",
")",
"{",
"//console.log(opt)",
"if",
"(",
"isStarted",
")",
"return",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"opt",
")",
"{",
"throw",
"\"Options required to start manager : \\\"cacheDir\\\", \\\"tcp\\\", \\\"port\\\"\"",
";",... | Starts the job manager
@param {Object}ManagerSpecs
@param {ManagerSpecs} cacheDir{String} Directory used for jobs caching
@param {ManagerSpecs} tcp{String} ip adress of the master node for netSocket
@param {ManagerSpecs} port{String} port number of the netSocket
@param {ManagerSpecs} slurmBinaries{String} path to slu... | [
"Starts",
"the",
"job",
"manager"
] | 002b064a700d3596d82e1c57110c0100a389f792 | https://github.com/glaunay/nslurm/blob/002b064a700d3596d82e1c57110c0100a389f792/index.js#L403-L452 | |
38,030 | commercetools/commercetools-sunrise-scenarios | features/utils/async.js | serial | function serial(promises) {
const results = [];
return promises
.reduce((chain, promise) =>
chain.then(result => {
results.push(result);
return promise
}), Promise.resolve())
.then(result => {
results.push(result);
... | javascript | function serial(promises) {
const results = [];
return promises
.reduce((chain, promise) =>
chain.then(result => {
results.push(result);
return promise
}), Promise.resolve())
.then(result => {
results.push(result);
... | [
"function",
"serial",
"(",
"promises",
")",
"{",
"const",
"results",
"=",
"[",
"]",
";",
"return",
"promises",
".",
"reduce",
"(",
"(",
"chain",
",",
"promise",
")",
"=>",
"chain",
".",
"then",
"(",
"result",
"=>",
"{",
"results",
".",
"push",
"(",
... | Take an iterable of Promises and invoke them serially, otherwise identical
to the `Promise.all` static method.
@param {Promise[]} promises
@return {Promise} | [
"Take",
"an",
"iterable",
"of",
"Promises",
"and",
"invoke",
"them",
"serially",
"otherwise",
"identical",
"to",
"the",
"Promise",
".",
"all",
"static",
"method",
"."
] | e84fa2f774b9be899939e3e58455eaff3298cf79 | https://github.com/commercetools/commercetools-sunrise-scenarios/blob/e84fa2f774b9be899939e3e58455eaff3298cf79/features/utils/async.js#L14-L28 |
38,031 | mojaie/kiwiii | src/common/mapper.js | singleToMulti | function singleToMulti(mapping) {
const newMapping = {};
Object.entries(mapping.mapping).forEach(m => {
newMapping[m[0]] = [m[1]];
});
return {
created: mapping.created,
fields: [mapping.field],
key: mapping.key,
mapping: newMapping
};
} | javascript | function singleToMulti(mapping) {
const newMapping = {};
Object.entries(mapping.mapping).forEach(m => {
newMapping[m[0]] = [m[1]];
});
return {
created: mapping.created,
fields: [mapping.field],
key: mapping.key,
mapping: newMapping
};
} | [
"function",
"singleToMulti",
"(",
"mapping",
")",
"{",
"const",
"newMapping",
"=",
"{",
"}",
";",
"Object",
".",
"entries",
"(",
"mapping",
".",
"mapping",
")",
".",
"forEach",
"(",
"m",
"=>",
"{",
"newMapping",
"[",
"m",
"[",
"0",
"]",
"]",
"=",
"... | Convert single field mapping to multi field mapping
@param {object} mapping - single field mapping
@return {object} multi field mapping | [
"Convert",
"single",
"field",
"mapping",
"to",
"multi",
"field",
"mapping"
] | 30d75685b1ab388b5f1467c753cacd090971ceba | https://github.com/mojaie/kiwiii/blob/30d75685b1ab388b5f1467c753cacd090971ceba/src/common/mapper.js#L12-L23 |
38,032 | mojaie/kiwiii | src/common/mapper.js | mappingToTable | function mappingToTable(mapping) {
const mp = mapping.hasOwnProperty('field') ? singleToMulti(mapping) : mapping;
const keyField = {key: mp.key, format: 'text'};
const data = {
fields: [keyField].concat(mp.fields),
records: Object.entries(mp.mapping).map(entry => {
const rcd = {};
rcd[mp.key] ... | javascript | function mappingToTable(mapping) {
const mp = mapping.hasOwnProperty('field') ? singleToMulti(mapping) : mapping;
const keyField = {key: mp.key, format: 'text'};
const data = {
fields: [keyField].concat(mp.fields),
records: Object.entries(mp.mapping).map(entry => {
const rcd = {};
rcd[mp.key] ... | [
"function",
"mappingToTable",
"(",
"mapping",
")",
"{",
"const",
"mp",
"=",
"mapping",
".",
"hasOwnProperty",
"(",
"'field'",
")",
"?",
"singleToMulti",
"(",
"mapping",
")",
":",
"mapping",
";",
"const",
"keyField",
"=",
"{",
"key",
":",
"mp",
".",
"key"... | Convert field mapping to table
@param {object} mapping - field mapping
@return {object} table object | [
"Convert",
"field",
"mapping",
"to",
"table"
] | 30d75685b1ab388b5f1467c753cacd090971ceba | https://github.com/mojaie/kiwiii/blob/30d75685b1ab388b5f1467c753cacd090971ceba/src/common/mapper.js#L31-L46 |
38,033 | mojaie/kiwiii | src/common/mapper.js | tableToMapping | function tableToMapping(table, key, ignore=['index']) {
const now = new Date();
const mapping = {
created: now.toString(),
fields: table.fields.filter(e => e.key !== key)
.filter(e => !ignore.includes(e.key)),
key: key,
mapping: {}
};
table.records.forEach(row => {
mapping.mapping[row[... | javascript | function tableToMapping(table, key, ignore=['index']) {
const now = new Date();
const mapping = {
created: now.toString(),
fields: table.fields.filter(e => e.key !== key)
.filter(e => !ignore.includes(e.key)),
key: key,
mapping: {}
};
table.records.forEach(row => {
mapping.mapping[row[... | [
"function",
"tableToMapping",
"(",
"table",
",",
"key",
",",
"ignore",
"=",
"[",
"'index'",
"]",
")",
"{",
"const",
"now",
"=",
"new",
"Date",
"(",
")",
";",
"const",
"mapping",
"=",
"{",
"created",
":",
"now",
".",
"toString",
"(",
")",
",",
"fiel... | Convert table to field mapping
@param {object} table - table
@param {object} key - key
@return {object} field mapping | [
"Convert",
"table",
"to",
"field",
"mapping"
] | 30d75685b1ab388b5f1467c753cacd090971ceba | https://github.com/mojaie/kiwiii/blob/30d75685b1ab388b5f1467c753cacd090971ceba/src/common/mapper.js#L55-L68 |
38,034 | mojaie/kiwiii | src/common/mapper.js | csvToMapping | function csvToMapping(csvString) {
const lines = csvString.split(/\n|\r|\r\n/);
const header = lines.shift().split(',');
const key = header.shift();
const now = new Date();
const headerIdx = [];
const fields = [];
header.forEach((h, i) => {
if (h === '') return;
headerIdx.push(i);
fields.push(... | javascript | function csvToMapping(csvString) {
const lines = csvString.split(/\n|\r|\r\n/);
const header = lines.shift().split(',');
const key = header.shift();
const now = new Date();
const headerIdx = [];
const fields = [];
header.forEach((h, i) => {
if (h === '') return;
headerIdx.push(i);
fields.push(... | [
"function",
"csvToMapping",
"(",
"csvString",
")",
"{",
"const",
"lines",
"=",
"csvString",
".",
"split",
"(",
"/",
"\\n|\\r|\\r\\n",
"/",
")",
";",
"const",
"header",
"=",
"lines",
".",
"shift",
"(",
")",
".",
"split",
"(",
"','",
")",
";",
"const",
... | Convert csv text to field mapping
@param {string} csvString - csv data text
@return {object} field mapping | [
"Convert",
"csv",
"text",
"to",
"field",
"mapping"
] | 30d75685b1ab388b5f1467c753cacd090971ceba | https://github.com/mojaie/kiwiii/blob/30d75685b1ab388b5f1467c753cacd090971ceba/src/common/mapper.js#L76-L103 |
38,035 | nwtjs/nwt | plugins/calendar.js | function(milliseconds) {
var formattedDate = '',
self = this,
dateObj = new Date(milliseconds),
format = {
d: function() {
var day = format.j()
return (day < 10) ? '0' + day : day
},
D: function() {
return self.weekdays[format.w()].substring(0, 3)
},
j: function() ... | javascript | function(milliseconds) {
var formattedDate = '',
self = this,
dateObj = new Date(milliseconds),
format = {
d: function() {
var day = format.j()
return (day < 10) ? '0' + day : day
},
D: function() {
return self.weekdays[format.w()].substring(0, 3)
},
j: function() ... | [
"function",
"(",
"milliseconds",
")",
"{",
"var",
"formattedDate",
"=",
"''",
",",
"self",
"=",
"this",
",",
"dateObj",
"=",
"new",
"Date",
"(",
"milliseconds",
")",
",",
"format",
"=",
"{",
"d",
":",
"function",
"(",
")",
"{",
"var",
"day",
"=",
"... | Formats a date | [
"Formats",
"a",
"date"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/calendar.js#L49-L104 | |
38,036 | nwtjs/nwt | plugins/calendar.js | function(date, full) {
return ((full == true) ? this.months[date] : ((this.months[date].length > 3) ? this.months[date].substring(0, 3) : this.months[date]))
} | javascript | function(date, full) {
return ((full == true) ? this.months[date] : ((this.months[date].length > 3) ? this.months[date].substring(0, 3) : this.months[date]))
} | [
"function",
"(",
"date",
",",
"full",
")",
"{",
"return",
"(",
"(",
"full",
"==",
"true",
")",
"?",
"this",
".",
"months",
"[",
"date",
"]",
":",
"(",
"(",
"this",
".",
"months",
"[",
"date",
"]",
".",
"length",
">",
"3",
")",
"?",
"this",
".... | Converts a month index to a string
@param object Month index
@param bool Whether or not to display the full string | [
"Converts",
"a",
"month",
"index",
"to",
"a",
"string"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/calendar.js#L111-L113 | |
38,037 | nwtjs/nwt | plugins/calendar.js | function(offset) {
offset = offset || 0
var year = this.year
var monthNum = this.month
monthNum += offset
if(monthNum < 0) { year-- }
if(monthNum > 11) { year++ }
return year
} | javascript | function(offset) {
offset = offset || 0
var year = this.year
var monthNum = this.month
monthNum += offset
if(monthNum < 0) { year-- }
if(monthNum > 11) { year++ }
return year
} | [
"function",
"(",
"offset",
")",
"{",
"offset",
"=",
"offset",
"||",
"0",
"var",
"year",
"=",
"this",
".",
"year",
"var",
"monthNum",
"=",
"this",
".",
"month",
"monthNum",
"+=",
"offset",
"if",
"(",
"monthNum",
"<",
"0",
")",
"{",
"year",
"--",
"}"... | Returns the year based on month offset
The year only changes if the month wraps to the next year
@param integer month offset | [
"Returns",
"the",
"year",
"based",
"on",
"month",
"offset",
"The",
"year",
"only",
"changes",
"if",
"the",
"month",
"wraps",
"to",
"the",
"next",
"year"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/calendar.js#L120-L130 | |
38,038 | nwtjs/nwt | plugins/calendar.js | function(offset) {
var month = this.getOffsetMonth(offset)
, year = this.getOffsetYear(offset)
// checks to see if february is a leap year otherwise return the respective # of days
return (month == 1 && !(year & 3) && (year % 1e2 || !(year % 4e2))) ? 29 : this.daysInMonth[month]
} | javascript | function(offset) {
var month = this.getOffsetMonth(offset)
, year = this.getOffsetYear(offset)
// checks to see if february is a leap year otherwise return the respective # of days
return (month == 1 && !(year & 3) && (year % 1e2 || !(year % 4e2))) ? 29 : this.daysInMonth[month]
} | [
"function",
"(",
"offset",
")",
"{",
"var",
"month",
"=",
"this",
".",
"getOffsetMonth",
"(",
"offset",
")",
",",
"year",
"=",
"this",
".",
"getOffsetYear",
"(",
"offset",
")",
"// checks to see if february is a leap year otherwise return the respective # of days",
"r... | Returns the current number of days in the month
@param integer Month offset for multi-pane implementation | [
"Returns",
"the",
"current",
"number",
"of",
"days",
"in",
"the",
"month"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/calendar.js#L173-L179 | |
38,039 | nwtjs/nwt | plugins/calendar.js | function() {
var html = ''
for(i = 0, x = this.weekdays.length; i < x; i++) {
html += '<th>' + this.weekdays[i].substring(0, 2) + '</th>'
}
return html
} | javascript | function() {
var html = ''
for(i = 0, x = this.weekdays.length; i < x; i++) {
html += '<th>' + this.weekdays[i].substring(0, 2) + '</th>'
}
return html
} | [
"function",
"(",
")",
"{",
"var",
"html",
"=",
"''",
"for",
"(",
"i",
"=",
"0",
",",
"x",
"=",
"this",
".",
"weekdays",
".",
"length",
";",
"i",
"<",
"x",
";",
"i",
"++",
")",
"{",
"html",
"+=",
"'<th>'",
"+",
"this",
".",
"weekdays",
"[",
... | Gets HTML for weekdays | [
"Gets",
"HTML",
"for",
"weekdays"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/calendar.js#L210-L217 | |
38,040 | nwtjs/nwt | plugins/calendar.js | function(offset) {
var monthNum = this.month
offset = offset || 0
monthNum += offset
if(monthNum < 0) { monthNum = 11 }
if(monthNum > 11) { monthNum = 0 }
var month = this.getOffsetMonth(offset)
, year = this.getOffsetYear(offset)
// get the first day of the month we are currently viewing
... | javascript | function(offset) {
var monthNum = this.month
offset = offset || 0
monthNum += offset
if(monthNum < 0) { monthNum = 11 }
if(monthNum > 11) { monthNum = 0 }
var month = this.getOffsetMonth(offset)
, year = this.getOffsetYear(offset)
// get the first day of the month we are currently viewing
... | [
"function",
"(",
"offset",
")",
"{",
"var",
"monthNum",
"=",
"this",
".",
"month",
"offset",
"=",
"offset",
"||",
"0",
"monthNum",
"+=",
"offset",
"if",
"(",
"monthNum",
"<",
"0",
")",
"{",
"monthNum",
"=",
"11",
"}",
"if",
"(",
"monthNum",
">",
"1... | Builds calendar markup
@param integer month offset | [
"Builds",
"calendar",
"markup"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/calendar.js#L224-L278 | |
38,041 | nwtjs/nwt | plugins/calendar.js | function() {
// First deselect everything
this.el.all('td.selected').removeClass('selected')
for (var i=0,date;date=this.selected[i];i++) {
var cell = this.el.one('.pane[data-month="' + date.month + '"][data-year="' + date.year + '"] td[data-day="' + date.day + '"]')
if (cell._node) {
cell.add... | javascript | function() {
// First deselect everything
this.el.all('td.selected').removeClass('selected')
for (var i=0,date;date=this.selected[i];i++) {
var cell = this.el.one('.pane[data-month="' + date.month + '"][data-year="' + date.year + '"] td[data-day="' + date.day + '"]')
if (cell._node) {
cell.add... | [
"function",
"(",
")",
"{",
"// First deselect everything",
"this",
".",
"el",
".",
"all",
"(",
"'td.selected'",
")",
".",
"removeClass",
"(",
"'selected'",
")",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"date",
";",
"date",
"=",
"this",
".",
"selected",
"... | Selects all cells in this.selection | [
"Selects",
"all",
"cells",
"in",
"this",
".",
"selection"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/calendar.js#L284-L294 | |
38,042 | danShumway/serverboy.js | src/interface.js | function () {
let _that = this[PRIVATE];
if (_that.initialized() && _that.running()) {
_that.gameboy.stopEmulator |= 2;
_that.frames = 0; //Reset internal variables
}
} | javascript | function () {
let _that = this[PRIVATE];
if (_that.initialized() && _that.running()) {
_that.gameboy.stopEmulator |= 2;
_that.frames = 0; //Reset internal variables
}
} | [
"function",
"(",
")",
"{",
"let",
"_that",
"=",
"this",
"[",
"PRIVATE",
"]",
";",
"if",
"(",
"_that",
".",
"initialized",
"(",
")",
"&&",
"_that",
".",
"running",
"(",
")",
")",
"{",
"_that",
".",
"gameboy",
".",
"stopEmulator",
"|=",
"2",
";",
"... | Stop emulator, reset relevant variables | [
"Stop",
"emulator",
"reset",
"relevant",
"variables"
] | 68f0ac88b5b280f64de2c8ae6d57d8a84cbe3628 | https://github.com/danShumway/serverboy.js/blob/68f0ac88b5b280f64de2c8ae6d57d8a84cbe3628/src/interface.js#L61-L67 | |
38,043 | xiaoyuze88/isomorphic-pkg-reader | lib/plistParser/bplistParser.js | readUInt64BE | function readUInt64BE(buffer, start) {
var data = buffer.slice(start, start + 8);
return data.readUInt32BE(4, 8);
} | javascript | function readUInt64BE(buffer, start) {
var data = buffer.slice(start, start + 8);
return data.readUInt32BE(4, 8);
} | [
"function",
"readUInt64BE",
"(",
"buffer",
",",
"start",
")",
"{",
"var",
"data",
"=",
"buffer",
".",
"slice",
"(",
"start",
",",
"start",
"+",
"8",
")",
";",
"return",
"data",
".",
"readUInt32BE",
"(",
"4",
",",
"8",
")",
";",
"}"
] | we're just going to toss the high order bits because javascript doesn't have 64-bit ints | [
"we",
"re",
"just",
"going",
"to",
"toss",
"the",
"high",
"order",
"bits",
"because",
"javascript",
"doesn",
"t",
"have",
"64",
"-",
"bit",
"ints"
] | d38a409035d0b4f50df4659a95695a27e7b3078c | https://github.com/xiaoyuze88/isomorphic-pkg-reader/blob/d38a409035d0b4f50df4659a95695a27e7b3078c/lib/plistParser/bplistParser.js#L296-L299 |
38,044 | LeanKit-Labs/autohost | src/http/http.js | expressInit | function expressInit( req, res, next ) {
req.next = next;
req.context = {};
// patching this according to how express does it
// not jshint ignoring the following lines because then it
// warns that expreq and expres aren't used.
// This works according to express implemenetation
// DO NOT CHANGE IT
req.__proto... | javascript | function expressInit( req, res, next ) {
req.next = next;
req.context = {};
// patching this according to how express does it
// not jshint ignoring the following lines because then it
// warns that expreq and expres aren't used.
// This works according to express implemenetation
// DO NOT CHANGE IT
req.__proto... | [
"function",
"expressInit",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",
"next",
"=",
"next",
";",
"req",
".",
"context",
"=",
"{",
"}",
";",
"// patching this according to how express does it",
"// not jshint ignoring the following lines because then it"... | adaptation of express's initializing middleware the original approach breaks engine-io | [
"adaptation",
"of",
"express",
"s",
"initializing",
"middleware",
"the",
"original",
"approach",
"breaks",
"engine",
"-",
"io"
] | b143e99336cbecf5ac5712c2b0c77cc091081983 | https://github.com/LeanKit-Labs/autohost/blob/b143e99336cbecf5ac5712c2b0c77cc091081983/src/http/http.js#L63-L75 |
38,045 | LeanKit-Labs/autohost | src/http/http.js | parseAhead | function parseAhead( router, req, done ) {
var idx = 0;
var stack = router.stack;
var params = {};
var method = req.method ? req.method.toLowerCase() : undefined;
next();
function next() {
var layer = stack[ idx++ ];
if ( !layer ) {
// strip dangling query params
params = _.transform( params, function(... | javascript | function parseAhead( router, req, done ) {
var idx = 0;
var stack = router.stack;
var params = {};
var method = req.method ? req.method.toLowerCase() : undefined;
next();
function next() {
var layer = stack[ idx++ ];
if ( !layer ) {
// strip dangling query params
params = _.transform( params, function(... | [
"function",
"parseAhead",
"(",
"router",
",",
"req",
",",
"done",
")",
"{",
"var",
"idx",
"=",
"0",
";",
"var",
"stack",
"=",
"router",
".",
"stack",
";",
"var",
"params",
"=",
"{",
"}",
";",
"var",
"method",
"=",
"req",
".",
"method",
"?",
"req"... | this might be the worst thing to ever happen to anything ever this is adapted directly from express layer.match | [
"this",
"might",
"be",
"the",
"worst",
"thing",
"to",
"ever",
"happen",
"to",
"anything",
"ever",
"this",
"is",
"adapted",
"directly",
"from",
"express",
"layer",
".",
"match"
] | b143e99336cbecf5ac5712c2b0c77cc091081983 | https://github.com/LeanKit-Labs/autohost/blob/b143e99336cbecf5ac5712c2b0c77cc091081983/src/http/http.js#L114-L138 |
38,046 | LeanKit-Labs/autohost | src/http/http.js | prefix | function prefix( state, url ) {
if ( state.config.urlPrefix ) {
if ( _.isRegExp( url ) ) {
return regex.prefix( state.config.urlPrefix, url );
} else {
var prefixIndex = url.indexOf( state.config.urlPrefix );
var appliedPrefix = prefixIndex === 0 ? '' : state.config.urlPrefix;
return buildUrl( appliedP... | javascript | function prefix( state, url ) {
if ( state.config.urlPrefix ) {
if ( _.isRegExp( url ) ) {
return regex.prefix( state.config.urlPrefix, url );
} else {
var prefixIndex = url.indexOf( state.config.urlPrefix );
var appliedPrefix = prefixIndex === 0 ? '' : state.config.urlPrefix;
return buildUrl( appliedP... | [
"function",
"prefix",
"(",
"state",
",",
"url",
")",
"{",
"if",
"(",
"state",
".",
"config",
".",
"urlPrefix",
")",
"{",
"if",
"(",
"_",
".",
"isRegExp",
"(",
"url",
")",
")",
"{",
"return",
"regex",
".",
"prefix",
"(",
"state",
".",
"config",
".... | apply prefix to url if one exists | [
"apply",
"prefix",
"to",
"url",
"if",
"one",
"exists"
] | b143e99336cbecf5ac5712c2b0c77cc091081983 | https://github.com/LeanKit-Labs/autohost/blob/b143e99336cbecf5ac5712c2b0c77cc091081983/src/http/http.js#L141-L153 |
38,047 | nwtjs/nwt | src/nodelist/js/nodelist.js | NWTNodeList | function NWTNodeList(nodes) {
localnwt.implement('DelayableQueue', this);
var wrappedNodes = [];
for( var i = 0, node ; node = nodes[i] ; i++ ) {
wrappedNodes.push(new NWTNodeInstance(node));
}
this.nodes = wrappedNodes;
var iteratedFunctions = [
'anim', 'appendTo', 'remove', 'addClass', 'removeClass',... | javascript | function NWTNodeList(nodes) {
localnwt.implement('DelayableQueue', this);
var wrappedNodes = [];
for( var i = 0, node ; node = nodes[i] ; i++ ) {
wrappedNodes.push(new NWTNodeInstance(node));
}
this.nodes = wrappedNodes;
var iteratedFunctions = [
'anim', 'appendTo', 'remove', 'addClass', 'removeClass',... | [
"function",
"NWTNodeList",
"(",
"nodes",
")",
"{",
"localnwt",
".",
"implement",
"(",
"'DelayableQueue'",
",",
"this",
")",
";",
"var",
"wrappedNodes",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"node",
";",
"node",
"=",
"nodes",
"[",... | A node iterator
@constructor | [
"A",
"node",
"iterator"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/src/nodelist/js/nodelist.js#L5-L34 |
38,048 | CodeCatalyst/grunt-sketch | tasks/sketch.js | registerTask | function registerTask( task ) {
grunt.registerMultiTask( task.name, task.help, function () {
var done = this.async();
if ( ensureSketchtool() ) {
var options = this.options();
var commands = [];
this.files.forEach( function( file ) {
file.src.filter( function ( src ) {
var command = crea... | javascript | function registerTask( task ) {
grunt.registerMultiTask( task.name, task.help, function () {
var done = this.async();
if ( ensureSketchtool() ) {
var options = this.options();
var commands = [];
this.files.forEach( function( file ) {
file.src.filter( function ( src ) {
var command = crea... | [
"function",
"registerTask",
"(",
"task",
")",
"{",
"grunt",
".",
"registerMultiTask",
"(",
"task",
".",
"name",
",",
"task",
".",
"help",
",",
"function",
"(",
")",
"{",
"var",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"if",
"(",
"ensureSketc... | Internal helper functions. | [
"Internal",
"helper",
"functions",
"."
] | 4ba6591c93f5d65d8abde702a40f7d778cb469b5 | https://github.com/CodeCatalyst/grunt-sketch/blob/4ba6591c93f5d65d8abde702a40f7d778cb469b5/tasks/sketch.js#L147-L170 |
38,049 | xiaoyuze88/isomorphic-pkg-reader | lib/plistParser/xmlPlistParser.js | parseString | function parseString (xml, callback) {
var doc, error, plist;
try {
doc = new DOMParser().parseFromString(xml);
plist = parsePlistXML(doc.documentElement);
} catch(e) {
error = e;
}
callback(error, plist);
} | javascript | function parseString (xml, callback) {
var doc, error, plist;
try {
doc = new DOMParser().parseFromString(xml);
plist = parsePlistXML(doc.documentElement);
} catch(e) {
error = e;
}
callback(error, plist);
} | [
"function",
"parseString",
"(",
"xml",
",",
"callback",
")",
"{",
"var",
"doc",
",",
"error",
",",
"plist",
";",
"try",
"{",
"doc",
"=",
"new",
"DOMParser",
"(",
")",
".",
"parseFromString",
"(",
"xml",
")",
";",
"plist",
"=",
"parsePlistXML",
"(",
"... | Parses a Plist XML string. Returns an Object. Takes a `callback` function.
@param {String} xml - the XML String to decode
@param {Function} callback - callback function
@returns {Mixed} the decoded value from the Plist XML
@api public
@deprecated not actually async. use parse() instead | [
"Parses",
"a",
"Plist",
"XML",
"string",
".",
"Returns",
"an",
"Object",
".",
"Takes",
"a",
"callback",
"function",
"."
] | d38a409035d0b4f50df4659a95695a27e7b3078c | https://github.com/xiaoyuze88/isomorphic-pkg-reader/blob/d38a409035d0b4f50df4659a95695a27e7b3078c/lib/plistParser/xmlPlistParser.js#L57-L66 |
38,050 | xiaoyuze88/isomorphic-pkg-reader | lib/plistParser/xmlPlistParser.js | parseStringSync | function parseStringSync (xml) {
var doc = new DOMParser().parseFromString(xml);
var plist;
if (doc.documentElement.nodeName !== 'plist') {
throw new Error('malformed document. First element should be <plist>');
}
plist = parsePlistXML(doc.documentElement);
// if the plist is an array with 1 element, p... | javascript | function parseStringSync (xml) {
var doc = new DOMParser().parseFromString(xml);
var plist;
if (doc.documentElement.nodeName !== 'plist') {
throw new Error('malformed document. First element should be <plist>');
}
plist = parsePlistXML(doc.documentElement);
// if the plist is an array with 1 element, p... | [
"function",
"parseStringSync",
"(",
"xml",
")",
"{",
"var",
"doc",
"=",
"new",
"DOMParser",
"(",
")",
".",
"parseFromString",
"(",
"xml",
")",
";",
"var",
"plist",
";",
"if",
"(",
"doc",
".",
"documentElement",
".",
"nodeName",
"!==",
"'plist'",
")",
"... | Parses a Plist XML string. Returns an Object.
@param {String} xml - the XML String to decode
@param {Function} callback - callback function
@returns {Mixed} the decoded value from the Plist XML
@api public
@deprecated use parse() instead | [
"Parses",
"a",
"Plist",
"XML",
"string",
".",
"Returns",
"an",
"Object",
"."
] | d38a409035d0b4f50df4659a95695a27e7b3078c | https://github.com/xiaoyuze88/isomorphic-pkg-reader/blob/d38a409035d0b4f50df4659a95695a27e7b3078c/lib/plistParser/xmlPlistParser.js#L78-L91 |
38,051 | nwtjs/nwt | nwt.js | function(implClass, modClass) {
var impls = {
DelayableQueue : [
/**
* Returns a queueable interface to the original object
* This allows us to insert delays between chainable method calls using the .wait() method
* Currently this is only implemented for the node class, but it should be possible to ... | javascript | function(implClass, modClass) {
var impls = {
DelayableQueue : [
/**
* Returns a queueable interface to the original object
* This allows us to insert delays between chainable method calls using the .wait() method
* Currently this is only implemented for the node class, but it should be possible to ... | [
"function",
"(",
"implClass",
",",
"modClass",
")",
"{",
"var",
"impls",
"=",
"{",
"DelayableQueue",
":",
"[",
"/**\n\t\t\t * Returns a queueable interface to the original object\n\t\t\t * This allows us to insert delays between chainable method calls using the .wait() method\n\t\t\t * C... | Implements an interface on an object | [
"Implements",
"an",
"interface",
"on",
"an",
"object"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/nwt.js#L15-L118 | |
38,052 | nwtjs/nwt | nwt.js | function() {
var self = this, item;
self.inWork = true;
if (!self.queue.length) {
return;
}
item = self.queue.shift();
if (item.type == 'wait') {
setTimeout(function(){
self._process();
}, item.duration*1000);
} else {
self.c... | javascript | function() {
var self = this, item;
self.inWork = true;
if (!self.queue.length) {
return;
}
item = self.queue.shift();
if (item.type == 'wait') {
setTimeout(function(){
self._process();
}, item.duration*1000);
} else {
self.c... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"item",
";",
"self",
".",
"inWork",
"=",
"true",
";",
"if",
"(",
"!",
"self",
".",
"queue",
".",
"length",
")",
"{",
"return",
";",
"}",
"item",
"=",
"self",
".",
"queue",
".",
"shift"... | Process the queue
Shifts an item off the queue and waits for it to finish | [
"Process",
"the",
"queue",
"Shifts",
"an",
"item",
"off",
"the",
"queue",
"and",
"waits",
"for",
"it",
"to",
"finish"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/nwt.js#L52-L73 | |
38,053 | nwtjs/nwt | nwt.js | function(event, callback) {
var args = Array.prototype.slice.call(arguments, 1);
localnwt.event._eventData = args;
var customEvt = y.createEvent("UIEvents");
customEvt.initEvent(event, true, false);
this._node.dispatchEvent(customEvt);
} | javascript | function(event, callback) {
var args = Array.prototype.slice.call(arguments, 1);
localnwt.event._eventData = args;
var customEvt = y.createEvent("UIEvents");
customEvt.initEvent(event, true, false);
this._node.dispatchEvent(customEvt);
} | [
"function",
"(",
"event",
",",
"callback",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"localnwt",
".",
"event",
".",
"_eventData",
"=",
"args",
";",
"var",
"customEvt",
"=... | Fires an event on a node | [
"Fires",
"an",
"event",
"on",
"a",
"node"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/nwt.js#L1034-L1042 | |
38,054 | mojaie/kiwiii | src/common/specs.js | isRunning | function isRunning(specs) {
return specs.dataset.some(coll => {
return coll.contents.some(e => {
return ['ready', 'queued', 'running', 'interrupted'].includes(e.status);
});
});
} | javascript | function isRunning(specs) {
return specs.dataset.some(coll => {
return coll.contents.some(e => {
return ['ready', 'queued', 'running', 'interrupted'].includes(e.status);
});
});
} | [
"function",
"isRunning",
"(",
"specs",
")",
"{",
"return",
"specs",
".",
"dataset",
".",
"some",
"(",
"coll",
"=>",
"{",
"return",
"coll",
".",
"contents",
".",
"some",
"(",
"e",
"=>",
"{",
"return",
"[",
"'ready'",
",",
"'queued'",
",",
"'running'",
... | Retern if the package has running tasks
@param {object} specs - package JSON
@return {bool} if there are any ongoing tasks | [
"Retern",
"if",
"the",
"package",
"has",
"running",
"tasks"
] | 30d75685b1ab388b5f1467c753cacd090971ceba | https://github.com/mojaie/kiwiii/blob/30d75685b1ab388b5f1467c753cacd090971ceba/src/common/specs.js#L12-L18 |
38,055 | nwtjs/nwt | plugins/bootstrap/typeahead.js | function(dir) {
var curr = this.menu.one('li.active'),
targetNode = curr[dir]();
this.menu.one('li.active').removeClass('active');
targetNode.addClass('active');
return this;
} | javascript | function(dir) {
var curr = this.menu.one('li.active'),
targetNode = curr[dir]();
this.menu.one('li.active').removeClass('active');
targetNode.addClass('active');
return this;
} | [
"function",
"(",
"dir",
")",
"{",
"var",
"curr",
"=",
"this",
".",
"menu",
".",
"one",
"(",
"'li.active'",
")",
",",
"targetNode",
"=",
"curr",
"[",
"dir",
"]",
"(",
")",
";",
"this",
".",
"menu",
".",
"one",
"(",
"'li.active'",
")",
".",
"remove... | Moves the active selected item
@param string (next | previous) | [
"Moves",
"the",
"active",
"selected",
"item"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/bootstrap/typeahead.js#L105-L113 | |
38,056 | nwtjs/nwt | plugins/bootstrap/typeahead.js | function(items) {
var itemMarkup = '', i;
for (i=0; i< items.length; i++) {
itemMarkup += '<li><a href="#" data-value="' + items[i] + '">' + this.highlighter(items[i]) + '</a></li>';
}
var inputRegion = this.node.region();
this.menu.setHtml(itemMarkup)
this.menu.one('li').addClass('active')
... | javascript | function(items) {
var itemMarkup = '', i;
for (i=0; i< items.length; i++) {
itemMarkup += '<li><a href="#" data-value="' + items[i] + '">' + this.highlighter(items[i]) + '</a></li>';
}
var inputRegion = this.node.region();
this.menu.setHtml(itemMarkup)
this.menu.one('li').addClass('active')
... | [
"function",
"(",
"items",
")",
"{",
"var",
"itemMarkup",
"=",
"''",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"items",
".",
"length",
";",
"i",
"++",
")",
"{",
"itemMarkup",
"+=",
"'<li><a href=\"#\" data-value=\"'",
"+",
"items",
"[",... | Renders the typeahead items
@param array Matched items to render | [
"Renders",
"the",
"typeahead",
"items"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/bootstrap/typeahead.js#L132-L153 | |
38,057 | artdecocode/erotic | build/index.js | erotic | function erotic(transparent) {
const { stack } = new Error()
const caller = getCallerFromArguments(arguments)
const entryStack = getEntryStack(stack, transparent)
return makeCallback(caller, entryStack, transparent)
} | javascript | function erotic(transparent) {
const { stack } = new Error()
const caller = getCallerFromArguments(arguments)
const entryStack = getEntryStack(stack, transparent)
return makeCallback(caller, entryStack, transparent)
} | [
"function",
"erotic",
"(",
"transparent",
")",
"{",
"const",
"{",
"stack",
"}",
"=",
"new",
"Error",
"(",
")",
"const",
"caller",
"=",
"getCallerFromArguments",
"(",
"arguments",
")",
"const",
"entryStack",
"=",
"getEntryStack",
"(",
"stack",
",",
"transpare... | Returns a function to create an error with a stack trace starting at the line in code when the call was made by the callee.
@param {boolean} [transparent] Pretend as if the call to the function lead to the error, without exposing any of the internal stack. | [
"Returns",
"a",
"function",
"to",
"create",
"an",
"error",
"with",
"a",
"stack",
"trace",
"starting",
"at",
"the",
"line",
"in",
"code",
"when",
"the",
"call",
"was",
"made",
"by",
"the",
"callee",
"."
] | 2d8cb268bd6ddc64a8bb90ac25d388e553866a0a | https://github.com/artdecocode/erotic/blob/2d8cb268bd6ddc64a8bb90ac25d388e553866a0a/build/index.js#L10-L16 |
38,058 | chriskinsman/s3-stream-download | index.js | S3StreamDownload | function S3StreamDownload (s3, s3Params, options) {
var downloader = new Downloader(s3, s3Params, options);
return new DownloadStream(downloader);
} | javascript | function S3StreamDownload (s3, s3Params, options) {
var downloader = new Downloader(s3, s3Params, options);
return new DownloadStream(downloader);
} | [
"function",
"S3StreamDownload",
"(",
"s3",
",",
"s3Params",
",",
"options",
")",
"{",
"var",
"downloader",
"=",
"new",
"Downloader",
"(",
"s3",
",",
"s3Params",
",",
"options",
")",
";",
"return",
"new",
"DownloadStream",
"(",
"downloader",
")",
";",
"}"
] | Creates a stream for download via multipart stream to S3.
@params {S3} s3
@params {Object} s3Params
@params {Object} options | [
"Creates",
"a",
"stream",
"for",
"download",
"via",
"multipart",
"stream",
"to",
"S3",
"."
] | e78dcd38e6a06ef0d8f47f1c8951d65ad5c6f93c | https://github.com/chriskinsman/s3-stream-download/blob/e78dcd38e6a06ef0d8f47f1c8951d65ad5c6f93c/index.js#L18-L21 |
38,059 | recidive/choko | lib/application.js | function(next) {
self.loadAllExtensions(function() {
// Add middleware to make html5mode work in angular.
self.routers.page.use(function(request, response, next) {
// If between JSON and HTML it prefers HTML, return index.html content since
// we know its a direct browser reque... | javascript | function(next) {
self.loadAllExtensions(function() {
// Add middleware to make html5mode work in angular.
self.routers.page.use(function(request, response, next) {
// If between JSON and HTML it prefers HTML, return index.html content since
// we know its a direct browser reque... | [
"function",
"(",
"next",
")",
"{",
"self",
".",
"loadAllExtensions",
"(",
"function",
"(",
")",
"{",
"// Add middleware to make html5mode work in angular.",
"self",
".",
"routers",
".",
"page",
".",
"use",
"(",
"function",
"(",
"request",
",",
"response",
",",
... | Load all extensions and call init hooks on all of them. | [
"Load",
"all",
"extensions",
"and",
"call",
"init",
"hooks",
"on",
"all",
"of",
"them",
"."
] | 7c0576c8c55543ec99d04ea609700765f178f73a | https://github.com/recidive/choko/blob/7c0576c8c55543ec99d04ea609700765f178f73a/lib/application.js#L125-L141 | |
38,060 | recidive/choko | lib/application.js | function(next) {
self.collect('field', function(error, fields) {
if (error) {
return callback(error);
}
self.fields = fields;
self.loadAllTypes(next);
});
} | javascript | function(next) {
self.collect('field', function(error, fields) {
if (error) {
return callback(error);
}
self.fields = fields;
self.loadAllTypes(next);
});
} | [
"function",
"(",
"next",
")",
"{",
"self",
".",
"collect",
"(",
"'field'",
",",
"function",
"(",
"error",
",",
"fields",
")",
"{",
"if",
"(",
"error",
")",
"{",
"return",
"callback",
"(",
"error",
")",
";",
"}",
"self",
".",
"fields",
"=",
"fields"... | Load all fields and types. | [
"Load",
"all",
"fields",
"and",
"types",
"."
] | 7c0576c8c55543ec99d04ea609700765f178f73a | https://github.com/recidive/choko/blob/7c0576c8c55543ec99d04ea609700765f178f73a/lib/application.js#L144-L153 | |
38,061 | recidive/choko | lib/application.js | function(next) {
self.storage.init(function(error, collections) {
if (error) {
return next(error);
}
self.collections = collections;
next();
});
} | javascript | function(next) {
self.storage.init(function(error, collections) {
if (error) {
return next(error);
}
self.collections = collections;
next();
});
} | [
"function",
"(",
"next",
")",
"{",
"self",
".",
"storage",
".",
"init",
"(",
"function",
"(",
"error",
",",
"collections",
")",
"{",
"if",
"(",
"error",
")",
"{",
"return",
"next",
"(",
"error",
")",
";",
"}",
"self",
".",
"collections",
"=",
"coll... | Initialize Storage. | [
"Initialize",
"Storage",
"."
] | 7c0576c8c55543ec99d04ea609700765f178f73a | https://github.com/recidive/choko/blob/7c0576c8c55543ec99d04ea609700765f178f73a/lib/application.js#L156-L164 | |
38,062 | cludden/mycro | hooks/routes/index.js | processHandler | function processHandler(fn) {
if (_.isFunction(handler)) {
return fn(null, handler);
}
if (_.isString(handler)) {
return self.processStringHandler(mycro, handler, fn);
}
if (_.isObject(handler)) {
... | javascript | function processHandler(fn) {
if (_.isFunction(handler)) {
return fn(null, handler);
}
if (_.isString(handler)) {
return self.processStringHandler(mycro, handler, fn);
}
if (_.isObject(handler)) {
... | [
"function",
"processHandler",
"(",
"fn",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"handler",
")",
")",
"{",
"return",
"fn",
"(",
"null",
",",
"handler",
")",
";",
"}",
"if",
"(",
"_",
".",
"isString",
"(",
"handler",
")",
")",
"{",
"retu... | process handler definition | [
"process",
"handler",
"definition"
] | 762e6ba0f38f37497eefb933252edc2c16bfb40b | https://github.com/cludden/mycro/blob/762e6ba0f38f37497eefb933252edc2c16bfb40b/hooks/routes/index.js#L145-L177 |
38,063 | besync/graphstore | packages/graphstore-dev/src/firebase/jparser.js | cleanItem | function cleanItem(value) {
var newvalue = null;
if (Array.isArray(value)) {
if (value.indexOf("consumer") > -1) {
value.forEach(function (key2) {
ids[key2] = "roles";
});
}
newvalue = [];
value.forE... | javascript | function cleanItem(value) {
var newvalue = null;
if (Array.isArray(value)) {
if (value.indexOf("consumer") > -1) {
value.forEach(function (key2) {
ids[key2] = "roles";
});
}
newvalue = [];
value.forE... | [
"function",
"cleanItem",
"(",
"value",
")",
"{",
"var",
"newvalue",
"=",
"null",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"if",
"(",
"value",
".",
"indexOf",
"(",
"\"consumer\"",
")",
">",
"-",
"1",
")",
"{",
"value",
... | REMOVE _temp and clean encrypted data | [
"REMOVE",
"_temp",
"and",
"clean",
"encrypted",
"data"
] | e615349a58c02e387768ee15044fbda237c6818b | https://github.com/besync/graphstore/blob/e615349a58c02e387768ee15044fbda237c6818b/packages/graphstore-dev/src/firebase/jparser.js#L38-L85 |
38,064 | besync/graphstore | packages/graphstore-dev/src/firebase/jparser.js | cleanItem3 | function cleanItem3(value, parent) {
var newvalue = null;
if (Array.isArray(value)) {
newvalue = [];
var isAllNumbers = (value.length > 0);
var isAllStrings = (value.length > 0)
value.forEach(function (item) {
if (typeof item !== 'number... | javascript | function cleanItem3(value, parent) {
var newvalue = null;
if (Array.isArray(value)) {
newvalue = [];
var isAllNumbers = (value.length > 0);
var isAllStrings = (value.length > 0)
value.forEach(function (item) {
if (typeof item !== 'number... | [
"function",
"cleanItem3",
"(",
"value",
",",
"parent",
")",
"{",
"var",
"newvalue",
"=",
"null",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"newvalue",
"=",
"[",
"]",
";",
"var",
"isAllNumbers",
"=",
"(",
"value",
".",
"l... | REMOVE DUPLICATE ENTITIES INSTANCE STRUCTURES | [
"REMOVE",
"DUPLICATE",
"ENTITIES",
"INSTANCE",
"STRUCTURES"
] | e615349a58c02e387768ee15044fbda237c6818b | https://github.com/besync/graphstore/blob/e615349a58c02e387768ee15044fbda237c6818b/packages/graphstore-dev/src/firebase/jparser.js#L167-L248 |
38,065 | LLK/po2icu | lib/po2icu.js | function (icuString, options) {
icuString = this.cleanWhiteSpace(icuString);
//args before kwargs
if (typeof options !== 'undefined') {
if (typeof options.string !== 'undefined') {
var stringRe = new RegExp(('\{' + options.string + '\}'), 'g');
icuStr... | javascript | function (icuString, options) {
icuString = this.cleanWhiteSpace(icuString);
//args before kwargs
if (typeof options !== 'undefined') {
if (typeof options.string !== 'undefined') {
var stringRe = new RegExp(('\{' + options.string + '\}'), 'g');
icuStr... | [
"function",
"(",
"icuString",
",",
"options",
")",
"{",
"icuString",
"=",
"this",
".",
"cleanWhiteSpace",
"(",
"icuString",
")",
";",
"//args before kwargs",
"if",
"(",
"typeof",
"options",
"!==",
"'undefined'",
")",
"{",
"if",
"(",
"typeof",
"options",
".",... | Converts an icu-formatted string into a po-formatted one for pytho
@param {string} icuString icu-formatted string
@param {object} options gives icu keywords that should be turned into
python args in po rather than python kwargs.
Possible keys to use: `string`, `number`.
@return {string} po-formatted... | [
"Converts",
"an",
"icu",
"-",
"formatted",
"string",
"into",
"a",
"po",
"-",
"formatted",
"one",
"for",
"pytho"
] | 9eb97f81f72b2fee02b77f1424702e019647e9b9 | https://github.com/LLK/po2icu/blob/9eb97f81f72b2fee02b77f1424702e019647e9b9/lib/po2icu.js#L48-L72 | |
38,066 | LLK/po2icu | lib/po2icu.js | function (msgs, pluralForms) {
var msgKey = 'digit';
var hasVariableName = false;
for (var i=0; i<msgs.length; i++) {
if (msgs[i].match(/%\([a-zA-Z0-9_.|]+\)d/g) !== null) {
var match = msgs[i].match(/%\([a-zA-Z0-9_.|]+\)d/g)[0];
msgKey = match.substri... | javascript | function (msgs, pluralForms) {
var msgKey = 'digit';
var hasVariableName = false;
for (var i=0; i<msgs.length; i++) {
if (msgs[i].match(/%\([a-zA-Z0-9_.|]+\)d/g) !== null) {
var match = msgs[i].match(/%\([a-zA-Z0-9_.|]+\)d/g)[0];
msgKey = match.substri... | [
"function",
"(",
"msgs",
",",
"pluralForms",
")",
"{",
"var",
"msgKey",
"=",
"'digit'",
";",
"var",
"hasVariableName",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"msgs",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",... | Converts a python po-formatted plural msg into an icu-formatted plural.
@param {list} [msgs] list of strings for each plural form
@param {list} [pluralForms] list of icu plural forms used by this language
choices are: ['zero', 'one', 'two', 'few', 'many', 'other'] | [
"Converts",
"a",
"python",
"po",
"-",
"formatted",
"plural",
"msg",
"into",
"an",
"icu",
"-",
"formatted",
"plural",
"."
] | 9eb97f81f72b2fee02b77f1424702e019647e9b9 | https://github.com/LLK/po2icu/blob/9eb97f81f72b2fee02b77f1424702e019647e9b9/lib/po2icu.js#L81-L107 | |
38,067 | jsantell/mock-s3 | lib/utils.js | removeFromList | function removeFromList (array, obj) {
for (var i = 0; i < array.length; i++) {
if (array[i] === obj) {
array.splice(i, 1);
}
return;
}
} | javascript | function removeFromList (array, obj) {
for (var i = 0; i < array.length; i++) {
if (array[i] === obj) {
array.splice(i, 1);
}
return;
}
} | [
"function",
"removeFromList",
"(",
"array",
",",
"obj",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"array",
"[",
"i",
"]",
"===",
"obj",
")",
"{",
"array",
".",
"spl... | Remove `obj` from `array`.
@param {Array} array
@param {Mixed} object | [
"Remove",
"obj",
"from",
"array",
"."
] | d02e3b0558cc60c7887232b69df41e2b0fe09147 | https://github.com/jsantell/mock-s3/blob/d02e3b0558cc60c7887232b69df41e2b0fe09147/lib/utils.js#L22-L29 |
38,068 | jsantell/mock-s3 | lib/utils.js | findWhere | function findWhere (array, obj) {
var props = Object.keys(obj);
for (var i = 0; i < array.length; i++) {
var passable = true;
for (var j = 0; j < props.length; j++) {
if (array[i][props[j]] !== obj[props[j]]) {
passable = false;
}
}
if (passable)
return array[i];
}
retu... | javascript | function findWhere (array, obj) {
var props = Object.keys(obj);
for (var i = 0; i < array.length; i++) {
var passable = true;
for (var j = 0; j < props.length; j++) {
if (array[i][props[j]] !== obj[props[j]]) {
passable = false;
}
}
if (passable)
return array[i];
}
retu... | [
"function",
"findWhere",
"(",
"array",
",",
"obj",
")",
"{",
"var",
"props",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"passable",... | Finds an object in `array` that matches all key-value pairs
defined in `obj`. Returns first object that matches. Similar to
underscore's `_.findWhere`.
@param {Array} array
@param {Object} obj
@return {Mixed} | [
"Finds",
"an",
"object",
"in",
"array",
"that",
"matches",
"all",
"key",
"-",
"value",
"pairs",
"defined",
"in",
"obj",
".",
"Returns",
"first",
"object",
"that",
"matches",
".",
"Similar",
"to",
"underscore",
"s",
"_",
".",
"findWhere",
"."
] | d02e3b0558cc60c7887232b69df41e2b0fe09147 | https://github.com/jsantell/mock-s3/blob/d02e3b0558cc60c7887232b69df41e2b0fe09147/lib/utils.js#L42-L55 |
38,069 | jsantell/mock-s3 | lib/utils.js | update | function update (obj1, obj2) {
Object.keys(obj2).forEach(function (prop) {
obj1[prop] = obj2[prop];
});
return obj1;
} | javascript | function update (obj1, obj2) {
Object.keys(obj2).forEach(function (prop) {
obj1[prop] = obj2[prop];
});
return obj1;
} | [
"function",
"update",
"(",
"obj1",
",",
"obj2",
")",
"{",
"Object",
".",
"keys",
"(",
"obj2",
")",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"obj1",
"[",
"prop",
"]",
"=",
"obj2",
"[",
"prop",
"]",
";",
"}",
")",
";",
"return",
"o... | Merges properties of obj2 into obj1.
@param {Object} obj1
@param {Object} obj2
@return {Object} | [
"Merges",
"properties",
"of",
"obj2",
"into",
"obj1",
"."
] | d02e3b0558cc60c7887232b69df41e2b0fe09147 | https://github.com/jsantell/mock-s3/blob/d02e3b0558cc60c7887232b69df41e2b0fe09147/lib/utils.js#L78-L83 |
38,070 | jsantell/mock-s3 | lib/utils.js | randomAlpha | function randomAlpha (n) {
var alpha = "abcdefghijklmnopqrstuvwxyz";
var res = "";
for (var i = 0; i < n; i++) {
res += alpha.charAt(Math.floor(Math.random() * alpha.length));
}
return res;
} | javascript | function randomAlpha (n) {
var alpha = "abcdefghijklmnopqrstuvwxyz";
var res = "";
for (var i = 0; i < n; i++) {
res += alpha.charAt(Math.floor(Math.random() * alpha.length));
}
return res;
} | [
"function",
"randomAlpha",
"(",
"n",
")",
"{",
"var",
"alpha",
"=",
"\"abcdefghijklmnopqrstuvwxyz\"",
";",
"var",
"res",
"=",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"res",
"+=",
"alpha",
".",
... | Generates a string of `n` random lowercase characters.
@param {Number} n
@return {String} | [
"Generates",
"a",
"string",
"of",
"n",
"random",
"lowercase",
"characters",
"."
] | d02e3b0558cc60c7887232b69df41e2b0fe09147 | https://github.com/jsantell/mock-s3/blob/d02e3b0558cc60c7887232b69df41e2b0fe09147/lib/utils.js#L144-L151 |
38,071 | impromptu/impromptu | lib/impromptu.js | Impromptu | function Impromptu() {
this.state = new Impromptu.State()
this._setRootPath(Impromptu.DEFAULT_CONFIG_DIR)
this.log = new Impromptu.Log(this.state)
this.exec = Impromptu.Exec(this.log)
this.color = new Impromptu.Color(this.state)
this.repository = new Impromptu.RepositoryFactory()
this.db = new Impromptu.... | javascript | function Impromptu() {
this.state = new Impromptu.State()
this._setRootPath(Impromptu.DEFAULT_CONFIG_DIR)
this.log = new Impromptu.Log(this.state)
this.exec = Impromptu.Exec(this.log)
this.color = new Impromptu.Color(this.state)
this.repository = new Impromptu.RepositoryFactory()
this.db = new Impromptu.... | [
"function",
"Impromptu",
"(",
")",
"{",
"this",
".",
"state",
"=",
"new",
"Impromptu",
".",
"State",
"(",
")",
"this",
".",
"_setRootPath",
"(",
"Impromptu",
".",
"DEFAULT_CONFIG_DIR",
")",
"this",
".",
"log",
"=",
"new",
"Impromptu",
".",
"Log",
"(",
... | The base Impromptu class.
@constructor | [
"The",
"base",
"Impromptu",
"class",
"."
] | 829798eda62771d6a6ed971d87eef7a461932704 | https://github.com/impromptu/impromptu/blob/829798eda62771d6a6ed971d87eef7a461932704/lib/impromptu.js#L14-L31 |
38,072 | MathiasPaumgarten/grunt-json-bake | tasks/json_bake.js | checkFile | function checkFile( path ) {
if ( typeof path === "undefined" || ! grunt.file.exists( path ) ) {
grunt.log.error( "Source file \"" + path + "\" not found." );
return false;
}
return true;
} | javascript | function checkFile( path ) {
if ( typeof path === "undefined" || ! grunt.file.exists( path ) ) {
grunt.log.error( "Source file \"" + path + "\" not found." );
return false;
}
return true;
} | [
"function",
"checkFile",
"(",
"path",
")",
"{",
"if",
"(",
"typeof",
"path",
"===",
"\"undefined\"",
"||",
"!",
"grunt",
".",
"file",
".",
"exists",
"(",
"path",
")",
")",
"{",
"grunt",
".",
"log",
".",
"error",
"(",
"\"Source file \\\"\"",
"+",
"path"... | Returns true if source points to a file | [
"Returns",
"true",
"if",
"source",
"points",
"to",
"a",
"file"
] | 315b1b95e95b9e54101cd51309a711e31ffcbb46 | https://github.com/MathiasPaumgarten/grunt-json-bake/blob/315b1b95e95b9e54101cd51309a711e31ffcbb46/tasks/json_bake.js#L82-L89 |
38,073 | MathiasPaumgarten/grunt-json-bake | tasks/json_bake.js | isIncludeFile | function isIncludeFile( path ) {
if ( fs.statSync( path ).isFile() &&
getIncludeFileExtensions().indexOf( getFileExtension( path ) ) !== - 1 ) return true;
return false;
} | javascript | function isIncludeFile( path ) {
if ( fs.statSync( path ).isFile() &&
getIncludeFileExtensions().indexOf( getFileExtension( path ) ) !== - 1 ) return true;
return false;
} | [
"function",
"isIncludeFile",
"(",
"path",
")",
"{",
"if",
"(",
"fs",
".",
"statSync",
"(",
"path",
")",
".",
"isFile",
"(",
")",
"&&",
"getIncludeFileExtensions",
"(",
")",
".",
"indexOf",
"(",
"getFileExtension",
"(",
"path",
")",
")",
"!==",
"-",
"1"... | Returns true if the path given points at a JSON file or accepted include file | [
"Returns",
"true",
"if",
"the",
"path",
"given",
"points",
"at",
"a",
"JSON",
"file",
"or",
"accepted",
"include",
"file"
] | 315b1b95e95b9e54101cd51309a711e31ffcbb46 | https://github.com/MathiasPaumgarten/grunt-json-bake/blob/315b1b95e95b9e54101cd51309a711e31ffcbb46/tasks/json_bake.js#L103-L108 |
38,074 | MathiasPaumgarten/grunt-json-bake | tasks/json_bake.js | parseJSON | function parseJSON( path, content ) {
return JSON.parse( content, function( key, value ) {
if ( options.stripComments && key === "{{comment}}" ) return undefined;
// Replace variables in their values
if ( Object.keys( options.variables ).length && typeof v... | javascript | function parseJSON( path, content ) {
return JSON.parse( content, function( key, value ) {
if ( options.stripComments && key === "{{comment}}" ) return undefined;
// Replace variables in their values
if ( Object.keys( options.variables ).length && typeof v... | [
"function",
"parseJSON",
"(",
"path",
",",
"content",
")",
"{",
"return",
"JSON",
".",
"parse",
"(",
"content",
",",
"function",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"options",
".",
"stripComments",
"&&",
"key",
"===",
"\"{{comment}}\"",
")",
... | Parses a JSON file and returns value as object | [
"Parses",
"a",
"JSON",
"file",
"and",
"returns",
"value",
"as",
"object"
] | 315b1b95e95b9e54101cd51309a711e31ffcbb46 | https://github.com/MathiasPaumgarten/grunt-json-bake/blob/315b1b95e95b9e54101cd51309a711e31ffcbb46/tasks/json_bake.js#L160-L184 |
38,075 | MathiasPaumgarten/grunt-json-bake | tasks/json_bake.js | replaceVariables | function replaceVariables( value ) {
return value.replace( options.variableRegex, function( match, key ) {
if ( options.variables[ key ] === undefined ) {
grunt.log.warn( "No variable definition found for: " + key );
return "";
}
... | javascript | function replaceVariables( value ) {
return value.replace( options.variableRegex, function( match, key ) {
if ( options.variables[ key ] === undefined ) {
grunt.log.warn( "No variable definition found for: " + key );
return "";
}
... | [
"function",
"replaceVariables",
"(",
"value",
")",
"{",
"return",
"value",
".",
"replace",
"(",
"options",
".",
"variableRegex",
",",
"function",
"(",
"match",
",",
"key",
")",
"{",
"if",
"(",
"options",
".",
"variables",
"[",
"key",
"]",
"===",
"undefin... | Replaces defined variables in the given value | [
"Replaces",
"defined",
"variables",
"in",
"the",
"given",
"value"
] | 315b1b95e95b9e54101cd51309a711e31ffcbb46 | https://github.com/MathiasPaumgarten/grunt-json-bake/blob/315b1b95e95b9e54101cd51309a711e31ffcbb46/tasks/json_bake.js#L189-L201 |
38,076 | MathiasPaumgarten/grunt-json-bake | tasks/json_bake.js | parseDirectory | function parseDirectory( path ) {
return fs.readdirSync( path )
.map( function( file ) {
var filePath = path + "/" + file;
if ( isIncludeFile( filePath ) ) return parseFile( filePath );
else if ( isDirectory( filePath ) ) return... | javascript | function parseDirectory( path ) {
return fs.readdirSync( path )
.map( function( file ) {
var filePath = path + "/" + file;
if ( isIncludeFile( filePath ) ) return parseFile( filePath );
else if ( isDirectory( filePath ) ) return... | [
"function",
"parseDirectory",
"(",
"path",
")",
"{",
"return",
"fs",
".",
"readdirSync",
"(",
"path",
")",
".",
"map",
"(",
"function",
"(",
"file",
")",
"{",
"var",
"filePath",
"=",
"path",
"+",
"\"/\"",
"+",
"file",
";",
"if",
"(",
"isIncludeFile",
... | Parses a directory and returns content as array | [
"Parses",
"a",
"directory",
"and",
"returns",
"content",
"as",
"array"
] | 315b1b95e95b9e54101cd51309a711e31ffcbb46 | https://github.com/MathiasPaumgarten/grunt-json-bake/blob/315b1b95e95b9e54101cd51309a711e31ffcbb46/tasks/json_bake.js#L213-L232 |
38,077 | nwtjs/nwt | plugins/scroller.js | function(e) {
var thumbOffset = this.thumb.region().height/2;
this.setPositionIfValid(e._e.pageY - (this.node.region().top + this.scrollbarOffset) - thumbOffset);
} | javascript | function(e) {
var thumbOffset = this.thumb.region().height/2;
this.setPositionIfValid(e._e.pageY - (this.node.region().top + this.scrollbarOffset) - thumbOffset);
} | [
"function",
"(",
"e",
")",
"{",
"var",
"thumbOffset",
"=",
"this",
".",
"thumb",
".",
"region",
"(",
")",
".",
"height",
"/",
"2",
";",
"this",
".",
"setPositionIfValid",
"(",
"e",
".",
"_e",
".",
"pageY",
"-",
"(",
"this",
".",
"node",
".",
"reg... | Update the position of the thumb from an event | [
"Update",
"the",
"position",
"of",
"the",
"thumb",
"from",
"an",
"event"
] | 49991293e621846e435992b764265abb13a7346b | https://github.com/nwtjs/nwt/blob/49991293e621846e435992b764265abb13a7346b/plugins/scroller.js#L107-L110 | |
38,078 | philidem/url-util-js | URL.js | _parseNetworkLocation | function _parseNetworkLocation(networkLocation, obj) {
var pos = networkLocation.indexOf(':');
if (pos === -1) {
obj.host = networkLocation;
} else {
obj.host = networkLocation.substring(0, pos);
if (pos < (networkLocation.length - 1)) {
obj.port = networkLocation.substring(pos + 1);
}
}
} | javascript | function _parseNetworkLocation(networkLocation, obj) {
var pos = networkLocation.indexOf(':');
if (pos === -1) {
obj.host = networkLocation;
} else {
obj.host = networkLocation.substring(0, pos);
if (pos < (networkLocation.length - 1)) {
obj.port = networkLocation.substring(pos + 1);
}
}
} | [
"function",
"_parseNetworkLocation",
"(",
"networkLocation",
",",
"obj",
")",
"{",
"var",
"pos",
"=",
"networkLocation",
".",
"indexOf",
"(",
"':'",
")",
";",
"if",
"(",
"pos",
"===",
"-",
"1",
")",
"{",
"obj",
".",
"host",
"=",
"networkLocation",
";",
... | Parse the network location which will contain the host and possibly
the port.
@param networkLocation
the network location portion of URL being parsed | [
"Parse",
"the",
"network",
"location",
"which",
"will",
"contain",
"the",
"host",
"and",
"possibly",
"the",
"port",
"."
] | 0c7575900028094ebaeb70d74f85dacf4b8680ef | https://github.com/philidem/url-util-js/blob/0c7575900028094ebaeb70d74f85dacf4b8680ef/URL.js#L33-L43 |
38,079 | impromptu/impromptu | lib/cache/GlobalCache.js | function(exists, done) {
if (exists) {
done(new AbstractCache.Error('The cache is currently locked.'))
} else {
client.get("lock-process:" + name, done)
}
} | javascript | function(exists, done) {
if (exists) {
done(new AbstractCache.Error('The cache is currently locked.'))
} else {
client.get("lock-process:" + name, done)
}
} | [
"function",
"(",
"exists",
",",
"done",
")",
"{",
"if",
"(",
"exists",
")",
"{",
"done",
"(",
"new",
"AbstractCache",
".",
"Error",
"(",
"'The cache is currently locked.'",
")",
")",
"}",
"else",
"{",
"client",
".",
"get",
"(",
"\"lock-process:\"",
"+",
... | Check if there's a process already running to update the cache. | [
"Check",
"if",
"there",
"s",
"a",
"process",
"already",
"running",
"to",
"update",
"the",
"cache",
"."
] | 829798eda62771d6a6ed971d87eef7a461932704 | https://github.com/impromptu/impromptu/blob/829798eda62771d6a6ed971d87eef7a461932704/lib/cache/GlobalCache.js#L86-L92 | |
38,080 | wprl/baucis-swagger | Controller.js | capitalize | function capitalize (s) {
if (!s) return s;
if (s.length === 1) return s.toUpperCase();
return s[0].toUpperCase() + s.substring(1);
} | javascript | function capitalize (s) {
if (!s) return s;
if (s.length === 1) return s.toUpperCase();
return s[0].toUpperCase() + s.substring(1);
} | [
"function",
"capitalize",
"(",
"s",
")",
"{",
"if",
"(",
"!",
"s",
")",
"return",
"s",
";",
"if",
"(",
"s",
".",
"length",
"===",
"1",
")",
"return",
"s",
".",
"toUpperCase",
"(",
")",
";",
"return",
"s",
"[",
"0",
"]",
".",
"toUpperCase",
"(",... | A method for capitalizing the first letter of a string | [
"A",
"method",
"for",
"capitalizing",
"the",
"first",
"letter",
"of",
"a",
"string"
] | 405ffc754555034b57ca633b9c2c30454789169e | https://github.com/wprl/baucis-swagger/blob/405ffc754555034b57ca633b9c2c30454789169e/Controller.js#L27-L31 |
38,081 | wprl/baucis-swagger | Controller.js | generateOperations | function generateOperations (plural) {
var operations = [];
controller.methods().forEach(function (verb) {
var operation = {};
var titlePlural = capitalize(controller.model().plural());
var titleSingular = capitalize(controller.model().singular());
// Don't do head, post/put for single... | javascript | function generateOperations (plural) {
var operations = [];
controller.methods().forEach(function (verb) {
var operation = {};
var titlePlural = capitalize(controller.model().plural());
var titleSingular = capitalize(controller.model().singular());
// Don't do head, post/put for single... | [
"function",
"generateOperations",
"(",
"plural",
")",
"{",
"var",
"operations",
"=",
"[",
"]",
";",
"controller",
".",
"methods",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"verb",
")",
"{",
"var",
"operation",
"=",
"{",
"}",
";",
"var",
"titlePlu... | Generate a list of a controller's operations | [
"Generate",
"a",
"list",
"of",
"a",
"controller",
"s",
"operations"
] | 405ffc754555034b57ca633b9c2c30454789169e | https://github.com/wprl/baucis-swagger/blob/405ffc754555034b57ca633b9c2c30454789169e/Controller.js#L260-L293 |
38,082 | impromptu/impromptu | lib/DB.js | DB | function DB() {
this.requests = {}
process.on('message', function(message) {
if (message.type !== 'cache:response') {
return
}
/** @type {{error: Error, response: string, uid: string, method: string}} */
var data = message.data
// The requests for this UID may not exist because there can ... | javascript | function DB() {
this.requests = {}
process.on('message', function(message) {
if (message.type !== 'cache:response') {
return
}
/** @type {{error: Error, response: string, uid: string, method: string}} */
var data = message.data
// The requests for this UID may not exist because there can ... | [
"function",
"DB",
"(",
")",
"{",
"this",
".",
"requests",
"=",
"{",
"}",
"process",
".",
"on",
"(",
"'message'",
",",
"function",
"(",
"message",
")",
"{",
"if",
"(",
"message",
".",
"type",
"!==",
"'cache:response'",
")",
"{",
"return",
"}",
"/** @t... | The Impromptu database client.
@constructor | [
"The",
"Impromptu",
"database",
"client",
"."
] | 829798eda62771d6a6ed971d87eef7a461932704 | https://github.com/impromptu/impromptu/blob/829798eda62771d6a6ed971d87eef7a461932704/lib/DB.js#L7-L30 |
38,083 | michaelnisi/pickup | repl.js | read | function read (parser, type, key, limit = Infinity) {
let count = 0
pipeline(parser, new Writable({
write (obj, enc, cb) {
if (typeof type === 'string') key = type
if (typeof type === 'number') {
limit = type
type = undefined
}
if (typeof key === 'number') {
li... | javascript | function read (parser, type, key, limit = Infinity) {
let count = 0
pipeline(parser, new Writable({
write (obj, enc, cb) {
if (typeof type === 'string') key = type
if (typeof type === 'number') {
limit = type
type = undefined
}
if (typeof key === 'number') {
li... | [
"function",
"read",
"(",
"parser",
",",
"type",
",",
"key",
",",
"limit",
"=",
"Infinity",
")",
"{",
"let",
"count",
"=",
"0",
"pipeline",
"(",
"parser",
",",
"new",
"Writable",
"(",
"{",
"write",
"(",
"obj",
",",
"enc",
",",
"cb",
")",
"{",
"if"... | Reads all data of type from parser matching key. You can skip type or pass Feed or Entry for only seeing to those. You might also limit messages. | [
"Reads",
"all",
"data",
"of",
"type",
"from",
"parser",
"matching",
"key",
".",
"You",
"can",
"skip",
"type",
"or",
"pass",
"Feed",
"or",
"Entry",
"for",
"only",
"seeing",
"to",
"those",
".",
"You",
"might",
"also",
"limit",
"messages",
"."
] | 582fba3f866a5c92bd46498323c3d11cc341183c | https://github.com/michaelnisi/pickup/blob/582fba3f866a5c92bd46498323c3d11cc341183c/repl.js#L43-L79 |
38,084 | rfink/verdict.js | lib/index.js | Ruleset | function Ruleset(rules, composite) {
if (!(this instanceof Ruleset)) {
return new Ruleset(rules, composite);
}
this.composite = composite || 'all';
this.rules = rules || [];
} | javascript | function Ruleset(rules, composite) {
if (!(this instanceof Ruleset)) {
return new Ruleset(rules, composite);
}
this.composite = composite || 'all';
this.rules = rules || [];
} | [
"function",
"Ruleset",
"(",
"rules",
",",
"composite",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Ruleset",
")",
")",
"{",
"return",
"new",
"Ruleset",
"(",
"rules",
",",
"composite",
")",
";",
"}",
"this",
".",
"composite",
"=",
"composite",... | Construct a new ruleset | [
"Construct",
"a",
"new",
"ruleset"
] | e7681c0593806ac097c01af7581a174227dc85d6 | https://github.com/rfink/verdict.js/blob/e7681c0593806ac097c01af7581a174227dc85d6/lib/index.js#L11-L17 |
38,085 | levexis/grunt-selenium-webdriver | tasks/selenium_webdriver.js | stop | function stop(next) {
if (phantomProcess) {
seleniumServerProcess.on('close', function (code, signal) {
// this should really resolve both callbacks rather than guessing phantom wrapper will terminate instantly
if (typeof next === 'function' && !seleniumServerProcess ) {
... | javascript | function stop(next) {
if (phantomProcess) {
seleniumServerProcess.on('close', function (code, signal) {
// this should really resolve both callbacks rather than guessing phantom wrapper will terminate instantly
if (typeof next === 'function' && !seleniumServerProcess ) {
... | [
"function",
"stop",
"(",
"next",
")",
"{",
"if",
"(",
"phantomProcess",
")",
"{",
"seleniumServerProcess",
".",
"on",
"(",
"'close'",
",",
"function",
"(",
"code",
",",
"signal",
")",
"{",
"// this should really resolve both callbacks rather than guessing phantom wrap... | Stop the servers
@param function optional callback
@private | [
"Stop",
"the",
"servers"
] | e9f63af80c8e6738b00812370c6f1ba13c5dc817 | https://github.com/levexis/grunt-selenium-webdriver/blob/e9f63af80c8e6738b00812370c6f1ba13c5dc817/tasks/selenium_webdriver.js#L216-L240 |
38,086 | mojaie/kiwiii | src/component/formBoxGroup.js | scaleBoxGroup | function scaleBoxGroup(selection) {
selection.classed('mb-3', true);
// Scale type
const scaleOptions = [
{key: 'linear', name: 'Linear'},
{key: 'log', name: 'Log'}
];
selection.append('div')
.classed('scale', true)
.classed('mb-1', true)
.call(lbox.selectBox, 'Scale')
.call(l... | javascript | function scaleBoxGroup(selection) {
selection.classed('mb-3', true);
// Scale type
const scaleOptions = [
{key: 'linear', name: 'Linear'},
{key: 'log', name: 'Log'}
];
selection.append('div')
.classed('scale', true)
.classed('mb-1', true)
.call(lbox.selectBox, 'Scale')
.call(l... | [
"function",
"scaleBoxGroup",
"(",
"selection",
")",
"{",
"selection",
".",
"classed",
"(",
"'mb-3'",
",",
"true",
")",
";",
"// Scale type",
"const",
"scaleOptions",
"=",
"[",
"{",
"key",
":",
"'linear'",
",",
"name",
":",
"'Linear'",
"}",
",",
"{",
"key... | Render scale and domain control box group
@param {d3.selection} selection - selection of box container (div element) | [
"Render",
"scale",
"and",
"domain",
"control",
"box",
"group"
] | 30d75685b1ab388b5f1467c753cacd090971ceba | https://github.com/mojaie/kiwiii/blob/30d75685b1ab388b5f1467c753cacd090971ceba/src/component/formBoxGroup.js#L107-L132 |
38,087 | impromptu/impromptu | lib/cache/AbstractCache.js | AbstractCache | function AbstractCache(state, name, options) {
this.state = state
this.name = name
this.options = options
this._update = this._update.bind(this)
this._setLock = false
this._setCallbacks = []
this._needsRefresh = false
this.state.on('refreshCache', function (needsRefresh) {
this._needsRefresh = nee... | javascript | function AbstractCache(state, name, options) {
this.state = state
this.name = name
this.options = options
this._update = this._update.bind(this)
this._setLock = false
this._setCallbacks = []
this._needsRefresh = false
this.state.on('refreshCache', function (needsRefresh) {
this._needsRefresh = nee... | [
"function",
"AbstractCache",
"(",
"state",
",",
"name",
",",
"options",
")",
"{",
"this",
".",
"state",
"=",
"state",
"this",
".",
"name",
"=",
"name",
"this",
".",
"options",
"=",
"options",
"this",
".",
"_update",
"=",
"this",
".",
"_update",
".",
... | An abstract class that manages how a method is cached.
@constructor
@param {State} state
@param {string} name The name of the cache key.
@param {Object} options The options for this instance of the cache. | [
"An",
"abstract",
"class",
"that",
"manages",
"how",
"a",
"method",
"is",
"cached",
"."
] | 829798eda62771d6a6ed971d87eef7a461932704 | https://github.com/impromptu/impromptu/blob/829798eda62771d6a6ed971d87eef7a461932704/lib/cache/AbstractCache.js#L16-L42 |
38,088 | byron-dupreez/aws-core-utils | other-lambdas.js | succeedLambdaCallback | function succeedLambdaCallback(callback, response, event, context) {
return executePreSuccessCallback(response, event, context)
.then(() => callback(null, response))
.catch(err => {
console.error(`Unexpected failure after executePreSuccessCallback`, err);
return callback(null, response);
});
} | javascript | function succeedLambdaCallback(callback, response, event, context) {
return executePreSuccessCallback(response, event, context)
.then(() => callback(null, response))
.catch(err => {
console.error(`Unexpected failure after executePreSuccessCallback`, err);
return callback(null, response);
});
} | [
"function",
"succeedLambdaCallback",
"(",
"callback",
",",
"response",
",",
"event",
",",
"context",
")",
"{",
"return",
"executePreSuccessCallback",
"(",
"response",
",",
"event",
",",
"context",
")",
".",
"then",
"(",
"(",
")",
"=>",
"callback",
"(",
"null... | Succeeds the given callback of an AWS Lambda, by invoking the given callback with the given response.
@param {Function} callback - the callback function passed as the last argument to your Lambda function on invocation.
@param {Object} response - a normal or Lambda Proxy integration response to be returned
@param {AWSE... | [
"Succeeds",
"the",
"given",
"callback",
"of",
"an",
"AWS",
"Lambda",
"by",
"invoking",
"the",
"given",
"callback",
"with",
"the",
"given",
"response",
"."
] | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/other-lambdas.js#L261-L268 |
38,089 | mailsvb/node-red-contrib-twitter-stream | twitter/twitter.js | TwitterAPIConnection | function TwitterAPIConnection(n) {
RED.nodes.createNode(this,n);
var node = this;
node.consumerKey = n.consumerKey;
node.consumerSecret = n.consumerSecret;
node.accessToken = n.accessToken;
node.accessSecret = n.accessSecret;
var id = node.consumerKey;
... | javascript | function TwitterAPIConnection(n) {
RED.nodes.createNode(this,n);
var node = this;
node.consumerKey = n.consumerKey;
node.consumerSecret = n.consumerSecret;
node.accessToken = n.accessToken;
node.accessSecret = n.accessSecret;
var id = node.consumerKey;
... | [
"function",
"TwitterAPIConnection",
"(",
"n",
")",
"{",
"RED",
".",
"nodes",
".",
"createNode",
"(",
"this",
",",
"n",
")",
";",
"var",
"node",
"=",
"this",
";",
"node",
".",
"consumerKey",
"=",
"n",
".",
"consumerKey",
";",
"node",
".",
"consumerSecre... | handle the connection to the Twitter API | [
"handle",
"the",
"connection",
"to",
"the",
"Twitter",
"API"
] | edc54952576006f46faf4cbc05f82bbf413a0c0c | https://github.com/mailsvb/node-red-contrib-twitter-stream/blob/edc54952576006f46faf4cbc05f82bbf413a0c0c/twitter/twitter.js#L11-L36 |
38,090 | wwayne/mooseql | lib/schema/index.js | buildSchema | function buildSchema(models, typeMap) {
let type;
var _models$map$reduce = models.map(model => {
type = typeMap[model.modelName];
return {
query: (0, _buildQuery2.default)(model, type),
mutation: (0, _buildMutation2.default)(model, type)
};
}).reduce((fields, modelField) => {
fields.q... | javascript | function buildSchema(models, typeMap) {
let type;
var _models$map$reduce = models.map(model => {
type = typeMap[model.modelName];
return {
query: (0, _buildQuery2.default)(model, type),
mutation: (0, _buildMutation2.default)(model, type)
};
}).reduce((fields, modelField) => {
fields.q... | [
"function",
"buildSchema",
"(",
"models",
",",
"typeMap",
")",
"{",
"let",
"type",
";",
"var",
"_models$map$reduce",
"=",
"models",
".",
"map",
"(",
"model",
"=>",
"{",
"type",
"=",
"typeMap",
"[",
"model",
".",
"modelName",
"]",
";",
"return",
"{",
"q... | Build graphql CRUD schema based on models and types
@params
- models {Array} mongoose models
- typeMap {Object} map of model and corresponding graphql type
@return
- grapqhl schema which has query and mutation | [
"Build",
"graphql",
"CRUD",
"schema",
"based",
"on",
"models",
"and",
"types"
] | 4bd5f1e0e378fee59524d79c42154dbe9b07421b | https://github.com/wwayne/mooseql/blob/4bd5f1e0e378fee59524d79c42154dbe9b07421b/lib/schema/index.js#L31-L54 |
38,091 | byron-dupreez/aws-core-utils | stages.js | loadDefaultStageHandlingOptions | function loadDefaultStageHandlingOptions() {
const options = require('./stages-options.json');
const defaultOptions = options ? options.stageHandlingOptions : {};
const defaults = {
envStageName: 'STAGE',
streamNameStageSeparator: '_',
resourceNameStageSeparator: '_',
injectInCase: 'upper',
e... | javascript | function loadDefaultStageHandlingOptions() {
const options = require('./stages-options.json');
const defaultOptions = options ? options.stageHandlingOptions : {};
const defaults = {
envStageName: 'STAGE',
streamNameStageSeparator: '_',
resourceNameStageSeparator: '_',
injectInCase: 'upper',
e... | [
"function",
"loadDefaultStageHandlingOptions",
"(",
")",
"{",
"const",
"options",
"=",
"require",
"(",
"'./stages-options.json'",
")",
";",
"const",
"defaultOptions",
"=",
"options",
"?",
"options",
".",
"stageHandlingOptions",
":",
"{",
"}",
";",
"const",
"defaul... | Loads the default stage handling options from the local stages-options.json file and fills in any missing options with the
static default options.
@returns {StageHandlingOptions} the default stage handling options | [
"Loads",
"the",
"default",
"stage",
"handling",
"options",
"from",
"the",
"local",
"stages",
"-",
"options",
".",
"json",
"file",
"and",
"fills",
"in",
"any",
"missing",
"options",
"with",
"the",
"static",
"default",
"options",
"."
] | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/stages.js#L231-L244 |
38,092 | byron-dupreez/aws-core-utils | stages.js | toStageSuffixedName | function toStageSuffixedName(unsuffixedName, separator, stage, inCase) {
const name = trim(unsuffixedName);
const stageSuffix = isNotBlank(stage) ? `${trimOrEmpty(separator)}${toCase(trim(stage), inCase)}` : '';
return isNotBlank(name) && isNotBlank(stageSuffix) && !name.endsWith(stageSuffix) ? `${name}${stageSuf... | javascript | function toStageSuffixedName(unsuffixedName, separator, stage, inCase) {
const name = trim(unsuffixedName);
const stageSuffix = isNotBlank(stage) ? `${trimOrEmpty(separator)}${toCase(trim(stage), inCase)}` : '';
return isNotBlank(name) && isNotBlank(stageSuffix) && !name.endsWith(stageSuffix) ? `${name}${stageSuf... | [
"function",
"toStageSuffixedName",
"(",
"unsuffixedName",
",",
"separator",
",",
"stage",
",",
"inCase",
")",
"{",
"const",
"name",
"=",
"trim",
"(",
"unsuffixedName",
")",
";",
"const",
"stageSuffix",
"=",
"isNotBlank",
"(",
"stage",
")",
"?",
"`",
"${",
... | Returns a stage-suffixed version of the given unsuffixed name with an appended stage suffix, which will contain the
given separator followed by the given stage, which will be appended in uppercase, lowercase or kept as is according
to the given inCase.
@param {string} unsuffixedName - the unsuffixed name
@param {string... | [
"Returns",
"a",
"stage",
"-",
"suffixed",
"version",
"of",
"the",
"given",
"unsuffixed",
"name",
"with",
"an",
"appended",
"stage",
"suffix",
"which",
"will",
"contain",
"the",
"given",
"separator",
"followed",
"by",
"the",
"given",
"stage",
"which",
"will",
... | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/stages.js#L864-L868 |
38,093 | byron-dupreez/aws-core-utils | stages.js | toCase | function toCase(value, asCase) {
if (isNotBlank(value)) {
// Convert the given asCase argument to lowercase to facilitate matching
const caseToUse = trimOrEmpty(asCase && asCase.toLowerCase ? asCase.toLowerCase() : asCase);
// Convert the given stage into the requested case
return caseToUse === 'lowe... | javascript | function toCase(value, asCase) {
if (isNotBlank(value)) {
// Convert the given asCase argument to lowercase to facilitate matching
const caseToUse = trimOrEmpty(asCase && asCase.toLowerCase ? asCase.toLowerCase() : asCase);
// Convert the given stage into the requested case
return caseToUse === 'lowe... | [
"function",
"toCase",
"(",
"value",
",",
"asCase",
")",
"{",
"if",
"(",
"isNotBlank",
"(",
"value",
")",
")",
"{",
"// Convert the given asCase argument to lowercase to facilitate matching",
"const",
"caseToUse",
"=",
"trimOrEmpty",
"(",
"asCase",
"&&",
"asCase",
".... | Converts the given value to uppercase, lowercase or keeps it as is according to the given asCase argument.
@param value - the value to convert or keep as is
@param {string} asCase - specifies whether to convert the value to uppercase (if 'uppercase' or 'upper') or to
lowercase (if 'lowercase' or 'lower') or to keep it ... | [
"Converts",
"the",
"given",
"value",
"to",
"uppercase",
"lowercase",
"or",
"keeps",
"it",
"as",
"is",
"according",
"to",
"the",
"given",
"asCase",
"argument",
"."
] | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/stages.js#L877-L887 |
38,094 | wwayne/mooseql | lib/utils.js | filterArgs | function filterArgs(defaultArgs, opt) {
opt = opt || {};
const packValueToNonNull = value => (0, _assign2.default)({}, value, { type: new _graphql.GraphQLNonNull(value.type) });
return (0, _entries2.default)(defaultArgs).filter(_ref => {
var _ref2 = (0, _slicedToArray3.default)(_ref, 2);
let arg = _ref2[... | javascript | function filterArgs(defaultArgs, opt) {
opt = opt || {};
const packValueToNonNull = value => (0, _assign2.default)({}, value, { type: new _graphql.GraphQLNonNull(value.type) });
return (0, _entries2.default)(defaultArgs).filter(_ref => {
var _ref2 = (0, _slicedToArray3.default)(_ref, 2);
let arg = _ref2[... | [
"function",
"filterArgs",
"(",
"defaultArgs",
",",
"opt",
")",
"{",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"const",
"packValueToNonNull",
"=",
"value",
"=>",
"(",
"0",
",",
"_assign2",
".",
"default",
")",
"(",
"{",
"}",
",",
"value",
",",
"{",
"t... | Filter arguments when doing CRUD
@params
- defaultArgs {Object} the result of buildArgs
- opt {Object {filter: {Bool}} options: id, plural, required, idRequired, onlyId | [
"Filter",
"arguments",
"when",
"doing",
"CRUD"
] | 4bd5f1e0e378fee59524d79c42154dbe9b07421b | https://github.com/wwayne/mooseql/blob/4bd5f1e0e378fee59524d79c42154dbe9b07421b/lib/utils.js#L37-L68 |
38,095 | wwayne/mooseql | lib/utils.js | toMongooseArgs | function toMongooseArgs(args) {
// Covert name_first to name: {first}
let keyDepth = [];
return (0, _entries2.default)(args).reduce((args, _ref7) => {
var _ref8 = (0, _slicedToArray3.default)(_ref7, 2);
let key = _ref8[0];
let value = _ref8[1];
keyDepth = key.split('_');
if (keyDepth.length ... | javascript | function toMongooseArgs(args) {
// Covert name_first to name: {first}
let keyDepth = [];
return (0, _entries2.default)(args).reduce((args, _ref7) => {
var _ref8 = (0, _slicedToArray3.default)(_ref7, 2);
let key = _ref8[0];
let value = _ref8[1];
keyDepth = key.split('_');
if (keyDepth.length ... | [
"function",
"toMongooseArgs",
"(",
"args",
")",
"{",
"// Covert name_first to name: {first}",
"let",
"keyDepth",
"=",
"[",
"]",
";",
"return",
"(",
"0",
",",
"_entries2",
".",
"default",
")",
"(",
"args",
")",
".",
"reduce",
"(",
"(",
"args",
",",
"_ref7",... | Convert args that graphql know to the args that mongoose know
so that the args can be used by mongoose to find or create | [
"Convert",
"args",
"that",
"graphql",
"know",
"to",
"the",
"args",
"that",
"mongoose",
"know",
"so",
"that",
"the",
"args",
"can",
"be",
"used",
"by",
"mongoose",
"to",
"find",
"or",
"create"
] | 4bd5f1e0e378fee59524d79c42154dbe9b07421b | https://github.com/wwayne/mooseql/blob/4bd5f1e0e378fee59524d79c42154dbe9b07421b/lib/utils.js#L74-L95 |
38,096 | elb-min-uhh/markdown-elearnjs | scripts/cleandocumentation.js | directoryCleanEverything | function directoryCleanEverything(dirPath, includeExtension, toRemove, replacement) {
if(!fs.existsSync(dirPath)) return;
let isDirectory = fs.statSync(dirPath).isDirectory();
// try cleaning package.json in current dir
if(!isDirectory && dirPath.match(new RegExp(includeExtension + "$", "g"))) {
... | javascript | function directoryCleanEverything(dirPath, includeExtension, toRemove, replacement) {
if(!fs.existsSync(dirPath)) return;
let isDirectory = fs.statSync(dirPath).isDirectory();
// try cleaning package.json in current dir
if(!isDirectory && dirPath.match(new RegExp(includeExtension + "$", "g"))) {
... | [
"function",
"directoryCleanEverything",
"(",
"dirPath",
",",
"includeExtension",
",",
"toRemove",
",",
"replacement",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"dirPath",
")",
")",
"return",
";",
"let",
"isDirectory",
"=",
"fs",
".",
"statSync"... | Removes the `toRemove` string from every package.json found in the subtree
@param {*} dirPath the parent dir | [
"Removes",
"the",
"toRemove",
"string",
"from",
"every",
"package",
".",
"json",
"found",
"in",
"the",
"subtree"
] | a09bcc497c3c50dd565b7f440fa1f7b62074d679 | https://github.com/elb-min-uhh/markdown-elearnjs/blob/a09bcc497c3c50dd565b7f440fa1f7b62074d679/scripts/cleandocumentation.js#L20-L39 |
38,097 | XOP/sass-vars-to-js | src/_get-var-value.js | resolveVarValue | function resolveVarValue (name, values) {
if (is.undef(values) || is.args.empty(arguments)) {
message('Error: Missing arguments');
return undefined;
}
if (!is.string(name) || !is.object(values)) {
message('Error: Check arguments type');
return undefined;
}
const var... | javascript | function resolveVarValue (name, values) {
if (is.undef(values) || is.args.empty(arguments)) {
message('Error: Missing arguments');
return undefined;
}
if (!is.string(name) || !is.object(values)) {
message('Error: Check arguments type');
return undefined;
}
const var... | [
"function",
"resolveVarValue",
"(",
"name",
",",
"values",
")",
"{",
"if",
"(",
"is",
".",
"undef",
"(",
"values",
")",
"||",
"is",
".",
"args",
".",
"empty",
"(",
"arguments",
")",
")",
"{",
"message",
"(",
"'Error: Missing arguments'",
")",
";",
"ret... | Finds predefined variable value in variables object
Returns variable value if any resolved
@param name
@param values
@returns {*} | [
"Finds",
"predefined",
"variable",
"value",
"in",
"variables",
"object",
"Returns",
"variable",
"value",
"if",
"any",
"resolved"
] | 87ad8588701a9c2e69ace75931947d11698f25f0 | https://github.com/XOP/sass-vars-to-js/blob/87ad8588701a9c2e69ace75931947d11698f25f0/src/_get-var-value.js#L12-L26 |
38,098 | XOP/sass-vars-to-js | src/utils/_message.js | message | function message (text) {
const normalText = text.toLowerCase();
if (~normalText.indexOf('warning')) {
log.warn(text)
} else if (~normalText.indexOf('error')) {
log.error(text);
} else {
log.debug(text);
}
} | javascript | function message (text) {
const normalText = text.toLowerCase();
if (~normalText.indexOf('warning')) {
log.warn(text)
} else if (~normalText.indexOf('error')) {
log.error(text);
} else {
log.debug(text);
}
} | [
"function",
"message",
"(",
"text",
")",
"{",
"const",
"normalText",
"=",
"text",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"~",
"normalText",
".",
"indexOf",
"(",
"'warning'",
")",
")",
"{",
"log",
".",
"warn",
"(",
"text",
")",
"}",
"else",
"... | Pretty logger
Returns beautified message
@param text | [
"Pretty",
"logger",
"Returns",
"beautified",
"message"
] | 87ad8588701a9c2e69ace75931947d11698f25f0 | https://github.com/XOP/sass-vars-to-js/blob/87ad8588701a9c2e69ace75931947d11698f25f0/src/utils/_message.js#L8-L18 |
38,099 | byron-dupreez/aws-core-utils | dynamodb-utils.js | toObjectFromDynamoDBMap | function toObjectFromDynamoDBMap(dynamoDBMap) {
if (!dynamoDBMap || typeof dynamoDBMap !== 'object') {
return dynamoDBMap;
}
const object = {};
const keys = Object.getOwnPropertyNames(dynamoDBMap);
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
object[key] = toValueFromAttributeValue... | javascript | function toObjectFromDynamoDBMap(dynamoDBMap) {
if (!dynamoDBMap || typeof dynamoDBMap !== 'object') {
return dynamoDBMap;
}
const object = {};
const keys = Object.getOwnPropertyNames(dynamoDBMap);
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
object[key] = toValueFromAttributeValue... | [
"function",
"toObjectFromDynamoDBMap",
"(",
"dynamoDBMap",
")",
"{",
"if",
"(",
"!",
"dynamoDBMap",
"||",
"typeof",
"dynamoDBMap",
"!==",
"'object'",
")",
"{",
"return",
"dynamoDBMap",
";",
"}",
"const",
"object",
"=",
"{",
"}",
";",
"const",
"keys",
"=",
... | Attempts to convert the given DynamoDB map object containing keys and Attribute values into a JavaScript object.
@param {Object} dynamoDBMap - a DynamoDB map object with keys and AttributeValue values
@returns {Object} a JavaScript object | [
"Attempts",
"to",
"convert",
"the",
"given",
"DynamoDB",
"map",
"object",
"containing",
"keys",
"and",
"Attribute",
"values",
"into",
"a",
"JavaScript",
"object",
"."
] | 2530155b5afc102f61658b28183a16027ecae86a | https://github.com/byron-dupreez/aws-core-utils/blob/2530155b5afc102f61658b28183a16027ecae86a/dynamodb-utils.js#L38-L49 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.