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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(options, callback) {
var that = this;
var data = that._searchInBbox(options.bbox);
callback(null, data);
} | javascript | function(options, callback) {
var that = this;
var data = that._searchInBbox(options.bbox);
callback(null, data);
} | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"data",
"=",
"that",
".",
"_searchInBbox",
"(",
"options",
".",
"bbox",
")",
";",
"callback",
"(",
"null",
",",
"data",
")",
";",
"}"
] | Loads and returns indexed data contained in the specified bounding box.
@param options.bbox
a bounding box used to search data | [
"Loads",
"and",
"returns",
"indexed",
"data",
"contained",
"in",
"the",
"specified",
"bounding",
"box",
"."
] | ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L34-L38 | train | |
mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(data) {
// Data indexing
this._rtree = rbush(9);
data = data || [];
var array = [];
var that = this;
function index(d) {
var bbox = that._getBoundingBox(d);
if (bbox) {
var key = that._toIndexKey(bbox);
key.... | javascript | function(data) {
// Data indexing
this._rtree = rbush(9);
data = data || [];
var array = [];
var that = this;
function index(d) {
var bbox = that._getBoundingBox(d);
if (bbox) {
var key = that._toIndexKey(bbox);
key.... | [
"function",
"(",
"data",
")",
"{",
"// Data indexing",
"this",
".",
"_rtree",
"=",
"rbush",
"(",
"9",
")",
";",
"data",
"=",
"data",
"||",
"[",
"]",
";",
"var",
"array",
"=",
"[",
"]",
";",
"var",
"that",
"=",
"this",
";",
"function",
"index",
"(... | Indexes the specified data array using a RTree index. | [
"Indexes",
"the",
"specified",
"data",
"array",
"using",
"a",
"RTree",
"index",
"."
] | ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L41-L66 | train | |
mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(bbox) {
var coords = this._toIndexKey(bbox);
var array = this._rtree.search(coords);
array = this._sortByDistance(array, bbox);
var result = [];
var filterMultiPoints = !!this.options.filterPoints;
for (var i = 0; i < array.length; i++) {
var arr = ar... | javascript | function(bbox) {
var coords = this._toIndexKey(bbox);
var array = this._rtree.search(coords);
array = this._sortByDistance(array, bbox);
var result = [];
var filterMultiPoints = !!this.options.filterPoints;
for (var i = 0; i < array.length; i++) {
var arr = ar... | [
"function",
"(",
"bbox",
")",
"{",
"var",
"coords",
"=",
"this",
".",
"_toIndexKey",
"(",
"bbox",
")",
";",
"var",
"array",
"=",
"this",
".",
"_rtree",
".",
"search",
"(",
"coords",
")",
";",
"array",
"=",
"this",
".",
"_sortByDistance",
"(",
"array"... | Searches resources in the specified bounding box. | [
"Searches",
"resources",
"in",
"the",
"specified",
"bounding",
"box",
"."
] | ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L69-L107 | train | |
mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(array, bbox) {
if (typeof this.options.sort === 'function') {
this._sortByDistance = this.options.sort;
} else {
this._sortByDistance = function(array, bbox) {
var p = bbox[0];
array.sort(function(a, b) {
var d = (a[1] ... | javascript | function(array, bbox) {
if (typeof this.options.sort === 'function') {
this._sortByDistance = this.options.sort;
} else {
this._sortByDistance = function(array, bbox) {
var p = bbox[0];
array.sort(function(a, b) {
var d = (a[1] ... | [
"function",
"(",
"array",
",",
"bbox",
")",
"{",
"if",
"(",
"typeof",
"this",
".",
"options",
".",
"sort",
"===",
"'function'",
")",
"{",
"this",
".",
"_sortByDistance",
"=",
"this",
".",
"options",
".",
"sort",
";",
"}",
"else",
"{",
"this",
".",
... | Sorts the given data array | [
"Sorts",
"the",
"given",
"data",
"array"
] | ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L112-L129 | train | |
mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(bbox) {
var a = +bbox[0][0], b = +bbox[0][1], c = +bbox[1][0], d = +bbox[1][1];
return [ Math.min(a, c), Math.min(b, d), Math.max(a, c), Math.max(b, d) ];
} | javascript | function(bbox) {
var a = +bbox[0][0], b = +bbox[0][1], c = +bbox[1][0], d = +bbox[1][1];
return [ Math.min(a, c), Math.min(b, d), Math.max(a, c), Math.max(b, d) ];
} | [
"function",
"(",
"bbox",
")",
"{",
"var",
"a",
"=",
"+",
"bbox",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"b",
"=",
"+",
"bbox",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"c",
"=",
"+",
"bbox",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"d",
"=",
"+",
"... | This method transforms a bounding box into a key for RTree index. | [
"This",
"method",
"transforms",
"a",
"bounding",
"box",
"into",
"a",
"key",
"for",
"RTree",
"index",
"."
] | ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L134-L137 | train | |
weexteam/weex-templater | lib/parsers/text.js | parseText | function parseText(text) {
text = text.replace(/\n/g, '')
/* istanbul ignore if */
if (!tagRE.test(text)) {
return null
}
var tokens = []
var lastIndex = tagRE.lastIndex = 0
var match, index, html, value, first, oneTime
/* eslint-disable no-cond-assign */
while (match = tagRE.exec(text)) {
/* es... | javascript | function parseText(text) {
text = text.replace(/\n/g, '')
/* istanbul ignore if */
if (!tagRE.test(text)) {
return null
}
var tokens = []
var lastIndex = tagRE.lastIndex = 0
var match, index, html, value, first, oneTime
/* eslint-disable no-cond-assign */
while (match = tagRE.exec(text)) {
/* es... | [
"function",
"parseText",
"(",
"text",
")",
"{",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"''",
")",
"/* istanbul ignore if */",
"if",
"(",
"!",
"tagRE",
".",
"test",
"(",
"text",
")",
")",
"{",
"return",
"null",
"}",
"va... | Parse a template text string into an array of tokens.
@param {String} text
@return {Array<Object> | null}
- {String} type
- {String} value
- {Boolean} [html]
- {Boolean} [oneTime] | [
"Parse",
"a",
"template",
"text",
"string",
"into",
"an",
"array",
"of",
"tokens",
"."
] | 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/lib/parsers/text.js#L16-L57 | train |
tdreyno/morlock.js | core/dom.js | makeViewportGetter_ | function makeViewportGetter_(dimension, inner, client) {
if (testMQ('(min-' + dimension + ':' + window[inner] + 'px)')) {
return function getWindowDimension_() {
return window[inner];
};
} else {
var docElem = document.documentElement;
return function getDocumentDimension_() {
return doc... | javascript | function makeViewportGetter_(dimension, inner, client) {
if (testMQ('(min-' + dimension + ':' + window[inner] + 'px)')) {
return function getWindowDimension_() {
return window[inner];
};
} else {
var docElem = document.documentElement;
return function getDocumentDimension_() {
return doc... | [
"function",
"makeViewportGetter_",
"(",
"dimension",
",",
"inner",
",",
"client",
")",
"{",
"if",
"(",
"testMQ",
"(",
"'(min-'",
"+",
"dimension",
"+",
"':'",
"+",
"window",
"[",
"inner",
"]",
"+",
"'px)'",
")",
")",
"{",
"return",
"function",
"getWindow... | Return a function which gets the viewport width or height.
@private
@param {String} dimension The dimension to look up.
@param {String} inner The inner dimension.
@param {String} client The client dimension.
@return {function} The getter function. | [
"Return",
"a",
"function",
"which",
"gets",
"the",
"viewport",
"width",
"or",
"height",
"."
] | a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/dom.js#L19-L30 | train |
tdreyno/morlock.js | core/dom.js | documentScrollY | function documentScrollY(targetElement) {
if (targetElement && (targetElement !== window)) {
return targetElement.scrollTop;
}
if (detectedIE10_ && (window.pageYOffset != document.documentElement.scrollTop)) {
return document.documentElement.scrollTop;
}
return window.pageYOffset || document.documen... | javascript | function documentScrollY(targetElement) {
if (targetElement && (targetElement !== window)) {
return targetElement.scrollTop;
}
if (detectedIE10_ && (window.pageYOffset != document.documentElement.scrollTop)) {
return document.documentElement.scrollTop;
}
return window.pageYOffset || document.documen... | [
"function",
"documentScrollY",
"(",
"targetElement",
")",
"{",
"if",
"(",
"targetElement",
"&&",
"(",
"targetElement",
"!==",
"window",
")",
")",
"{",
"return",
"targetElement",
".",
"scrollTop",
";",
"}",
"if",
"(",
"detectedIE10_",
"&&",
"(",
"window",
"."... | Get the document scroll.
@param {Element} targetElement - Optional target element.
@return {number} | [
"Get",
"the",
"document",
"scroll",
"."
] | a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/dom.js#L42-L52 | train |
tdreyno/morlock.js | core/dom.js | getRect | function getRect(elem) {
if (elem && !elem.nodeType) {
elem = elem[0];
}
if (!elem || 1 !== elem.nodeType) {
return false;
}
var bounds = elem.getBoundingClientRect();
return {
height: bounds.bottom - bounds.top,
width: bounds.right - bounds.left,
top: bounds.top,
left: bounds.lef... | javascript | function getRect(elem) {
if (elem && !elem.nodeType) {
elem = elem[0];
}
if (!elem || 1 !== elem.nodeType) {
return false;
}
var bounds = elem.getBoundingClientRect();
return {
height: bounds.bottom - bounds.top,
width: bounds.right - bounds.left,
top: bounds.top,
left: bounds.lef... | [
"function",
"getRect",
"(",
"elem",
")",
"{",
"if",
"(",
"elem",
"&&",
"!",
"elem",
".",
"nodeType",
")",
"{",
"elem",
"=",
"elem",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"!",
"elem",
"||",
"1",
"!==",
"elem",
".",
"nodeType",
")",
"{",
"return",
... | Calculate the rectangle of the element with an optional buffer.
@param {Element} elem The element.
@param {number} buffer An extra padding. | [
"Calculate",
"the",
"rectangle",
"of",
"the",
"element",
"with",
"an",
"optional",
"buffer",
"."
] | a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/dom.js#L59-L76 | train |
wercker/directory-to-object | index.js | dto | function dto(opts, cb) {
opts = 'string' == typeof opts
? {path: opts}
: opts
const path = opts.path || process.cwd()
cb = cb || function(){}
assert.equal(typeof path, 'string')
assert.equal(typeof cb, 'function')
saveDirs(path, {}, function(err, res) {
if (err) return cb(err)
saveFiles(p... | javascript | function dto(opts, cb) {
opts = 'string' == typeof opts
? {path: opts}
: opts
const path = opts.path || process.cwd()
cb = cb || function(){}
assert.equal(typeof path, 'string')
assert.equal(typeof cb, 'function')
saveDirs(path, {}, function(err, res) {
if (err) return cb(err)
saveFiles(p... | [
"function",
"dto",
"(",
"opts",
",",
"cb",
")",
"{",
"opts",
"=",
"'string'",
"==",
"typeof",
"opts",
"?",
"{",
"path",
":",
"opts",
"}",
":",
"opts",
"const",
"path",
"=",
"opts",
".",
"path",
"||",
"process",
".",
"cwd",
"(",
")",
"cb",
"=",
... | directory-to-object @param {Object|String} opts @param {Function} cb | [
"directory",
"-",
"to",
"-",
"object"
] | ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L10-L25 | train |
wercker/directory-to-object | index.js | saveDirs | function saveDirs(path, obj, cb) {
var currDir = ''
var root = ''
walk.walk(path, walkFn, function(err) {
if (err) return cb(err)
cb(null, obj)
})
function walkFn(baseDir, filename, stat, next) {
if (!root) root = baseDir
baseDir = stripLeadingSlash(baseDir.split(root)[1])
if (!baseD... | javascript | function saveDirs(path, obj, cb) {
var currDir = ''
var root = ''
walk.walk(path, walkFn, function(err) {
if (err) return cb(err)
cb(null, obj)
})
function walkFn(baseDir, filename, stat, next) {
if (!root) root = baseDir
baseDir = stripLeadingSlash(baseDir.split(root)[1])
if (!baseD... | [
"function",
"saveDirs",
"(",
"path",
",",
"obj",
",",
"cb",
")",
"{",
"var",
"currDir",
"=",
"''",
"var",
"root",
"=",
"''",
"walk",
".",
"walk",
"(",
"path",
",",
"walkFn",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
... | Save directory structure. @param {String} path @param {Object} obj @param {Function} cb | [
"Save",
"directory",
"structure",
"."
] | ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L31-L57 | train |
wercker/directory-to-object | index.js | saveFiles | function saveFiles(path, opts, obj, cb) {
const noDot = opts.noDot
var root = ''
walk.walk(path, walkFn, function (err) {
if (err) cb(err)
cb(null, obj)
})
function walkFn(baseDir, filename, stat, next) {
if (!root) root = baseDir
baseDir = stripLeadingSlash(baseDir.split(root)[1])
if ... | javascript | function saveFiles(path, opts, obj, cb) {
const noDot = opts.noDot
var root = ''
walk.walk(path, walkFn, function (err) {
if (err) cb(err)
cb(null, obj)
})
function walkFn(baseDir, filename, stat, next) {
if (!root) root = baseDir
baseDir = stripLeadingSlash(baseDir.split(root)[1])
if ... | [
"function",
"saveFiles",
"(",
"path",
",",
"opts",
",",
"obj",
",",
"cb",
")",
"{",
"const",
"noDot",
"=",
"opts",
".",
"noDot",
"var",
"root",
"=",
"''",
"walk",
".",
"walk",
"(",
"path",
",",
"walkFn",
",",
"function",
"(",
"err",
")",
"{",
"if... | Save filenames in dir structure. @param {String} path @param {Object} opts @param {Object} obj @param {Function} cb | [
"Save",
"filenames",
"in",
"dir",
"structure",
"."
] | ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L64-L84 | train |
wercker/directory-to-object | index.js | setObject | function setObject(path, obj, val) {
path = path.split('/')
path.forEach(function(subPath) {
obj = obj[subPath] = obj[subPath] || val
})
} | javascript | function setObject(path, obj, val) {
path = path.split('/')
path.forEach(function(subPath) {
obj = obj[subPath] = obj[subPath] || val
})
} | [
"function",
"setObject",
"(",
"path",
",",
"obj",
",",
"val",
")",
"{",
"path",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"path",
".",
"forEach",
"(",
"function",
"(",
"subPath",
")",
"{",
"obj",
"=",
"obj",
"[",
"subPath",
"]",
"=",
"obj",
"["... | Set a nested value on an object. @param {String} path @param {Object} obj @param {Any} value | [
"Set",
"a",
"nested",
"value",
"on",
"an",
"object",
"."
] | ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L97-L102 | train |
wercker/directory-to-object | index.js | pushArr | function pushArr(path, obj, val) {
path = path.split('/')
path.forEach(function(subPath) {
if (Array.isArray(obj[subPath])) return obj[subPath].push(val)
obj = obj[subPath]
})
} | javascript | function pushArr(path, obj, val) {
path = path.split('/')
path.forEach(function(subPath) {
if (Array.isArray(obj[subPath])) return obj[subPath].push(val)
obj = obj[subPath]
})
} | [
"function",
"pushArr",
"(",
"path",
",",
"obj",
",",
"val",
")",
"{",
"path",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"path",
".",
"forEach",
"(",
"function",
"(",
"subPath",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
"[",
"sub... | Push a value to an array nested in an object. @param {String} path @param {Object} opts @param {Object} obj @param {Any} value | [
"Push",
"a",
"value",
"to",
"an",
"array",
"nested",
"in",
"an",
"object",
"."
] | ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L109-L115 | train |
tdreyno/morlock.js | controllers/scroll-position-controller.js | ScrollPositionController | function ScrollPositionController(targetScrollY) {
if (!(this instanceof ScrollPositionController)) {
return new ScrollPositionController(targetScrollY);
}
Emitter.mixin(this);
var trackerStream = ScrollTrackerStream.create(targetScrollY);
Stream.onValue(trackerStream, Util.partial(this.trigger, 'both')... | javascript | function ScrollPositionController(targetScrollY) {
if (!(this instanceof ScrollPositionController)) {
return new ScrollPositionController(targetScrollY);
}
Emitter.mixin(this);
var trackerStream = ScrollTrackerStream.create(targetScrollY);
Stream.onValue(trackerStream, Util.partial(this.trigger, 'both')... | [
"function",
"ScrollPositionController",
"(",
"targetScrollY",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ScrollPositionController",
")",
")",
"{",
"return",
"new",
"ScrollPositionController",
"(",
"targetScrollY",
")",
";",
"}",
"Emitter",
".",
"mixin",... | Provides a familiar OO-style API for tracking scroll position.
@constructor
@param {Element} targetScrollY The position to track.
@return {Object} The API with a `on` function to attach scrollEnd
callbacks and an `observeElement` function to detect when elements
enter and exist the viewport. | [
"Provides",
"a",
"familiar",
"OO",
"-",
"style",
"API",
"for",
"tracking",
"scroll",
"position",
"."
] | a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/controllers/scroll-position-controller.js#L14-L29 | train |
tdreyno/morlock.js | streams/scroll-tracker-stream.js | create | function create(targetScrollY) {
var scrollPositionStream = ScrollStream.create();
var overTheLineStream = Stream.create();
var pastScrollY = false;
var firstRun = true;
Stream.onValue(scrollPositionStream, function onScrollTrackPosition_(currentScrollY) {
if ((firstRun || pastScrollY) && (currentScrollY... | javascript | function create(targetScrollY) {
var scrollPositionStream = ScrollStream.create();
var overTheLineStream = Stream.create();
var pastScrollY = false;
var firstRun = true;
Stream.onValue(scrollPositionStream, function onScrollTrackPosition_(currentScrollY) {
if ((firstRun || pastScrollY) && (currentScrollY... | [
"function",
"create",
"(",
"targetScrollY",
")",
"{",
"var",
"scrollPositionStream",
"=",
"ScrollStream",
".",
"create",
"(",
")",
";",
"var",
"overTheLineStream",
"=",
"Stream",
".",
"create",
"(",
")",
";",
"var",
"pastScrollY",
"=",
"false",
";",
"var",
... | Create a new Stream containing events which fire when a position has
been scrolled past.
@param {number} targetScrollY The position we are tracking.
@return {Stream} The resulting stream. | [
"Create",
"a",
"new",
"Stream",
"containing",
"events",
"which",
"fire",
"when",
"a",
"position",
"has",
"been",
"scrolled",
"past",
"."
] | a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/streams/scroll-tracker-stream.js#L10-L29 | train |
cyrillef/forge.model.derivative-js | src/model/JobPayloadItem.js | function(type) {
var _this = this;
JobSvfOutputPayload.call(_this, type);
JobThumbnailOutputPayload.call(_this, type);
JobStlOutputPayload.call(_this, type);
JobStepOutputPayload.call(_this, type);
JobIgesOutputPayload.call(_this, type);
JobObjOutputPayload.call(_this, type);
} | javascript | function(type) {
var _this = this;
JobSvfOutputPayload.call(_this, type);
JobThumbnailOutputPayload.call(_this, type);
JobStlOutputPayload.call(_this, type);
JobStepOutputPayload.call(_this, type);
JobIgesOutputPayload.call(_this, type);
JobObjOutputPayload.call(_this, type);
} | [
"function",
"(",
"type",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"JobSvfOutputPayload",
".",
"call",
"(",
"_this",
",",
"type",
")",
";",
"JobThumbnailOutputPayload",
".",
"call",
"(",
"_this",
",",
"type",
")",
";",
"JobStlOutputPayload",
".",
"call",... | The JobPayloadItem model module.
@module model/JobPayloadItem
Constructs a new <code>JobPayloadItem</code>.
Output description object, depends of the type
@alias module:model/JobPayloadItem
@class
@implements module:model/JobSvfOutputPayload
@implements module:model/JobThumbnailOutputPayload
@implements module:model/... | [
"The",
"JobPayloadItem",
"model",
"module",
"."
] | 519966c12679820027e623b615868e7b7913cecc | https://github.com/cyrillef/forge.model.derivative-js/blob/519966c12679820027e623b615868e7b7913cecc/src/model/JobPayloadItem.js#L67-L76 | train | |
tdreyno/morlock.js | controllers/resize-controller.js | ResizeController | function ResizeController(options) {
if (!(this instanceof ResizeController)) {
return new ResizeController(options);
}
Emitter.mixin(this);
options = options || {};
var resizeStream = ResizeStream.create(options);
Stream.onValue(resizeStream, Util.partial(this.trigger, 'resize'));
var debounceMs ... | javascript | function ResizeController(options) {
if (!(this instanceof ResizeController)) {
return new ResizeController(options);
}
Emitter.mixin(this);
options = options || {};
var resizeStream = ResizeStream.create(options);
Stream.onValue(resizeStream, Util.partial(this.trigger, 'resize'));
var debounceMs ... | [
"function",
"ResizeController",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ResizeController",
")",
")",
"{",
"return",
"new",
"ResizeController",
"(",
"options",
")",
";",
"}",
"Emitter",
".",
"mixin",
"(",
"this",
")",
";",
"o... | Provides a familiar OO-style API for tracking resize events.
@constructor
@param {Object=} options The options passed to the resize tracker.
@return {Object} The API with a `on` function to attach callbacks
to resize events and breakpoint changes. | [
"Provides",
"a",
"familiar",
"OO",
"-",
"style",
"API",
"for",
"tracking",
"resize",
"events",
"."
] | a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/controllers/resize-controller.js#L13-L37 | train |
jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | maybeTriggerImageLoad | function maybeTriggerImageLoad(image, event) {
if (!image.getAttribute('data-loaded') && isElementVisible(image)) {
image.dispatchEvent(event);
return true;
}
return false;
} | javascript | function maybeTriggerImageLoad(image, event) {
if (!image.getAttribute('data-loaded') && isElementVisible(image)) {
image.dispatchEvent(event);
return true;
}
return false;
} | [
"function",
"maybeTriggerImageLoad",
"(",
"image",
",",
"event",
")",
"{",
"if",
"(",
"!",
"image",
".",
"getAttribute",
"(",
"'data-loaded'",
")",
"&&",
"isElementVisible",
"(",
"image",
")",
")",
"{",
"image",
".",
"dispatchEvent",
"(",
"event",
")",
";"... | Check if an image is visible and trigger an event if so.
@param {Element} image the image to check
@param {Event} event an event to dispatch if the image is in the viewport
@return {Boolean} true if the image is in the viewport; false if not | [
"Check",
"if",
"an",
"image",
"is",
"visible",
"and",
"trigger",
"an",
"event",
"if",
"so",
"."
] | d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L54-L62 | train |
jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | loadImage | function loadImage(event) {
var image = event.target;
// Swap in the srcset info and add an attribute to prevent duplicate loads.
image.srcset = image.getAttribute('data-lazyload');
image.setAttribute('data-loaded', true);
} | javascript | function loadImage(event) {
var image = event.target;
// Swap in the srcset info and add an attribute to prevent duplicate loads.
image.srcset = image.getAttribute('data-lazyload');
image.setAttribute('data-loaded', true);
} | [
"function",
"loadImage",
"(",
"event",
")",
"{",
"var",
"image",
"=",
"event",
".",
"target",
";",
"// Swap in the srcset info and add an attribute to prevent duplicate loads.",
"image",
".",
"srcset",
"=",
"image",
".",
"getAttribute",
"(",
"'data-lazyload'",
")",
";... | This almost seems too easy, but we simply swap in the correct srcset.
@param {Event} event the triggered event
@return {Void} | [
"This",
"almost",
"seems",
"too",
"easy",
"but",
"we",
"simply",
"swap",
"in",
"the",
"correct",
"srcset",
"."
] | d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L78-L84 | train |
jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | removeLoadingClass | function removeLoadingClass(image, loadingClass) {
var element = image;
var shouldReturn = false;
/*
* Since there may be additional elements wrapping the image (e.g. a link),
* we run a loop to check the image’s ancestors until we either find the
* element with the loading class or hit the `body` eleme... | javascript | function removeLoadingClass(image, loadingClass) {
var element = image;
var shouldReturn = false;
/*
* Since there may be additional elements wrapping the image (e.g. a link),
* we run a loop to check the image’s ancestors until we either find the
* element with the loading class or hit the `body` eleme... | [
"function",
"removeLoadingClass",
"(",
"image",
",",
"loadingClass",
")",
"{",
"var",
"element",
"=",
"image",
";",
"var",
"shouldReturn",
"=",
"false",
";",
"/*\n * Since there may be additional elements wrapping the image (e.g. a link),\n * we run a loop to check the image’... | Remove the loading class from the lazyload wrapper.
@param {Element} image the image being loaded
@param {String} loadingClass the class to remove
@return {Void} | [
"Remove",
"the",
"loading",
"class",
"from",
"the",
"lazyload",
"wrapper",
"."
] | d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L92-L113 | train |
jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | initialize | function initialize(_ref) {
var _ref$containerClass = _ref.containerClass,
containerClass = _ref$containerClass === undefined ? 'js--lazyload' : _ref$containerClass,
_ref$loadingClass = _ref.loadingClass,
loadingClass = _ref$loadingClass === undefined ? 'js--lazyload--loading' : _ref$loadingClass,
... | javascript | function initialize(_ref) {
var _ref$containerClass = _ref.containerClass,
containerClass = _ref$containerClass === undefined ? 'js--lazyload' : _ref$containerClass,
_ref$loadingClass = _ref.loadingClass,
loadingClass = _ref$loadingClass === undefined ? 'js--lazyload--loading' : _ref$loadingClass,
... | [
"function",
"initialize",
"(",
"_ref",
")",
"{",
"var",
"_ref$containerClass",
"=",
"_ref",
".",
"containerClass",
",",
"containerClass",
"=",
"_ref$containerClass",
"===",
"undefined",
"?",
"'js--lazyload'",
":",
"_ref$containerClass",
",",
"_ref$loadingClass",
"=",
... | Initializes the lazyloader and adds the relevant classes and handlers.
@param {String} options.containerClass the lazyloaded image wrapper
@param {String} options.loadingClass the class that signifies loading
@param {Function} options.callback a function to fire on image load
@return {Function} ... | [
"Initializes",
"the",
"lazyloader",
"and",
"adds",
"the",
"relevant",
"classes",
"and",
"handlers",
"."
] | d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L128-L185 | train |
jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | lazyLoadImages | function lazyLoadImages() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// If we have `srcset` support, initialize the lazyloader.
/* istanbul ignore else: unreasonable to test browser support just for a no-op */
if ('srcset' in document.createElement('img')) {
retu... | javascript | function lazyLoadImages() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// If we have `srcset` support, initialize the lazyloader.
/* istanbul ignore else: unreasonable to test browser support just for a no-op */
if ('srcset' in document.createElement('img')) {
retu... | [
"function",
"lazyLoadImages",
"(",
")",
"{",
"var",
"config",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"{",
"}",
";",
"// If we have `srcset` support, initialize th... | The public function to initialize lazyloading
@param {Object} config configuration options (see `initialize()`)
@return {Function} a function to manually check for images to lazy load | [
"The",
"public",
"function",
"to",
"initialize",
"lazyloading"
] | d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L192-L206 | train |
djett41/node-feedjett | lib/feedjett.js | FeedJett | function FeedJett (options) {
if (!(this instanceof FeedJett)) {
return new FeedJett(options);
}
TransformStream.call(this);
this._readableState.objectMode = true;
this._readableState.highWaterMark = 16; // max. # of output nodes buffered
this.init();
this.parseOptions(options);
sax.MAX_BUFFER_LE... | javascript | function FeedJett (options) {
if (!(this instanceof FeedJett)) {
return new FeedJett(options);
}
TransformStream.call(this);
this._readableState.objectMode = true;
this._readableState.highWaterMark = 16; // max. # of output nodes buffered
this.init();
this.parseOptions(options);
sax.MAX_BUFFER_LE... | [
"function",
"FeedJett",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"FeedJett",
")",
")",
"{",
"return",
"new",
"FeedJett",
"(",
"options",
")",
";",
"}",
"TransformStream",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_... | FeedJett constructor. Most apps will only use one instance.
Exposes a duplex (transform) stream to parse a feed. | [
"FeedJett",
"constructor",
".",
"Most",
"apps",
"will",
"only",
"use",
"one",
"instance",
"."
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/feedjett.js#L54-L76 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/console.js | Console | function Console(game, messageHistoryCount, elClassName) {
this.el = document.createElement('div');
this.el.className = elClassName || 'console';
this.messageHistoryCount = messageHistoryCount || this.messageHistoryCount;
this.game = game;
} | javascript | function Console(game, messageHistoryCount, elClassName) {
this.el = document.createElement('div');
this.el.className = elClassName || 'console';
this.messageHistoryCount = messageHistoryCount || this.messageHistoryCount;
this.game = game;
} | [
"function",
"Console",
"(",
"game",
",",
"messageHistoryCount",
",",
"elClassName",
")",
"{",
"this",
".",
"el",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"this",
".",
"el",
".",
"className",
"=",
"elClassName",
"||",
"'console'",
";",... | Manages the display and history of console messages to the user.
"The troll hits you dealing 10 damage."
"You die."
@class Console
@constructor
@param {Game} game - Game instance this obj is attached to.
@param {Number} [messageHistoryCount=5] - Number of messages to display at once.
@param {String} [elClassName='conso... | [
"Manages",
"the",
"display",
"and",
"history",
"of",
"console",
"messages",
"to",
"the",
"user",
".",
"The",
"troll",
"hits",
"you",
"dealing",
"10",
"damage",
".",
"You",
"die",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/console.js#L14-L19 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/console.js | function(message){
if(this.el.children.length > this.messageHistoryCount - 1){
var childEl = this.el.childNodes[0];
childEl.remove();
}
var messageEl = document.createElement('div');
messageEl.innerHTML = message;
this.el.appen... | javascript | function(message){
if(this.el.children.length > this.messageHistoryCount - 1){
var childEl = this.el.childNodes[0];
childEl.remove();
}
var messageEl = document.createElement('div');
messageEl.innerHTML = message;
this.el.appen... | [
"function",
"(",
"message",
")",
"{",
"if",
"(",
"this",
".",
"el",
".",
"children",
".",
"length",
">",
"this",
".",
"messageHistoryCount",
"-",
"1",
")",
"{",
"var",
"childEl",
"=",
"this",
".",
"el",
".",
"childNodes",
"[",
"0",
"]",
";",
"child... | Adds a message to the console.
@method log
@param {String} - Message to be added. | [
"Adds",
"a",
"message",
"to",
"the",
"console",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/console.js#L51-L61 | train | |
commenthol/debug-level | src/node.js | Log | function Log (name, opts) {
if (!(this instanceof Log)) return new Log(name, opts)
Object.assign(options,
inspectOpts(process.env),
inspectNamespaces(process.env)
)
LogBase.call(this, name, Object.assign({}, options, opts))
const colorFn = (n) => chalk.hex(n)
this.color = selectColor(name, colorFn)
... | javascript | function Log (name, opts) {
if (!(this instanceof Log)) return new Log(name, opts)
Object.assign(options,
inspectOpts(process.env),
inspectNamespaces(process.env)
)
LogBase.call(this, name, Object.assign({}, options, opts))
const colorFn = (n) => chalk.hex(n)
this.color = selectColor(name, colorFn)
... | [
"function",
"Log",
"(",
"name",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Log",
")",
")",
"return",
"new",
"Log",
"(",
"name",
",",
"opts",
")",
"Object",
".",
"assign",
"(",
"options",
",",
"inspectOpts",
"(",
"process",
"... | creates a new logger
@constructor
@param {String} name - namespace of Logger | [
"creates",
"a",
"new",
"logger"
] | e310fe5452984d898adfb8f924ac6f9021b05457 | https://github.com/commenthol/debug-level/blob/e310fe5452984d898adfb8f924ac6f9021b05457/src/node.js#L31-L44 | train |
Lanfei/websocket-lib | lib/client.js | ClientSession | function ClientSession(request, socket, head, client) {
Session.call(this, request, socket, head);
/**
* The client instance of this session.
* @type {Client}
*/
this.client = client;
this.state = Session.STATE_OPEN;
this._init();
} | javascript | function ClientSession(request, socket, head, client) {
Session.call(this, request, socket, head);
/**
* The client instance of this session.
* @type {Client}
*/
this.client = client;
this.state = Session.STATE_OPEN;
this._init();
} | [
"function",
"ClientSession",
"(",
"request",
",",
"socket",
",",
"head",
",",
"client",
")",
"{",
"Session",
".",
"call",
"(",
"this",
",",
"request",
",",
"socket",
",",
"head",
")",
";",
"/**\n\t * The client instance of this session.\n\t * @type {Client}\n\t */",... | WebSocket Client Session
@constructor
@extends Session
@param {IncomingMessage} request see {@link Session#request}
@param {Socket} socket see {@link Session#socket}
@param {Buffer} [head] Data that received with headers.
@param {Client} [client] see {@link ClientSession#cli... | [
"WebSocket",
"Client",
"Session"
] | d39f704490fb91b1e2897712b280c0e5ac79e123 | https://github.com/Lanfei/websocket-lib/blob/d39f704490fb91b1e2897712b280c0e5ac79e123/lib/client.js#L131-L143 | train |
CodersBrothers/coolors | coolors.js | coolors | function coolors(msg, config){
if(supportsColor) {
switch (typeof config) {
case 'string':
if(plugins[config]){
msg = plugins[config](msg);
}
break;
case 'object':
var decorators = Object.... | javascript | function coolors(msg, config){
if(supportsColor) {
switch (typeof config) {
case 'string':
if(plugins[config]){
msg = plugins[config](msg);
}
break;
case 'object':
var decorators = Object.... | [
"function",
"coolors",
"(",
"msg",
",",
"config",
")",
"{",
"if",
"(",
"supportsColor",
")",
"{",
"switch",
"(",
"typeof",
"config",
")",
"{",
"case",
"'string'",
":",
"if",
"(",
"plugins",
"[",
"config",
"]",
")",
"{",
"msg",
"=",
"plugins",
"[",
... | CREATE A COOL LOG
@param {String} msg
@param {String|Object} config | [
"CREATE",
"A",
"COOL",
"LOG"
] | 3d0d34ba285d156b14a25def5615d8c5c77d2032 | https://github.com/CodersBrothers/coolors/blob/3d0d34ba285d156b14a25def5615d8c5c77d2032/coolors.js#L58-L82 | train |
nodeca/plurals-cldr | index.js | add | function add(locales, rule) {
var i;
rule.c = rule.c ? rule.c.map(unpack) : [ 'other' ];
rule.o = rule.o ? rule.o.map(unpack) : [ 'other' ];
for (i = 0; i < locales.length; i++) {
s[locales[i]] = rule;
}
} | javascript | function add(locales, rule) {
var i;
rule.c = rule.c ? rule.c.map(unpack) : [ 'other' ];
rule.o = rule.o ? rule.o.map(unpack) : [ 'other' ];
for (i = 0; i < locales.length; i++) {
s[locales[i]] = rule;
}
} | [
"function",
"add",
"(",
"locales",
",",
"rule",
")",
"{",
"var",
"i",
";",
"rule",
".",
"c",
"=",
"rule",
".",
"c",
"?",
"rule",
".",
"c",
".",
"map",
"(",
"unpack",
")",
":",
"[",
"'other'",
"]",
";",
"rule",
".",
"o",
"=",
"rule",
".",
"o... | adds given `rule` pluralizer for given `locales` into `storage` | [
"adds",
"given",
"rule",
"pluralizer",
"for",
"given",
"locales",
"into",
"storage"
] | d93a4f130d0610605ff76761ef8e6abd4271639d | https://github.com/nodeca/plurals-cldr/blob/d93a4f130d0610605ff76761ef8e6abd4271639d/index.js#L108-L117 | train |
jonkemp/css-rules | index.js | extract | function extract(selectorText) {
var attr = 0,
sels = [],
sel = '',
i,
c,
l = selectorText.length;
for (i = 0; i < l; i++) {
c = selectorText.charAt(i);
if (attr) {
if (c === '[' || c === '(') {
attr--;
}
... | javascript | function extract(selectorText) {
var attr = 0,
sels = [],
sel = '',
i,
c,
l = selectorText.length;
for (i = 0; i < l; i++) {
c = selectorText.charAt(i);
if (attr) {
if (c === '[' || c === '(') {
attr--;
}
... | [
"function",
"extract",
"(",
"selectorText",
")",
"{",
"var",
"attr",
"=",
"0",
",",
"sels",
"=",
"[",
"]",
",",
"sel",
"=",
"''",
",",
"i",
",",
"c",
",",
"l",
"=",
"selectorText",
".",
"length",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",... | Returns an array of the selectors.
@license Sizzle CSS Selector Engine - MIT
@param {String} selectorText from cssom
@api public | [
"Returns",
"an",
"array",
"of",
"the",
"selectors",
"."
] | 7d13cf85f06d80d192189a797ed96df298f9b01d | https://github.com/jonkemp/css-rules/blob/7d13cf85f06d80d192189a797ed96df298f9b01d/index.js#L13-L47 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | MultiObjectManager | function MultiObjectManager(game, ObjectConstructor, width, height) {
this.game = game;
this.ObjectConstructor = ObjectConstructor;
this.objects = [];
this.map = new RL.Array2d();
this.setSize(width, height);
var map = this.map;
this.map.each(function(val, x, y){... | javascript | function MultiObjectManager(game, ObjectConstructor, width, height) {
this.game = game;
this.ObjectConstructor = ObjectConstructor;
this.objects = [];
this.map = new RL.Array2d();
this.setSize(width, height);
var map = this.map;
this.map.each(function(val, x, y){... | [
"function",
"MultiObjectManager",
"(",
"game",
",",
"ObjectConstructor",
",",
"width",
",",
"height",
")",
"{",
"this",
".",
"game",
"=",
"game",
";",
"this",
".",
"ObjectConstructor",
"=",
"ObjectConstructor",
";",
"this",
".",
"objects",
"=",
"[",
"]",
"... | Manages a list of object and their tile positions.
Multiple objects can be at a given tile map coord.
Handles adding, removing, moving objects within the game.
@class MultiObjectManager
@constructor
@param {Game} game - Game instance this `MultiObjectManager` is attached to.
@param {Object} ObjectConstructor - Object c... | [
"Manages",
"a",
"list",
"of",
"object",
"and",
"their",
"tile",
"positions",
".",
"Multiple",
"objects",
"can",
"be",
"at",
"a",
"given",
"tile",
"map",
"coord",
".",
"Handles",
"adding",
"removing",
"moving",
"objects",
"within",
"the",
"game",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L15-L26 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, filter) {
if(filter){
var result = this.map.get(x, y);
if(result){
return result.filter(filter);
}
}
return this.map.get(x, y);
} | javascript | function(x, y, filter) {
if(filter){
var result = this.map.get(x, y);
if(result){
return result.filter(filter);
}
}
return this.map.get(x, y);
} | [
"function",
"(",
"x",
",",
"y",
",",
"filter",
")",
"{",
"if",
"(",
"filter",
")",
"{",
"var",
"result",
"=",
"this",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"if",
"(",
"result",
")",
"{",
"return",
"result",
".",
"filter",
"(",... | Retrieves all objects at given map tile coord.
@method get
@param {Number} x - The tile map x coord.
@param {Number} y - The tile map y coord.
@param {Function} [filter] - A function to filter the array of objects returned `function(object){ return true }`.
@return {Array} | [
"Retrieves",
"all",
"objects",
"at",
"given",
"map",
"tile",
"coord",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L60-L68 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, filter){
var arr = this.map.get(x, y);
if(arr){
if(filter){
for(var i = arr.length - 1; i >= 0; i--){
var item = arr[i];
if(filter(item)){
return item;
... | javascript | function(x, y, filter){
var arr = this.map.get(x, y);
if(arr){
if(filter){
for(var i = arr.length - 1; i >= 0; i--){
var item = arr[i];
if(filter(item)){
return item;
... | [
"function",
"(",
"x",
",",
"y",
",",
"filter",
")",
"{",
"var",
"arr",
"=",
"this",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"if",
"(",
"arr",
")",
"{",
"if",
"(",
"filter",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"arr",
".",
... | Retrieves the last object in array at given map tile coord.
@method getLast
@param {Number} x - The tile map x coord.
@param {Number} y - The tile map y coord.
@param {Function} [filter] - A function to filter the object returned at this map tile coord `function(object){ return true }`. The last object in the array th... | [
"Retrieves",
"the",
"last",
"object",
"in",
"array",
"at",
"given",
"map",
"tile",
"coord",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L103-L117 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, obj) {
if(typeof obj === 'string'){
obj = this.makeNewObjectFromType(obj);
}
obj.game = this.game;
obj.x = x;
obj.y = y;
this.objects.push(obj);
var arr = this.map.get(x, y);
arr.push(obj);
... | javascript | function(x, y, obj) {
if(typeof obj === 'string'){
obj = this.makeNewObjectFromType(obj);
}
obj.game = this.game;
obj.x = x;
obj.y = y;
this.objects.push(obj);
var arr = this.map.get(x, y);
arr.push(obj);
... | [
"function",
"(",
"x",
",",
"y",
",",
"obj",
")",
"{",
"if",
"(",
"typeof",
"obj",
"===",
"'string'",
")",
"{",
"obj",
"=",
"this",
".",
"makeNewObjectFromType",
"(",
"obj",
")",
";",
"}",
"obj",
".",
"game",
"=",
"this",
".",
"game",
";",
"obj",
... | Adds an object to the manager at given map tile coord. Multiple objects can be added to the same coord.
@method add
@param {Number} x - Map tile coord x.
@param {Number} y - Map tile coord y.
@param {Object|String} obj - The Object being set at given coords. If `obj` is a string a new Object will be created using `this... | [
"Adds",
"an",
"object",
"to",
"the",
"manager",
"at",
"given",
"map",
"tile",
"coord",
".",
"Multiple",
"objects",
"can",
"be",
"added",
"to",
"the",
"same",
"coord",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L127-L141 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(obj) {
var arr = this.map.get(obj.x, obj.y);
var index = arr.indexOf(obj);
arr.splice(index, 1);
index = this.objects.indexOf(obj);
this.objects.splice(index, 1);
if(obj.onRemove){
obj.onRemove();
}
} | javascript | function(obj) {
var arr = this.map.get(obj.x, obj.y);
var index = arr.indexOf(obj);
arr.splice(index, 1);
index = this.objects.indexOf(obj);
this.objects.splice(index, 1);
if(obj.onRemove){
obj.onRemove();
}
} | [
"function",
"(",
"obj",
")",
"{",
"var",
"arr",
"=",
"this",
".",
"map",
".",
"get",
"(",
"obj",
".",
"x",
",",
"obj",
".",
"y",
")",
";",
"var",
"index",
"=",
"arr",
".",
"indexOf",
"(",
"obj",
")",
";",
"arr",
".",
"splice",
"(",
"index",
... | Removes an entity from the manager.
@method remove
@param {Obj} obj - The objity to be removed. | [
"Removes",
"an",
"entity",
"from",
"the",
"manager",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L148-L157 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, filter){
var arr = this.get(x, y, filter);
for(var i = arr.length - 1; i >= 0; i--){
this.remove(arr[i]);
}
} | javascript | function(x, y, filter){
var arr = this.get(x, y, filter);
for(var i = arr.length - 1; i >= 0; i--){
this.remove(arr[i]);
}
} | [
"function",
"(",
"x",
",",
"y",
",",
"filter",
")",
"{",
"var",
"arr",
"=",
"this",
".",
"get",
"(",
"x",
",",
"y",
",",
"filter",
")",
";",
"for",
"(",
"var",
"i",
"=",
"arr",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",... | Remove all objects from given location.
@method removeAt
@param {Number} x - Tile map x coord.
@param {Number} y - Tile map y coord.
@param {Function} [filter] - A function to filter the objects removed `function(object){ return true }`. | [
"Remove",
"all",
"objects",
"from",
"given",
"location",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L166-L171 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, object) {
this.remove(object);
object.x = x;
object.y = y;
this.add(x, y, object);
} | javascript | function(x, y, object) {
this.remove(object);
object.x = x;
object.y = y;
this.add(x, y, object);
} | [
"function",
"(",
"x",
",",
"y",
",",
"object",
")",
"{",
"this",
".",
"remove",
"(",
"object",
")",
";",
"object",
".",
"x",
"=",
"x",
";",
"object",
".",
"y",
"=",
"y",
";",
"this",
".",
"add",
"(",
"x",
",",
"y",
",",
"object",
")",
";",
... | Changes the position of an entity already added to this entityManager.
@method move
@param {Number} x - The new map tile coordinate position of the entity on the x axis.
@param {Number} y - The new map tile coordinate position of the entity on the y axis.
@param {Obj} object - The objectity to be removed. | [
"Changes",
"the",
"position",
"of",
"an",
"entity",
"already",
"added",
"to",
"this",
"entityManager",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L180-L185 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function() {
this.objects = [];
this.map.reset();
var map = this.map;
this.map.each(function(val, x, y){
map.set(x, y, []);
});
} | javascript | function() {
this.objects = [];
this.map.reset();
var map = this.map;
this.map.each(function(val, x, y){
map.set(x, y, []);
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"objects",
"=",
"[",
"]",
";",
"this",
".",
"map",
".",
"reset",
"(",
")",
";",
"var",
"map",
"=",
"this",
".",
"map",
";",
"this",
".",
"map",
".",
"each",
"(",
"function",
"(",
"val",
",",
"x",
",",
... | Resets this entityManager.
@method reset | [
"Resets",
"this",
"entityManager",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L191-L198 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(width, height){
this.map.setSize(width, height);
var map = this.map;
this.map.each(function(val, x, y){
if(val === void 0){
map.set(x, y, []);
}
});
} | javascript | function(width, height){
this.map.setSize(width, height);
var map = this.map;
this.map.each(function(val, x, y){
if(val === void 0){
map.set(x, y, []);
}
});
} | [
"function",
"(",
"width",
",",
"height",
")",
"{",
"this",
".",
"map",
".",
"setSize",
"(",
"width",
",",
"height",
")",
";",
"var",
"map",
"=",
"this",
".",
"map",
";",
"this",
".",
"map",
".",
"each",
"(",
"function",
"(",
"val",
",",
"x",
",... | Sets the size of the map to manage objects within.
@method setSize
@param {Number} width - Width of current map in tiles.
@param {Number} height - Height of current map in tiles. | [
"Sets",
"the",
"size",
"of",
"the",
"map",
"to",
"manage",
"objects",
"within",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L206-L214 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, settings){
settings = settings || {};
if(settings.filter){
var filter = settings.filter;
settings.filter = function(objects){
return objects.filter(filter);
};
}
var results = this.map.getA... | javascript | function(x, y, settings){
settings = settings || {};
if(settings.filter){
var filter = settings.filter;
settings.filter = function(objects){
return objects.filter(filter);
};
}
var results = this.map.getA... | [
"function",
"(",
"x",
",",
"y",
",",
"settings",
")",
"{",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"if",
"(",
"settings",
".",
"filter",
")",
"{",
"var",
"filter",
"=",
"settings",
".",
"filter",
";",
"settings",
".",
"filter",
"=",
"func... | Same as `this.map.getAdjacent`, but merges all results into on flat array.
@method getAdjacent
@param {Number} x - Map tile x coord.
@param {Number} y - Map tile y coord;
@param {Object} [settings]
@return {Array} | [
"Same",
"as",
"this",
".",
"map",
".",
"getAdjacent",
"but",
"merges",
"all",
"results",
"into",
"on",
"flat",
"array",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L224-L236 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/player.js | Player | function Player(game) {
this.game = game;
this.fov = new RL.FovROT(game);
// modify fov to set tiles as explored
this.fov.setMapTileVisible = function(x, y, range, visibility){
RL.FovROT.prototype.setMapTileVisible.call(this, x, y, range, visibility);
if(visibili... | javascript | function Player(game) {
this.game = game;
this.fov = new RL.FovROT(game);
// modify fov to set tiles as explored
this.fov.setMapTileVisible = function(x, y, range, visibility){
RL.FovROT.prototype.setMapTileVisible.call(this, x, y, range, visibility);
if(visibili... | [
"function",
"Player",
"(",
"game",
")",
"{",
"this",
".",
"game",
"=",
"game",
";",
"this",
".",
"fov",
"=",
"new",
"RL",
".",
"FovROT",
"(",
"game",
")",
";",
"// modify fov to set tiles as explored",
"this",
".",
"fov",
".",
"setMapTileVisible",
"=",
"... | Represents the player.
Very similar to Entity
Handles functionality triggered by keyboard and mouse Input
@class Player
@constructor
@uses TileDraw
@param {Game} game - game instance this obj is attached to | [
"Represents",
"the",
"player",
".",
"Very",
"similar",
"to",
"Entity",
"Handles",
"functionality",
"triggered",
"by",
"keyboard",
"and",
"mouse",
"Input"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/player.js#L13-L31 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/player.js | function(){
var x = this.x,
y = this.y,
fieldRange = this.fovFieldRange,
direction = this.fovDirection,
maxViewDistance = this.fovMaxViewDistance;
this.fov.update(x, y, fieldRange, direction, maxViewDistance, this);
} | javascript | function(){
var x = this.x,
y = this.y,
fieldRange = this.fovFieldRange,
direction = this.fovDirection,
maxViewDistance = this.fovMaxViewDistance;
this.fov.update(x, y, fieldRange, direction, maxViewDistance, this);
} | [
"function",
"(",
")",
"{",
"var",
"x",
"=",
"this",
".",
"x",
",",
"y",
"=",
"this",
".",
"y",
",",
"fieldRange",
"=",
"this",
".",
"fovFieldRange",
",",
"direction",
"=",
"this",
".",
"fovDirection",
",",
"maxViewDistance",
"=",
"this",
".",
"fovMax... | Updates this.fov
@method updateFov | [
"Updates",
"this",
".",
"fov"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/player.js#L144-L151 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/player.js | function(action) {
// if the action is a direction
if(RL.Util.DIRECTIONS_4.indexOf(action) !== -1){
var offsetCoord = RL.Util.getOffsetCoordsFromDirection(action),
moveToX = this.x + offsetCoord.x,
moveToY = this.y + offsetCoord.y;
... | javascript | function(action) {
// if the action is a direction
if(RL.Util.DIRECTIONS_4.indexOf(action) !== -1){
var offsetCoord = RL.Util.getOffsetCoordsFromDirection(action),
moveToX = this.x + offsetCoord.x,
moveToY = this.y + offsetCoord.y;
... | [
"function",
"(",
"action",
")",
"{",
"// if the action is a direction",
"if",
"(",
"RL",
".",
"Util",
".",
"DIRECTIONS_4",
".",
"indexOf",
"(",
"action",
")",
"!==",
"-",
"1",
")",
"{",
"var",
"offsetCoord",
"=",
"RL",
".",
"Util",
".",
"getOffsetCoordsFro... | Called when user key is pressed with action of key pressed as an arg.
@method update
@param {String} action - action bound to key pressed by user
@return {Bool} true if action was taken. | [
"Called",
"when",
"user",
"key",
"is",
"pressed",
"with",
"action",
"of",
"key",
"pressed",
"as",
"an",
"arg",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/player.js#L181-L196 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/player.js | function(x, y){
if(this.canMoveTo(x, y)){
this.moveTo(x, y);
return true;
} else {
// entity occupying target tile (if any)
var targetTileEnt = this.game.entityManager.get(x, y);
// if already occupied
... | javascript | function(x, y){
if(this.canMoveTo(x, y)){
this.moveTo(x, y);
return true;
} else {
// entity occupying target tile (if any)
var targetTileEnt = this.game.entityManager.get(x, y);
// if already occupied
... | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"if",
"(",
"this",
".",
"canMoveTo",
"(",
"x",
",",
"y",
")",
")",
"{",
"this",
".",
"moveTo",
"(",
"x",
",",
"y",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"// entity occupying target tile (if any... | Move action.
@method move
@param {Number} x - Map tile cood to move to.
@param {Number} y - Map tile cood to move to.
@return {Bool} true if action was taken. | [
"Move",
"action",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/player.js#L205-L223 | train | |
jonjomckay/jjgraph | javascript/examples/grapheditor/www/js/EditorUi.js | function(cells, asText)
{
graph.getModel().beginUpdate();
try
{
// Applies only basic text styles
if (asText)
{
var edge = graph.getModel().isEdge(cell);
var current = (edge) ? graph.currentEdgeStyle : graph.currentVertexStyle;
var textStyles = ['fontSize', 'fontFamily', 'fontColor'];
... | javascript | function(cells, asText)
{
graph.getModel().beginUpdate();
try
{
// Applies only basic text styles
if (asText)
{
var edge = graph.getModel().isEdge(cell);
var current = (edge) ? graph.currentEdgeStyle : graph.currentVertexStyle;
var textStyles = ['fontSize', 'fontFamily', 'fontColor'];
... | [
"function",
"(",
"cells",
",",
"asText",
")",
"{",
"graph",
".",
"getModel",
"(",
")",
".",
"beginUpdate",
"(",
")",
";",
"try",
"{",
"// Applies only basic text styles",
"if",
"(",
"asText",
")",
"{",
"var",
"edge",
"=",
"graph",
".",
"getModel",
"(",
... | Implements a global current style for edges and vertices that is applied to new cells | [
"Implements",
"a",
"global",
"current",
"style",
"for",
"edges",
"and",
"vertices",
"that",
"is",
"applied",
"to",
"new",
"cells"
] | f041596ea8cb33e7a47e8c029008f13b31a92469 | https://github.com/jonjomckay/jjgraph/blob/f041596ea8cb33e7a47e8c029008f13b31a92469/javascript/examples/grapheditor/www/js/EditorUi.js#L500-L594 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/fov-rot.js | function(direction){
var coord = RL.Util.getOffsetCoordsFromDirection(direction);
return [coord.x, coord.y];
} | javascript | function(direction){
var coord = RL.Util.getOffsetCoordsFromDirection(direction);
return [coord.x, coord.y];
} | [
"function",
"(",
"direction",
")",
"{",
"var",
"coord",
"=",
"RL",
".",
"Util",
".",
"getOffsetCoordsFromDirection",
"(",
"direction",
")",
";",
"return",
"[",
"coord",
".",
"x",
",",
"coord",
".",
"y",
"]",
";",
"}"
] | Converts a string direction to an rot direction
@method directionStringToArray
@param {String} direction - Direction of fov (used as default) (not used for fieldRange 360) valid directions: ['up', 'down', 'left', 'right', 'up_left', 'up_right', 'down_left', 'down_right'].
@return {Array} [x, y] | [
"Converts",
"a",
"string",
"direction",
"to",
"an",
"rot",
"direction"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/fov-rot.js#L89-L92 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/fov-rot.js | function(x, y, fieldRange, direction, maxViewDistance, entity){
if(fieldRange === void 0){
fieldRange = this.fieldRange;
}
if(direction === void 0){
direction = this.direction;
}
if(fieldRange !== 360 && typeof direction === ... | javascript | function(x, y, fieldRange, direction, maxViewDistance, entity){
if(fieldRange === void 0){
fieldRange = this.fieldRange;
}
if(direction === void 0){
direction = this.direction;
}
if(fieldRange !== 360 && typeof direction === ... | [
"function",
"(",
"x",
",",
"y",
",",
"fieldRange",
",",
"direction",
",",
"maxViewDistance",
",",
"entity",
")",
"{",
"if",
"(",
"fieldRange",
"===",
"void",
"0",
")",
"{",
"fieldRange",
"=",
"this",
".",
"fieldRange",
";",
"}",
"if",
"(",
"direction",... | Calculates the fovROT data relative to given coords.
@method update
@param {Number} x - The map coordinate position to calculate FovROT from on the x axis.
@param {Number} y - The map coordinate position to calculate FovROT from on the y axis.
@param {Number} [fieldRange = this.fieldRange || 360] - Field Range of view ... | [
"Calculates",
"the",
"fovROT",
"data",
"relative",
"to",
"given",
"coords",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/fov-rot.js#L104-L143 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/fov-rot.js | function(x, y, range, visibility){
this.fovMap.set(x, y, visibility);
if(visibility){
var tile = this.game.map.get(x, y);
if(tile){
var key = x + ',' + y;
// check for duplicates
if(this.visibleTileKeys.i... | javascript | function(x, y, range, visibility){
this.fovMap.set(x, y, visibility);
if(visibility){
var tile = this.game.map.get(x, y);
if(tile){
var key = x + ',' + y;
// check for duplicates
if(this.visibleTileKeys.i... | [
"function",
"(",
"x",
",",
"y",
",",
"range",
",",
"visibility",
")",
"{",
"this",
".",
"fovMap",
".",
"set",
"(",
"x",
",",
"y",
",",
"visibility",
")",
";",
"if",
"(",
"visibility",
")",
"{",
"var",
"tile",
"=",
"this",
".",
"game",
".",
"map... | Sets the visibility of a checked map tile
@method setMapTileVisible
@param {Number} x - The map coord position to set.
@param {Number} y - The map coord position to set.
@param {Number} range - The distance from this fov origin.
@param {Number} visibility - The visibility of this tile coord. | [
"Sets",
"the",
"visibility",
"of",
"a",
"checked",
"map",
"tile"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/fov-rot.js#L177-L195 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/manual-src/task.js | function(files, metalsmith, done){
var yuiDocsData = require('../docs/data.json');
var makeUrl = function(docClass, method){
var out = '/docs/classes/' + docClass + '.html';
if(method){
out += '#method_' + method;
}
... | javascript | function(files, metalsmith, done){
var yuiDocsData = require('../docs/data.json');
var makeUrl = function(docClass, method){
var out = '/docs/classes/' + docClass + '.html';
if(method){
out += '#method_' + method;
}
... | [
"function",
"(",
"files",
",",
"metalsmith",
",",
"done",
")",
"{",
"var",
"yuiDocsData",
"=",
"require",
"(",
"'../docs/data.json'",
")",
";",
"var",
"makeUrl",
"=",
"function",
"(",
"docClass",
",",
"method",
")",
"{",
"var",
"out",
"=",
"'/docs/classes/... | sets yui docs data to pages with "docs_class" set | [
"sets",
"yui",
"docs",
"data",
"to",
"pages",
"with",
"docs_class",
"set"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/manual-src/task.js#L64-L107 | train | |
jacoborus/deep-json | index.js | function (file) {
var folder = path.dirname(file) + '/' + path.basename( file, '.json' );
return fs.existsSync(folder) && isDir(folder) ? folder : false;
} | javascript | function (file) {
var folder = path.dirname(file) + '/' + path.basename( file, '.json' );
return fs.existsSync(folder) && isDir(folder) ? folder : false;
} | [
"function",
"(",
"file",
")",
"{",
"var",
"folder",
"=",
"path",
".",
"dirname",
"(",
"file",
")",
"+",
"'/'",
"+",
"path",
".",
"basename",
"(",
"file",
",",
"'.json'",
")",
";",
"return",
"fs",
".",
"existsSync",
"(",
"folder",
")",
"&&",
"isDir"... | return path of folder with same name as .json file if exists | [
"return",
"path",
"of",
"folder",
"with",
"same",
"name",
"as",
".",
"json",
"file",
"if",
"exists"
] | d41f35cc67b21b87c39da42d264bbdcf891ec93c | https://github.com/jacoborus/deep-json/blob/d41f35cc67b21b87c39da42d264bbdcf891ec93c/index.js#L13-L16 | train | |
jacoborus/deep-json | index.js | function (parent) {
var elems = fs.readdirSync( parent ),
d = {
files : [],
folders : []
};
// get files and folders paths
elems.forEach( function (elem) {
var el = parent + '/' + elem;
if (!isDir( el )) {
d.files.push( el );
} else if (!fs.existsSync( el + '.json')) {
// add folder only if ha... | javascript | function (parent) {
var elems = fs.readdirSync( parent ),
d = {
files : [],
folders : []
};
// get files and folders paths
elems.forEach( function (elem) {
var el = parent + '/' + elem;
if (!isDir( el )) {
d.files.push( el );
} else if (!fs.existsSync( el + '.json')) {
// add folder only if ha... | [
"function",
"(",
"parent",
")",
"{",
"var",
"elems",
"=",
"fs",
".",
"readdirSync",
"(",
"parent",
")",
",",
"d",
"=",
"{",
"files",
":",
"[",
"]",
",",
"folders",
":",
"[",
"]",
"}",
";",
"// get files and folders paths",
"elems",
".",
"forEach",
"(... | get the paths of files and folders inside a folder | [
"get",
"the",
"paths",
"of",
"files",
"and",
"folders",
"inside",
"a",
"folder"
] | d41f35cc67b21b87c39da42d264bbdcf891ec93c | https://github.com/jacoborus/deep-json/blob/d41f35cc67b21b87c39da42d264bbdcf891ec93c/index.js#L19-L38 | train | |
jacoborus/deep-json | index.js | function (file) {
var config = require( file ),
namesake = getNamesake( file );
return namesake ? extend( config, getData.folder( namesake )) : config;
} | javascript | function (file) {
var config = require( file ),
namesake = getNamesake( file );
return namesake ? extend( config, getData.folder( namesake )) : config;
} | [
"function",
"(",
"file",
")",
"{",
"var",
"config",
"=",
"require",
"(",
"file",
")",
",",
"namesake",
"=",
"getNamesake",
"(",
"file",
")",
";",
"return",
"namesake",
"?",
"extend",
"(",
"config",
",",
"getData",
".",
"folder",
"(",
"namesake",
")",
... | get file data and extend it with folder data of folder with same name | [
"get",
"file",
"data",
"and",
"extend",
"it",
"with",
"folder",
"data",
"of",
"folder",
"with",
"same",
"name"
] | d41f35cc67b21b87c39da42d264bbdcf891ec93c | https://github.com/jacoborus/deep-json/blob/d41f35cc67b21b87c39da42d264bbdcf891ec93c/index.js#L44-L49 | train | |
jacoborus/deep-json | index.js | function (folder) {
var elems = getFolderElements( folder ),
result = {};
// files
elems.files.forEach( function (route) {
// get object name
var fileName = path.basename( route, '.json' );
// assign object data from file
result[ fileName ] = getData.file( route );
});
// no namesake folders
... | javascript | function (folder) {
var elems = getFolderElements( folder ),
result = {};
// files
elems.files.forEach( function (route) {
// get object name
var fileName = path.basename( route, '.json' );
// assign object data from file
result[ fileName ] = getData.file( route );
});
// no namesake folders
... | [
"function",
"(",
"folder",
")",
"{",
"var",
"elems",
"=",
"getFolderElements",
"(",
"folder",
")",
",",
"result",
"=",
"{",
"}",
";",
"// files",
"elems",
".",
"files",
".",
"forEach",
"(",
"function",
"(",
"route",
")",
"{",
"// get object name",
"var",... | get data from folders and files inside a folder | [
"get",
"data",
"from",
"folders",
"and",
"files",
"inside",
"a",
"folder"
] | d41f35cc67b21b87c39da42d264bbdcf891ec93c | https://github.com/jacoborus/deep-json/blob/d41f35cc67b21b87c39da42d264bbdcf891ec93c/index.js#L52-L73 | train | |
commenthol/debug-level | src/browser.js | Log | function Log (name, opts) {
if (!(this instanceof Log)) return new Log(name, opts)
const _storage = storage()
Object.assign(options,
inspectOpts(_storage),
inspectNamespaces(_storage)
)
options.colors = options.colors === false ? false : supportsColors()
LogBase.call(this, name, Object.assign({}, o... | javascript | function Log (name, opts) {
if (!(this instanceof Log)) return new Log(name, opts)
const _storage = storage()
Object.assign(options,
inspectOpts(_storage),
inspectNamespaces(_storage)
)
options.colors = options.colors === false ? false : supportsColors()
LogBase.call(this, name, Object.assign({}, o... | [
"function",
"Log",
"(",
"name",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Log",
")",
")",
"return",
"new",
"Log",
"(",
"name",
",",
"opts",
")",
"const",
"_storage",
"=",
"storage",
"(",
")",
"Object",
".",
"assign",
"(",
... | creates a new logger for the browser
@constructor
@param {String} name - namespace of Logger | [
"creates",
"a",
"new",
"logger",
"for",
"the",
"browser"
] | e310fe5452984d898adfb8f924ac6f9021b05457 | https://github.com/commenthol/debug-level/blob/e310fe5452984d898adfb8f924ac6f9021b05457/src/browser.js#L82-L96 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/object-manager.js | ObjectManager | function ObjectManager(game, ObjectConstructor, width, height) {
this.game = game;
this.ObjectConstructor = ObjectConstructor;
this.objects = [];
this.map = new RL.Array2d(width, height);
} | javascript | function ObjectManager(game, ObjectConstructor, width, height) {
this.game = game;
this.ObjectConstructor = ObjectConstructor;
this.objects = [];
this.map = new RL.Array2d(width, height);
} | [
"function",
"ObjectManager",
"(",
"game",
",",
"ObjectConstructor",
",",
"width",
",",
"height",
")",
"{",
"this",
".",
"game",
"=",
"game",
";",
"this",
".",
"ObjectConstructor",
"=",
"ObjectConstructor",
";",
"this",
".",
"objects",
"=",
"[",
"]",
";",
... | Manages a list of all objects and their tile positions.
Handles adding, removing, moving objects within the game.
@class ObjectManager
@constructor
@param {Game} game - Game instance this `ObjectManager` is attached to.
@param {Object} ObjectConstructor - Object constructor used to create new objects with `this.add()`.... | [
"Manages",
"a",
"list",
"of",
"all",
"objects",
"and",
"their",
"tile",
"positions",
".",
"Handles",
"adding",
"removing",
"moving",
"objects",
"within",
"the",
"game",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/object-manager.js#L14-L19 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/object-manager.js | function(x, y, obj) {
if(typeof obj === 'string'){
obj = this.makeNewObjectFromType(obj);
}
var existing = this.get(x, y);
if(existing){
this.remove(existing);
}
obj.game = this.game;
obj.x = x;
... | javascript | function(x, y, obj) {
if(typeof obj === 'string'){
obj = this.makeNewObjectFromType(obj);
}
var existing = this.get(x, y);
if(existing){
this.remove(existing);
}
obj.game = this.game;
obj.x = x;
... | [
"function",
"(",
"x",
",",
"y",
",",
"obj",
")",
"{",
"if",
"(",
"typeof",
"obj",
"===",
"'string'",
")",
"{",
"obj",
"=",
"this",
".",
"makeNewObjectFromType",
"(",
"obj",
")",
";",
"}",
"var",
"existing",
"=",
"this",
".",
"get",
"(",
"x",
",",... | Adds an object to the manager at given map tile coord.
If an object is already at this map tile coord it is removed from the manager completely.
@method add
@param {Number} x - The tile map coord x.
@param {Number} y - The tile map coord y.
@param {Object|String} obj - The Object being set at given coords. If obj is a ... | [
"Adds",
"an",
"object",
"to",
"the",
"manager",
"at",
"given",
"map",
"tile",
"coord",
".",
"If",
"an",
"object",
"is",
"already",
"at",
"this",
"map",
"tile",
"coord",
"it",
"is",
"removed",
"from",
"the",
"manager",
"completely",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/object-manager.js#L65-L82 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/object-manager.js | function(object) {
this.map.remove(object.x, object.y);
var index = this.objects.indexOf(object);
this.objects.splice(index, 1);
if(object.onRemove){
object.onRemove();
}
} | javascript | function(object) {
this.map.remove(object.x, object.y);
var index = this.objects.indexOf(object);
this.objects.splice(index, 1);
if(object.onRemove){
object.onRemove();
}
} | [
"function",
"(",
"object",
")",
"{",
"this",
".",
"map",
".",
"remove",
"(",
"object",
".",
"x",
",",
"object",
".",
"y",
")",
";",
"var",
"index",
"=",
"this",
".",
"objects",
".",
"indexOf",
"(",
"object",
")",
";",
"this",
".",
"objects",
".",... | Removes an object from the manager.
@method remove
@param {Object} object - The objectity to be removed. | [
"Removes",
"an",
"object",
"from",
"the",
"manager",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/object-manager.js#L89-L96 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/object-manager.js | function(x, y, object) {
var existing = this.get(object.x, object.y);
if(existing !== object){
throw new Error({error: 'Attempting to move object not in correct position in Object manager', x: x, y: y, object: object});
}
if(this.objects.indexOf(object) =... | javascript | function(x, y, object) {
var existing = this.get(object.x, object.y);
if(existing !== object){
throw new Error({error: 'Attempting to move object not in correct position in Object manager', x: x, y: y, object: object});
}
if(this.objects.indexOf(object) =... | [
"function",
"(",
"x",
",",
"y",
",",
"object",
")",
"{",
"var",
"existing",
"=",
"this",
".",
"get",
"(",
"object",
".",
"x",
",",
"object",
".",
"y",
")",
";",
"if",
"(",
"existing",
"!==",
"object",
")",
"{",
"throw",
"new",
"Error",
"(",
"{"... | Changes the position of an object already added to this objectManager.
@method move
@param {Number} x - The destination tile map coord x.
@param {Number} y - The destination tile map coord y.
@param {Obj} object - The objectity to be removed. | [
"Changes",
"the",
"position",
"of",
"an",
"object",
"already",
"added",
"to",
"this",
"objectManager",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/object-manager.js#L105-L118 | train | |
nodeca/plurals-cldr | support/generate.js | toSingleRule | function toSingleRule(str) {
return str
// replace modulus with shortcuts
.replace(/([nivwft]) % (\d+)/g, '$1$2')
// replace ranges
.replace(/([nivwft]\d*) (=|\!=) (\d+[.,][.,\d]+)/g, function (match, v, cond, range) {
// range = 5,8,9 (simple set)
if (range.indexOf('..') < 0 && range.ind... | javascript | function toSingleRule(str) {
return str
// replace modulus with shortcuts
.replace(/([nivwft]) % (\d+)/g, '$1$2')
// replace ranges
.replace(/([nivwft]\d*) (=|\!=) (\d+[.,][.,\d]+)/g, function (match, v, cond, range) {
// range = 5,8,9 (simple set)
if (range.indexOf('..') < 0 && range.ind... | [
"function",
"toSingleRule",
"(",
"str",
")",
"{",
"return",
"str",
"// replace modulus with shortcuts",
".",
"replace",
"(",
"/",
"([nivwft]) % (\\d+)",
"/",
"g",
",",
"'$1$2'",
")",
"// replace ranges",
".",
"replace",
"(",
"/",
"([nivwft]\\d*) (=|\\!=) (\\d+[.,][.,\... | Create equation for single form rule | [
"Create",
"equation",
"for",
"single",
"form",
"rule"
] | d93a4f130d0610605ff76761ef8e6abd4271639d | https://github.com/nodeca/plurals-cldr/blob/d93a4f130d0610605ff76761ef8e6abd4271639d/support/generate.js#L92-L133 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets-finder.js | function(game, settings){
this.game = game;
settings = settings || {};
this.x = settings.x || this.x;
this.y = settings.y || this.y;
this.limitToFov = setting... | javascript | function(game, settings){
this.game = game;
settings = settings || {};
this.x = settings.x || this.x;
this.y = settings.y || this.y;
this.limitToFov = setting... | [
"function",
"(",
"game",
",",
"settings",
")",
"{",
"this",
".",
"game",
"=",
"game",
";",
"settings",
"=",
"settings",
"||",
"{",
"}",
";",
"this",
".",
"x",
"=",
"settings",
".",
"x",
"||",
"this",
".",
"x",
";",
"this",
".",
"y",
"=",
"setti... | Gets a list of valid targets filtered by provided criteria.
@class ValidTargetsFinder
@constructor
@param {Game} game
@param {Object} settings
@param {Number} settings.x - The x map tile coord to use as the origin of the attack.
@param {Number} settings.y ... | [
"Gets",
"a",
"list",
"of",
"valid",
"targets",
"filtered",
"by",
"provided",
"criteria",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets-finder.js#L21-L36 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets-finder.js | function(){
var tiles = this.getValidTargetTiles();
var result = [];
for (var i = 0; i < tiles.length; i++) {
var tile = tiles[i];
var targets = this.getValidTargetsAtPosition(tile.x, tile.y);
result = result.concat(targets);
... | javascript | function(){
var tiles = this.getValidTargetTiles();
var result = [];
for (var i = 0; i < tiles.length; i++) {
var tile = tiles[i];
var targets = this.getValidTargetsAtPosition(tile.x, tile.y);
result = result.concat(targets);
... | [
"function",
"(",
")",
"{",
"var",
"tiles",
"=",
"this",
".",
"getValidTargetTiles",
"(",
")",
";",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tiles",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
... | Gets all valid targets.
@method getValidTargets
@return {Array} | [
"Gets",
"all",
"valid",
"targets",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets-finder.js#L125-L137 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets-finder.js | function(){
var tiles = [];
if(this.limitToFov){
var fovTiles = this.limitToFov.visibleTiles;
for (var i = 0; i < fovTiles.length; i++) {
var fovTile = fovTiles[i];
// if no max range, if there is a max range check it
... | javascript | function(){
var tiles = [];
if(this.limitToFov){
var fovTiles = this.limitToFov.visibleTiles;
for (var i = 0; i < fovTiles.length; i++) {
var fovTile = fovTiles[i];
// if no max range, if there is a max range check it
... | [
"function",
"(",
")",
"{",
"var",
"tiles",
"=",
"[",
"]",
";",
"if",
"(",
"this",
".",
"limitToFov",
")",
"{",
"var",
"fovTiles",
"=",
"this",
".",
"limitToFov",
".",
"visibleTiles",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"fovTiles... | Get tile coords a valid target may be on. Only checking range and fov, not objects on the tile.
@method getValidTargetTiles
@return {Array} of Tile objects | [
"Get",
"tile",
"coords",
"a",
"valid",
"target",
"may",
"be",
"on",
".",
"Only",
"checking",
"range",
"and",
"fov",
"not",
"objects",
"on",
"the",
"tile",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets-finder.js#L144-L184 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets-finder.js | function(x, y){
var objects = this.game.getObjectsAtPostion(x, y);
var range = RL.Util.getDistance(this.x, this.y, x, y);
var _this = this;
var filtered = objects.filter(function(target){
return _this.checkValidTarget(target);
});
... | javascript | function(x, y){
var objects = this.game.getObjectsAtPostion(x, y);
var range = RL.Util.getDistance(this.x, this.y, x, y);
var _this = this;
var filtered = objects.filter(function(target){
return _this.checkValidTarget(target);
});
... | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"objects",
"=",
"this",
".",
"game",
".",
"getObjectsAtPostion",
"(",
"x",
",",
"y",
")",
";",
"var",
"range",
"=",
"RL",
".",
"Util",
".",
"getDistance",
"(",
"this",
".",
"x",
",",
"this",
".",
... | Get valid target objects on a tile coord.
@method getValidTargetsAtPosition
@param {Number} x - Map tile coord to get valid target objects from.
@param {Number} y - Map tile coord to get valid target objects from.
@return {Array} mixed objects | [
"Get",
"valid",
"target",
"objects",
"on",
"a",
"tile",
"coord",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets-finder.js#L193-L204 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets-finder.js | function(target, x, y, range){
x = x || target.x;
y = y || target.y;
range = range || RL.Util.getDistance(this.x, this.y, x, y);
return {
x: x,
y: y,
range: range,
value: target
};
} | javascript | function(target, x, y, range){
x = x || target.x;
y = y || target.y;
range = range || RL.Util.getDistance(this.x, this.y, x, y);
return {
x: x,
y: y,
range: range,
value: target
};
} | [
"function",
"(",
"target",
",",
"x",
",",
"y",
",",
"range",
")",
"{",
"x",
"=",
"x",
"||",
"target",
".",
"x",
";",
"y",
"=",
"y",
"||",
"target",
".",
"y",
";",
"range",
"=",
"range",
"||",
"RL",
".",
"Util",
".",
"getDistance",
"(",
"this"... | Wraps a target object in a container object with x, y, range
@method prepareTargetObject
@param {Object} target
@param {Number} [x=target.x]
@param {Number} [y=target.y]
@param {Number} [range] range from `this.x`, `this.y` to x,y
@return {Object} result result object
`
return {
x: x, // target x tile coord
y: y, // ta... | [
"Wraps",
"a",
"target",
"object",
"in",
"a",
"container",
"object",
"with",
"x",
"y",
"range"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets-finder.js#L227-L237 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets-finder.js | function(target){
// skip valid type check if value evaluating to false or empty array.
if(!this.validTypes || !this.validTypes.length){
return true;
}
for(var i = this.validTypes.length - 1; i >= 0; i--){
var type = this.validTypes[i];
... | javascript | function(target){
// skip valid type check if value evaluating to false or empty array.
if(!this.validTypes || !this.validTypes.length){
return true;
}
for(var i = this.validTypes.length - 1; i >= 0; i--){
var type = this.validTypes[i];
... | [
"function",
"(",
"target",
")",
"{",
"// skip valid type check if value evaluating to false or empty array.",
"if",
"(",
"!",
"this",
".",
"validTypes",
"||",
"!",
"this",
".",
"validTypes",
".",
"length",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"var",... | Checks if a target object is an instance of a type in `this.validTypes`.
@method checkValidType
@param {Object} target - The target to be checked.
@return {Bool} `true` if valid. | [
"Checks",
"if",
"a",
"target",
"object",
"is",
"an",
"instance",
"of",
"a",
"type",
"in",
"this",
".",
"validTypes",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets-finder.js#L245-L260 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets-finder.js | function(target){
if(this.exclude){
if(target === this.exclude){
return false;
}
// if exclude is array and target is in it
if(Object.isArray(this.exclude) && this.exclude.indexOf(target) !== -1){
return ... | javascript | function(target){
if(this.exclude){
if(target === this.exclude){
return false;
}
// if exclude is array and target is in it
if(Object.isArray(this.exclude) && this.exclude.indexOf(target) !== -1){
return ... | [
"function",
"(",
"target",
")",
"{",
"if",
"(",
"this",
".",
"exclude",
")",
"{",
"if",
"(",
"target",
"===",
"this",
".",
"exclude",
")",
"{",
"return",
"false",
";",
"}",
"// if exclude is array and target is in it",
"if",
"(",
"Object",
".",
"isArray",
... | Checks if an object is a valid target for this action.
@method checkValidTarget
@param {Object} target - The target to be checked.
@return {Bool} `true` if valid. | [
"Checks",
"if",
"an",
"object",
"is",
"a",
"valid",
"target",
"for",
"this",
"action",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets-finder.js#L268-L286 | train | |
wilmoore/uuid-regexp.js | index.js | re | function re (opts) {
opts = opts || {}
return new RegExp(
format('\\b(?:%s)\\b', regexp.versioned.source + (opts.nil ? '|' + regexp.nil.source : '')),
'i' + (opts.flags || '')
)
} | javascript | function re (opts) {
opts = opts || {}
return new RegExp(
format('\\b(?:%s)\\b', regexp.versioned.source + (opts.nil ? '|' + regexp.nil.source : '')),
'i' + (opts.flags || '')
)
} | [
"function",
"re",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
"return",
"new",
"RegExp",
"(",
"format",
"(",
"'\\\\b(?:%s)\\\\b'",
",",
"regexp",
".",
"versioned",
".",
"source",
"+",
"(",
"opts",
".",
"nil",
"?",
"'|'",
"+",
"regexp"... | RegExp for finding an RFC4122 compliant UUID in a string.
@param {Object} opts
Options object.
@param {String} [opts.flags]
Additional RegExp flags ('i' is always set).
@param {Boolean} [opts.nil]
Whether to include the nil/empty UUID pattern.
@return {RegExp}
RegExp for finding an RFC4122 compliant UUID in a strin... | [
"RegExp",
"for",
"finding",
"an",
"RFC4122",
"compliant",
"UUID",
"in",
"a",
"string",
"."
] | 674d65e5e371d7c126a58a09281e8e21ee503e9a | https://github.com/wilmoore/uuid-regexp.js/blob/674d65e5e371d7c126a58a09281e8e21ee503e9a/index.js#L32-L39 | train |
75lb/object-get | lib/object-get.js | objectGet | function objectGet (object, expression) {
if (!(object && expression)) throw new Error('both object and expression args are required')
return expression.trim().split('.').reduce(function (prev, curr) {
var arr = curr.match(/(.*?)\[(.*?)\]/)
if (arr) {
return prev && prev[arr[1]][arr[2]]
} else {
... | javascript | function objectGet (object, expression) {
if (!(object && expression)) throw new Error('both object and expression args are required')
return expression.trim().split('.').reduce(function (prev, curr) {
var arr = curr.match(/(.*?)\[(.*?)\]/)
if (arr) {
return prev && prev[arr[1]][arr[2]]
} else {
... | [
"function",
"objectGet",
"(",
"object",
",",
"expression",
")",
"{",
"if",
"(",
"!",
"(",
"object",
"&&",
"expression",
")",
")",
"throw",
"new",
"Error",
"(",
"'both object and expression args are required'",
")",
"return",
"expression",
".",
"trim",
"(",
")"... | Returns the value at the given property.
@param {object} - the input object
@param {string} - the property accessor expression.
@returns {*}
@alias module:object-get
@example
> objectGet({ animal: 'cow' }, 'animal')
'cow'
> objectGet({ animal: { mood: 'lazy' } }, 'animal')
{ mood: 'lazy' }
> objectGet({ animal: { mo... | [
"Returns",
"the",
"value",
"at",
"the",
"given",
"property",
"."
] | 67fe4b92af9a3f3311e90c9a89d35f24a956e5df | https://github.com/75lb/object-get/blob/67fe4b92af9a3f3311e90c9a89d35f24a956e5df/lib/object-get.js#L44-L54 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/input.js | Input | function Input(onKeyAction, bindings) {
this.bindings = {};
if (onKeyAction !== void 0) {
this.onKeyAction = onKeyAction;
}
if (bindings !== void 0) {
this.addBindings(bindings);
}
this.startListening();
} | javascript | function Input(onKeyAction, bindings) {
this.bindings = {};
if (onKeyAction !== void 0) {
this.onKeyAction = onKeyAction;
}
if (bindings !== void 0) {
this.addBindings(bindings);
}
this.startListening();
} | [
"function",
"Input",
"(",
"onKeyAction",
",",
"bindings",
")",
"{",
"this",
".",
"bindings",
"=",
"{",
"}",
";",
"if",
"(",
"onKeyAction",
"!==",
"void",
"0",
")",
"{",
"this",
".",
"onKeyAction",
"=",
"onKeyAction",
";",
"}",
"if",
"(",
"bindings",
... | Helper for binding user key input to actions.
@class Input
@constructor
@param {Function} onKeyAction - Function called when a key bound to an action is pressed (function(action){}).
@param {Object} bindings - An object of key val pairs mapping an action to an array of keys that trigger it. Input.Keys is used to conver... | [
"Helper",
"for",
"binding",
"user",
"key",
"input",
"to",
"actions",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/input.js#L22-L31 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/input.js | function(bindings) {
for (var action in bindings) {
var keys = bindings[action];
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
this.bindAction(action, key);
}
}
} | javascript | function(bindings) {
for (var action in bindings) {
var keys = bindings[action];
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
this.bindAction(action, key);
}
}
} | [
"function",
"(",
"bindings",
")",
"{",
"for",
"(",
"var",
"action",
"in",
"bindings",
")",
"{",
"var",
"keys",
"=",
"bindings",
"[",
"action",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")"... | Loads multiple action key bindings
@method addBindings
@param {Object} bindings - An object of key val pairs mapping an action to an array of keys that trigger it. Input.Keys is used to convert input key string names to key codes.
@param bindings.action1 {Array} Input keys mapped to action1. ['A', 'B', ...]
@param bind... | [
"Loads",
"multiple",
"action",
"key",
"bindings"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/input.js#L91-L99 | train | |
sergeyt/fetch-stream | src/index.js | pump | function pump(reader, handler) {
reader.read().then(result => {
if (result.done) {
return;
}
if (handler(result.value) === false) {
// cancelling
return;
}
pump(reader, handler);
});
} | javascript | function pump(reader, handler) {
reader.read().then(result => {
if (result.done) {
return;
}
if (handler(result.value) === false) {
// cancelling
return;
}
pump(reader, handler);
});
} | [
"function",
"pump",
"(",
"reader",
",",
"handler",
")",
"{",
"reader",
".",
"read",
"(",
")",
".",
"then",
"(",
"result",
"=>",
"{",
"if",
"(",
"result",
".",
"done",
")",
"{",
"return",
";",
"}",
"if",
"(",
"handler",
"(",
"result",
".",
"value"... | reads all chunks | [
"reads",
"all",
"chunks"
] | eab91c059ce3b1d172fd44890769c761bb4b7aa3 | https://github.com/sergeyt/fetch-stream/blob/eab91c059ce3b1d172fd44890769c761bb4b7aa3/src/index.js#L13-L24 | train |
nodeca/event-wire | index.js | _hook | function _hook(slf, name, handlerInfo, params) {
if (!slf.__hooks[name]) return;
slf.__hooks[name].forEach(function (hook) {
hook(handlerInfo, params);
});
} | javascript | function _hook(slf, name, handlerInfo, params) {
if (!slf.__hooks[name]) return;
slf.__hooks[name].forEach(function (hook) {
hook(handlerInfo, params);
});
} | [
"function",
"_hook",
"(",
"slf",
",",
"name",
",",
"handlerInfo",
",",
"params",
")",
"{",
"if",
"(",
"!",
"slf",
".",
"__hooks",
"[",
"name",
"]",
")",
"return",
";",
"slf",
".",
"__hooks",
"[",
"name",
"]",
".",
"forEach",
"(",
"function",
"(",
... | Helper to run hooks | [
"Helper",
"to",
"run",
"hooks"
] | ae8d1e419bf20991ac716248914f688f1e2f6322 | https://github.com/nodeca/event-wire/blob/ae8d1e419bf20991ac716248914f688f1e2f6322/index.js#L214-L220 | train |
nodeca/event-wire | index.js | wrap_cb | function wrap_cb(fn, P) {
return function (params) {
return new P(function (resolve, reject) {
fn(params, function (err) { return !err ? resolve() : reject(err); });
});
};
} | javascript | function wrap_cb(fn, P) {
return function (params) {
return new P(function (resolve, reject) {
fn(params, function (err) { return !err ? resolve() : reject(err); });
});
};
} | [
"function",
"wrap_cb",
"(",
"fn",
",",
"P",
")",
"{",
"return",
"function",
"(",
"params",
")",
"{",
"return",
"new",
"P",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"fn",
"(",
"params",
",",
"function",
"(",
"err",
")",
"{",
"return... | Wrap handler with callback | [
"Wrap",
"handler",
"with",
"callback"
] | ae8d1e419bf20991ac716248914f688f1e2f6322 | https://github.com/nodeca/event-wire/blob/ae8d1e419bf20991ac716248914f688f1e2f6322/index.js#L246-L252 | train |
nodeca/event-wire | index.js | finalizeHandler | function finalizeHandler(p, hInfo) {
if (!p) return;
return p
.catch(storeErrOnce)
.then(function () {
if (errored && !hInfo.ensure) return null;
_hook(self, 'eachAfter', hInfo, params);
})
.catch(storeErrOnce);
} | javascript | function finalizeHandler(p, hInfo) {
if (!p) return;
return p
.catch(storeErrOnce)
.then(function () {
if (errored && !hInfo.ensure) return null;
_hook(self, 'eachAfter', hInfo, params);
})
.catch(storeErrOnce);
} | [
"function",
"finalizeHandler",
"(",
"p",
",",
"hInfo",
")",
"{",
"if",
"(",
"!",
"p",
")",
"return",
";",
"return",
"p",
".",
"catch",
"(",
"storeErrOnce",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"errored",
"&&",
"!",
"hInfo",
... | Finalize handler exec - should care about errors and post-hooks. | [
"Finalize",
"handler",
"exec",
"-",
"should",
"care",
"about",
"errors",
"and",
"post",
"-",
"hooks",
"."
] | ae8d1e419bf20991ac716248914f688f1e2f6322 | https://github.com/nodeca/event-wire/blob/ae8d1e419bf20991ac716248914f688f1e2f6322/index.js#L303-L313 | train |
sergeyt/fetch-stream | lib/index.js | fetchStream | function fetchStream() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var callback = arguments[1];
var cb = callback;
var stream = null;
if (cb === undefined) {
stream = makeStream();
cb = stream.handler;
}
var url = typeof options === 'string' ? options : options.u... | javascript | function fetchStream() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var callback = arguments[1];
var cb = callback;
var stream = null;
if (cb === undefined) {
stream = makeStream();
cb = stream.handler;
}
var url = typeof options === 'string' ? options : options.u... | [
"function",
"fetchStream",
"(",
")",
"{",
"var",
"options",
"=",
"arguments",
".",
"length",
"<=",
"0",
"||",
"arguments",
"[",
"0",
"]",
"===",
"undefined",
"?",
"{",
"}",
":",
"arguments",
"[",
"0",
"]",
";",
"var",
"callback",
"=",
"arguments",
"[... | Fetches resource stream.
@param {object} [options] URL or options of request.
@param {function} [callback] The callback to process each chunk in the stream. | [
"Fetches",
"resource",
"stream",
"."
] | eab91c059ce3b1d172fd44890769c761bb4b7aa3 | https://github.com/sergeyt/fetch-stream/blob/eab91c059ce3b1d172fd44890769c761bb4b7aa3/lib/index.js#L94-L146 | train |
ahmed-dinar/codeforces-api-node | src/codeforces.js | callApi | function callApi(method, parameters, callback) {
if (typeof parameters === 'undefined') {
throw new Error('undefined is not a valid parameters object.');
}
if( typeof parameters !== 'object' ){
throw new Error('valid parameters object required.');
}
var opts = this.options;
v... | javascript | function callApi(method, parameters, callback) {
if (typeof parameters === 'undefined') {
throw new Error('undefined is not a valid parameters object.');
}
if( typeof parameters !== 'object' ){
throw new Error('valid parameters object required.');
}
var opts = this.options;
v... | [
"function",
"callApi",
"(",
"method",
",",
"parameters",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"parameters",
"===",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'undefined is not a valid parameters object.'",
")",
";",
"}",
"if",
"(",
"typ... | Send request to api
@param {string} method - method of API request.
@param {object} parameters - API url parameters
@param {function} callback
@returns {*} | [
"Send",
"request",
"to",
"api"
] | 2f85a6d833b32012adbf87440b2c16aeb4c167f7 | https://github.com/ahmed-dinar/codeforces-api-node/blob/2f85a6d833b32012adbf87440b2c16aeb4c167f7/src/codeforces.js#L98-L144 | train |
ahmed-dinar/codeforces-api-node | src/codeforces.js | handleCallback | function handleCallback(callback, err, httpResponse, body) {
if(err){
return callback(err);
}
//
// API returns error
//
if( body.status !== 'OK' ){
return callback(new Error(body.comment));
}
return callback(null, body.result);
} | javascript | function handleCallback(callback, err, httpResponse, body) {
if(err){
return callback(err);
}
//
// API returns error
//
if( body.status !== 'OK' ){
return callback(new Error(body.comment));
}
return callback(null, body.result);
} | [
"function",
"handleCallback",
"(",
"callback",
",",
"err",
",",
"httpResponse",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"//",
"// API returns error",
"//",
"if",
"(",
"body",
".",
"status",
"!... | Handle user callback
@param callback - user callback
@param err - request errors
@param httpResponse - request HTTP response
@param body - request response body
@returns {*} | [
"Handle",
"user",
"callback"
] | 2f85a6d833b32012adbf87440b2c16aeb4c167f7 | https://github.com/ahmed-dinar/codeforces-api-node/blob/2f85a6d833b32012adbf87440b2c16aeb4c167f7/src/codeforces.js#L156-L170 | train |
ahmed-dinar/codeforces-api-node | src/codeforces.js | makeApiUrl | function makeApiUrl(options,parameters) {
var query = parameters;
//
// If any parameter given in array, make it string separated by semicolon(;)
//
for(let key in query){
if( _.isArray(query[key]) ){
query[key] = _.join(query[key],';');
}
}
let curTime = Math.... | javascript | function makeApiUrl(options,parameters) {
var query = parameters;
//
// If any parameter given in array, make it string separated by semicolon(;)
//
for(let key in query){
if( _.isArray(query[key]) ){
query[key] = _.join(query[key],';');
}
}
let curTime = Math.... | [
"function",
"makeApiUrl",
"(",
"options",
",",
"parameters",
")",
"{",
"var",
"query",
"=",
"parameters",
";",
"//",
"// If any parameter given in array, make it string separated by semicolon(;)",
"//",
"for",
"(",
"let",
"key",
"in",
"query",
")",
"{",
"if",
"(",
... | Generate API url according to CF API rules
@param {array} options - main class options
@param {array} parameters - API url parameters [see doc]
@returns {string} - final url | [
"Generate",
"API",
"url",
"according",
"to",
"CF",
"API",
"rules"
] | 2f85a6d833b32012adbf87440b2c16aeb4c167f7 | https://github.com/ahmed-dinar/codeforces-api-node/blob/2f85a6d833b32012adbf87440b2c16aeb4c167f7/src/codeforces.js#L192-L235 | train |
Lanfei/websocket-lib | lib/server.js | ServerSession | function ServerSession(request, socket, head, server) {
Session.call(this, request, socket, head);
this._resHeaders = {};
this._headerSent = false;
/**
* The server instance of this session.
* @type {Server}
*/
this.server = server;
/**
* The HTTP status code of handshake.
* @type {Number}
* @de... | javascript | function ServerSession(request, socket, head, server) {
Session.call(this, request, socket, head);
this._resHeaders = {};
this._headerSent = false;
/**
* The server instance of this session.
* @type {Server}
*/
this.server = server;
/**
* The HTTP status code of handshake.
* @type {Number}
* @de... | [
"function",
"ServerSession",
"(",
"request",
",",
"socket",
",",
"head",
",",
"server",
")",
"{",
"Session",
".",
"call",
"(",
"this",
",",
"request",
",",
"socket",
",",
"head",
")",
";",
"this",
".",
"_resHeaders",
"=",
"{",
"}",
";",
"this",
".",
... | WebSocket Server Session
@constructor
@extends Session
@param {IncomingMessage} request see {@link Session#request}
@param {Socket} socket see {@link Session#socket}
@param {Buffer} [head] Data that received with headers.
@param {Server} [server] see {@link ServerSession#ser... | [
"WebSocket",
"Server",
"Session"
] | d39f704490fb91b1e2897712b280c0e5ac79e123 | https://github.com/Lanfei/websocket-lib/blob/d39f704490fb91b1e2897712b280c0e5ac79e123/lib/server.js#L227-L251 | train |
martinj/node-async-queue | async-queue.js | function (job) {
if (job) {
if (arguments.length > 1) {
this.jobs = this.jobs.concat(Array.prototype.slice.call(arguments));
} else {
this.jobs.push(job);
}
}
return this;
} | javascript | function (job) {
if (job) {
if (arguments.length > 1) {
this.jobs = this.jobs.concat(Array.prototype.slice.call(arguments));
} else {
this.jobs.push(job);
}
}
return this;
} | [
"function",
"(",
"job",
")",
"{",
"if",
"(",
"job",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"{",
"this",
".",
"jobs",
"=",
"this",
".",
"jobs",
".",
"concat",
"(",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(... | Add job to the queue
@param {Function} job | [
"Add",
"job",
"to",
"the",
"queue"
] | 2b3870020611babbf2c4851c9b51da780da056eb | https://github.com/martinj/node-async-queue/blob/2b3870020611babbf2c4851c9b51da780da056eb/async-queue.js#L37-L46 | train | |
martinj/node-async-queue | async-queue.js | function (err) {
if (this.jobs.length) {
var job = this.jobs.shift();
try {
job(err, this);
} catch (e) {
this.next(e);
}
} else {
this.running = false;
}
} | javascript | function (err) {
if (this.jobs.length) {
var job = this.jobs.shift();
try {
job(err, this);
} catch (e) {
this.next(e);
}
} else {
this.running = false;
}
} | [
"function",
"(",
"err",
")",
"{",
"if",
"(",
"this",
".",
"jobs",
".",
"length",
")",
"{",
"var",
"job",
"=",
"this",
".",
"jobs",
".",
"shift",
"(",
")",
";",
"try",
"{",
"job",
"(",
"err",
",",
"this",
")",
";",
"}",
"catch",
"(",
"e",
")... | Run the next job in queue
@private
@param {Object} err | [
"Run",
"the",
"next",
"job",
"in",
"queue"
] | 2b3870020611babbf2c4851c9b51da780da056eb | https://github.com/martinj/node-async-queue/blob/2b3870020611babbf2c4851c9b51da780da056eb/async-queue.js#L98-L109 | train | |
juttle/juttle-elastic-adapter | lib/utils.js | index_date | function index_date(timestamp, interval) {
function double_digitize(str) {
return (str.length === 1) ? ('0' + str) : str;
}
var year = timestamp.getUTCFullYear();
var month = (timestamp.getUTCMonth() + 1).toString();
switch (interval) {
case 'day':
var day = timestamp.g... | javascript | function index_date(timestamp, interval) {
function double_digitize(str) {
return (str.length === 1) ? ('0' + str) : str;
}
var year = timestamp.getUTCFullYear();
var month = (timestamp.getUTCMonth() + 1).toString();
switch (interval) {
case 'day':
var day = timestamp.g... | [
"function",
"index_date",
"(",
"timestamp",
",",
"interval",
")",
"{",
"function",
"double_digitize",
"(",
"str",
")",
"{",
"return",
"(",
"str",
".",
"length",
"===",
"1",
")",
"?",
"(",
"'0'",
"+",
"str",
")",
":",
"str",
";",
"}",
"var",
"year",
... | YYYY.MM.dd | [
"YYYY",
".",
"MM",
".",
"dd"
] | 7b3b1c46943381230bc7dde33874a738a0a50cbe | https://github.com/juttle/juttle-elastic-adapter/blob/7b3b1c46943381230bc7dde33874a738a0a50cbe/lib/utils.js#L40-L69 | train |
nickzuber/needle | src/BinarySearchTree/binarySearchTree.js | deleteHelper | function deleteHelper (data, node, nodeType, parentNode) {
if (node === null) {
return false;
}
// @TODO handle object comparisons -- doing a stringify is horrible dont do that
if (data === node.data) {
if (nodeType === Types.RIGHT) {
parentNode.right = null;
} else {
parentNode.left = ... | javascript | function deleteHelper (data, node, nodeType, parentNode) {
if (node === null) {
return false;
}
// @TODO handle object comparisons -- doing a stringify is horrible dont do that
if (data === node.data) {
if (nodeType === Types.RIGHT) {
parentNode.right = null;
} else {
parentNode.left = ... | [
"function",
"deleteHelper",
"(",
"data",
",",
"node",
",",
"nodeType",
",",
"parentNode",
")",
"{",
"if",
"(",
"node",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"// @TODO handle object comparisons -- doing a stringify is horrible dont do that",
"if",
"("... | Deletes a node from the tree with the value of `data`.
@param {any} data The data of the node to delete.
@param {Node} node The current node being analyzed.
@param {Node} nodeType The type of child of the current node being analyzed.
@param {Node} parentNode The last node that was analyzed.
@return {... | [
"Deletes",
"a",
"node",
"from",
"the",
"tree",
"with",
"the",
"value",
"of",
"data",
"."
] | 9565b3c193b93d67ffed39d430eba395a7bb5531 | https://github.com/nickzuber/needle/blob/9565b3c193b93d67ffed39d430eba395a7bb5531/src/BinarySearchTree/binarySearchTree.js#L231-L262 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/manual/index/entity/js/basic-movement.js | function(direction){
var directionCoords = {
up: {x: 0, y:-1},
right: {x: 1, y: 0},
down: {x: 0, y: 1},
left: {x:-1, y: 0}
};
return directionCoords[direction];
} | javascript | function(direction){
var directionCoords = {
up: {x: 0, y:-1},
right: {x: 1, y: 0},
down: {x: 0, y: 1},
left: {x:-1, y: 0}
};
return directionCoords[direction];
} | [
"function",
"(",
"direction",
")",
"{",
"var",
"directionCoords",
"=",
"{",
"up",
":",
"{",
"x",
":",
"0",
",",
"y",
":",
"-",
"1",
"}",
",",
"right",
":",
"{",
"x",
":",
"1",
",",
"y",
":",
"0",
"}",
",",
"down",
":",
"{",
"x",
":",
"0",... | Gets the adjustment coord from a direction string.
@method directionToAdjustCoord
@param {String} direction - The current direction.
@return {Object} {x: 0, y: 0} | [
"Gets",
"the",
"adjustment",
"coord",
"from",
"a",
"direction",
"string",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/manual/index/entity/js/basic-movement.js#L21-L29 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/manual/index/entity/js/basic-movement.js | function(currentDirection){
var directions = ['up', 'right', 'down', 'left'],
currentDirIndex = directions.indexOf(currentDirection),
newDirIndex;
// if currentDirection is not valid or is the last in the array use the first direction in the array
if(c... | javascript | function(currentDirection){
var directions = ['up', 'right', 'down', 'left'],
currentDirIndex = directions.indexOf(currentDirection),
newDirIndex;
// if currentDirection is not valid or is the last in the array use the first direction in the array
if(c... | [
"function",
"(",
"currentDirection",
")",
"{",
"var",
"directions",
"=",
"[",
"'up'",
",",
"'right'",
",",
"'down'",
",",
"'left'",
"]",
",",
"currentDirIndex",
"=",
"directions",
".",
"indexOf",
"(",
"currentDirection",
")",
",",
"newDirIndex",
";",
"// if ... | Gets the next direction in the list
@method getNextDirection
@param {String} direction - The current direction.
@return {String} | [
"Gets",
"the",
"next",
"direction",
"in",
"the",
"list"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/manual/index/entity/js/basic-movement.js#L37-L48 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/manual/index/entity/js/basic-movement.js | function(x, y) {
// remove light from current position
if(this.game.lighting.get(this.x, this.y)){
this.game.lighting.remove(this.x, this.y);
}
// add to new position
this.game.lighting.set(x, y, this.light_r, this.light_g, this.light_b);
... | javascript | function(x, y) {
// remove light from current position
if(this.game.lighting.get(this.x, this.y)){
this.game.lighting.remove(this.x, this.y);
}
// add to new position
this.game.lighting.set(x, y, this.light_r, this.light_g, this.light_b);
... | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"// remove light from current position",
"if",
"(",
"this",
".",
"game",
".",
"lighting",
".",
"get",
"(",
"this",
".",
"x",
",",
"this",
".",
"y",
")",
")",
"{",
"this",
".",
"game",
".",
"lighting",
".",
... | Changes the position of this entity on the map.
@method moveTo
@param {Number} x - The tile map x coord to move to.
@param {Number} y - The tile map y coord to move to. | [
"Changes",
"the",
"position",
"of",
"this",
"entity",
"on",
"the",
"map",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/manual/index/entity/js/basic-movement.js#L84-L93 | train | |
overtrue/validator.js | lib/validator.js | extend | function extend() {
var src, copy, name, options, clone;
var target = arguments[0] || {};
var i = 1;
var length = arguments.length;
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) {
// Extend the base object
... | javascript | function extend() {
var src, copy, name, options, clone;
var target = arguments[0] || {};
var i = 1;
var length = arguments.length;
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) {
// Extend the base object
... | [
"function",
"extend",
"(",
")",
"{",
"var",
"src",
",",
"copy",
",",
"name",
",",
"options",
",",
"clone",
";",
"var",
"target",
"=",
"arguments",
"[",
"0",
"]",
"||",
"{",
"}",
";",
"var",
"i",
"=",
"1",
";",
"var",
"length",
"=",
"arguments",
... | Based on jquery's extend function | [
"Based",
"on",
"jquery",
"s",
"extend",
"function"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L97-L133 | train |
overtrue/validator.js | lib/validator.js | _explodeRules | function _explodeRules(rules) {
for (var i in rules) {
if (is_string(rules[i])) {
rules[i] = rules[i].split('|');
}
}
return rules;
} | javascript | function _explodeRules(rules) {
for (var i in rules) {
if (is_string(rules[i])) {
rules[i] = rules[i].split('|');
}
}
return rules;
} | [
"function",
"_explodeRules",
"(",
"rules",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"rules",
")",
"{",
"if",
"(",
"is_string",
"(",
"rules",
"[",
"i",
"]",
")",
")",
"{",
"rules",
"[",
"i",
"]",
"=",
"rules",
"[",
"i",
"]",
".",
"split",
"(",
... | explode the rules into an array of rules.
@return {Void} | [
"explode",
"the",
"rules",
"into",
"an",
"array",
"of",
"rules",
"."
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L211-L218 | train |
overtrue/validator.js | lib/validator.js | _parseRule | function _parseRule(rule) {
var parameters = [];
// The format for specifying validation rules and parameters follows an
// easy {rule}:{parameters} formatting convention. For instance the
// rule "Max:3" states that the value may only be three letters.
if (rule.indexOf(':')) {
var ruleInfo ... | javascript | function _parseRule(rule) {
var parameters = [];
// The format for specifying validation rules and parameters follows an
// easy {rule}:{parameters} formatting convention. For instance the
// rule "Max:3" states that the value may only be three letters.
if (rule.indexOf(':')) {
var ruleInfo ... | [
"function",
"_parseRule",
"(",
"rule",
")",
"{",
"var",
"parameters",
"=",
"[",
"]",
";",
"// The format for specifying validation rules and parameters follows an",
"// easy {rule}:{parameters} formatting convention. For instance the",
"// rule \"Max:3\" states that the value may only be... | parse the rule
@param {Array} rule
@return {Object} | [
"parse",
"the",
"rule"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L227-L239 | train |
overtrue/validator.js | lib/validator.js | _parseParameters | function _parseParameters(rule, parameter) {
if (rule.toLowerCase() == 'regex') return [parameter];
if (is_string(parameter)) {
return parameter.split(',');
};
return [];
} | javascript | function _parseParameters(rule, parameter) {
if (rule.toLowerCase() == 'regex') return [parameter];
if (is_string(parameter)) {
return parameter.split(',');
};
return [];
} | [
"function",
"_parseParameters",
"(",
"rule",
",",
"parameter",
")",
"{",
"if",
"(",
"rule",
".",
"toLowerCase",
"(",
")",
"==",
"'regex'",
")",
"return",
"[",
"parameter",
"]",
";",
"if",
"(",
"is_string",
"(",
"parameter",
")",
")",
"{",
"return",
"pa... | parse parameters of rule
@param {String} rule
@param {String} parameter
@return {Array} | [
"parse",
"parameters",
"of",
"rule"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L249-L256 | train |
overtrue/validator.js | lib/validator.js | _addFailure | function _addFailure(attribute, rule, parameters) {
_addError(attribute, rule, parameters);
if (! _failedRules[attribute]) {
_failedRules[attribute] = {};
}
_failedRules[attribute][rule] = parameters;
} | javascript | function _addFailure(attribute, rule, parameters) {
_addError(attribute, rule, parameters);
if (! _failedRules[attribute]) {
_failedRules[attribute] = {};
}
_failedRules[attribute][rule] = parameters;
} | [
"function",
"_addFailure",
"(",
"attribute",
",",
"rule",
",",
"parameters",
")",
"{",
"_addError",
"(",
"attribute",
",",
"rule",
",",
"parameters",
")",
";",
"if",
"(",
"!",
"_failedRules",
"[",
"attribute",
"]",
")",
"{",
"_failedRules",
"[",
"attribute... | add a failure rule
@param {String} attribute
@param {String} rule
@param {Array} parameters
@return {Void} | [
"add",
"a",
"failure",
"rule"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L267-L273 | train |
overtrue/validator.js | lib/validator.js | _addError | function _addError(attribute, rule, parameters) {
if (_errors[attribute]) {
return;
};
_errors[attribute] = _formatMessage(_getMessage(attribute, rule) || '', attribute, rule, parameters);
} | javascript | function _addError(attribute, rule, parameters) {
if (_errors[attribute]) {
return;
};
_errors[attribute] = _formatMessage(_getMessage(attribute, rule) || '', attribute, rule, parameters);
} | [
"function",
"_addError",
"(",
"attribute",
",",
"rule",
",",
"parameters",
")",
"{",
"if",
"(",
"_errors",
"[",
"attribute",
"]",
")",
"{",
"return",
";",
"}",
";",
"_errors",
"[",
"attribute",
"]",
"=",
"_formatMessage",
"(",
"_getMessage",
"(",
"attrib... | add a error message
@param {String} attribute
@param {String} rule
@param {Array} parameters
@return {Void} | [
"add",
"a",
"error",
"message"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L284-L289 | train |
overtrue/validator.js | lib/validator.js | _getMessage | function _getMessage(attribute, rule) {
var message = _messages[rule];
if (is_object(message)) {
var value = _getValue(attribute);
if (is_array(value) && message['array']) {
return message['array'];
} else if (_resolvers.numeric(value) && message['numeric']) {
return message['... | javascript | function _getMessage(attribute, rule) {
var message = _messages[rule];
if (is_object(message)) {
var value = _getValue(attribute);
if (is_array(value) && message['array']) {
return message['array'];
} else if (_resolvers.numeric(value) && message['numeric']) {
return message['... | [
"function",
"_getMessage",
"(",
"attribute",
",",
"rule",
")",
"{",
"var",
"message",
"=",
"_messages",
"[",
"rule",
"]",
";",
"if",
"(",
"is_object",
"(",
"message",
")",
")",
"{",
"var",
"value",
"=",
"_getValue",
"(",
"attribute",
")",
";",
"if",
... | get attribute message
@param {String} attribute
@param {String} rule
@return {String} | [
"get",
"attribute",
"message"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L310-L325 | train |
overtrue/validator.js | lib/validator.js | _formatMessage | function _formatMessage(message, attribute, rule, parameters) {
parameters.unshift(_getAttribute(attribute));
for(i in parameters){
message = message.replace(/:[a-zA-z_][a-zA-z_0-9]+/, parameters[i]);
}
if (typeof _replacers[rule] === 'function') {
message = _replacers[rule](message, attri... | javascript | function _formatMessage(message, attribute, rule, parameters) {
parameters.unshift(_getAttribute(attribute));
for(i in parameters){
message = message.replace(/:[a-zA-z_][a-zA-z_0-9]+/, parameters[i]);
}
if (typeof _replacers[rule] === 'function') {
message = _replacers[rule](message, attri... | [
"function",
"_formatMessage",
"(",
"message",
",",
"attribute",
",",
"rule",
",",
"parameters",
")",
"{",
"parameters",
".",
"unshift",
"(",
"_getAttribute",
"(",
"attribute",
")",
")",
";",
"for",
"(",
"i",
"in",
"parameters",
")",
"{",
"message",
"=",
... | replace attributes.
@param {String} message
@param {String} attribute
@param {String} rule
@param {Array} parameters
@return {String} | [
"replace",
"attributes",
"."
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L337-L349 | train |
overtrue/validator.js | lib/validator.js | _getAttribute | function _getAttribute(attribute) {
if (is_string(_attributes[attribute])) {
return _attributes[attribute];
}
if ((line = _translator.trans(attribute)) !== attribute) {
return line;
} else {
return attribute.replace('_', ' ');
}
} | javascript | function _getAttribute(attribute) {
if (is_string(_attributes[attribute])) {
return _attributes[attribute];
}
if ((line = _translator.trans(attribute)) !== attribute) {
return line;
} else {
return attribute.replace('_', ' ');
}
} | [
"function",
"_getAttribute",
"(",
"attribute",
")",
"{",
"if",
"(",
"is_string",
"(",
"_attributes",
"[",
"attribute",
"]",
")",
")",
"{",
"return",
"_attributes",
"[",
"attribute",
"]",
";",
"}",
"if",
"(",
"(",
"line",
"=",
"_translator",
".",
"trans",... | get attribute name
@param {String} attribute
@return {String} | [
"get",
"attribute",
"name"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L358-L368 | train |
overtrue/validator.js | lib/validator.js | _getRule | function _getRule(attribute, rules) {
rules = rules || [];
if ( ! rules[attribute]) {
return;
}
for(var i in rules[attribute]) {
var value = rules[attribute][i];
parsedRule = _parseRule(rule);
if (in_array(parsedRule.rule, rules))
return [parsedRule.rule, parsedRule.pa... | javascript | function _getRule(attribute, rules) {
rules = rules || [];
if ( ! rules[attribute]) {
return;
}
for(var i in rules[attribute]) {
var value = rules[attribute][i];
parsedRule = _parseRule(rule);
if (in_array(parsedRule.rule, rules))
return [parsedRule.rule, parsedRule.pa... | [
"function",
"_getRule",
"(",
"attribute",
",",
"rules",
")",
"{",
"rules",
"=",
"rules",
"||",
"[",
"]",
";",
"if",
"(",
"!",
"rules",
"[",
"attribute",
"]",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"i",
"in",
"rules",
"[",
"attribute",
"... | get rule and parameters of a rules
@param {String} attribute
@param {String|array} rules
@return {Array|null} | [
"get",
"rule",
"and",
"parameters",
"of",
"a",
"rules"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L390-L404 | train |
overtrue/validator.js | lib/validator.js | _getSize | function _getSize(attribute, value) {
hasNumeric = _hasRule(attribute, _numericRules);
// This method will determine if the attribute is a number, string, or file and
// return the proper size accordingly. If it is a number, then number itself
// is the size. If it is a file, we take kilobytes, and for... | javascript | function _getSize(attribute, value) {
hasNumeric = _hasRule(attribute, _numericRules);
// This method will determine if the attribute is a number, string, or file and
// return the proper size accordingly. If it is a number, then number itself
// is the size. If it is a file, we take kilobytes, and for... | [
"function",
"_getSize",
"(",
"attribute",
",",
"value",
")",
"{",
"hasNumeric",
"=",
"_hasRule",
"(",
"attribute",
",",
"_numericRules",
")",
";",
"// This method will determine if the attribute is a number, string, or file and",
"// return the proper size accordingly. If it is a... | get attribute size
@param {String} attribute
@param {Mixed} value
@return {Number} | [
"get",
"attribute",
"size"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L414-L428 | train |
overtrue/validator.js | lib/validator.js | _requireParameterCount | function _requireParameterCount(count, parameters, rule) {
if (parameters.length < count) {
throw Error('Validation rule"' + rule + '" requires at least ' + count + ' parameters.');
}
} | javascript | function _requireParameterCount(count, parameters, rule) {
if (parameters.length < count) {
throw Error('Validation rule"' + rule + '" requires at least ' + count + ' parameters.');
}
} | [
"function",
"_requireParameterCount",
"(",
"count",
",",
"parameters",
",",
"rule",
")",
"{",
"if",
"(",
"parameters",
".",
"length",
"<",
"count",
")",
"{",
"throw",
"Error",
"(",
"'Validation rule\"'",
"+",
"rule",
"+",
"'\" requires at least '",
"+",
"count... | check parameters count
@param {Number} count
@param {Array} parameters
@param {String} rule
@return {Void} | [
"check",
"parameters",
"count"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L439-L443 | train |
overtrue/validator.js | lib/validator.js | _allFailingRequired | function _allFailingRequired(attributes) {
for (var i in attributes) {
var akey = attributes[i];
if (resolvers.validateRequired(key, self._getValue(key))) {
return false;
}
}
return true;
} | javascript | function _allFailingRequired(attributes) {
for (var i in attributes) {
var akey = attributes[i];
if (resolvers.validateRequired(key, self._getValue(key))) {
return false;
}
}
return true;
} | [
"function",
"_allFailingRequired",
"(",
"attributes",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"attributes",
")",
"{",
"var",
"akey",
"=",
"attributes",
"[",
"i",
"]",
";",
"if",
"(",
"resolvers",
".",
"validateRequired",
"(",
"key",
",",
"self",
".",
"... | all failing check
@param {Array} attributes
@return {Boolean} | [
"all",
"failing",
"check"
] | ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c | https://github.com/overtrue/validator.js/blob/ae20d12cd097ef6dc2e7b13ee9e58d4ed617529c/lib/validator.js#L452-L462 | 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.