_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q33700
_anyFailingRequired
train
function _anyFailingRequired(attributes) { for (var i in attributes) { var key = attributes[i]; if ( ! _resolvers.validateRequired(key, self.date[key])) { return true; } } return false; }
javascript
{ "resource": "" }
q33701
train
function(rule, message) { if (is_object(rule)) { _messages = extend({}, _messages, rule); } else if (is_string(rule)) { _messages[rule] = message; } }
javascript
{ "resource": "" }
q33702
train
function(attribute, alias) { if (is_object(attribute)) { _attributes = extend({}, _attributes, attribute); } else if (is_string(attribute)) { _attributes[attribute] = alias; } }
javascript
{ "resource": "" }
q33703
train
function(value, alias) { if (is_object(value)) { _values = extend({}, _values, value); } else if (is_string(rule)) { _values[value] = alias; } }
javascript
{ "resource": "" }
q33704
train
function(rule, fn) { if (is_object(rule)) { _replacers = extend({}, _replacers, rule); } else if (is_string(rule)) { _replacers[rule] = fn; } }
javascript
{ "resource": "" }
q33705
makeHoliday
train
function makeHoliday(date, info, observedInfo) { // always make the holiday. var holiday = { info: info, date: { month: date.getMonth(), day : date.getDate() } } // if the holiday info's `bank` value has a function then // give it the date so it can evaluate the value. if ('functi...
javascript
{ "resource": "" }
q33706
newYearsSpecial
train
function newYearsSpecial(year) { // 1. hold onto the date, we'll need it in #3 var date = holidays.newYearsDay(year) // 2. do the usual. var newYears = makeHoliday( date, { name: 'New Year\'s Day', bank: !date.observed }, { name: 'New Year\'s Day (Observed)', bank: true } ) // 3. check if the...
javascript
{ "resource": "" }
q33707
train
function(action, implementation){ this.performableActions = this.performableActions || {}; this.performableActions[action] = this.performableActions[action] || {}; this.performableActions[action].actionName = this...
javascript
{ "resource": "" }
q33708
train
function(action, settings){ var handler = this.performableActions[action]; if(!handler){ return false; } if(!handler.getTargetsForAction){ return false; } settings = settings || {}; if(!settings.skipCan...
javascript
{ "resource": "" }
q33709
train
function(action, target, settings){ if(!this.performableActions){ return false; } var handler = this.performableActions[action]; if(!handler){ return false; } // target cannot resolve any actions if(!targ...
javascript
{ "resource": "" }
q33710
train
function(action, target, settings){ if(!this.performableActions){ return false; } var handler = this.performableActions[action]; if(!handler){ return false; } settings = settings || {}; // the functions ...
javascript
{ "resource": "" }
q33711
train
function(action, implementation){ this.resolvableActions = this.resolvableActions || {}; this.resolvableActions[action] = this.resolvableActions[action] || {}; this.resolvableActions[action].actionName = this.r...
javascript
{ "resource": "" }
q33712
train
function(action, source, settings){ if(!this.resolvableActions){ return false; } var handler = this.resolvableActions[action]; if(!handler){ return false; } if(handler.canResolveAction === false){ ret...
javascript
{ "resource": "" }
q33713
train
function(action, source, settings){ if(!this.resolvableActions){ return false; } var handler = this.resolvableActions[action]; if(!handler){ return false; } settings = settings || {}; if(!settings.skipCan...
javascript
{ "resource": "" }
q33714
train
function (metric) { var now = (new Date().getTime()).toFixed(0) var line = null if (metric.sct === 'OS' && /collectd/.test(metric.name)) { line = this.collectdFormatLine(metric) } else { if (metric.sct === 'OS') { // new OS metric format if (metric.filters ins...
javascript
{ "resource": "" }
q33715
monitor
train
function monitor() { if(!child.pid) { // If the number of periodic starts exceeds the max, kill the process if (starts >= options.maxRetries) { if ((Date.now() - startTime) > maxMilliseconds) { console.error( `Too many restarts within the last ${maxMilliseconds / 1000} seco...
javascript
{ "resource": "" }
q33716
Game
train
function Game() { // un-populated instance of Array2d this.map = new RL.Map(this); this.entityManager = new RL.ObjectManager(this, RL.Entity); this.renderer = new RL.Renderer(this); this.console = new RL.Console(this); this.lighting = new RL.LightingROT(this); /...
javascript
{ "resource": "" }
q33717
train
function(width, height){ this.map.setSize(width, height); this.player.fov.setSize(width, height); this.entityManager.setSize(width, height); this.lighting.setSize(width, height); }
javascript
{ "resource": "" }
q33718
train
function(action) { if(!this.gameOver){ var result = this.player.update(action); if(result){ this.entityManager.update(this.player); this.player.updateFov(); this.lighting.update(); this.renderer...
javascript
{ "resource": "" }
q33719
train
function(x, y){ var coords = this.renderer.mouseToTileCoords(x, y), tile = this.map.get(coords.x, coords.y); if(!tile){ return; } var entityTile = this.entityManager.get(tile.x, tile.y); if(entityTile){ this.cons...
javascript
{ "resource": "" }
q33720
train
function(x, y){ var coords = this.renderer.mouseToTileCoords(x, y), tile = this.map.get(coords.x, coords.y); if(tile){ this.renderer.hoveredTileX = tile.x; this.renderer.hoveredTileY = tile.y; } else { this.renderer.hove...
javascript
{ "resource": "" }
q33721
train
function(x, y){ var result = []; var entity = this.entityManager.get(x, y); if(entity){ result.push(entity); } // add items or any other objects that can be placed at a tile coord position return result; }
javascript
{ "resource": "" }
q33722
train
function(entity, x, y){ var tile = this.map.get(x, y); // if tile blocks movement if(!tile || !tile.passable){ return false; } return true; }
javascript
{ "resource": "" }
q33723
train
function(entity, x, y){ if(!this.entityCanMoveThrough(entity, x, y)){ return false; } // check if occupied by entity if(this.entityManager.get(x, y)){ return false; } return true; }
javascript
{ "resource": "" }
q33724
train
function(entity, x, y){ var tile = this.map.get(x, y); return tile && !tile.blocksLos; }
javascript
{ "resource": "" }
q33725
handleRecipeFiles
train
function handleRecipeFiles(folderPath) { if (handled[folderPath]) { return; } handled[folderPath] = true; handleRecipeFile(path.join(folderPath, 'tsconfig.json')); handleRecipeFiles(path.dirname(folderPath)); }
javascript
{ "resource": "" }
q33726
handleRecipeFile
train
function handleRecipeFile(recipePath) { var contents = null; try { contents = fs.readFileSync(recipePath); } catch (err) { // Not finding a recipe is OK return; } var config = null; try { config = JSON.parse(contents.toString()); } catch (err) { ...
javascript
{ "resource": "" }
q33727
middleware
train
function middleware (opts) { opts = Object.assign({maxSize: 100, logAll: false}, opts) const log = opts.logAll ? new CustomLog() : void (0) const loggers = new Loggers(opts.maxSize) return function (req, res) { let query = req.query if (!req.query) { query = qsParse(urlParse(req.url).query) }...
javascript
{ "resource": "" }
q33728
train
function(base){ if(typeof base === 'undefined'){ throw new Error("Too few arguments in RollingHash constructor"); }else if(typeof base !== 'number'){ throw new TypeError("Invalid argument; expected a number in RollingHash constructor"); } // The base of the number system this.BASE = base; // The...
javascript
{ "resource": "" }
q33729
Lexerific
train
function Lexerific(config, _, FSM, Lexeme, StateGenerator, Token, TreeNode) { var _this = this; this._ = _; // Create a finite state machine for lexing this.fsm = new FSM({ name: 'lexerific', debug: true, resetAtRoot: true // erase history for every root bound transition }); this.fsm.on('retur...
javascript
{ "resource": "" }
q33730
train
function() { return { char: this.char, color: this.color, bgColor: this.bgColor, borderColor: this.borderColor, borderWidth: this.borderWidth, ...
javascript
{ "resource": "" }
q33731
train
function(defaults, settings) { var out = {}; for (var key in defaults) { if (key in settings) { out[key] = settings[key]; } else { out[key] = defaults[key]; } } return out; }
javascript
{ "resource": "" }
q33732
train
function(destination){ var sources = Array.prototype.slice.call(arguments, 1); for (var i = 0; i < sources.length; i++) { var source = sources[i]; for(var key in source){ destination[key] = source[key]; } } ...
javascript
{ "resource": "" }
q33733
train
function(x1, y1, x2, y2, diagonalMovement){ if(!diagonalMovement){ return Math.abs(x2 - x1) + Math.abs(y2 - y1); } else { return Math.max(Math.abs(x2 - x1), Math.abs(y2 - y1)); } }
javascript
{ "resource": "" }
q33734
train
function(jsStr, __parObj){ if (!__parObj){ return eval(jsStr); }; var s = ""; var n; for (n in __parObj){ s += "var " + n + " = __parObj." + n + ";"; }; //s = "(function(){" + s; s += jsStr; //s += "})();"; return eval(s); ...
javascript
{ "resource": "" }
q33735
HlrLookupClient
train
function HlrLookupClient(username, password, noSsl) { this.username = username; this.password = password; this.url = (noSsl ? 'http' : 'https') + '://www.hlr-lookups.com/api'; }
javascript
{ "resource": "" }
q33736
RendererLayer
train
function RendererLayer(game, type, settings) { this.game = game; this.type = type; var typeData = RendererLayer.Types[type]; RL.Util.merge(this, typeData); for(var key in settings){ if(this[key] !== void 0){ this[key] = settings[key]; } ...
javascript
{ "resource": "" }
q33737
train
function(x, y, prevTileData){ var tileData = this.getTileData(x, y, prevTileData); if(this.mergeWithPrevLayer && prevTileData){ return this.mergeTileData(prevTileData, tileData); } return tileData; }
javascript
{ "resource": "" }
q33738
train
function(tileData1, tileData2){ var result = {}, key, val; for(key in tileData1){ result[key] = tileData1[key]; } for(key in tileData2){ val = tileData2[key]; if(val !== false && val !== void 0){ ...
javascript
{ "resource": "" }
q33739
endStream
train
function endStream(cb) { // If no files were passed in, no files go out ... if (!latestFile || (Object.keys(concats).length === 0 && concats.constructor === Object)) { cb(); return; } // Prepare a method for pushing the stream const pushJoinedFile = (join...
javascript
{ "resource": "" }
q33740
ContentRange
train
function ContentRange(unit, range, length) { this.unit = unit; this.range = range; this.length = length; if (this.range.high && this.length && this.length <= this.range.high) { throw new Error('Length is less than or equal to the range'); } }
javascript
{ "resource": "" }
q33741
load
train
function load() { Desktop.fetch('localStorage', 'getAll').then((storage) => { Meteor._localStorage.storage = storage; }).catch(() => { retries += 1; if (retries < 5) { load(); } else { console.error('failed to load localStorage contents'); } })...
javascript
{ "resource": "" }
q33742
LightingROT
train
function LightingROT(game, settings) { settings = settings || {}; this.game = game; this.lightingMap = new RL.Array2d(); this.lightingMap.set = this.lightingMap.set.bind(this.lightingMap); this.checkVisible = this.checkVisible.bind(this); this._fov = new ROT.FOV.PreciseS...
javascript
{ "resource": "" }
q33743
train
function(x, y, tileData){ var light = this.ambientLight; var lighting = this.get(x, y); var overlay = function(c1, c2){ var out = c1.slice(); for (var i = 0; i < 3; i++) { var a = c1[i], b = c2[i]; ...
javascript
{ "resource": "" }
q33744
train
function(x, y, r, g, b){ this._lighting.setLight(x, y, [r, g, b]); this._dirty = true; }
javascript
{ "resource": "" }
q33745
train
function(x, y){ var tile = this.game.map.get(x, y); if(!tile){ return 0; } if(tile.lightingReflectivity){ return tile.lightingReflectivity; } if(tile.blocksLos){ return this.defaultWallReflectivity...
javascript
{ "resource": "" }
q33746
train
function(next) { if (!inNativeApp) return next(null, false, null, null, null); if (resourceIsBinary(filePath)) { var fullPath = shared.removeUrlMultislashes(fileFullPathRoot + '/' + filePath), xhr; xhr = new XMLHttpRequest(); xhr.open("...
javascript
{ "resource": "" }
q33747
train
function(foundInCacheSeed, fullPath, data, compiled, next) { if (foundInCacheSeed) { debugLog("Found resource in cache seed: " + cacheUrl) if (data) { async.waterfall([ function(next) { if (url.match(/\.css$/)) { ...
javascript
{ "resource": "" }
q33748
UInt
train
function UInt(args) { // Assign default valus this._value = null; this._bytes = null; this._bits = null; this._isHex = false; // Set constraints if present if(args && (isNatural(args.bits) || isNatural(args.bytes))) { // Set the size if either is used this._bits = args.bits || 0; ...
javascript
{ "resource": "" }
q33749
reduceRight
train
function reduceRight(collection, callback, accumulator, thisArg) { if (!collection) { return accumulator; } var length = collection.length, noaccum = arguments.length < 3; if(thisArg) { callback = iteratorBind(callback, thisArg); } if (length === length >>> 0) { if (l...
javascript
{ "resource": "" }
q33750
toArray
train
function toArray(collection) { if (!collection) { return []; } if (toString.call(collection.toArray) == funcClass) { return collection.toArray(); } var length = collection.length; if (length === length >>> 0) { return slice.call(collection); } return values(collection);...
javascript
{ "resource": "" }
q33751
initial
train
function initial(array, n, guard) { if (!array) { return []; } return slice.call(array, 0, -((n == undefined || guard) ? 1 : n)); }
javascript
{ "resource": "" }
q33752
intersection
train
function intersection(array) { var result = []; if (!array) { return result; } var value, index = -1, length = array.length, others = slice.call(arguments, 1); while (++index < length) { value = array[index]; if (indexOf(result, value) < 0 && ever...
javascript
{ "resource": "" }
q33753
last
train
function last(array, n, guard) { if (array) { var length = array.length; return (n == undefined || guard) ? array[length - 1] : slice.call(array, -n || length); } }
javascript
{ "resource": "" }
q33754
union
train
function union() { var index = -1, result = [], flattened = concat.apply(result, arguments), length = flattened.length; while (++index < length) { if (indexOf(result, flattened[index]) < 0) { result.push(flattened[index]); } } return result; }
javascript
{ "resource": "" }
q33755
bind
train
function bind(func, thisArg) { var methodName, isFunc = toString.call(func) == funcClass; // juggle arguments if (!isFunc) { methodName = thisArg; thisArg = func; } // use if `Function#bind` is faster else if (nativeBind) { return nativeBind.call.apply(nativeBind, argu...
javascript
{ "resource": "" }
q33756
bindAll
train
function bindAll(object) { var funcs = arguments, index = 1; if (funcs.length == 1) { index = 0; funcs = functions(object); } for (var length = funcs.length; index < length; index++) { object[funcs[index]] = bind(object[funcs[index]], object); } return object; }
javascript
{ "resource": "" }
q33757
debounce
train
function debounce(func, wait, immediate) { var args, result, thisArg, timeoutId; function delayed() { timeoutId = undefined; if (!immediate) { func.apply(thisArg, args); } } return function() { var isImmediate = immediate && !timeoutId; arg...
javascript
{ "resource": "" }
q33758
memoize
train
function memoize(func, resolver) { var cache = {}; return function() { var prop = resolver ? resolver.apply(this, arguments) : arguments[0]; return hasOwnProperty.call(cache, prop) ? cache[prop] : (cache[prop] = func.apply(this, arguments)); }; }
javascript
{ "resource": "" }
q33759
once
train
function once(func) { var result, ran = false; return function() { if (ran) { return result; } ran = true; result = func.apply(this, arguments); return result; }; }
javascript
{ "resource": "" }
q33760
throttle
train
function throttle(func, wait) { var args, result, thisArg, timeoutId, lastCalled = 0; function trailingCall() { lastCalled = new Date; timeoutId = undefined; func.apply(thisArg, args); } return function() { var now = new Date, remain = ...
javascript
{ "resource": "" }
q33761
wrap
train
function wrap(func, wrapper) { return function() { var args = [func]; if (arguments.length) { push.apply(args, arguments); } return wrapper.apply(this, args); }; }
javascript
{ "resource": "" }
q33762
pick
train
function pick(object) { var prop, index = 0, props = concat.apply(ArrayProto, arguments), length = props.length, result = {}; // start `index` at `1` to skip `object` while (++index < length) { prop = props[index]; if (prop in object) { result[prop] = obj...
javascript
{ "resource": "" }
q33763
size
train
function size(value) { var className = toString.call(value); return className == arrayClass || className == stringClass ? value.length : keys(value).length; }
javascript
{ "resource": "" }
q33764
result
train
function result(object, property) { // based on Backbone's private `getValue` function // https://github.com/documentcloud/backbone/blob/0.9.9/backbone.js#L1419-1424 if (!object) { return null; } var value = object[property]; return toString.call(value) == funcClass ? object[property]() : ...
javascript
{ "resource": "" }
q33765
template
train
function template(text, data, options) { options || (options = {}); var result, defaults = lodash.templateSettings, escapeDelimiter = options.escape, evaluateDelimiter = options.evaluate, interpolateDelimiter = options.interpolate, variable = options.variable; // us...
javascript
{ "resource": "" }
q33766
FidonetURL
train
function FidonetURL(initialString){ if(!( this instanceof FidonetURL )){ return new FidonetURL(initialString); } parseFundamentalSections.call(this, initialString); parseOptionalPart.call(this); parseRequiredPart.call(this); }
javascript
{ "resource": "" }
q33767
checking
train
function checking(desc, args, body, n, options) { if (typeof n === 'undefined') { n = 1000; options = {}; } if (typeof options === 'undefined' && typeof n !== 'number') { options = n; n = 1000; } it(desc, function() { checkers.forAll(args, body).check(n, optio...
javascript
{ "resource": "" }
q33768
train
function(str, maxWidth) { var result = []; /* first tokenization pass - split texts and color formatting commands */ var offset = 0; str.replace(this.RE_COLORS, function(match, type, name, index) { /* string before */ var part = str.substring(offset, index); if (part.length) { result.push({ t...
javascript
{ "resource": "" }
q33769
train
function(color1, color2) { var result = color1.slice(); for (var i=0;i<3;i++) { for (var j=1;j<arguments.length;j++) { result[i] += arguments[j][i]; } } return result; }
javascript
{ "resource": "" }
q33770
train
function(color1, color2) { for (var i=0;i<3;i++) { for (var j=1;j<arguments.length;j++) { color1[i] += arguments[j][i]; } } return color1; }
javascript
{ "resource": "" }
q33771
train
function(color, diff) { if (!(diff instanceof Array)) { diff = ROT.RNG.getNormal(0, diff); } var result = color.slice(); for (var i=0;i<3;i++) { result[i] += (diff instanceof Array ? Math.round(ROT.RNG.getNormal(0, diff[i])) : diff); } return result; }
javascript
{ "resource": "" }
q33772
train
function(color) { var l = color[2]; if (color[1] == 0) { l = Math.round(l*255); return [l, l, l]; } else { function hue2rgb(p, q, t) { if (t < 0) t += 1; if (t > 1) t -= 1; if (t < 1/6) return p + (q - p) * 6 * t; if (t < 1/2) return q; if (t < 2/3) return p + (q - p) * (2/3 - t) * 6...
javascript
{ "resource": "" }
q33773
dict
train
function dict(options = {}) { if (options.lowerCase) { return dictCache[0] || (dictCache[0] = require("../dict/lc-dictionary.json")); } else { return dictCache[1] || (dictCache[1] = require("../dict/dictionary.json")); } }
javascript
{ "resource": "" }
q33774
correctWordsFor
train
function correctWordsFor(word, options = {}) { word = String(word || ""); const found = (options.caseSensitive ? dict()[word] : dict({ lowerCase: true })[word.toLowerCase()] ); return found ? found.split(",") : []; }
javascript
{ "resource": "" }
q33775
correct
train
function correct(str, options, callback) { if (typeof options === "function") { callback = options; options = {}; } const {caseSensitive, overrideCases} = options || {}; str = String(str || ""); const dic = dict({ lowerCase: true }); const re = regexp(caseSensitive ? "g" : "ig"); return str.repl...
javascript
{ "resource": "" }
q33776
Renderer
train
function Renderer(game, width, height, tileSize, canvasClassName) { this.layers = []; this.game = game; this.canvas = document.createElement('canvas'); this.ctx = this.canvas.getContext('2d'); this.canvas.className = canvasClassName || 'renderer'; this.buffer = this.canva...
javascript
{ "resource": "" }
q33777
train
function(x, y, tileData, ctx) { ctx = ctx || this.bufferCtx; var originalX = x, originalY = y; x -= this.originX; y -= this.originY; if(tileData.bgColor){ ctx.fillStyle = tileData.bgColor; ctx.fillRect( ...
javascript
{ "resource": "" }
q33778
train
function(x, y){ var pos = this.canvas.getBoundingClientRect(), mx = x - pos.left, my = y - pos.top; return this.pixelToTileCoords(mx, my); }
javascript
{ "resource": "" }
q33779
train
function(x, y){ return { x: Math.floor(x / this.tileSize) + this.originX, y: Math.floor(y / this.tileSize) + this.originY }; }
javascript
{ "resource": "" }
q33780
train
function(color, ctx){ ctx = ctx || this.bufferCtx; ctx.fillStyle = color || this.bgColor; ctx.fillRect( 0, 0, this.canvas.width, this.canvas.height ); }
javascript
{ "resource": "" }
q33781
train
function(width, height) { this.width = width; this.height = height; for (var i = 0; i < this.width; i++) { if(!this.data){ this.data = []; } if(this.data[i] === void 0){ this.data[i] = []; ...
javascript
{ "resource": "" }
q33782
train
function(x, y, settings) { settings = settings || {}; var filter = settings.filter !== void 0 ? settings.filter : false, withCoords = settings.withCoords !== void 0 ? settings.withCoords : false, withDiagonals = settings.w...
javascript
{ "resource": "" }
q33783
train
function(x, y, settings) { settings = settings || {}; var radius = settings.radius || 1, filter = settings.filter || false, withCoords = settings.withCoords || false, includeTarget = settings.incl...
javascript
{ "resource": "" }
q33784
train
function(x0, y0, x1, y1, condition, withCoords) { withCoords = withCoords || false; condition = condition || false; var output = [], dx = Math.abs(x1 - x0), dy = Math.abs(y1 - y0), sx = (x0 < x1) ? 1 : -1, sy = (y0 < y1)...
javascript
{ "resource": "" }
q33785
train
function(startX, startY, settings) { settings = settings || {}; var maxRadius = settings.maxRadius || 1, filter = settings.filter || false, withCoords = settings.withCoords || false; var currentDistance = 1, result...
javascript
{ "resource": "" }
q33786
train
function(filter, withCoords){ withCoords = withCoords || false; var output = []; for (var x = 0; x < this.width; x++) { for (var y = 0; y < this.height; y++) { var val = this.get(x, y); if(filter(val, x, y)){ ...
javascript
{ "resource": "" }
q33787
train
function(){ var newArray = new Array2d(this.width, this.height); for(var x = this.width - 1; x >= 0; x--){ for(var y = this.height - 1; y >= 0; y--){ var val = this.get(x, y); if(val !== void 0){ newArray.set(x, y, v...
javascript
{ "resource": "" }
q33788
train
function(func, context){ for(var x = this.width - 1; x >= 0; x--){ for(var y = this.height - 1; y >= 0; y--){ var val = this.get(x, y); if(context){ func.call(context, val, x, y); } else { ...
javascript
{ "resource": "" }
q33789
buildInputsArray
train
function buildInputsArray(rawInputsString) { let returnArray = []; // eslint-disable-line const rawMethodInputs = rawInputsString.split(','); // no inputs if (typeof rawMethodInputs === 'undefined' || rawMethodInputs.length === 0) { return []; } rawMethodInputs.forEach((rawMethodInput) => { const ...
javascript
{ "resource": "" }
q33790
solidityToABI
train
function solidityToABI(methodInterface) { // count open and clsoed const methodABIObject = {}; // not a string if (typeof methodInterface !== 'string') { throw new Error(`Method interface must be a string, currently ${typeof methodInterface}`); } // empty string if (methodInterface.length === 0) { ...
javascript
{ "resource": "" }
q33791
train
function(obj){ if(ko.isWriteableObservable(obj)) return ko.observable(obj()); if(obj === null || typeof obj !== 'object') return obj; var temp = obj.constructor(); for (var key in obj) { temp[key] = Utils.cloneObjKnockout(obj[key]); } return temp; }
javascript
{ "resource": "" }
q33792
train
function(_options){ var self = this, //model options = _options || {}, success = options.success; //custom success function passed in _options options.success = function(data){ delete data[self.idAttribute]; var defaults = Utils.cloneObjKnockout(self.defaults); s...
javascript
{ "resource": "" }
q33793
train
function(model_s, create, options){ var toAdd = model_s instanceof Array ? model_s : [model_s], self = this; ko.utils.arrayForEach(toAdd, function(attributes){ var model; if(attributes instanceof Model){ model = attributes; model.collection = self; }els...
javascript
{ "resource": "" }
q33794
train
function(_options){ var self = this, //collection options = _options || {}, success = options.success; //custom success function passed in _options options.success = function(data){ var toAdd = []; for(var model in data){ toAdd.push(data[model]); } ...
javascript
{ "resource": "" }
q33795
Tile
train
function Tile(game, type, x, y) { this.game = game; this.x = x; this.y = y; this.type = type; var typeData = Tile.Types[type]; RL.Util.merge(this, typeData); this.id = tileId++; if(this.init){ this.init(game, type, x, y); } }
javascript
{ "resource": "" }
q33796
baseTranspose
train
function baseTranspose(matrix) { return map(head(matrix), function (column, index) { return map(matrix, function (row) { return row[index]; }); }); }
javascript
{ "resource": "" }
q33797
train
function(game, targets, settings){ this.game = game; settings = settings || {}; this.typeSortPriority = settings.typeSortPriority || [].concat(this.typeSortPriority); var width = settings.mapWidth || this.game.map.width; var height = settings.mapWidth || this.game.map.width; ...
javascript
{ "resource": "" }
q33798
train
function(targets){ targets = targets || []; this.targets = targets; this.map.reset(); for(var i = targets.length - 1; i >= 0; i--){ var target = targets[i]; this.map.add(target.x, target.y, target); } }
javascript
{ "resource": "" }
q33799
train
function(target){ var index = this.targets.indexOf(target); if(index !== -1){ this.current = target; return true; } return false; }
javascript
{ "resource": "" }