repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
overtrue/validator.js | lib/validator.js | _anyFailingRequired | function _anyFailingRequired(attributes) {
for (var i in attributes) {
var key = attributes[i];
if ( ! _resolvers.validateRequired(key, self.date[key])) {
return true;
}
}
return false;
} | javascript | function _anyFailingRequired(attributes) {
for (var i in attributes) {
var key = attributes[i];
if ( ! _resolvers.validateRequired(key, self.date[key])) {
return true;
}
}
return false;
} | [
"function",
"_anyFailingRequired",
"(",
"attributes",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"attributes",
")",
"{",
"var",
"key",
"=",
"attributes",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"_resolvers",
".",
"validateRequired",
"(",
"key",
",",
"self",
"... | determine if any of the given attributes fail the required test.
@param array $attributes
@return bool | [
"determine",
"if",
"any",
"of",
"the",
"given",
"attributes",
"fail",
"the",
"required",
"test",
"."
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L470-L479 | train |
overtrue/validator.js | lib/validator.js | function(rule, message) {
if (is_object(rule)) {
_messages = extend({}, _messages, rule);
} else if (is_string(rule)) {
_messages[rule] = message;
}
} | javascript | function(rule, message) {
if (is_object(rule)) {
_messages = extend({}, _messages, rule);
} else if (is_string(rule)) {
_messages[rule] = message;
}
} | [
"function",
"(",
"rule",
",",
"message",
")",
"{",
"if",
"(",
"is_object",
"(",
"rule",
")",
")",
"{",
"_messages",
"=",
"extend",
"(",
"{",
"}",
",",
"_messages",
",",
"rule",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"rule",
")",
")",... | add custom messages
@param {String/Object} rule
@param {String} message
@return {Void} | [
"add",
"custom",
"messages"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L741-L747 | train | |
overtrue/validator.js | lib/validator.js | function(attribute, alias) {
if (is_object(attribute)) {
_attributes = extend({}, _attributes, attribute);
} else if (is_string(attribute)) {
_attributes[attribute] = alias;
}
} | javascript | function(attribute, alias) {
if (is_object(attribute)) {
_attributes = extend({}, _attributes, attribute);
} else if (is_string(attribute)) {
_attributes[attribute] = alias;
}
} | [
"function",
"(",
"attribute",
",",
"alias",
")",
"{",
"if",
"(",
"is_object",
"(",
"attribute",
")",
")",
"{",
"_attributes",
"=",
"extend",
"(",
"{",
"}",
",",
"_attributes",
",",
"attribute",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"att... | add attributes alias
@param {String/Object} attribute
@param {String} alias
@return {Void} | [
"add",
"attributes",
"alias"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L757-L763 | train | |
overtrue/validator.js | lib/validator.js | function(value, alias) {
if (is_object(value)) {
_values = extend({}, _values, value);
} else if (is_string(rule)) {
_values[value] = alias;
}
} | javascript | function(value, alias) {
if (is_object(value)) {
_values = extend({}, _values, value);
} else if (is_string(rule)) {
_values[value] = alias;
}
} | [
"function",
"(",
"value",
",",
"alias",
")",
"{",
"if",
"(",
"is_object",
"(",
"value",
")",
")",
"{",
"_values",
"=",
"extend",
"(",
"{",
"}",
",",
"_values",
",",
"value",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"rule",
")",
")",
... | add values alias
@param {String/Object} attribute
@param {String} alias
@return {Void} | [
"add",
"values",
"alias"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L773-L779 | train | |
overtrue/validator.js | lib/validator.js | function(rule, fn) {
if (is_object(rule)) {
_replacers = extend({}, _replacers, rule);
} else if (is_string(rule)) {
_replacers[rule] = fn;
}
} | javascript | function(rule, fn) {
if (is_object(rule)) {
_replacers = extend({}, _replacers, rule);
} else if (is_string(rule)) {
_replacers[rule] = fn;
}
} | [
"function",
"(",
"rule",
",",
"fn",
")",
"{",
"if",
"(",
"is_object",
"(",
"rule",
")",
")",
"{",
"_replacers",
"=",
"extend",
"(",
"{",
"}",
",",
"_replacers",
",",
"rule",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"rule",
")",
")",
... | add message replacers
@param {String/Object} rule
@param {Function} fn
@return {Void} | [
"add",
"message",
"replacers"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L789-L795 | train | |
elidoran/node-date-holidays-us | lib/index.js | makeHoliday | function makeHoliday(date, info, observedInfo) {
// always make the holiday.
var holiday = {
info: info,
date: {
month: date.getMonth(),
day : date.getDate()
}
}
// if the holiday info's `bank` value has a function then
// give it the date so it can evaluate the value.
if ('functi... | javascript | function makeHoliday(date, info, observedInfo) {
// always make the holiday.
var holiday = {
info: info,
date: {
month: date.getMonth(),
day : date.getDate()
}
}
// if the holiday info's `bank` value has a function then
// give it the date so it can evaluate the value.
if ('functi... | [
"function",
"makeHoliday",
"(",
"date",
",",
"info",
",",
"observedInfo",
")",
"{",
"// always make the holiday.",
"var",
"holiday",
"=",
"{",
"info",
":",
"info",
",",
"date",
":",
"{",
"month",
":",
"date",
".",
"getMonth",
"(",
")",
",",
"day",
":",
... | helper function which accepts the calculated holiday date and holiday info's. if an observed date was produced then it returns both holidays. also helps with the `bank` boolean value. | [
"helper",
"function",
"which",
"accepts",
"the",
"calculated",
"holiday",
"date",
"and",
"holiday",
"info",
"s",
".",
"if",
"an",
"observed",
"date",
"was",
"produced",
"then",
"it",
"returns",
"both",
"holidays",
".",
"also",
"helps",
"with",
"the",
"bank",... | 7e3ada9bddcbe79e4f1eaf7161629cd7759fc275 | https://github.com/elidoran/node-date-holidays-us/blob/7e3ada9bddcbe79e4f1eaf7161629cd7759fc275/lib/index.js#L198-L233 | train |
elidoran/node-date-holidays-us | lib/index.js | newYearsSpecial | function newYearsSpecial(year) {
// 1. hold onto the date, we'll need it in #3
var date = holidays.newYearsDay(year)
// 2. do the usual.
var newYears = makeHoliday(
date,
{ name: 'New Year\'s Day', bank: !date.observed },
{ name: 'New Year\'s Day (Observed)', bank: true }
)
// 3. check if the... | javascript | function newYearsSpecial(year) {
// 1. hold onto the date, we'll need it in #3
var date = holidays.newYearsDay(year)
// 2. do the usual.
var newYears = makeHoliday(
date,
{ name: 'New Year\'s Day', bank: !date.observed },
{ name: 'New Year\'s Day (Observed)', bank: true }
)
// 3. check if the... | [
"function",
"newYearsSpecial",
"(",
"year",
")",
"{",
"// 1. hold onto the date, we'll need it in #3",
"var",
"date",
"=",
"holidays",
".",
"newYearsDay",
"(",
"year",
")",
"// 2. do the usual.",
"var",
"newYears",
"=",
"makeHoliday",
"(",
"date",
",",
"{",
"name",
... | The New Year's holiday can have an observed date in the previous year. That messes with the whole "generate and cache holidays by year" thing. This handles it by identifying when that happens and specifying the custom year. The @date/holidays package handles the custom year as of v0.3.1. | [
"The",
"New",
"Year",
"s",
"holiday",
"can",
"have",
"an",
"observed",
"date",
"in",
"the",
"previous",
"year",
".",
"That",
"messes",
"with",
"the",
"whole",
"generate",
"and",
"cache",
"holidays",
"by",
"year",
"thing",
".",
"This",
"handles",
"it",
"b... | 7e3ada9bddcbe79e4f1eaf7161629cd7759fc275 | https://github.com/elidoran/node-date-holidays-us/blob/7e3ada9bddcbe79e4f1eaf7161629cd7759fc275/lib/index.js#L339-L358 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mixins/action-interface.js | function(action, implementation){
this.performableActions = this.performableActions || {};
this.performableActions[action] = this.performableActions[action] || {};
this.performableActions[action].actionName = this... | javascript | function(action, implementation){
this.performableActions = this.performableActions || {};
this.performableActions[action] = this.performableActions[action] || {};
this.performableActions[action].actionName = this... | [
"function",
"(",
"action",
",",
"implementation",
")",
"{",
"this",
".",
"performableActions",
"=",
"this",
".",
"performableActions",
"||",
"{",
"}",
";",
"this",
".",
"performableActions",
"[",
"action",
"]",
"=",
"this",
".",
"performableActions",
"[",
"a... | Sets a performable action implementation on object.
@method setPerformableAction
@param {String} action - The action name.
@param {PerformableAction} implementation - Object to set as the action implementation.
or a string to lookup an implementation `RL.PerformableActions[implementation]`. | [
"Sets",
"a",
"performable",
"action",
"implementation",
"on",
"object",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mixins/action-interface.js#L20-L34 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mixins/action-interface.js | function(action, settings){
var handler = this.performableActions[action];
if(!handler){
return false;
}
if(!handler.getTargetsForAction){
return false;
}
settings = settings || {};
if(!settings.skipCan... | javascript | function(action, settings){
var handler = this.performableActions[action];
if(!handler){
return false;
}
if(!handler.getTargetsForAction){
return false;
}
settings = settings || {};
if(!settings.skipCan... | [
"function",
"(",
"action",
",",
"settings",
")",
"{",
"var",
"handler",
"=",
"this",
".",
"performableActions",
"[",
"action",
"]",
";",
"if",
"(",
"!",
"handler",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"handler",
".",
"getTargetsForAct... | Returns a list of valid targets to perform an action on.
@method getTargetsForAction
@param {String} action - The action to get targets for.
@param {Object} [settings] - Settings for the action.
@return {Array} Array of valid targets. | [
"Returns",
"a",
"list",
"of",
"valid",
"targets",
"to",
"perform",
"an",
"action",
"on",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mixins/action-interface.js#L43-L59 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mixins/action-interface.js | function(action, target, settings){
if(!this.performableActions){
return false;
}
var handler = this.performableActions[action];
if(!handler){
return false;
}
// target cannot resolve any actions
if(!targ... | javascript | function(action, target, settings){
if(!this.performableActions){
return false;
}
var handler = this.performableActions[action];
if(!handler){
return false;
}
// target cannot resolve any actions
if(!targ... | [
"function",
"(",
"action",
",",
"target",
",",
"settings",
")",
"{",
"if",
"(",
"!",
"this",
".",
"performableActions",
")",
"{",
"return",
"false",
";",
"}",
"var",
"handler",
"=",
"this",
".",
"performableActions",
"[",
"action",
"]",
";",
"if",
"(",... | Checks if source can perform an action on target with given settings.
@method canPerformActionOnTarget
@param {string} action - The action to check.
@param {Object} target - The target object to check against.
@param {Object} [settings] - Settings for the action.
@param {Object} [settings.skipCanPerformAction] - If tru... | [
"Checks",
"if",
"source",
"can",
"perform",
"an",
"action",
"on",
"target",
"with",
"given",
"settings",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mixins/action-interface.js#L96-L118 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mixins/action-interface.js | function(action, target, settings){
if(!this.performableActions){
return false;
}
var handler = this.performableActions[action];
if(!handler){
return false;
}
settings = settings || {};
// the functions ... | javascript | function(action, target, settings){
if(!this.performableActions){
return false;
}
var handler = this.performableActions[action];
if(!handler){
return false;
}
settings = settings || {};
// the functions ... | [
"function",
"(",
"action",
",",
"target",
",",
"settings",
")",
"{",
"if",
"(",
"!",
"this",
".",
"performableActions",
")",
"{",
"return",
"false",
";",
"}",
"var",
"handler",
"=",
"this",
".",
"performableActions",
"[",
"action",
"]",
";",
"if",
"(",... | Performs an action on target with given settings.
@method performAction
@param {String} action - The action to perform.
@param {Object} target - The target object to perform the action on.
@param {Object} [settings] - Settings for the action.
@param {Object} [settings.skipCanPerformAction] - If true skips checking that... | [
"Performs",
"an",
"action",
"on",
"target",
"with",
"given",
"settings",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mixins/action-interface.js#L130-L166 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mixins/action-interface.js | function(action, implementation){
this.resolvableActions = this.resolvableActions || {};
this.resolvableActions[action] = this.resolvableActions[action] || {};
this.resolvableActions[action].actionName = this.r... | javascript | function(action, implementation){
this.resolvableActions = this.resolvableActions || {};
this.resolvableActions[action] = this.resolvableActions[action] || {};
this.resolvableActions[action].actionName = this.r... | [
"function",
"(",
"action",
",",
"implementation",
")",
"{",
"this",
".",
"resolvableActions",
"=",
"this",
".",
"resolvableActions",
"||",
"{",
"}",
";",
"this",
".",
"resolvableActions",
"[",
"action",
"]",
"=",
"this",
".",
"resolvableActions",
"[",
"actio... | Sets a resolvable action implementation on object.
@method setResolvableAction
@param {String} action - The action name.
@param {ResolvableAction} [implementation] - Object to set as the action implementation. | [
"Sets",
"a",
"resolvable",
"action",
"implementation",
"on",
"object",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mixins/action-interface.js#L184-L197 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mixins/action-interface.js | function(action, source, settings){
if(!this.resolvableActions){
return false;
}
var handler = this.resolvableActions[action];
if(!handler){
return false;
}
if(handler.canResolveAction === false){
ret... | javascript | function(action, source, settings){
if(!this.resolvableActions){
return false;
}
var handler = this.resolvableActions[action];
if(!handler){
return false;
}
if(handler.canResolveAction === false){
ret... | [
"function",
"(",
"action",
",",
"source",
",",
"settings",
")",
"{",
"if",
"(",
"!",
"this",
".",
"resolvableActions",
")",
"{",
"return",
"false",
";",
"}",
"var",
"handler",
"=",
"this",
".",
"resolvableActions",
"[",
"action",
"]",
";",
"if",
"(",
... | Checks if a target can resolve an action with given source and settings. `this` is the target.
@method canResolveAction
@param {String} action - The action being performed on this target to resolve.
@param {Object} source - The source object performing the action on this target.
@param {Object} [settings] - Settings fo... | [
"Checks",
"if",
"a",
"target",
"can",
"resolve",
"an",
"action",
"with",
"given",
"source",
"and",
"settings",
".",
"this",
"is",
"the",
"target",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mixins/action-interface.js#L207-L222 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mixins/action-interface.js | function(action, source, settings){
if(!this.resolvableActions){
return false;
}
var handler = this.resolvableActions[action];
if(!handler){
return false;
}
settings = settings || {};
if(!settings.skipCan... | javascript | function(action, source, settings){
if(!this.resolvableActions){
return false;
}
var handler = this.resolvableActions[action];
if(!handler){
return false;
}
settings = settings || {};
if(!settings.skipCan... | [
"function",
"(",
"action",
",",
"source",
",",
"settings",
")",
"{",
"if",
"(",
"!",
"this",
".",
"resolvableActions",
")",
"{",
"return",
"false",
";",
"}",
"var",
"handler",
"=",
"this",
".",
"resolvableActions",
"[",
"action",
"]",
";",
"if",
"(",
... | Resolves an action on target from source with given settings.
@method performAction
@param {String} action - The action being performed on this target to resolve.
@param {Object} source - The source object performing the action on this target.
@param {Object} [settings] - Settings for the action.
@param {Object} [setti... | [
"Resolves",
"an",
"action",
"on",
"target",
"from",
"source",
"with",
"given",
"settings",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mixins/action-interface.js#L233-L253 | train | |
sematext/spm-agent-os | linuxAgent.js | function (metric) {
var now = (new Date().getTime()).toFixed(0)
var line = null
if (metric.sct === 'OS' && /collectd/.test(metric.name)) {
line = this.collectdFormatLine(metric)
} else {
if (metric.sct === 'OS') {
// new OS metric format
if (metric.filters ins... | javascript | function (metric) {
var now = (new Date().getTime()).toFixed(0)
var line = null
if (metric.sct === 'OS' && /collectd/.test(metric.name)) {
line = this.collectdFormatLine(metric)
} else {
if (metric.sct === 'OS') {
// new OS metric format
if (metric.filters ins... | [
"function",
"(",
"metric",
")",
"{",
"var",
"now",
"=",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
")",
".",
"toFixed",
"(",
"0",
")",
"var",
"line",
"=",
"null",
"if",
"(",
"metric",
".",
"sct",
"===",
"'OS'",
"&&",
"/",
"collectd... | osnet 1457010656149 lo 0 0 | [
"osnet",
"1457010656149",
"lo",
"0",
"0"
] | e3083f56b9d8542de29fc53679da8e8f4d1d4493 | https://github.com/sematext/spm-agent-os/blob/e3083f56b9d8542de29fc53679da8e8f4d1d4493/linuxAgent.js#L49-L69 | train | |
deepstreamIO/deepstream.io-service | src/daemon.js | monitor | function monitor() {
if(!child.pid) {
// If the number of periodic starts exceeds the max, kill the process
if (starts >= options.maxRetries) {
if ((Date.now() - startTime) > maxMilliseconds) {
console.error(
`Too many restarts within the last ${maxMilliseconds / 1000} seco... | javascript | function monitor() {
if(!child.pid) {
// If the number of periodic starts exceeds the max, kill the process
if (starts >= options.maxRetries) {
if ((Date.now() - startTime) > maxMilliseconds) {
console.error(
`Too many restarts within the last ${maxMilliseconds / 1000} seco... | [
"function",
"monitor",
"(",
")",
"{",
"if",
"(",
"!",
"child",
".",
"pid",
")",
"{",
"// If the number of periodic starts exceeds the max, kill the process",
"if",
"(",
"starts",
">=",
"options",
".",
"maxRetries",
")",
"{",
"if",
"(",
"(",
"Date",
".",
"now",... | Monitor the process to make sure it is running | [
"Monitor",
"the",
"process",
"to",
"make",
"sure",
"it",
"is",
"running"
] | f0a4f482eb027cc503e86d7d6a298cfee03883e3 | https://github.com/deepstreamIO/deepstream.io-service/blob/f0a4f482eb027cc503e86d7d6a298cfee03883e3/src/daemon.js#L16-L44 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | Game | function Game() {
// un-populated instance of Array2d
this.map = new RL.Map(this);
this.entityManager = new RL.ObjectManager(this, RL.Entity);
this.renderer = new RL.Renderer(this);
this.console = new RL.Console(this);
this.lighting = new RL.LightingROT(this);
/... | javascript | function Game() {
// un-populated instance of Array2d
this.map = new RL.Map(this);
this.entityManager = new RL.ObjectManager(this, RL.Entity);
this.renderer = new RL.Renderer(this);
this.console = new RL.Console(this);
this.lighting = new RL.LightingROT(this);
/... | [
"function",
"Game",
"(",
")",
"{",
"// un-populated instance of Array2d",
"this",
".",
"map",
"=",
"new",
"RL",
".",
"Map",
"(",
"this",
")",
";",
"this",
".",
"entityManager",
"=",
"new",
"RL",
".",
"ObjectManager",
"(",
"this",
",",
"RL",
".",
"Entity"... | Container for all game objects.
Handles updating the state of game objects each turn.
Listens for player input to trigger and resolve new turns.
@class Game
@constructor | [
"Container",
"for",
"all",
"game",
"objects",
".",
"Handles",
"updating",
"the",
"state",
"of",
"game",
"objects",
"each",
"turn",
".",
"Listens",
"for",
"player",
"input",
"to",
"trigger",
"and",
"resolve",
"new",
"turns",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L11-L33 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | function(width, height){
this.map.setSize(width, height);
this.player.fov.setSize(width, height);
this.entityManager.setSize(width, height);
this.lighting.setSize(width, height);
} | javascript | function(width, height){
this.map.setSize(width, height);
this.player.fov.setSize(width, height);
this.entityManager.setSize(width, height);
this.lighting.setSize(width, height);
} | [
"function",
"(",
"width",
",",
"height",
")",
"{",
"this",
".",
"map",
".",
"setSize",
"(",
"width",
",",
"height",
")",
";",
"this",
".",
"player",
".",
"fov",
".",
"setSize",
"(",
"width",
",",
"height",
")",
";",
"this",
".",
"entityManager",
".... | Sets the size of the map resizing this.map and this.entityManager.
@method setMapSize
@param {Number} width - Width in tilse to set map and entityManager to.
@param {Number} height - Height in tilse to set map and entityManager to. | [
"Sets",
"the",
"size",
"of",
"the",
"map",
"resizing",
"this",
".",
"map",
"and",
"this",
".",
"entityManager",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L115-L120 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | function(action) {
if(!this.gameOver){
var result = this.player.update(action);
if(result){
this.entityManager.update(this.player);
this.player.updateFov();
this.lighting.update();
this.renderer... | javascript | function(action) {
if(!this.gameOver){
var result = this.player.update(action);
if(result){
this.entityManager.update(this.player);
this.player.updateFov();
this.lighting.update();
this.renderer... | [
"function",
"(",
"action",
")",
"{",
"if",
"(",
"!",
"this",
".",
"gameOver",
")",
"{",
"var",
"result",
"=",
"this",
".",
"player",
".",
"update",
"(",
"action",
")",
";",
"if",
"(",
"result",
")",
"{",
"this",
".",
"entityManager",
".",
"update",... | Handles user input actions.
@method onKeyAction
@param {String} action - Action triggered by user input. | [
"Handles",
"user",
"input",
"actions",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L140-L157 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | function(x, y){
var coords = this.renderer.mouseToTileCoords(x, y),
tile = this.map.get(coords.x, coords.y);
if(!tile){
return;
}
var entityTile = this.entityManager.get(tile.x, tile.y);
if(entityTile){
this.cons... | javascript | function(x, y){
var coords = this.renderer.mouseToTileCoords(x, y),
tile = this.map.get(coords.x, coords.y);
if(!tile){
return;
}
var entityTile = this.entityManager.get(tile.x, tile.y);
if(entityTile){
this.cons... | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"coords",
"=",
"this",
".",
"renderer",
".",
"mouseToTileCoords",
"(",
"x",
",",
"y",
")",
",",
"tile",
"=",
"this",
".",
"map",
".",
"get",
"(",
"coords",
".",
"x",
",",
"coords",
".",
"y",
")",... | Handles tile mouse click events.
@method onClick
@param {Number} x - Mouse x coord relative to window.
@param {Number} y - Mouse y coord relative to window. | [
"Handles",
"tile",
"mouse",
"click",
"events",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L165-L178 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | function(x, y){
var coords = this.renderer.mouseToTileCoords(x, y),
tile = this.map.get(coords.x, coords.y);
if(tile){
this.renderer.hoveredTileX = tile.x;
this.renderer.hoveredTileY = tile.y;
} else {
this.renderer.hove... | javascript | function(x, y){
var coords = this.renderer.mouseToTileCoords(x, y),
tile = this.map.get(coords.x, coords.y);
if(tile){
this.renderer.hoveredTileX = tile.x;
this.renderer.hoveredTileY = tile.y;
} else {
this.renderer.hove... | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"coords",
"=",
"this",
".",
"renderer",
".",
"mouseToTileCoords",
"(",
"x",
",",
"y",
")",
",",
"tile",
"=",
"this",
".",
"map",
".",
"get",
"(",
"coords",
".",
"x",
",",
"coords",
".",
"y",
")",... | Handles tile mouse hover events
@method onHover
@param {Number} x - Mouse x coord relative to window.
@param {Number} y - Mouse y coord relative to window. | [
"Handles",
"tile",
"mouse",
"hover",
"events"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L186-L197 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | function(x, y){
var result = [];
var entity = this.entityManager.get(x, y);
if(entity){
result.push(entity);
}
// add items or any other objects that can be placed at a tile coord position
return result;
} | javascript | function(x, y){
var result = [];
var entity = this.entityManager.get(x, y);
if(entity){
result.push(entity);
}
// add items or any other objects that can be placed at a tile coord position
return result;
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"entity",
"=",
"this",
".",
"entityManager",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"if",
"(",
"entity",
")",
"{",
"result",
".",
"push",
"(",
"entity",
... | Gets all objects at tile position
@method getObjectsAtPostion
@param {Number} x
@param {Number} y
@return {Array} | [
"Gets",
"all",
"objects",
"at",
"tile",
"position"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L206-L217 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | function(entity, x, y){
var tile = this.map.get(x, y);
// if tile blocks movement
if(!tile || !tile.passable){
return false;
}
return true;
} | javascript | function(entity, x, y){
var tile = this.map.get(x, y);
// if tile blocks movement
if(!tile || !tile.passable){
return false;
}
return true;
} | [
"function",
"(",
"entity",
",",
"x",
",",
"y",
")",
"{",
"var",
"tile",
"=",
"this",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"// if tile blocks movement",
"if",
"(",
"!",
"tile",
"||",
"!",
"tile",
".",
"passable",
")",
"{",
"return... | Checks if an entity can move through a map tile.
This does NOT check for entities on the tile blocking movement.
This is where code for special cases changing an entity's ability to pass through a tile should be placed.
Things like flying, swimming and ghosts moving through walls.
@method entityCanMoveThrough
@param {E... | [
"Checks",
"if",
"an",
"entity",
"can",
"move",
"through",
"a",
"map",
"tile",
".",
"This",
"does",
"NOT",
"check",
"for",
"entities",
"on",
"the",
"tile",
"blocking",
"movement",
".",
"This",
"is",
"where",
"code",
"for",
"special",
"cases",
"changing",
... | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L230-L237 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | function(entity, x, y){
if(!this.entityCanMoveThrough(entity, x, y)){
return false;
}
// check if occupied by entity
if(this.entityManager.get(x, y)){
return false;
}
return true;
} | javascript | function(entity, x, y){
if(!this.entityCanMoveThrough(entity, x, y)){
return false;
}
// check if occupied by entity
if(this.entityManager.get(x, y)){
return false;
}
return true;
} | [
"function",
"(",
"entity",
",",
"x",
",",
"y",
")",
"{",
"if",
"(",
"!",
"this",
".",
"entityCanMoveThrough",
"(",
"entity",
",",
"x",
",",
"y",
")",
")",
"{",
"return",
"false",
";",
"}",
"// check if occupied by entity",
"if",
"(",
"this",
".",
"en... | Checks if an entity can move through and into a map tile and that tile is un-occupied.
@method entityCanMoveTo
@param {Entity} entity - The entity to check.
@param {Number} x - The x map tile coord to check.
@param {Number} y - The y map tile coord to check.
@return {Bool} | [
"Checks",
"if",
"an",
"entity",
"can",
"move",
"through",
"and",
"into",
"a",
"map",
"tile",
"and",
"that",
"tile",
"is",
"un",
"-",
"occupied",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L247-L256 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/game.js | function(entity, x, y){
var tile = this.map.get(x, y);
return tile && !tile.blocksLos;
} | javascript | function(entity, x, y){
var tile = this.map.get(x, y);
return tile && !tile.blocksLos;
} | [
"function",
"(",
"entity",
",",
"x",
",",
"y",
")",
"{",
"var",
"tile",
"=",
"this",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"return",
"tile",
"&&",
"!",
"tile",
".",
"blocksLos",
";",
"}"
] | Checks if a map tile can be seen through.
This is where code for special cases like smoke, fog, x-ray vision can be implemented by checking the entity param.
@method entityCanSeeThrough
@param {Number} x - The x map tile coord to check.
@param {Number} y - The y map tile coord to check.
@return {Bool} | [
"Checks",
"if",
"a",
"map",
"tile",
"can",
"be",
"seen",
"through",
".",
"This",
"is",
"where",
"code",
"for",
"special",
"cases",
"like",
"smoke",
"fog",
"x",
"-",
"ray",
"vision",
"can",
"be",
"implemented",
"by",
"checking",
"the",
"entity",
"param",
... | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/game.js#L283-L286 | train | |
alexandrudima/typescript-with-globs | lib/tscg.js | handleRecipeFiles | function handleRecipeFiles(folderPath) {
if (handled[folderPath]) {
return;
}
handled[folderPath] = true;
handleRecipeFile(path.join(folderPath, 'tsconfig.json'));
handleRecipeFiles(path.dirname(folderPath));
} | javascript | function handleRecipeFiles(folderPath) {
if (handled[folderPath]) {
return;
}
handled[folderPath] = true;
handleRecipeFile(path.join(folderPath, 'tsconfig.json'));
handleRecipeFiles(path.dirname(folderPath));
} | [
"function",
"handleRecipeFiles",
"(",
"folderPath",
")",
"{",
"if",
"(",
"handled",
"[",
"folderPath",
"]",
")",
"{",
"return",
";",
"}",
"handled",
"[",
"folderPath",
"]",
"=",
"true",
";",
"handleRecipeFile",
"(",
"path",
".",
"join",
"(",
"folderPath",
... | Walk up all folders and discover `tsconfig.json` files. | [
"Walk",
"up",
"all",
"folders",
"and",
"discover",
"tsconfig",
".",
"json",
"files",
"."
] | ac63cf7a20f75626aee7c817a31af7e14a4e3603 | https://github.com/alexandrudima/typescript-with-globs/blob/ac63cf7a20f75626aee7c817a31af7e14a4e3603/lib/tscg.js#L11-L19 | train |
alexandrudima/typescript-with-globs | lib/tscg.js | handleRecipeFile | function handleRecipeFile(recipePath) {
var contents = null;
try {
contents = fs.readFileSync(recipePath);
} catch (err) {
// Not finding a recipe is OK
return;
}
var config = null;
try {
config = JSON.parse(contents.toString());
} catch (err) {
... | javascript | function handleRecipeFile(recipePath) {
var contents = null;
try {
contents = fs.readFileSync(recipePath);
} catch (err) {
// Not finding a recipe is OK
return;
}
var config = null;
try {
config = JSON.parse(contents.toString());
} catch (err) {
... | [
"function",
"handleRecipeFile",
"(",
"recipePath",
")",
"{",
"var",
"contents",
"=",
"null",
";",
"try",
"{",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"recipePath",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"// Not finding a recipe is OK\r",
"ret... | Given a recipe is found at `recipePath`, create a `tsconfig.json` sibling file with the glob resolved. | [
"Given",
"a",
"recipe",
"is",
"found",
"at",
"recipePath",
"create",
"a",
"tsconfig",
".",
"json",
"sibling",
"file",
"with",
"the",
"glob",
"resolved",
"."
] | ac63cf7a20f75626aee7c817a31af7e14a4e3603 | https://github.com/alexandrudima/typescript-with-globs/blob/ac63cf7a20f75626aee7c817a31af7e14a4e3603/lib/tscg.js#L24-L60 | train |
commenthol/debug-level | src/middleware.js | middleware | function middleware (opts) {
opts = Object.assign({maxSize: 100, logAll: false}, opts)
const log = opts.logAll ? new CustomLog() : void (0)
const loggers = new Loggers(opts.maxSize)
return function (req, res) {
let query = req.query
if (!req.query) {
query = qsParse(urlParse(req.url).query)
}... | javascript | function middleware (opts) {
opts = Object.assign({maxSize: 100, logAll: false}, opts)
const log = opts.logAll ? new CustomLog() : void (0)
const loggers = new Loggers(opts.maxSize)
return function (req, res) {
let query = req.query
if (!req.query) {
query = qsParse(urlParse(req.url).query)
}... | [
"function",
"middleware",
"(",
"opts",
")",
"{",
"opts",
"=",
"Object",
".",
"assign",
"(",
"{",
"maxSize",
":",
"100",
",",
"logAll",
":",
"false",
"}",
",",
"opts",
")",
"const",
"log",
"=",
"opts",
".",
"logAll",
"?",
"new",
"CustomLog",
"(",
")... | connect middleware which logs browser based logs on server side
sends a transparent gif as response
@param {Object} [opts]
@param {Object} [opts.maxSize=100] - max number of different name loggers
@param {Object} [opts.logAll=false] - log everything even strings
@return {function} connect middleware | [
"connect",
"middleware",
"which",
"logs",
"browser",
"based",
"logs",
"on",
"server",
"side",
"sends",
"a",
"transparent",
"gif",
"as",
"response"
] | e310fe5452984d898adfb8f924ac6f9021b05457 | https://github.com/commenthol/debug-level/blob/e310fe5452984d898adfb8f924ac6f9021b05457/src/middleware.js#L44-L81 | train |
nickzuber/needle | src/RollingHash/rollingHash.js | function(base){
if(typeof base === 'undefined'){
throw new Error("Too few arguments in RollingHash constructor");
}else if(typeof base !== 'number'){
throw new TypeError("Invalid argument; expected a number in RollingHash constructor");
}
// The base of the number system
this.BASE = base;
// The... | javascript | function(base){
if(typeof base === 'undefined'){
throw new Error("Too few arguments in RollingHash constructor");
}else if(typeof base !== 'number'){
throw new TypeError("Invalid argument; expected a number in RollingHash constructor");
}
// The base of the number system
this.BASE = base;
// The... | [
"function",
"(",
"base",
")",
"{",
"if",
"(",
"typeof",
"base",
"===",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Too few arguments in RollingHash constructor\"",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"base",
"!==",
"'number'",
")",
"{",... | Single argument constructor which defines the base of the working
@param {number} the base value of the rolling hash to compute its operations
@return {void} | [
"Single",
"argument",
"constructor",
"which",
"defines",
"the",
"base",
"of",
"the",
"working"
] | 9565b3c193b93d67ffed39d430eba395a7bb5531 | https://github.com/nickzuber/needle/blob/9565b3c193b93d67ffed39d430eba395a7bb5531/src/RollingHash/rollingHash.js#L85-L110 | train | |
loverly/lexerific | lib/Lexerific.js | Lexerific | function Lexerific(config, _, FSM, Lexeme, StateGenerator, Token, TreeNode) {
var _this = this;
this._ = _;
// Create a finite state machine for lexing
this.fsm = new FSM({
name: 'lexerific',
debug: true,
resetAtRoot: true // erase history for every root bound transition
});
this.fsm.on('retur... | javascript | function Lexerific(config, _, FSM, Lexeme, StateGenerator, Token, TreeNode) {
var _this = this;
this._ = _;
// Create a finite state machine for lexing
this.fsm = new FSM({
name: 'lexerific',
debug: true,
resetAtRoot: true // erase history for every root bound transition
});
this.fsm.on('retur... | [
"function",
"Lexerific",
"(",
"config",
",",
"_",
",",
"FSM",
",",
"Lexeme",
",",
"StateGenerator",
",",
"Token",
",",
"TreeNode",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"this",
".",
"_",
"=",
"_",
";",
"// Create a finite state machine for lexing",
"... | The Lexerific library extends the Transform stream class. Depending on the
mode it either takes in buffers as input or a stream of token objects.
Configuration options:
* `mode` - Either `string` or `token` depending on what type of input
should be consumed. `token` mode is for secondary scanning passes
In `string`... | [
"The",
"Lexerific",
"library",
"extends",
"the",
"Transform",
"stream",
"class",
".",
"Depending",
"on",
"the",
"mode",
"it",
"either",
"takes",
"in",
"buffers",
"as",
"input",
"or",
"a",
"stream",
"of",
"token",
"objects",
"."
] | ba10e4fdadd0d627a57b1997044d6f7b0282b862 | https://github.com/loverly/lexerific/blob/ba10e4fdadd0d627a57b1997044d6f7b0282b862/lib/Lexerific.js#L17-L59 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mixins.js | function() {
return {
char: this.char,
color: this.color,
bgColor: this.bgColor,
borderColor: this.borderColor,
borderWidth: this.borderWidth,
... | javascript | function() {
return {
char: this.char,
color: this.color,
bgColor: this.bgColor,
borderColor: this.borderColor,
borderWidth: this.borderWidth,
... | [
"function",
"(",
")",
"{",
"return",
"{",
"char",
":",
"this",
".",
"char",
",",
"color",
":",
"this",
".",
"color",
",",
"bgColor",
":",
"this",
".",
"bgColor",
",",
"borderColor",
":",
"this",
".",
"borderColor",
",",
"borderWidth",
":",
"this",
".... | Returns as `tileData`object used by `Renderer` objects to draw tiles.
@method getTileDrawData
@return {TileDrawData} | [
"Returns",
"as",
"tileData",
"object",
"used",
"by",
"Renderer",
"objects",
"to",
"draw",
"tiles",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mixins.js#L27-L43 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/util.js | function(defaults, settings) {
var out = {};
for (var key in defaults) {
if (key in settings) {
out[key] = settings[key];
} else {
out[key] = defaults[key];
}
}
return out;
} | javascript | function(defaults, settings) {
var out = {};
for (var key in defaults) {
if (key in settings) {
out[key] = settings[key];
} else {
out[key] = defaults[key];
}
}
return out;
} | [
"function",
"(",
"defaults",
",",
"settings",
")",
"{",
"var",
"out",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"defaults",
")",
"{",
"if",
"(",
"key",
"in",
"settings",
")",
"{",
"out",
"[",
"key",
"]",
"=",
"settings",
"[",
"key",
"... | Merges settings with default values.
@method mergeDefaults
@static
@param {Object} defaults - Default values to merge with.
@param {Object} settings - Settings to merge with default values.
@return {Object} A new object with settings replacing defaults. | [
"Merges",
"settings",
"with",
"default",
"values",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/util.js#L137-L147 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/util.js | function(destination){
var sources = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < sources.length; i++) {
var source = sources[i];
for(var key in source){
destination[key] = source[key];
}
}
... | javascript | function(destination){
var sources = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < sources.length; i++) {
var source = sources[i];
for(var key in source){
destination[key] = source[key];
}
}
... | [
"function",
"(",
"destination",
")",
"{",
"var",
"sources",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"sources",
".",
"length",
";",
"i",
"++"... | Copy all of the properties in the source objects over to the destination object, and return the destination object.
It's in-order, so the last source will override properties of the same name in previous arguments.
@method merge
@static
@param {Object} destination - The object to copy properties to.
@param {Object} sou... | [
"Copy",
"all",
"of",
"the",
"properties",
"in",
"the",
"source",
"objects",
"over",
"to",
"the",
"destination",
"object",
"and",
"return",
"the",
"destination",
"object",
".",
"It",
"s",
"in",
"-",
"order",
"so",
"the",
"last",
"source",
"will",
"override"... | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/util.js#L158-L167 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/util.js | function(x1, y1, x2, y2, diagonalMovement){
if(!diagonalMovement){
return Math.abs(x2 - x1) + Math.abs(y2 - y1);
} else {
return Math.max(Math.abs(x2 - x1), Math.abs(y2 - y1));
}
} | javascript | function(x1, y1, x2, y2, diagonalMovement){
if(!diagonalMovement){
return Math.abs(x2 - x1) + Math.abs(y2 - y1);
} else {
return Math.max(Math.abs(x2 - x1), Math.abs(y2 - y1));
}
} | [
"function",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"diagonalMovement",
")",
"{",
"if",
"(",
"!",
"diagonalMovement",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"x2",
"-",
"x1",
")",
"+",
"Math",
".",
"abs",
"(",
"y2",
"-",
"y1",
")"... | Gets the distance in tile moves from point 1 to point 2.
@method getTileMoveDistance
@param {Number} x1
@param {Number} y1
@param {Number} x2
@param {Number} y2
@param {Bool} [diagonalMovement=false]if true, calculate the distance taking into account diagonal movement.
@return {Number} | [
"Gets",
"the",
"distance",
"in",
"tile",
"moves",
"from",
"point",
"1",
"to",
"point",
"2",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/util.js#L193-L199 | train | |
soliton4/promiseland | promiseland.js | function(jsStr, __parObj){
if (!__parObj){
return eval(jsStr);
};
var s = "";
var n;
for (n in __parObj){
s += "var " + n + " = __parObj." + n + ";";
};
//s = "(function(){" + s;
s += jsStr;
//s += "})();";
return eval(s);
... | javascript | function(jsStr, __parObj){
if (!__parObj){
return eval(jsStr);
};
var s = "";
var n;
for (n in __parObj){
s += "var " + n + " = __parObj." + n + ";";
};
//s = "(function(){" + s;
s += jsStr;
//s += "})();";
return eval(s);
... | [
"function",
"(",
"jsStr",
",",
"__parObj",
")",
"{",
"if",
"(",
"!",
"__parObj",
")",
"{",
"return",
"eval",
"(",
"jsStr",
")",
";",
"}",
";",
"var",
"s",
"=",
"\"\"",
";",
"var",
"n",
";",
"for",
"(",
"n",
"in",
"__parObj",
")",
"{",
"s",
"+... | eval this is here because its pure javascript | [
"eval",
"this",
"is",
"here",
"because",
"its",
"pure",
"javascript"
] | 27ccbe9cabbfa4b36fb0395dbcc5d30470f2ba89 | https://github.com/soliton4/promiseland/blob/27ccbe9cabbfa4b36fb0395dbcc5d30470f2ba89/promiseland.js#L40-L56 | train | |
vmgltd/hlr-lookup-api-nodejs-sdk | src/lib/node-hlr-client.js | HlrLookupClient | function HlrLookupClient(username, password, noSsl) {
this.username = username;
this.password = password;
this.url = (noSsl ? 'http' : 'https') + '://www.hlr-lookups.com/api';
} | javascript | function HlrLookupClient(username, password, noSsl) {
this.username = username;
this.password = password;
this.url = (noSsl ? 'http' : 'https') + '://www.hlr-lookups.com/api';
} | [
"function",
"HlrLookupClient",
"(",
"username",
",",
"password",
",",
"noSsl",
")",
"{",
"this",
".",
"username",
"=",
"username",
";",
"this",
".",
"password",
"=",
"password",
";",
"this",
".",
"url",
"=",
"(",
"noSsl",
"?",
"'http'",
":",
"'https'",
... | Initializes the HLR Lookup Client
@param username - www.hlr-lookups.com username
@param password - www.hlr-lookups.com password
@param noSsl - set to true to disable SSL
@constructor | [
"Initializes",
"the",
"HLR",
"Lookup",
"Client"
] | d36bb40152622b5854b05ef90a6a5748045af408 | https://github.com/vmgltd/hlr-lookup-api-nodejs-sdk/blob/d36bb40152622b5854b05ef90a6a5748045af408/src/lib/node-hlr-client.js#L13-L19 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/renderer-layer.js | RendererLayer | function RendererLayer(game, type, settings) {
this.game = game;
this.type = type;
var typeData = RendererLayer.Types[type];
RL.Util.merge(this, typeData);
for(var key in settings){
if(this[key] !== void 0){
this[key] = settings[key];
}
... | javascript | function RendererLayer(game, type, settings) {
this.game = game;
this.type = type;
var typeData = RendererLayer.Types[type];
RL.Util.merge(this, typeData);
for(var key in settings){
if(this[key] !== void 0){
this[key] = settings[key];
}
... | [
"function",
"RendererLayer",
"(",
"game",
",",
"type",
",",
"settings",
")",
"{",
"this",
".",
"game",
"=",
"game",
";",
"this",
".",
"type",
"=",
"type",
";",
"var",
"typeData",
"=",
"RendererLayer",
".",
"Types",
"[",
"type",
"]",
";",
"RL",
".",
... | Represents a map tile layer to be rendered.
@class RendererLayer
@constructor
@param {Game} game - Game instance this obj is attached to.
@param {String} type - Type of `RendererLayer`. When created this object is merged with the value of `RendererLayer.Types[type]`. | [
"Represents",
"a",
"map",
"tile",
"layer",
"to",
"be",
"rendered",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/renderer-layer.js#L11-L22 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/renderer-layer.js | function(x, y, prevTileData){
var tileData = this.getTileData(x, y, prevTileData);
if(this.mergeWithPrevLayer && prevTileData){
return this.mergeTileData(prevTileData, tileData);
}
return tileData;
} | javascript | function(x, y, prevTileData){
var tileData = this.getTileData(x, y, prevTileData);
if(this.mergeWithPrevLayer && prevTileData){
return this.mergeTileData(prevTileData, tileData);
}
return tileData;
} | [
"function",
"(",
"x",
",",
"y",
",",
"prevTileData",
")",
"{",
"var",
"tileData",
"=",
"this",
".",
"getTileData",
"(",
"x",
",",
"y",
",",
"prevTileData",
")",
";",
"if",
"(",
"this",
".",
"mergeWithPrevLayer",
"&&",
"prevTileData",
")",
"{",
"return"... | Get layer's `TileData` for a given map tile coord.
Optionally modifying the `prevTileData` object param if `this.mergeWithPrevLayer = true`.
@method getModifiedTileData
@param {Number} x - Map tile x coord.
@param {Object} y - Map tile y coord.
@param {Object} [prevTileData] - `tileData` object for the given map tile c... | [
"Get",
"layer",
"s",
"TileData",
"for",
"a",
"given",
"map",
"tile",
"coord",
".",
"Optionally",
"modifying",
"the",
"prevTileData",
"object",
"param",
"if",
"this",
".",
"mergeWithPrevLayer",
"=",
"true",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/renderer-layer.js#L99-L105 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/renderer-layer.js | function(tileData1, tileData2){
var result = {},
key, val;
for(key in tileData1){
result[key] = tileData1[key];
}
for(key in tileData2){
val = tileData2[key];
if(val !== false && val !== void 0){
... | javascript | function(tileData1, tileData2){
var result = {},
key, val;
for(key in tileData1){
result[key] = tileData1[key];
}
for(key in tileData2){
val = tileData2[key];
if(val !== false && val !== void 0){
... | [
"function",
"(",
"tileData1",
",",
"tileData2",
")",
"{",
"var",
"result",
"=",
"{",
"}",
",",
"key",
",",
"val",
";",
"for",
"(",
"key",
"in",
"tileData1",
")",
"{",
"result",
"[",
"key",
"]",
"=",
"tileData1",
"[",
"key",
"]",
";",
"}",
"for",
... | Merges 2 `tileData` objects.
Used to Merges layers of the same tile before drawing them.
@method mergeTileData
@param {TileData} tileData1 - `tileData` to merge to.
@param {TileData} tileData2 - `tileData` to merge from, properties with values on tileData2 replace matching properties on tileData1
@return {TileData} A n... | [
"Merges",
"2",
"tileData",
"objects",
".",
"Used",
"to",
"Merges",
"layers",
"of",
"the",
"same",
"tile",
"before",
"drawing",
"them",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/renderer-layer.js#L115-L128 | train | |
jkphl/gulp-concat-flatten | index.js | endStream | function endStream(cb) {
// If no files were passed in, no files go out ...
if (!latestFile || (Object.keys(concats).length === 0 && concats.constructor === Object)) {
cb();
return;
}
// Prepare a method for pushing the stream
const pushJoinedFile = (join... | javascript | function endStream(cb) {
// If no files were passed in, no files go out ...
if (!latestFile || (Object.keys(concats).length === 0 && concats.constructor === Object)) {
cb();
return;
}
// Prepare a method for pushing the stream
const pushJoinedFile = (join... | [
"function",
"endStream",
"(",
"cb",
")",
"{",
"// If no files were passed in, no files go out ...",
"if",
"(",
"!",
"latestFile",
"||",
"(",
"Object",
".",
"keys",
"(",
"concats",
")",
".",
"length",
"===",
"0",
"&&",
"concats",
".",
"constructor",
"===",
"Obj... | End the stream
@param {Function} cb Callback | [
"End",
"the",
"stream"
] | 0b59787b2ceb4538fcfb7907c2cec6ac452b4d87 | https://github.com/jkphl/gulp-concat-flatten/blob/0b59787b2ceb4538fcfb7907c2cec6ac452b4d87/index.js#L175-L211 | train |
clns/node-http-range | lib/content-range.js | ContentRange | function ContentRange(unit, range, length) {
this.unit = unit;
this.range = range;
this.length = length;
if (this.range.high && this.length && this.length <= this.range.high) {
throw new Error('Length is less than or equal to the range');
}
} | javascript | function ContentRange(unit, range, length) {
this.unit = unit;
this.range = range;
this.length = length;
if (this.range.high && this.length && this.length <= this.range.high) {
throw new Error('Length is less than or equal to the range');
}
} | [
"function",
"ContentRange",
"(",
"unit",
",",
"range",
",",
"length",
")",
"{",
"this",
".",
"unit",
"=",
"unit",
";",
"this",
".",
"range",
"=",
"range",
";",
"this",
".",
"length",
"=",
"length",
";",
"if",
"(",
"this",
".",
"range",
".",
"high",... | Content-Range HTTP Header class.
@param {String} unit Usually "bytes", but can be any token; http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.12
@param {RangeSpec|String|'*'} range A RangeSpec instance, a string like '0-49' or '*' if unknown
@param {Number|'*'} length The total length of the full entity-body... | [
"Content",
"-",
"Range",
"HTTP",
"Header",
"class",
"."
] | 0a16a5cdcc7d30ea14712054e683852c524d51de | https://github.com/clns/node-http-range/blob/0a16a5cdcc7d30ea14712054e683852c524d51de/lib/content-range.js#L13-L20 | train |
wojtkowiak/meteor-desktop-localstorage | plugins/localstorage/localstorage.js | load | function load() {
Desktop.fetch('localStorage', 'getAll').then((storage) => {
Meteor._localStorage.storage = storage;
}).catch(() => {
retries += 1;
if (retries < 5) {
load();
} else {
console.error('failed to load localStorage contents');
}
})... | javascript | function load() {
Desktop.fetch('localStorage', 'getAll').then((storage) => {
Meteor._localStorage.storage = storage;
}).catch(() => {
retries += 1;
if (retries < 5) {
load();
} else {
console.error('failed to load localStorage contents');
}
})... | [
"function",
"load",
"(",
")",
"{",
"Desktop",
".",
"fetch",
"(",
"'localStorage'",
",",
"'getAll'",
")",
".",
"then",
"(",
"(",
"storage",
")",
"=>",
"{",
"Meteor",
".",
"_localStorage",
".",
"storage",
"=",
"storage",
";",
"}",
")",
".",
"catch",
"(... | Fetches local storage data from the meteor-desktop-localstorage plugin.
Retries 5 times, then fails. | [
"Fetches",
"local",
"storage",
"data",
"from",
"the",
"meteor",
"-",
"desktop",
"-",
"localstorage",
"plugin",
".",
"Retries",
"5",
"times",
"then",
"fails",
"."
] | 1a4ffb47aca5ae302ebf47ec1e060b5c1a8066e1 | https://github.com/wojtkowiak/meteor-desktop-localstorage/blob/1a4ffb47aca5ae302ebf47ec1e060b5c1a8066e1/plugins/localstorage/localstorage.js#L8-L19 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/lighting-rot.js | LightingROT | function LightingROT(game, settings) {
settings = settings || {};
this.game = game;
this.lightingMap = new RL.Array2d();
this.lightingMap.set = this.lightingMap.set.bind(this.lightingMap);
this.checkVisible = this.checkVisible.bind(this);
this._fov = new ROT.FOV.PreciseS... | javascript | function LightingROT(game, settings) {
settings = settings || {};
this.game = game;
this.lightingMap = new RL.Array2d();
this.lightingMap.set = this.lightingMap.set.bind(this.lightingMap);
this.checkVisible = this.checkVisible.bind(this);
this._fov = new ROT.FOV.PreciseS... | [
"function",
"LightingROT",
"(",
"game",
",",
"settings",
")",
"{",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"this",
".",
"game",
"=",
"game",
";",
"this",
".",
"lightingMap",
"=",
"new",
"RL",
".",
"Array2d",
"(",
")",
";",
"this",
".",
"l... | Represents lighting in the game map. requires ROT.js
Manages position of lights.
Calculates illumination of map tiles.
@class LightingROT
@constructor
@param {Game} game - Game instance this obj is attached to.
@param {Object} [settings] - LightingROT settings object.
@param {Number} [settings.range] - Maximum range fo... | [
"Represents",
"lighting",
"in",
"the",
"game",
"map",
".",
"requires",
"ROT",
".",
"js",
"Manages",
"position",
"of",
"lights",
".",
"Calculates",
"illumination",
"of",
"map",
"tiles",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/lighting-rot.js#L16-L37 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/lighting-rot.js | function(x, y, tileData){
var light = this.ambientLight;
var lighting = this.get(x, y);
var overlay = function(c1, c2){
var out = c1.slice();
for (var i = 0; i < 3; i++) {
var a = c1[i],
b = c2[i];
... | javascript | function(x, y, tileData){
var light = this.ambientLight;
var lighting = this.get(x, y);
var overlay = function(c1, c2){
var out = c1.slice();
for (var i = 0; i < 3; i++) {
var a = c1[i],
b = c2[i];
... | [
"function",
"(",
"x",
",",
"y",
",",
"tileData",
")",
"{",
"var",
"light",
"=",
"this",
".",
"ambientLight",
";",
"var",
"lighting",
"=",
"this",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"var",
"overlay",
"=",
"function",
"(",
"c1",
",",
"c2",
... | Shades tileData using lighting.
@method shadeTile
@param {Number} x - The x map coordinate to shade.
@param {Number} y - The y map coordinate to shade.
@param {TileData} tileData - The `TileData` object to shade.
@return {TileData} | [
"Shades",
"tileData",
"using",
"lighting",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/lighting-rot.js#L121-L155 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/lighting-rot.js | function(x, y, r, g, b){
this._lighting.setLight(x, y, [r, g, b]);
this._dirty = true;
} | javascript | function(x, y, r, g, b){
this._lighting.setLight(x, y, [r, g, b]);
this._dirty = true;
} | [
"function",
"(",
"x",
",",
"y",
",",
"r",
",",
"g",
",",
"b",
")",
"{",
"this",
".",
"_lighting",
".",
"setLight",
"(",
"x",
",",
"y",
",",
"[",
"r",
",",
"g",
",",
"b",
"]",
")",
";",
"this",
".",
"_dirty",
"=",
"true",
";",
"}"
] | Set a light position and color
@method set
@param {Number} x - The map coordinate position to set lightin on the x axis.
@param {Number} y - The map coordinate position to set lightin on the y axis.
@param {Number} r - Red.
@param {Number} g - Green.
@param {Number} b - Blue. | [
"Set",
"a",
"light",
"position",
"and",
"color"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/lighting-rot.js#L176-L179 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/lighting-rot.js | function(x, y){
var tile = this.game.map.get(x, y);
if(!tile){
return 0;
}
if(tile.lightingReflectivity){
return tile.lightingReflectivity;
}
if(tile.blocksLos){
return this.defaultWallReflectivity... | javascript | function(x, y){
var tile = this.game.map.get(x, y);
if(!tile){
return 0;
}
if(tile.lightingReflectivity){
return tile.lightingReflectivity;
}
if(tile.blocksLos){
return this.defaultWallReflectivity... | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"tile",
"=",
"this",
".",
"game",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"if",
"(",
"!",
"tile",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"tile",
".",
"lightingReflectivity"... | Returns the reflectivity value of a tile
@method getTileReflectivity
@param {Number} x - Map tile x coord.
@param {Number} y - Map tile y coord. | [
"Returns",
"the",
"reflectivity",
"value",
"of",
"a",
"tile"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/lighting-rot.js#L197-L213 | train | |
danieldkim/charlotte | lib/charlotte.js | function(next) {
if (!inNativeApp) return next(null, false, null, null, null);
if (resourceIsBinary(filePath)) {
var fullPath = shared.removeUrlMultislashes(fileFullPathRoot + '/' + filePath),
xhr;
xhr = new XMLHttpRequest();
xhr.open("... | javascript | function(next) {
if (!inNativeApp) return next(null, false, null, null, null);
if (resourceIsBinary(filePath)) {
var fullPath = shared.removeUrlMultislashes(fileFullPathRoot + '/' + filePath),
xhr;
xhr = new XMLHttpRequest();
xhr.open("... | [
"function",
"(",
"next",
")",
"{",
"if",
"(",
"!",
"inNativeApp",
")",
"return",
"next",
"(",
"null",
",",
"false",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"if",
"(",
"resourceIsBinary",
"(",
"filePath",
")",
")",
"{",
"var",
"fullPath",
"... | try to retrieve from cache seed | [
"try",
"to",
"retrieve",
"from",
"cache",
"seed"
] | b4f0afddd6660194b09026513aeeb1c851913044 | https://github.com/danieldkim/charlotte/blob/b4f0afddd6660194b09026513aeeb1c851913044/lib/charlotte.js#L543-L563 | train | |
danieldkim/charlotte | lib/charlotte.js | function(foundInCacheSeed, fullPath, data, compiled, next) {
if (foundInCacheSeed) {
debugLog("Found resource in cache seed: " + cacheUrl)
if (data) {
async.waterfall([
function(next) {
if (url.match(/\.css$/)) {
... | javascript | function(foundInCacheSeed, fullPath, data, compiled, next) {
if (foundInCacheSeed) {
debugLog("Found resource in cache seed: " + cacheUrl)
if (data) {
async.waterfall([
function(next) {
if (url.match(/\.css$/)) {
... | [
"function",
"(",
"foundInCacheSeed",
",",
"fullPath",
",",
"data",
",",
"compiled",
",",
"next",
")",
"{",
"if",
"(",
"foundInCacheSeed",
")",
"{",
"debugLog",
"(",
"\"Found resource in cache seed: \"",
"+",
"cacheUrl",
")",
"if",
"(",
"data",
")",
"{",
"asy... | get from server or write to cache if necessary | [
"get",
"from",
"server",
"or",
"write",
"to",
"cache",
"if",
"necessary"
] | b4f0afddd6660194b09026513aeeb1c851913044 | https://github.com/danieldkim/charlotte/blob/b4f0afddd6660194b09026513aeeb1c851913044/lib/charlotte.js#L566-L591 | train | |
flowgrammable/uint-js | uint.js | UInt | function UInt(args) {
// Assign default valus
this._value = null;
this._bytes = null;
this._bits = null;
this._isHex = false;
// Set constraints if present
if(args && (isNatural(args.bits) || isNatural(args.bytes))) {
// Set the size if either is used
this._bits = args.bits || 0;
... | javascript | function UInt(args) {
// Assign default valus
this._value = null;
this._bytes = null;
this._bits = null;
this._isHex = false;
// Set constraints if present
if(args && (isNatural(args.bits) || isNatural(args.bytes))) {
// Set the size if either is used
this._bits = args.bits || 0;
... | [
"function",
"UInt",
"(",
"args",
")",
"{",
"// Assign default valus\r",
"this",
".",
"_value",
"=",
"null",
";",
"this",
".",
"_bytes",
"=",
"null",
";",
"this",
".",
"_bits",
"=",
"null",
";",
"this",
".",
"_isHex",
"=",
"false",
";",
"// Set constraint... | FIXME old version memoizes 'HEX' if used to set | [
"FIXME",
"old",
"version",
"memoizes",
"HEX",
"if",
"used",
"to",
"set"
] | f9e13967708f47cdd0c3389c2d3c8bc04a98d5dc | https://github.com/flowgrammable/uint-js/blob/f9e13967708f47cdd0c3389c2d3c8bc04a98d5dc/uint.js#L183-L243 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | reduceRight | function reduceRight(collection, callback, accumulator, thisArg) {
if (!collection) {
return accumulator;
}
var length = collection.length,
noaccum = arguments.length < 3;
if(thisArg) {
callback = iteratorBind(callback, thisArg);
}
if (length === length >>> 0) {
if (l... | javascript | function reduceRight(collection, callback, accumulator, thisArg) {
if (!collection) {
return accumulator;
}
var length = collection.length,
noaccum = arguments.length < 3;
if(thisArg) {
callback = iteratorBind(callback, thisArg);
}
if (length === length >>> 0) {
if (l... | [
"function",
"reduceRight",
"(",
"collection",
",",
"callback",
",",
"accumulator",
",",
"thisArg",
")",
"{",
"if",
"(",
"!",
"collection",
")",
"{",
"return",
"accumulator",
";",
"}",
"var",
"length",
"=",
"collection",
".",
"length",
",",
"noaccum",
"=",
... | The right-associative version of `_.reduce`.
@static
@memberOf _
@alias foldr
@category Collections
@param {Array|Object} collection The collection to iterate over.
@param {Function} callback The function called per iteration.
@param {Mixed} [accumulator] Initial value of the accumulator.
@param {Mixed} [thisArg] The ... | [
"The",
"right",
"-",
"associative",
"version",
"of",
"_",
".",
"reduce",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L839-L872 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | toArray | function toArray(collection) {
if (!collection) {
return [];
}
if (toString.call(collection.toArray) == funcClass) {
return collection.toArray();
}
var length = collection.length;
if (length === length >>> 0) {
return slice.call(collection);
}
return values(collection);... | javascript | function toArray(collection) {
if (!collection) {
return [];
}
if (toString.call(collection.toArray) == funcClass) {
return collection.toArray();
}
var length = collection.length;
if (length === length >>> 0) {
return slice.call(collection);
}
return values(collection);... | [
"function",
"toArray",
"(",
"collection",
")",
"{",
"if",
"(",
"!",
"collection",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"toString",
".",
"call",
"(",
"collection",
".",
"toArray",
")",
"==",
"funcClass",
")",
"{",
"return",
"collection",
... | Converts the `collection`, into an array. Useful for converting the
`arguments` object.
@static
@memberOf _
@category Collections
@param {Array|Object} collection The collection to convert.
@returns {Array} Returns the new converted array.
@example
(function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
/... | [
"Converts",
"the",
"collection",
"into",
"an",
"array",
".",
"Useful",
"for",
"converting",
"the",
"arguments",
"object",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L933-L945 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | initial | function initial(array, n, guard) {
if (!array) {
return [];
}
return slice.call(array, 0, -((n == undefined || guard) ? 1 : n));
} | javascript | function initial(array, n, guard) {
if (!array) {
return [];
}
return slice.call(array, 0, -((n == undefined || guard) ? 1 : n));
} | [
"function",
"initial",
"(",
"array",
",",
"n",
",",
"guard",
")",
"{",
"if",
"(",
"!",
"array",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"slice",
".",
"call",
"(",
"array",
",",
"0",
",",
"-",
"(",
"(",
"n",
"==",
"undefined",
"||",
... | Gets all but the last value of `array`. Pass `n` to exclude the last `n`
values from the result.
@static
@memberOf _
@category Arrays
@param {Array} array The array to query.
@param {Number} [n] The number of elements to return.
@param {Object} [guard] Internally used to allow this method to work with
others like `_.m... | [
"Gets",
"all",
"but",
"the",
"last",
"value",
"of",
"array",
".",
"Pass",
"n",
"to",
"exclude",
"the",
"last",
"n",
"values",
"from",
"the",
"result",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L1186-L1191 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | intersection | function intersection(array) {
var result = [];
if (!array) {
return result;
}
var value,
index = -1,
length = array.length,
others = slice.call(arguments, 1);
while (++index < length) {
value = array[index];
if (indexOf(result, value) < 0 &&
ever... | javascript | function intersection(array) {
var result = [];
if (!array) {
return result;
}
var value,
index = -1,
length = array.length,
others = slice.call(arguments, 1);
while (++index < length) {
value = array[index];
if (indexOf(result, value) < 0 &&
ever... | [
"function",
"intersection",
"(",
"array",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"array",
")",
"{",
"return",
"result",
";",
"}",
"var",
"value",
",",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
".",
"length",
","... | Computes the intersection of all the passed-in arrays.
@static
@memberOf _
@category Arrays
@param {Array} [array1, array2, ...] Arrays to process.
@returns {Array} Returns a new array of unique values, in order, that are
present in **all** of the arrays.
@example
_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
/... | [
"Computes",
"the",
"intersection",
"of",
"all",
"the",
"passed",
"-",
"in",
"arrays",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L1207-L1225 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | last | function last(array, n, guard) {
if (array) {
var length = array.length;
return (n == undefined || guard) ? array[length - 1] : slice.call(array, -n || length);
}
} | javascript | function last(array, n, guard) {
if (array) {
var length = array.length;
return (n == undefined || guard) ? array[length - 1] : slice.call(array, -n || length);
}
} | [
"function",
"last",
"(",
"array",
",",
"n",
",",
"guard",
")",
"{",
"if",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"return",
"(",
"n",
"==",
"undefined",
"||",
"guard",
")",
"?",
"array",
"[",
"length",
"-",
"1",... | Gets the last value of the `array`. Pass `n` to return the lasy `n` values
of the `array`.
@static
@memberOf _
@category Arrays
@param {Array} array The array to query.
@param {Number} [n] The number of elements to return.
@param {Object} [guard] Internally used to allow this method to work with
others like `_.map` wi... | [
"Gets",
"the",
"last",
"value",
"of",
"the",
"array",
".",
"Pass",
"n",
"to",
"return",
"the",
"lasy",
"n",
"values",
"of",
"the",
"array",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L1245-L1250 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | union | function union() {
var index = -1,
result = [],
flattened = concat.apply(result, arguments),
length = flattened.length;
while (++index < length) {
if (indexOf(result, flattened[index]) < 0) {
result.push(flattened[index]);
}
}
return result;
} | javascript | function union() {
var index = -1,
result = [],
flattened = concat.apply(result, arguments),
length = flattened.length;
while (++index < length) {
if (indexOf(result, flattened[index]) < 0) {
result.push(flattened[index]);
}
}
return result;
} | [
"function",
"union",
"(",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"result",
"=",
"[",
"]",
",",
"flattened",
"=",
"concat",
".",
"apply",
"(",
"result",
",",
"arguments",
")",
",",
"length",
"=",
"flattened",
".",
"length",
";",
"while",
"(",... | Computes the union of the passed-in arrays.
@static
@memberOf _
@category Arrays
@param {Array} [array1, array2, ...] Arrays to process.
@returns {Array} Returns a new array of unique values, in order, that are
present in one or more of the arrays.
@example
_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
// => [1, 2, 3,... | [
"Computes",
"the",
"union",
"of",
"the",
"passed",
"-",
"in",
"arrays",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L1635-L1647 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | bind | function bind(func, thisArg) {
var methodName,
isFunc = toString.call(func) == funcClass;
// juggle arguments
if (!isFunc) {
methodName = thisArg;
thisArg = func;
}
// use if `Function#bind` is faster
else if (nativeBind) {
return nativeBind.call.apply(nativeBind, argu... | javascript | function bind(func, thisArg) {
var methodName,
isFunc = toString.call(func) == funcClass;
// juggle arguments
if (!isFunc) {
methodName = thisArg;
thisArg = func;
}
// use if `Function#bind` is faster
else if (nativeBind) {
return nativeBind.call.apply(nativeBind, argu... | [
"function",
"bind",
"(",
"func",
",",
"thisArg",
")",
"{",
"var",
"methodName",
",",
"isFunc",
"=",
"toString",
".",
"call",
"(",
"func",
")",
"==",
"funcClass",
";",
"// juggle arguments",
"if",
"(",
"!",
"isFunc",
")",
"{",
"methodName",
"=",
"thisArg"... | Creates a new function that, when called, invokes `func` with the `this`
binding of `thisArg` and prepends any additional `bind` arguments to those
passed to the bound function. Lazy defined methods may be bound by passing
the object they are bound to as `func` and the method name as `thisArg`.
@static
@memberOf _
@ca... | [
"Creates",
"a",
"new",
"function",
"that",
"when",
"called",
"invokes",
"func",
"with",
"the",
"this",
"binding",
"of",
"thisArg",
"and",
"prepends",
"any",
"additional",
"bind",
"arguments",
"to",
"those",
"passed",
"to",
"the",
"bound",
"function",
".",
"L... | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L1851-L1897 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | bindAll | function bindAll(object) {
var funcs = arguments,
index = 1;
if (funcs.length == 1) {
index = 0;
funcs = functions(object);
}
for (var length = funcs.length; index < length; index++) {
object[funcs[index]] = bind(object[funcs[index]], object);
}
return object;
} | javascript | function bindAll(object) {
var funcs = arguments,
index = 1;
if (funcs.length == 1) {
index = 0;
funcs = functions(object);
}
for (var length = funcs.length; index < length; index++) {
object[funcs[index]] = bind(object[funcs[index]], object);
}
return object;
} | [
"function",
"bindAll",
"(",
"object",
")",
"{",
"var",
"funcs",
"=",
"arguments",
",",
"index",
"=",
"1",
";",
"if",
"(",
"funcs",
".",
"length",
"==",
"1",
")",
"{",
"index",
"=",
"0",
";",
"funcs",
"=",
"functions",
"(",
"object",
")",
";",
"}"... | Binds methods on `object` to `object`, overwriting the existing method.
If no method names are provided, all the function properties of `object`
will be bound.
@static
@memberOf _
@category Functions
@param {Object} object The object to bind and assign the bound methods to.
@param {String} [methodName1, methodName2, .... | [
"Binds",
"methods",
"on",
"object",
"to",
"object",
"overwriting",
"the",
"existing",
"method",
".",
"If",
"no",
"method",
"names",
"are",
"provided",
"all",
"the",
"function",
"properties",
"of",
"object",
"will",
"be",
"bound",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L1922-L1934 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | debounce | function debounce(func, wait, immediate) {
var args,
result,
thisArg,
timeoutId;
function delayed() {
timeoutId = undefined;
if (!immediate) {
func.apply(thisArg, args);
}
}
return function() {
var isImmediate = immediate && !timeoutId;
arg... | javascript | function debounce(func, wait, immediate) {
var args,
result,
thisArg,
timeoutId;
function delayed() {
timeoutId = undefined;
if (!immediate) {
func.apply(thisArg, args);
}
}
return function() {
var isImmediate = immediate && !timeoutId;
arg... | [
"function",
"debounce",
"(",
"func",
",",
"wait",
",",
"immediate",
")",
"{",
"var",
"args",
",",
"result",
",",
"thisArg",
",",
"timeoutId",
";",
"function",
"delayed",
"(",
")",
"{",
"timeoutId",
"=",
"undefined",
";",
"if",
"(",
"!",
"immediate",
")... | Creates a new function that will delay the execution of `func` until after
`wait` milliseconds have elapsed since the last time it was invoked. Pass
`true` for `immediate` to cause debounce to invoke `func` on the leading,
instead of the trailing, edge of the `wait` timeout. Subsequent calls to
the debounced function w... | [
"Creates",
"a",
"new",
"function",
"that",
"will",
"delay",
"the",
"execution",
"of",
"func",
"until",
"after",
"wait",
"milliseconds",
"have",
"elapsed",
"since",
"the",
"last",
"time",
"it",
"was",
"invoked",
".",
"Pass",
"true",
"for",
"immediate",
"to",
... | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L1987-L2013 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | memoize | function memoize(func, resolver) {
var cache = {};
return function() {
var prop = resolver ? resolver.apply(this, arguments) : arguments[0];
return hasOwnProperty.call(cache, prop)
? cache[prop]
: (cache[prop] = func.apply(this, arguments));
};
} | javascript | function memoize(func, resolver) {
var cache = {};
return function() {
var prop = resolver ? resolver.apply(this, arguments) : arguments[0];
return hasOwnProperty.call(cache, prop)
? cache[prop]
: (cache[prop] = func.apply(this, arguments));
};
} | [
"function",
"memoize",
"(",
"func",
",",
"resolver",
")",
"{",
"var",
"cache",
"=",
"{",
"}",
";",
"return",
"function",
"(",
")",
"{",
"var",
"prop",
"=",
"resolver",
"?",
"resolver",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
":",
"arguments... | Creates a new function that memoizes the result of `func`. If `resolver` is
passed, it will be used to determine the cache key for storing the result
based on the arguments passed to the memoized function. By default, the first
argument passed to the memoized function is used as the cache key.
@static
@memberOf _
@cat... | [
"Creates",
"a",
"new",
"function",
"that",
"memoizes",
"the",
"result",
"of",
"func",
".",
"If",
"resolver",
"is",
"passed",
"it",
"will",
"be",
"used",
"to",
"determine",
"the",
"cache",
"key",
"for",
"storing",
"the",
"result",
"based",
"on",
"the",
"a... | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L2075-L2083 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | once | function once(func) {
var result,
ran = false;
return function() {
if (ran) {
return result;
}
ran = true;
result = func.apply(this, arguments);
return result;
};
} | javascript | function once(func) {
var result,
ran = false;
return function() {
if (ran) {
return result;
}
ran = true;
result = func.apply(this, arguments);
return result;
};
} | [
"function",
"once",
"(",
"func",
")",
"{",
"var",
"result",
",",
"ran",
"=",
"false",
";",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"ran",
")",
"{",
"return",
"result",
";",
"}",
"ran",
"=",
"true",
";",
"result",
"=",
"func",
".",
"apply"... | Creates a new function that is restricted to one execution. Repeat calls to
the function will return the value of the first call.
@static
@memberOf _
@category Functions
@param {Function} func The function to restrict.
@returns {Function} Returns the new restricted function.
@example
var initialize = _.once(createApp... | [
"Creates",
"a",
"new",
"function",
"that",
"is",
"restricted",
"to",
"one",
"execution",
".",
"Repeat",
"calls",
"to",
"the",
"function",
"will",
"return",
"the",
"value",
"of",
"the",
"first",
"call",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L2101-L2113 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | throttle | function throttle(func, wait) {
var args,
result,
thisArg,
timeoutId,
lastCalled = 0;
function trailingCall() {
lastCalled = new Date;
timeoutId = undefined;
func.apply(thisArg, args);
}
return function() {
var now = new Date,
remain = ... | javascript | function throttle(func, wait) {
var args,
result,
thisArg,
timeoutId,
lastCalled = 0;
function trailingCall() {
lastCalled = new Date;
timeoutId = undefined;
func.apply(thisArg, args);
}
return function() {
var now = new Date,
remain = ... | [
"function",
"throttle",
"(",
"func",
",",
"wait",
")",
"{",
"var",
"args",
",",
"result",
",",
"thisArg",
",",
"timeoutId",
",",
"lastCalled",
"=",
"0",
";",
"function",
"trailingCall",
"(",
")",
"{",
"lastCalled",
"=",
"new",
"Date",
";",
"timeoutId",
... | Creates a new function that, when executed, will only call the `func`
function at most once per every `wait` milliseconds. If the throttled
function is invoked more than once during the `wait` timeout, `func` will
also be called on the trailing edge of the timeout. Subsequent calls to the
throttled function will return... | [
"Creates",
"a",
"new",
"function",
"that",
"when",
"executed",
"will",
"only",
"call",
"the",
"func",
"function",
"at",
"most",
"once",
"per",
"every",
"wait",
"milliseconds",
".",
"If",
"the",
"throttled",
"function",
"is",
"invoked",
"more",
"than",
"once"... | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L2170-L2199 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | wrap | function wrap(func, wrapper) {
return function() {
var args = [func];
if (arguments.length) {
push.apply(args, arguments);
}
return wrapper.apply(this, args);
};
} | javascript | function wrap(func, wrapper) {
return function() {
var args = [func];
if (arguments.length) {
push.apply(args, arguments);
}
return wrapper.apply(this, args);
};
} | [
"function",
"wrap",
"(",
"func",
",",
"wrapper",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"func",
"]",
";",
"if",
"(",
"arguments",
".",
"length",
")",
"{",
"push",
".",
"apply",
"(",
"args",
",",
"arguments",
")",
... | Create a new function that passes the `func` function to the `wrapper`
function as its first argument. Additional arguments are appended to those
passed to the `wrapper` function.
@static
@memberOf _
@category Functions
@param {Function} func The function to wrap.
@param {Function} wrapper The wrapper function.
@param... | [
"Create",
"a",
"new",
"function",
"that",
"passes",
"the",
"func",
"function",
"to",
"the",
"wrapper",
"function",
"as",
"its",
"first",
"argument",
".",
"Additional",
"arguments",
"are",
"appended",
"to",
"those",
"passed",
"to",
"the",
"wrapper",
"function",... | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L2222-L2230 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | pick | function pick(object) {
var prop,
index = 0,
props = concat.apply(ArrayProto, arguments),
length = props.length,
result = {};
// start `index` at `1` to skip `object`
while (++index < length) {
prop = props[index];
if (prop in object) {
result[prop] = obj... | javascript | function pick(object) {
var prop,
index = 0,
props = concat.apply(ArrayProto, arguments),
length = props.length,
result = {};
// start `index` at `1` to skip `object`
while (++index < length) {
prop = props[index];
if (prop in object) {
result[prop] = obj... | [
"function",
"pick",
"(",
"object",
")",
"{",
"var",
"prop",
",",
"index",
"=",
"0",
",",
"props",
"=",
"concat",
".",
"apply",
"(",
"ArrayProto",
",",
"arguments",
")",
",",
"length",
"=",
"props",
".",
"length",
",",
"result",
"=",
"{",
"}",
";",
... | Creates an object composed of the specified properties. Property names may
be specified as individual arguments or as arrays of property names.
@static
@memberOf _
@category Objects
@param {Object} object The object to pluck.
@param {Object} [prop1, prop2, ...] The properties to pick.
@returns {Object} Returns an obje... | [
"Creates",
"an",
"object",
"composed",
"of",
"the",
"specified",
"properties",
".",
"Property",
"names",
"may",
"be",
"specified",
"as",
"individual",
"arguments",
"or",
"as",
"arrays",
"of",
"property",
"names",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L2895-L2910 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | size | function size(value) {
var className = toString.call(value);
return className == arrayClass || className == stringClass
? value.length
: keys(value).length;
} | javascript | function size(value) {
var className = toString.call(value);
return className == arrayClass || className == stringClass
? value.length
: keys(value).length;
} | [
"function",
"size",
"(",
"value",
")",
"{",
"var",
"className",
"=",
"toString",
".",
"call",
"(",
"value",
")",
";",
"return",
"className",
"==",
"arrayClass",
"||",
"className",
"==",
"stringClass",
"?",
"value",
".",
"length",
":",
"keys",
"(",
"value... | Gets the size of `value` by returning `value.length` if `value` is a string
or array, or the number of own enumerable properties if `value` is an object.
@deprecated
@static
@memberOf _
@category Objects
@param {Array|Object|String} value The value to inspect.
@returns {Number} Returns `value.length` if `value` is a s... | [
"Gets",
"the",
"size",
"of",
"value",
"by",
"returning",
"value",
".",
"length",
"if",
"value",
"is",
"a",
"string",
"or",
"array",
"or",
"the",
"number",
"of",
"own",
"enumerable",
"properties",
"if",
"value",
"is",
"an",
"object",
"."
] | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L2934-L2939 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | result | function result(object, property) {
// based on Backbone's private `getValue` function
// https://github.com/documentcloud/backbone/blob/0.9.9/backbone.js#L1419-1424
if (!object) {
return null;
}
var value = object[property];
return toString.call(value) == funcClass ? object[property]() : ... | javascript | function result(object, property) {
// based on Backbone's private `getValue` function
// https://github.com/documentcloud/backbone/blob/0.9.9/backbone.js#L1419-1424
if (!object) {
return null;
}
var value = object[property];
return toString.call(value) == funcClass ? object[property]() : ... | [
"function",
"result",
"(",
"object",
",",
"property",
")",
"{",
"// based on Backbone's private `getValue` function",
"// https://github.com/documentcloud/backbone/blob/0.9.9/backbone.js#L1419-1424",
"if",
"(",
"!",
"object",
")",
"{",
"return",
"null",
";",
"}",
"var",
"va... | Resolves the value of `property` on `object`. If `property` is a function
it will be invoked and its result returned, else the property value is
returned. If `object` is falsey, then `null` is returned.
@deprecated
@static
@memberOf _
@category Utilities
@param {Object} object The object to inspect.
@param {String} pr... | [
"Resolves",
"the",
"value",
"of",
"property",
"on",
"object",
".",
"If",
"property",
"is",
"a",
"function",
"it",
"will",
"be",
"invoked",
"and",
"its",
"result",
"returned",
"else",
"the",
"property",
"value",
"is",
"returned",
".",
"If",
"object",
"is",
... | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L3084-L3092 | train |
kmalakoff/backbone-modelref | vendor/optional/lodash-0.3.2.js | template | function template(text, data, options) {
options || (options = {});
var result,
defaults = lodash.templateSettings,
escapeDelimiter = options.escape,
evaluateDelimiter = options.evaluate,
interpolateDelimiter = options.interpolate,
variable = options.variable;
// us... | javascript | function template(text, data, options) {
options || (options = {});
var result,
defaults = lodash.templateSettings,
escapeDelimiter = options.escape,
evaluateDelimiter = options.evaluate,
interpolateDelimiter = options.interpolate,
variable = options.variable;
// us... | [
"function",
"template",
"(",
"text",
",",
"data",
",",
"options",
")",
"{",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
";",
"var",
"result",
",",
"defaults",
"=",
"lodash",
".",
"templateSettings",
",",
"escapeDelimiter",
"=",
"options",
".",
... | A micro-templating method, similar to John Resig's implementation.
Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and
correctly escapes quotes within interpolated code.
@static
@memberOf _
@category Utilities
@param {String} text The template text.
@param {Obect} data The data object used to po... | [
"A",
"micro",
"-",
"templating",
"method",
"similar",
"to",
"John",
"Resig",
"s",
"implementation",
".",
"Lo",
"-",
"Dash",
"templating",
"handles",
"arbitrary",
"delimiters",
"preserves",
"whitespace",
"and",
"correctly",
"escapes",
"quotes",
"within",
"interpola... | efdd402c676554991ff1d4cdc10818fca8f87187 | https://github.com/kmalakoff/backbone-modelref/blob/efdd402c676554991ff1d4cdc10818fca8f87187/vendor/optional/lodash-0.3.2.js#L3145-L3214 | train |
Mithgol/FGHI-URL | index.js | FidonetURL | function FidonetURL(initialString){
if(!( this instanceof FidonetURL )){
return new FidonetURL(initialString);
}
parseFundamentalSections.call(this, initialString);
parseOptionalPart.call(this);
parseRequiredPart.call(this);
} | javascript | function FidonetURL(initialString){
if(!( this instanceof FidonetURL )){
return new FidonetURL(initialString);
}
parseFundamentalSections.call(this, initialString);
parseOptionalPart.call(this);
parseRequiredPart.call(this);
} | [
"function",
"FidonetURL",
"(",
"initialString",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"FidonetURL",
")",
")",
"{",
"return",
"new",
"FidonetURL",
"(",
"initialString",
")",
";",
"}",
"parseFundamentalSections",
".",
"call",
"(",
"this",
",",
... | The FGHI URL object's constructor takes a string | [
"The",
"FGHI",
"URL",
"object",
"s",
"constructor",
"takes",
"a",
"string"
] | 8a4d2dbb4efb5ed26c0a3e25170746b90932ccae | https://github.com/Mithgol/FGHI-URL/blob/8a4d2dbb4efb5ed26c0a3e25170746b90932ccae/index.js#L333-L341 | train |
glenjamin/checkers | mocha.js | checking | function checking(desc, args, body, n, options) {
if (typeof n === 'undefined') {
n = 1000;
options = {};
}
if (typeof options === 'undefined' && typeof n !== 'number') {
options = n;
n = 1000;
}
it(desc, function() {
checkers.forAll(args, body).check(n, optio... | javascript | function checking(desc, args, body, n, options) {
if (typeof n === 'undefined') {
n = 1000;
options = {};
}
if (typeof options === 'undefined' && typeof n !== 'number') {
options = n;
n = 1000;
}
it(desc, function() {
checkers.forAll(args, body).check(n, optio... | [
"function",
"checking",
"(",
"desc",
",",
"args",
",",
"body",
",",
"n",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"n",
"===",
"'undefined'",
")",
"{",
"n",
"=",
"1000",
";",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"typeof",
"options"... | Generate a mocha example
@param {string} desc The example description
@param {array} args List of generators to pass to body
@param {function} body Function to check, should return true or false
@param {number} n The number of iterations to check (optional)
@param {object} options Additiona... | [
"Generate",
"a",
"mocha",
"example"
] | fdbe549ae138564343f139ae35c0602d83674fd0 | https://github.com/glenjamin/checkers/blob/fdbe549ae138564343f139ae35c0602d83674fd0/mocha.js#L19-L31 | train |
THEjoezack/BoxPusher | public/rot.js/rot.js | function(str, maxWidth) {
var result = [];
/* first tokenization pass - split texts and color formatting commands */
var offset = 0;
str.replace(this.RE_COLORS, function(match, type, name, index) {
/* string before */
var part = str.substring(offset, index);
if (part.length) {
result.push({
t... | javascript | function(str, maxWidth) {
var result = [];
/* first tokenization pass - split texts and color formatting commands */
var offset = 0;
str.replace(this.RE_COLORS, function(match, type, name, index) {
/* string before */
var part = str.substring(offset, index);
if (part.length) {
result.push({
t... | [
"function",
"(",
"str",
",",
"maxWidth",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"/* first tokenization pass - split texts and color formatting commands */",
"var",
"offset",
"=",
"0",
";",
"str",
".",
"replace",
"(",
"this",
".",
"RE_COLORS",
",",
"funct... | Convert string to a series of a formatting commands | [
"Convert",
"string",
"to",
"a",
"series",
"of",
"a",
"formatting",
"commands"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/rot.js/rot.js#L401-L436 | train | |
THEjoezack/BoxPusher | public/rot.js/rot.js | function(color1, color2) {
var result = color1.slice();
for (var i=0;i<3;i++) {
for (var j=1;j<arguments.length;j++) {
result[i] += arguments[j][i];
}
}
return result;
} | javascript | function(color1, color2) {
var result = color1.slice();
for (var i=0;i<3;i++) {
for (var j=1;j<arguments.length;j++) {
result[i] += arguments[j][i];
}
}
return result;
} | [
"function",
"(",
"color1",
",",
"color2",
")",
"{",
"var",
"result",
"=",
"color1",
".",
"slice",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"1",
";",
"j",
"... | Add two or more colors
@param {number[]} color1
@param {number[]} color2
@returns {number[]} | [
"Add",
"two",
"or",
"more",
"colors"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/rot.js/rot.js#L4483-L4491 | train | |
THEjoezack/BoxPusher | public/rot.js/rot.js | function(color1, color2) {
for (var i=0;i<3;i++) {
for (var j=1;j<arguments.length;j++) {
color1[i] += arguments[j][i];
}
}
return color1;
} | javascript | function(color1, color2) {
for (var i=0;i<3;i++) {
for (var j=1;j<arguments.length;j++) {
color1[i] += arguments[j][i];
}
}
return color1;
} | [
"function",
"(",
"color1",
",",
"color2",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"1",
";",
"j",
"<",
"arguments",
".",
"length",
";",
"j",
"++",
")",
"{",
"co... | Add two or more colors, MODIFIES FIRST ARGUMENT
@param {number[]} color1
@param {number[]} color2
@returns {number[]} | [
"Add",
"two",
"or",
"more",
"colors",
"MODIFIES",
"FIRST",
"ARGUMENT"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/rot.js/rot.js#L4499-L4506 | train | |
THEjoezack/BoxPusher | public/rot.js/rot.js | function(color, diff) {
if (!(diff instanceof Array)) { diff = ROT.RNG.getNormal(0, diff); }
var result = color.slice();
for (var i=0;i<3;i++) {
result[i] += (diff instanceof Array ? Math.round(ROT.RNG.getNormal(0, diff[i])) : diff);
}
return result;
} | javascript | function(color, diff) {
if (!(diff instanceof Array)) { diff = ROT.RNG.getNormal(0, diff); }
var result = color.slice();
for (var i=0;i<3;i++) {
result[i] += (diff instanceof Array ? Math.round(ROT.RNG.getNormal(0, diff[i])) : diff);
}
return result;
} | [
"function",
"(",
"color",
",",
"diff",
")",
"{",
"if",
"(",
"!",
"(",
"diff",
"instanceof",
"Array",
")",
")",
"{",
"diff",
"=",
"ROT",
".",
"RNG",
".",
"getNormal",
"(",
"0",
",",
"diff",
")",
";",
"}",
"var",
"result",
"=",
"color",
".",
"sli... | Create a new random color based on this one
@param {number[]} color
@param {number[]} diff Set of standard deviations
@returns {number[]} | [
"Create",
"a",
"new",
"random",
"color",
"based",
"on",
"this",
"one"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/rot.js/rot.js#L4580-L4587 | train | |
THEjoezack/BoxPusher | public/rot.js/rot.js | function(color) {
var l = color[2];
if (color[1] == 0) {
l = Math.round(l*255);
return [l, l, l];
} else {
function hue2rgb(p, q, t) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1/6) return p + (q - p) * 6 * t;
if (t < 1/2) return q;
if (t < 2/3) return p + (q - p) * (2/3 - t) * 6... | javascript | function(color) {
var l = color[2];
if (color[1] == 0) {
l = Math.round(l*255);
return [l, l, l];
} else {
function hue2rgb(p, q, t) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1/6) return p + (q - p) * 6 * t;
if (t < 1/2) return q;
if (t < 2/3) return p + (q - p) * (2/3 - t) * 6... | [
"function",
"(",
"color",
")",
"{",
"var",
"l",
"=",
"color",
"[",
"2",
"]",
";",
"if",
"(",
"color",
"[",
"1",
"]",
"==",
"0",
")",
"{",
"l",
"=",
"Math",
".",
"round",
"(",
"l",
"*",
"255",
")",
";",
"return",
"[",
"l",
",",
"l",
",",
... | Converts an HSL color value to RGB. Expects 0..1 inputs, produces 0..255 outputs.
@param {number[]} color
@returns {number[]} | [
"Converts",
"an",
"HSL",
"color",
"value",
"to",
"RGB",
".",
"Expects",
"0",
"..",
"1",
"inputs",
"produces",
"0",
"..",
"255",
"outputs",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/rot.js/rot.js#L4623-L4647 | train | |
io-monad/misspellings | src/misspellings.js | dict | function dict(options = {}) {
if (options.lowerCase) {
return dictCache[0] || (dictCache[0] = require("../dict/lc-dictionary.json"));
} else {
return dictCache[1] || (dictCache[1] = require("../dict/dictionary.json"));
}
} | javascript | function dict(options = {}) {
if (options.lowerCase) {
return dictCache[0] || (dictCache[0] = require("../dict/lc-dictionary.json"));
} else {
return dictCache[1] || (dictCache[1] = require("../dict/dictionary.json"));
}
} | [
"function",
"dict",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"options",
".",
"lowerCase",
")",
"{",
"return",
"dictCache",
"[",
"0",
"]",
"||",
"(",
"dictCache",
"[",
"0",
"]",
"=",
"require",
"(",
"\"../dict/lc-dictionary.json\"",
")",
")",... | Getter for the dictionary of misspellings.
This getter lazy-loads the dictionary file and caches it internally.
@param {Object} [options] Options.
@param {Boolean} [options.lowerCase=false]
If `true`, returns a dictionary with all keys in lower-case.
@return {Object} Dictionary object.
The key is misspelled word, an... | [
"Getter",
"for",
"the",
"dictionary",
"of",
"misspellings",
"."
] | 9281c7400348f69ba86af0567571d210253e246a | https://github.com/io-monad/misspellings/blob/9281c7400348f69ba86af0567571d210253e246a/src/misspellings.js#L45-L51 | train |
io-monad/misspellings | src/misspellings.js | correctWordsFor | function correctWordsFor(word, options = {}) {
word = String(word || "");
const found = (options.caseSensitive ?
dict()[word] :
dict({ lowerCase: true })[word.toLowerCase()]
);
return found ? found.split(",") : [];
} | javascript | function correctWordsFor(word, options = {}) {
word = String(word || "");
const found = (options.caseSensitive ?
dict()[word] :
dict({ lowerCase: true })[word.toLowerCase()]
);
return found ? found.split(",") : [];
} | [
"function",
"correctWordsFor",
"(",
"word",
",",
"options",
"=",
"{",
"}",
")",
"{",
"word",
"=",
"String",
"(",
"word",
"||",
"\"\"",
")",
";",
"const",
"found",
"=",
"(",
"options",
".",
"caseSensitive",
"?",
"dict",
"(",
")",
"[",
"word",
"]",
"... | Get correct words from misspelling.
It is case-insensitive by default.
Set `caseSensitive` to `true` if you need.
@param {string} word Misspelled word.
@param {Object} options Options.
@param {Boolean} [options.caseSensitive=false]
If `true`, do case-sensitive search.
@return {string[]} An array of correct words.
... | [
"Get",
"correct",
"words",
"from",
"misspelling",
"."
] | 9281c7400348f69ba86af0567571d210253e246a | https://github.com/io-monad/misspellings/blob/9281c7400348f69ba86af0567571d210253e246a/src/misspellings.js#L91-L98 | train |
io-monad/misspellings | src/misspellings.js | correct | function correct(str, options, callback) {
if (typeof options === "function") {
callback = options;
options = {};
}
const {caseSensitive, overrideCases} = options || {};
str = String(str || "");
const dic = dict({ lowerCase: true });
const re = regexp(caseSensitive ? "g" : "ig");
return str.repl... | javascript | function correct(str, options, callback) {
if (typeof options === "function") {
callback = options;
options = {};
}
const {caseSensitive, overrideCases} = options || {};
str = String(str || "");
const dic = dict({ lowerCase: true });
const re = regexp(caseSensitive ? "g" : "ig");
return str.repl... | [
"function",
"correct",
"(",
"str",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"\"function\"",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"const",
"{",
"caseSensitive",
",",
"ove... | Correct all misspellings in a string.
It is case-insensitive by default, but it tries to keep cases
(upper to upper, lower to lower) after misspellings corrected.
You can skip options and call in `correct(str, callback)` form.
@param {string} str A target string.
@param {Object} [options] Options.
@param {Boolean}... | [
"Correct",
"all",
"misspellings",
"in",
"a",
"string",
"."
] | 9281c7400348f69ba86af0567571d210253e246a | https://github.com/io-monad/misspellings/blob/9281c7400348f69ba86af0567571d210253e246a/src/misspellings.js#L120-L150 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/renderer.js | Renderer | function Renderer(game, width, height, tileSize, canvasClassName) {
this.layers = [];
this.game = game;
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
this.canvas.className = canvasClassName || 'renderer';
this.buffer = this.canva... | javascript | function Renderer(game, width, height, tileSize, canvasClassName) {
this.layers = [];
this.game = game;
this.canvas = document.createElement('canvas');
this.ctx = this.canvas.getContext('2d');
this.canvas.className = canvasClassName || 'renderer';
this.buffer = this.canva... | [
"function",
"Renderer",
"(",
"game",
",",
"width",
",",
"height",
",",
"tileSize",
",",
"canvasClassName",
")",
"{",
"this",
".",
"layers",
"=",
"[",
"]",
";",
"this",
".",
"game",
"=",
"game",
";",
"this",
".",
"canvas",
"=",
"document",
".",
"creat... | Renders the current game state using html5 canvas.
@class Renderer
@constructor
@param {Game} game - Game instance this obj is attached to.
@param {Number} width - Width of the map view in tiles.
@param {Number} height - Height of the map view in tiles.
@param {Number} tileSize - Width and height of tiles when drawn.
@... | [
"Renders",
"the",
"current",
"game",
"state",
"using",
"html5",
"canvas",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/renderer.js#L14-L25 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/renderer.js | function(x, y, tileData, ctx) {
ctx = ctx || this.bufferCtx;
var originalX = x,
originalY = y;
x -= this.originX;
y -= this.originY;
if(tileData.bgColor){
ctx.fillStyle = tileData.bgColor;
ctx.fillRect(
... | javascript | function(x, y, tileData, ctx) {
ctx = ctx || this.bufferCtx;
var originalX = x,
originalY = y;
x -= this.originX;
y -= this.originY;
if(tileData.bgColor){
ctx.fillStyle = tileData.bgColor;
ctx.fillRect(
... | [
"function",
"(",
"x",
",",
"y",
",",
"tileData",
",",
"ctx",
")",
"{",
"ctx",
"=",
"ctx",
"||",
"this",
".",
"bufferCtx",
";",
"var",
"originalX",
"=",
"x",
",",
"originalY",
"=",
"y",
";",
"x",
"-=",
"this",
".",
"originX",
";",
"y",
"-=",
"th... | Draws a single tile to the map view.
@method drawTileToCanvas
@param {Number} x - Map tile coord on the x axis.
@param {Number} y - Map tile coord on the y axis.
@param {Object} tileData - Object containing tile draw settings.
@param {Object} [tileData.char] - The character to draw.
@param {Object} [tileData.color] - T... | [
"Draws",
"a",
"single",
"tile",
"to",
"the",
"map",
"view",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/renderer.js#L274-L366 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/renderer.js | function(x, y){
var pos = this.canvas.getBoundingClientRect(),
mx = x - pos.left,
my = y - pos.top;
return this.pixelToTileCoords(mx, my);
} | javascript | function(x, y){
var pos = this.canvas.getBoundingClientRect(),
mx = x - pos.left,
my = y - pos.top;
return this.pixelToTileCoords(mx, my);
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"pos",
"=",
"this",
".",
"canvas",
".",
"getBoundingClientRect",
"(",
")",
",",
"mx",
"=",
"x",
"-",
"pos",
".",
"left",
",",
"my",
"=",
"y",
"-",
"pos",
".",
"top",
";",
"return",
"this",
".",
... | Converts mouse pixel coords to map tile coords. Mouse pixel coords must be relative to the current window.
@method mouseToTileCoords
@param {Number} x - Mouse pixel x coord.
@param {Number} y - Mouse pixel y coord.
@return {Object|False} {x: 0, y: 0} | [
"Converts",
"mouse",
"pixel",
"coords",
"to",
"map",
"tile",
"coords",
".",
"Mouse",
"pixel",
"coords",
"must",
"be",
"relative",
"to",
"the",
"current",
"window",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/renderer.js#L375-L380 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/renderer.js | function(x, y){
return {
x: Math.floor(x / this.tileSize) + this.originX,
y: Math.floor(y / this.tileSize) + this.originY
};
} | javascript | function(x, y){
return {
x: Math.floor(x / this.tileSize) + this.originX,
y: Math.floor(y / this.tileSize) + this.originY
};
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"return",
"{",
"x",
":",
"Math",
".",
"floor",
"(",
"x",
"/",
"this",
".",
"tileSize",
")",
"+",
"this",
".",
"originX",
",",
"y",
":",
"Math",
".",
"floor",
"(",
"y",
"/",
"this",
".",
"tileSize",
")... | Converts map view pixel coords to map tile coords. Map view pixel coords are relative to the top left of the canvas element.
@method pixelToTileCoords
@param {Number} x - Map view pixel x coord.
@param {Number} y - Map view pixel y coord.
@return {Object|False} {x: 0, y: 0} | [
"Converts",
"map",
"view",
"pixel",
"coords",
"to",
"map",
"tile",
"coords",
".",
"Map",
"view",
"pixel",
"coords",
"are",
"relative",
"to",
"the",
"top",
"left",
"of",
"the",
"canvas",
"element",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/renderer.js#L389-L394 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/renderer.js | function(color, ctx){
ctx = ctx || this.bufferCtx;
ctx.fillStyle = color || this.bgColor;
ctx.fillRect(
0,
0,
this.canvas.width,
this.canvas.height
);
} | javascript | function(color, ctx){
ctx = ctx || this.bufferCtx;
ctx.fillStyle = color || this.bgColor;
ctx.fillRect(
0,
0,
this.canvas.width,
this.canvas.height
);
} | [
"function",
"(",
"color",
",",
"ctx",
")",
"{",
"ctx",
"=",
"ctx",
"||",
"this",
".",
"bufferCtx",
";",
"ctx",
".",
"fillStyle",
"=",
"color",
"||",
"this",
".",
"bgColor",
";",
"ctx",
".",
"fillRect",
"(",
"0",
",",
"0",
",",
"this",
".",
"canva... | Fills the canvas with a given color.
@method fillBg
@param {String} [color=this.bgColor]
@param {CanvasRenderingContext2D} [ctx=this.bufferCtx] | [
"Fills",
"the",
"canvas",
"with",
"a",
"given",
"color",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/renderer.js#L414-L423 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/array-2d.js | function(width, height) {
this.width = width;
this.height = height;
for (var i = 0; i < this.width; i++) {
if(!this.data){
this.data = [];
}
if(this.data[i] === void 0){
this.data[i] = [];
... | javascript | function(width, height) {
this.width = width;
this.height = height;
for (var i = 0; i < this.width; i++) {
if(!this.data){
this.data = [];
}
if(this.data[i] === void 0){
this.data[i] = [];
... | [
"function",
"(",
"width",
",",
"height",
")",
"{",
"this",
".",
"width",
"=",
"width",
";",
"this",
".",
"height",
"=",
"height",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"width",
";",
"i",
"++",
")",
"{",
"if",
"(",... | Updates the size of this Array2d without destroying data.
@method setSize
@param {Number} width - The new width.
@param {Number} height - The new height. | [
"Updates",
"the",
"size",
"of",
"this",
"Array2d",
"without",
"destroying",
"data",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/array-2d.js#L61-L73 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/array-2d.js | function(x, y, settings) {
settings = settings || {};
var filter = settings.filter !== void 0 ? settings.filter : false,
withCoords = settings.withCoords !== void 0 ? settings.withCoords : false,
withDiagonals = settings.w... | javascript | function(x, y, settings) {
settings = settings || {};
var filter = settings.filter !== void 0 ? settings.filter : false,
withCoords = settings.withCoords !== void 0 ? settings.withCoords : false,
withDiagonals = settings.w... | [
"function",
"(",
"x",
",",
"y",
",",
"settings",
")",
"{",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"var",
"filter",
"=",
"settings",
".",
"filter",
"!==",
"void",
"0",
"?",
"settings",
".",
"filter",
":",
"false",
",",
"withCoords",
"=",
... | Retrieves an array of values of adjacent coords.
@method getAdjacent
@param {Number} x - Map tile x coord to get adjacent values of.
@param {Number} y - Map tile y coord to get adjacent values of.
@param {Object} [settings] -
@param {Bool} [settings.withCoords=false] - If true the returned array will include the coords... | [
"Retrieves",
"an",
"array",
"of",
"values",
"of",
"adjacent",
"coords",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/array-2d.js#L124-L192 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/array-2d.js | function(x, y, settings) {
settings = settings || {};
var radius = settings.radius || 1,
filter = settings.filter || false,
withCoords = settings.withCoords || false,
includeTarget = settings.incl... | javascript | function(x, y, settings) {
settings = settings || {};
var radius = settings.radius || 1,
filter = settings.filter || false,
withCoords = settings.withCoords || false,
includeTarget = settings.incl... | [
"function",
"(",
"x",
",",
"y",
",",
"settings",
")",
"{",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"var",
"radius",
"=",
"settings",
".",
"radius",
"||",
"1",
",",
"filter",
"=",
"settings",
".",
"filter",
"||",
"false",
",",
"withCoords",
... | Retrieves an array of values of coords within a given radius.
@method getWithinSquareRadius
@param {Number} x - Map tile x coord at the center of the radius.
@param {Number} y - Map tile x coord at the center of the radius.
@param {Object} [settings] -
@param {Number} [settings.radius=1] - Radius of the area to retriev... | [
"Retrieves",
"an",
"array",
"of",
"values",
"of",
"coords",
"within",
"a",
"given",
"radius",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/array-2d.js#L206-L256 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/array-2d.js | function(x0, y0, x1, y1, condition, withCoords) {
withCoords = withCoords || false;
condition = condition || false;
var output = [],
dx = Math.abs(x1 - x0),
dy = Math.abs(y1 - y0),
sx = (x0 < x1) ? 1 : -1,
sy = (y0 < y1)... | javascript | function(x0, y0, x1, y1, condition, withCoords) {
withCoords = withCoords || false;
condition = condition || false;
var output = [],
dx = Math.abs(x1 - x0),
dy = Math.abs(y1 - y0),
sx = (x0 < x1) ? 1 : -1,
sy = (y0 < y1)... | [
"function",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"condition",
",",
"withCoords",
")",
"{",
"withCoords",
"=",
"withCoords",
"||",
"false",
";",
"condition",
"=",
"condition",
"||",
"false",
";",
"var",
"output",
"=",
"[",
"]",
",",
"dx",
... | Retrieves an array of values of coords along a line starting at point 0 and crossing point 1 until it hits the edge of the 2d array or a coord value returning true when passed to the condtion function.
@method getLineThrough
@param {Number} x0 - Map tile x coord of start.
@param {Number} y0 - Map tile y coord of start.... | [
"Retrieves",
"an",
"array",
"of",
"values",
"of",
"coords",
"along",
"a",
"line",
"starting",
"at",
"point",
"0",
"and",
"crossing",
"point",
"1",
"until",
"it",
"hits",
"the",
"edge",
"of",
"the",
"2d",
"array",
"or",
"a",
"coord",
"value",
"returning",... | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/array-2d.js#L269-L311 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/array-2d.js | function(startX, startY, settings) {
settings = settings || {};
var maxRadius = settings.maxRadius || 1,
filter = settings.filter || false,
withCoords = settings.withCoords || false;
var currentDistance = 1,
result... | javascript | function(startX, startY, settings) {
settings = settings || {};
var maxRadius = settings.maxRadius || 1,
filter = settings.filter || false,
withCoords = settings.withCoords || false;
var currentDistance = 1,
result... | [
"function",
"(",
"startX",
",",
"startY",
",",
"settings",
")",
"{",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"var",
"maxRadius",
"=",
"settings",
".",
"maxRadius",
"||",
"1",
",",
"filter",
"=",
"settings",
".",
"filter",
"||",
"false",
",",
... | Retrieves an array of the nearest coord values meeting checked requirements. If multiple coord values were matched at the same nearest distance, the returned array will contain multiple matched coord values.
Used for projecting path of ranged attacks, pushed entities, ect.
@method getNearest
@param {Number} tileX - Map... | [
"Retrieves",
"an",
"array",
"of",
"the",
"nearest",
"coord",
"values",
"meeting",
"checked",
"requirements",
".",
"If",
"multiple",
"coord",
"values",
"were",
"matched",
"at",
"the",
"same",
"nearest",
"distance",
"the",
"returned",
"array",
"will",
"contain",
... | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/array-2d.js#L325-L406 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/array-2d.js | function(filter, withCoords){
withCoords = withCoords || false;
var output = [];
for (var x = 0; x < this.width; x++) {
for (var y = 0; y < this.height; y++) {
var val = this.get(x, y);
if(filter(val, x, y)){
... | javascript | function(filter, withCoords){
withCoords = withCoords || false;
var output = [];
for (var x = 0; x < this.width; x++) {
for (var y = 0; y < this.height; y++) {
var val = this.get(x, y);
if(filter(val, x, y)){
... | [
"function",
"(",
"filter",
",",
"withCoords",
")",
"{",
"withCoords",
"=",
"withCoords",
"||",
"false",
";",
"var",
"output",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"x",
"=",
"0",
";",
"x",
"<",
"this",
".",
"width",
";",
"x",
"++",
")",
"{",
"... | Retrieves an array of the filtered values.
@method filter
@param {Function} filter - A function to determine if a value is to be included in results (returns true). (function(value, x, y){ return true;})
@param {Bool} [withCoords=false] - If true the returned array will include the coords of each value ([{x: 0, y: 0, v... | [
"Retrieves",
"an",
"array",
"of",
"the",
"filtered",
"values",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/array-2d.js#L415-L435 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/array-2d.js | function(){
var newArray = new Array2d(this.width, this.height);
for(var x = this.width - 1; x >= 0; x--){
for(var y = this.height - 1; y >= 0; y--){
var val = this.get(x, y);
if(val !== void 0){
newArray.set(x, y, v... | javascript | function(){
var newArray = new Array2d(this.width, this.height);
for(var x = this.width - 1; x >= 0; x--){
for(var y = this.height - 1; y >= 0; y--){
var val = this.get(x, y);
if(val !== void 0){
newArray.set(x, y, v... | [
"function",
"(",
")",
"{",
"var",
"newArray",
"=",
"new",
"Array2d",
"(",
"this",
".",
"width",
",",
"this",
".",
"height",
")",
";",
"for",
"(",
"var",
"x",
"=",
"this",
".",
"width",
"-",
"1",
";",
"x",
">=",
"0",
";",
"x",
"--",
")",
"{",
... | Creates a copy of this Array2d. Shallow copies values.
@method copy
@return {Array2d} | [
"Creates",
"a",
"copy",
"of",
"this",
"Array2d",
".",
"Shallow",
"copies",
"values",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/array-2d.js#L442-L453 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/array-2d.js | function(func, context){
for(var x = this.width - 1; x >= 0; x--){
for(var y = this.height - 1; y >= 0; y--){
var val = this.get(x, y);
if(context){
func.call(context, val, x, y);
} else {
... | javascript | function(func, context){
for(var x = this.width - 1; x >= 0; x--){
for(var y = this.height - 1; y >= 0; y--){
var val = this.get(x, y);
if(context){
func.call(context, val, x, y);
} else {
... | [
"function",
"(",
"func",
",",
"context",
")",
"{",
"for",
"(",
"var",
"x",
"=",
"this",
".",
"width",
"-",
"1",
";",
"x",
">=",
"0",
";",
"x",
"--",
")",
"{",
"for",
"(",
"var",
"y",
"=",
"this",
".",
"height",
"-",
"1",
";",
"y",
">=",
"... | Loops over each coord value.
@method each
@param {Function} func - A function to call on each coord value. (function(value, x, y){})
@param {Object} [context] - Context to call the function with (func.call(context, val, x, y))
@return {Array2d} | [
"Loops",
"over",
"each",
"coord",
"value",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/array-2d.js#L462-L473 | train | |
SilentCicero/solidity-to-abi | src/index.js | buildInputsArray | function buildInputsArray(rawInputsString) {
let returnArray = []; // eslint-disable-line
const rawMethodInputs = rawInputsString.split(',');
// no inputs
if (typeof rawMethodInputs === 'undefined' || rawMethodInputs.length === 0) {
return [];
}
rawMethodInputs.forEach((rawMethodInput) => {
const ... | javascript | function buildInputsArray(rawInputsString) {
let returnArray = []; // eslint-disable-line
const rawMethodInputs = rawInputsString.split(',');
// no inputs
if (typeof rawMethodInputs === 'undefined' || rawMethodInputs.length === 0) {
return [];
}
rawMethodInputs.forEach((rawMethodInput) => {
const ... | [
"function",
"buildInputsArray",
"(",
"rawInputsString",
")",
"{",
"let",
"returnArray",
"=",
"[",
"]",
";",
"// eslint-disable-line",
"const",
"rawMethodInputs",
"=",
"rawInputsString",
".",
"split",
"(",
"','",
")",
";",
"// no inputs",
"if",
"(",
"typeof",
"ra... | build inputs or outputs array from raw inputs string | [
"build",
"inputs",
"or",
"outputs",
"array",
"from",
"raw",
"inputs",
"string"
] | 2d97d2c53a90f670ced1e010684897d9d46eb9d2 | https://github.com/SilentCicero/solidity-to-abi/blob/2d97d2c53a90f670ced1e010684897d9d46eb9d2/src/index.js#L2-L26 | train |
SilentCicero/solidity-to-abi | src/index.js | solidityToABI | function solidityToABI(methodInterface) {
// count open and clsoed
const methodABIObject = {};
// not a string
if (typeof methodInterface !== 'string') {
throw new Error(`Method interface must be a string, currently ${typeof methodInterface}`);
}
// empty string
if (methodInterface.length === 0) {
... | javascript | function solidityToABI(methodInterface) {
// count open and clsoed
const methodABIObject = {};
// not a string
if (typeof methodInterface !== 'string') {
throw new Error(`Method interface must be a string, currently ${typeof methodInterface}`);
}
// empty string
if (methodInterface.length === 0) {
... | [
"function",
"solidityToABI",
"(",
"methodInterface",
")",
"{",
"// count open and clsoed",
"const",
"methodABIObject",
"=",
"{",
"}",
";",
"// not a string",
"if",
"(",
"typeof",
"methodInterface",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
... | parse a solidity method interface | [
"parse",
"a",
"solidity",
"method",
"interface"
] | 2d97d2c53a90f670ced1e010684897d9d46eb9d2 | https://github.com/SilentCicero/solidity-to-abi/blob/2d97d2c53a90f670ced1e010684897d9d46eb9d2/src/index.js#L29-L91 | train |
paglias/KnockoutApp | build/knockout.app.js | function(obj){
if(ko.isWriteableObservable(obj)) return ko.observable(obj());
if(obj === null || typeof obj !== 'object') return obj;
var temp = obj.constructor();
for (var key in obj) {
temp[key] = Utils.cloneObjKnockout(obj[key]);
}
return temp;
} | javascript | function(obj){
if(ko.isWriteableObservable(obj)) return ko.observable(obj());
if(obj === null || typeof obj !== 'object') return obj;
var temp = obj.constructor();
for (var key in obj) {
temp[key] = Utils.cloneObjKnockout(obj[key]);
}
return temp;
} | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"ko",
".",
"isWriteableObservable",
"(",
"obj",
")",
")",
"return",
"ko",
".",
"observable",
"(",
"obj",
"(",
")",
")",
";",
"if",
"(",
"obj",
"===",
"null",
"||",
"typeof",
"obj",
"!==",
"'object'",
")"... | Used to clone an object with Knockout observable properties | [
"Used",
"to",
"clone",
"an",
"object",
"with",
"Knockout",
"observable",
"properties"
] | 7010bc4508c2ec05154c966519325a3f61add3e5 | https://github.com/paglias/KnockoutApp/blob/7010bc4508c2ec05154c966519325a3f61add3e5/build/knockout.app.js#L76-L86 | train | |
paglias/KnockoutApp | build/knockout.app.js | function(_options){
var self = this, //model
options = _options || {},
success = options.success; //custom success function passed in _options
options.success = function(data){
delete data[self.idAttribute];
var defaults = Utils.cloneObjKnockout(self.defaults);
s... | javascript | function(_options){
var self = this, //model
options = _options || {},
success = options.success; //custom success function passed in _options
options.success = function(data){
delete data[self.idAttribute];
var defaults = Utils.cloneObjKnockout(self.defaults);
s... | [
"function",
"(",
"_options",
")",
"{",
"var",
"self",
"=",
"this",
",",
"//model",
"options",
"=",
"_options",
"||",
"{",
"}",
",",
"success",
"=",
"options",
".",
"success",
";",
"//custom success function passed in _options",
"options",
".",
"success",
"=",
... | Fetch the model on the server and replace its attributes with the one fetched Options for the sync method can be passed as an object | [
"Fetch",
"the",
"model",
"on",
"the",
"server",
"and",
"replace",
"its",
"attributes",
"with",
"the",
"one",
"fetched",
"Options",
"for",
"the",
"sync",
"method",
"can",
"be",
"passed",
"as",
"an",
"object"
] | 7010bc4508c2ec05154c966519325a3f61add3e5 | https://github.com/paglias/KnockoutApp/blob/7010bc4508c2ec05154c966519325a3f61add3e5/build/knockout.app.js#L204-L217 | train | |
paglias/KnockoutApp | build/knockout.app.js | function(model_s, create, options){
var toAdd = model_s instanceof Array ? model_s : [model_s],
self = this;
ko.utils.arrayForEach(toAdd, function(attributes){
var model;
if(attributes instanceof Model){
model = attributes;
model.collection = self;
}els... | javascript | function(model_s, create, options){
var toAdd = model_s instanceof Array ? model_s : [model_s],
self = this;
ko.utils.arrayForEach(toAdd, function(attributes){
var model;
if(attributes instanceof Model){
model = attributes;
model.collection = self;
}els... | [
"function",
"(",
"model_s",
",",
"create",
",",
"options",
")",
"{",
"var",
"toAdd",
"=",
"model_s",
"instanceof",
"Array",
"?",
"model_s",
":",
"[",
"model_s",
"]",
",",
"self",
"=",
"this",
";",
"ko",
".",
"utils",
".",
"arrayForEach",
"(",
"toAdd",
... | Add one or more models to collection and optionally create them on the server setting the 'create' parameter to 'true' It will also add a reference to the collection on each model | [
"Add",
"one",
"or",
"more",
"models",
"to",
"collection",
"and",
"optionally",
"create",
"them",
"on",
"the",
"server",
"setting",
"the",
"create",
"parameter",
"to",
"true",
"It",
"will",
"also",
"add",
"a",
"reference",
"to",
"the",
"collection",
"on",
"... | 7010bc4508c2ec05154c966519325a3f61add3e5 | https://github.com/paglias/KnockoutApp/blob/7010bc4508c2ec05154c966519325a3f61add3e5/build/knockout.app.js#L304-L319 | train | |
paglias/KnockoutApp | build/knockout.app.js | function(_options){
var self = this, //collection
options = _options || {},
success = options.success; //custom success function passed in _options
options.success = function(data){
var toAdd = [];
for(var model in data){
toAdd.push(data[model]);
}
... | javascript | function(_options){
var self = this, //collection
options = _options || {},
success = options.success; //custom success function passed in _options
options.success = function(data){
var toAdd = [];
for(var model in data){
toAdd.push(data[model]);
}
... | [
"function",
"(",
"_options",
")",
"{",
"var",
"self",
"=",
"this",
",",
"//collection",
"options",
"=",
"_options",
"||",
"{",
"}",
",",
"success",
"=",
"options",
".",
"success",
";",
"//custom success function passed in _options",
"options",
".",
"success",
... | Fetch models from server and add them to the collection. Options for the sync method can be passed as an object | [
"Fetch",
"models",
"from",
"server",
"and",
"add",
"them",
"to",
"the",
"collection",
".",
"Options",
"for",
"the",
"sync",
"method",
"can",
"be",
"passed",
"as",
"an",
"object"
] | 7010bc4508c2ec05154c966519325a3f61add3e5 | https://github.com/paglias/KnockoutApp/blob/7010bc4508c2ec05154c966519325a3f61add3e5/build/knockout.app.js#L332-L350 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/tile.js | Tile | function Tile(game, type, x, y) {
this.game = game;
this.x = x;
this.y = y;
this.type = type;
var typeData = Tile.Types[type];
RL.Util.merge(this, typeData);
this.id = tileId++;
if(this.init){
this.init(game, type, x, y);
}
} | javascript | function Tile(game, type, x, y) {
this.game = game;
this.x = x;
this.y = y;
this.type = type;
var typeData = Tile.Types[type];
RL.Util.merge(this, typeData);
this.id = tileId++;
if(this.init){
this.init(game, type, x, y);
}
} | [
"function",
"Tile",
"(",
"game",
",",
"type",
",",
"x",
",",
"y",
")",
"{",
"this",
".",
"game",
"=",
"game",
";",
"this",
".",
"x",
"=",
"x",
";",
"this",
".",
"y",
"=",
"y",
";",
"this",
".",
"type",
"=",
"type",
";",
"var",
"typeData",
"... | Represents a tile in the game map.
@class Tile
@constructor
@uses TileDraw
@param {Object} game - Game instance this obj is attached to.
@param {String} type - Type of tile. When created this object is merged with the value of Tile.Types[type].
@param {Number} x - The map tile coordinate position of this tile on the x ... | [
"Represents",
"a",
"tile",
"in",
"the",
"game",
"map",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/tile.js#L16-L30 | train |
jlmorgan/lodash-transpose | src/transpose.js | baseTranspose | function baseTranspose(matrix) {
return map(head(matrix), function (column, index) {
return map(matrix, function (row) {
return row[index];
});
});
} | javascript | function baseTranspose(matrix) {
return map(head(matrix), function (column, index) {
return map(matrix, function (row) {
return row[index];
});
});
} | [
"function",
"baseTranspose",
"(",
"matrix",
")",
"{",
"return",
"map",
"(",
"head",
"(",
"matrix",
")",
",",
"function",
"(",
"column",
",",
"index",
")",
"{",
"return",
"map",
"(",
"matrix",
",",
"function",
"(",
"row",
")",
"{",
"return",
"row",
"[... | Base matrix transpose. Turns an n by m matrix into m by n.
@private
@param {Array} matrix - Two-dimensional array (n by m).
@returns {Array} Returns m by n matrix. | [
"Base",
"matrix",
"transpose",
".",
"Turns",
"an",
"n",
"by",
"m",
"matrix",
"into",
"m",
"by",
"n",
"."
] | 2cb7573293431f109796cf2c3f619bd83545b1a3 | https://github.com/jlmorgan/lodash-transpose/blob/2cb7573293431f109796cf2c3f619bd83545b1a3/src/transpose.js#L16-L22 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets.js | function(game, targets, settings){
this.game = game;
settings = settings || {};
this.typeSortPriority = settings.typeSortPriority || [].concat(this.typeSortPriority);
var width = settings.mapWidth || this.game.map.width;
var height = settings.mapWidth || this.game.map.width;
... | javascript | function(game, targets, settings){
this.game = game;
settings = settings || {};
this.typeSortPriority = settings.typeSortPriority || [].concat(this.typeSortPriority);
var width = settings.mapWidth || this.game.map.width;
var height = settings.mapWidth || this.game.map.width;
... | [
"function",
"(",
"game",
",",
"targets",
",",
"settings",
")",
"{",
"this",
".",
"game",
"=",
"game",
";",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"this",
".",
"typeSortPriority",
"=",
"settings",
".",
"typeSortPriority",
"||",
"[",
"]",
".",... | Manages a list of valid targets and which is currently selected.
@class ValidTargets
@constructor
@param {Game} game - Game instance this obj is attached to.
@param {Array} [targets=Array] An Array of valid target objects to select from (intended to be in the format `validTargetsFinder.getValidTargets()` returns).
@par... | [
"Manages",
"a",
"list",
"of",
"valid",
"targets",
"and",
"which",
"is",
"currently",
"selected",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets.js#L16-L30 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets.js | function(targets){
targets = targets || [];
this.targets = targets;
this.map.reset();
for(var i = targets.length - 1; i >= 0; i--){
var target = targets[i];
this.map.add(target.x, target.y, target);
}
} | javascript | function(targets){
targets = targets || [];
this.targets = targets;
this.map.reset();
for(var i = targets.length - 1; i >= 0; i--){
var target = targets[i];
this.map.add(target.x, target.y, target);
}
} | [
"function",
"(",
"targets",
")",
"{",
"targets",
"=",
"targets",
"||",
"[",
"]",
";",
"this",
".",
"targets",
"=",
"targets",
";",
"this",
".",
"map",
".",
"reset",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"targets",
".",
"length",
"-",
"1",
... | Sets the targets, replacing currently set ones.
@method setTargets
@param {Array} targets | [
"Sets",
"the",
"targets",
"replacing",
"currently",
"set",
"ones",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets.js#L78-L86 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets.js | function(target){
var index = this.targets.indexOf(target);
if(index !== -1){
this.current = target;
return true;
}
return false;
} | javascript | function(target){
var index = this.targets.indexOf(target);
if(index !== -1){
this.current = target;
return true;
}
return false;
} | [
"function",
"(",
"target",
")",
"{",
"var",
"index",
"=",
"this",
".",
"targets",
".",
"indexOf",
"(",
"target",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"this",
".",
"current",
"=",
"target",
";",
"return",
"true",
";",
"}",
"ret... | Sets the currently selected target object.
@method setCurrent
@param {Object} target
@return {Bool} If target was found in `this.targets`. (only set if found). | [
"Sets",
"the",
"currently",
"selected",
"target",
"object",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets.js#L94-L101 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.