_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q34300
firstFunction
train
function firstFunction(args) { for (var i = 0, len = args.length; i < len; i++) { if (typeof args[i] === 'function') { return args[i]; } } return null; }
javascript
{ "resource": "" }
q34301
serializeCallback
train
function serializeCallback(args) { var callback; debug('Transforming callback in ', args); return args.map(function(arg) { if (typeof arg !== 'function') return arg; // It shouldn't be an argument after the callback function invariant(!callback, 'Only one callback function is allowed.'); callb...
javascript
{ "resource": "" }
q34302
promisify
train
function promisify(func) { return function promisified() { var args = Array.prototype.slice.call(arguments); var context = this; return new Promise(function(resolve, reject) { try { func.apply(context, args.concat(function(err, data) { if (err) { return reject(err); ...
javascript
{ "resource": "" }
q34303
changeConfig
train
function changeConfig(oldConfig, newConfig) { invariant(isObject(oldConfig), 'Old config is not valid'); invariant(isObject(newConfig), 'Config is not valid'); if (newConfig.host) { var host = newConfig.host; var prefix = ''; if (host.indexOf('http://') < 0 && host.indexOf('https://') < 0) { p...
javascript
{ "resource": "" }
q34304
appendCode
train
function appendCode() { if (state === "code") { state = "text"; if (!isWhitespace(codeBuffer)) { content += codeOpen + codeBuffer.replace(/^(?:\s*\n)+/, "").replace(/[\s\n]*$/, "") + codeClose; } codeBuffer = ""; } }
javascript
{ "resource": "" }
q34305
sendCommand
train
function sendCommand(command, mac, params, callback, scope) { var commandParts = []; // check for callback instead of params if (typeof params == 'function') { callback = params; params = ''; scope = callback; } var completeCommand = ''; ...
javascript
{ "resource": "" }
q34306
addFileToFolder
train
function addFileToFolder(arrayBuffer) { // Construct the endpoint. var fileCollectionEndpoint = String.format(spFormFactory.getFileEndpointUri(_spPageContextInfo.webAbsoluteUrl, doclibname, foldername) + "/add(overwrite=true, url='{0}')", fileuniquename); // Send the request and ret...
javascript
{ "resource": "" }
q34307
updateListItem
train
function updateListItem(itemMetadata, customFileMetadata) { // Define the list item changes. Use the FileLeafRef property to change the display name. // Assemble the file update metadata var metadata = { __metadata: { type: itemMetadata.type ...
javascript
{ "resource": "" }
q34308
parseIpcMessage
train
function parseIpcMessage(message, cb) { var requestId; if (message._requestId == null) { // eslint-disable-line eqeqeq throw new Error('Invalid message: ' + JSON.stringify(message)); } requestId = message._requestId; delete message._requestId; return cb(+requestId, message); }
javascript
{ "resource": "" }
q34309
parseMessageLines
train
function parseMessageLines(lines, getLine, cb) { var matches, line, lineParts; if (arguments.length < 3) { cb = getLine; getLine = false; } RE_MESSAGE_LINE.lastIndex = 0; while ((matches = RE_MESSAGE_LINE.exec(lines))) { line = matches[1]; lines = matches[2]; if (line === '') { con...
javascript
{ "resource": "" }
q34310
sendIpc
train
function sendIpc(message) { var requestIds; clearTimeout(retryTimer); if (message) { tranRequests[message._requestId] = message; } if ((requestIds = Object.keys(tranRequests)).length) { if (!childProc) { throw new Error('Child process already exited.'); } requestIds.forEach(function(requestI...
javascript
{ "resource": "" }
q34311
isOutside
train
function isOutside (feature, poly) { var a = feature.bbox = feature.bbox || extent(feature) var b = poly.bbox = poly.bbox || extent(poly) return a[2] < b[0] || a[0] > b[2] || a[3] < b[1] || a[1] > b[3] }
javascript
{ "resource": "" }
q34312
highlight
train
function highlight(value) { const el = document.createElement('div'); cm(el, { value, mode: { name: 'jsx', typescript: true }, scrollbarStyle: 'null', inputStyle: 'contenteditable' }); const dom = (0, _cheerio.load)(el.innerHTML), lines = dom('.CodeMirror-line'); // eslint-disable-next-line lodash/pr...
javascript
{ "resource": "" }
q34313
highlightHTML
train
function highlightHTML(code = '') { if (!code) { return ''; } const { dom, lines } = highlight(code); return dom.html(lines); }
javascript
{ "resource": "" }
q34314
evaluatePackage
train
function evaluatePackage(filename, attr, format) { var pkgs = require(path.resolve(filename)).pkgs; var pkg = pkgs[attr](); var expr = nijs.jsToNix(pkg, format); return expr; }
javascript
{ "resource": "" }
q34315
evaluatePackageAsync
train
function evaluatePackageAsync(filename, attr, format, callback) { var pkgs = require(path.resolve(filename)).pkgs; slasp.sequence([ function(callback) { pkgs[attr](callback); }, function(callback, pkg) { var expr = nijs.jsToNix(pkg, format); ...
javascript
{ "resource": "" }
q34316
onScreenBtnClick
train
function onScreenBtnClick (event) { const screenId = event.currentTarget.getAttribute('data-screen'); // if the current screen is the same as the clicked one if (screenId === screenNavigator.currentItemId) return; // display the new screen screenNavigator.showScreen(screenId); }
javascript
{ "resource": "" }
q34317
train
function( aPortNumber ) { var listener = zMIDI._listenerMap[ aPortNumber], inChannel; if ( listener ) { inChannel = zMIDI.getInChannels()[ aPortNumber ]; inChannel.close(); inChannel.removeEventListener( "midimessage", listener...
javascript
{ "resource": "" }
q34318
train
function() { if ( zMIDI.isConnected() ) { var inputs = /** @type {Array.<MIDIInput>} */ ( [] ); var iface = zMIDI._interface; if ( typeof iface.inputs === "function" ) { inputs = iface.inputs(); ...
javascript
{ "resource": "" }
q34319
train
function() { if ( zMIDI.isConnected() ) { var outputs = /** @type {Array.<MIDIOutput>} */ ( [] ); var iface = zMIDI._interface; if ( typeof iface.outputs === "function" ) { outputs = iface.outputs(); ...
javascript
{ "resource": "" }
q34320
sendRequest
train
function sendRequest(operationName, body, callback, context) { if (_.isFunction(body)) { context = callback; callback = body; body = undefined; } body || (body = {}); body = new Buffer(_.isString(body) ? body : JSON.stringify(body)); var httpOpts = { host: SERVICE_NAME.toLowerCase() + '.' + regio...
javascript
{ "resource": "" }
q34321
getTextBindingForToken
train
function getTextBindingForToken(Directive, tokenText) { tokenText = tokenText.trim(); let directiveInstances = PRIVATE.get(Directive); if (!directiveInstances) { directiveInstances = {}; PRIVATE.set(Directive, directiveInstances); } if (!directiveInstances[tokenText]) { di...
javascript
{ "resource": "" }
q34322
DomainNameRule
train
function DomainNameRule(data) { if (typeof (data) === "undefined") { return; } // // matches // this.domain = data.domain; if (data.aliases instanceof Array) { this.aliases = data.aliases.slice(); } else { this.aliases...
javascript
{ "resource": "" }
q34323
FlickrImageDownloader
train
function FlickrImageDownloader () { var that = this; that.url = ''; that.delay = 500; that.downloadFolder = ''; that.paths = {}; that.paths.base = 'https://www.flickr.com'; that.paths.photostream = 'photos/!username'; that.paths.set = that.paths.photostream + '/sets'; that.paths.favorites = that.paths.photo...
javascript
{ "resource": "" }
q34324
signStr
train
function signStr(str, key) { var hmac = crypto.createHmac('sha1', key); hmac.update(str); return hmac.digest('base64').replace(/\+/g, '-').replace(/\//g, '_'); }
javascript
{ "resource": "" }
q34325
train
function (changeset) { changeset.forEach(function(change) { if(change.name!=="__target__") { if(change.type==="delete") { delete proxy[change.name]; } else if(change.type==="update") { // update handler if target key value changes from function to non-function or from a non-function to ...
javascript
{ "resource": "" }
q34326
traverse
train
function traverse(obj) { each(obj, (val, indexOrProp) => { // Move deeper into the object const next = obj[indexOrProp]; // If we can go no further, then quit if (MongoObject.isBasicObject(next)) { traverse(next); } else if (Array.isArray(next)) { obj[i...
javascript
{ "resource": "" }
q34327
extractOp
train
function extractOp(position) { const firstPositionPiece = position.slice(0, position.indexOf('[')); return (firstPositionPiece.substring(0, 1) === '$') ? firstPositionPiece : null; }
javascript
{ "resource": "" }
q34328
isFreshEnough
train
function isFreshEnough(entry, req) { // If no cache-control header in request, then entry is fresh // if it hasn't expired. if (!("cache-control" in req.headers)) { return new Date().getTime() < entry.expires; } var headers = parseHeader(req.headers["cache-control"]); if ("must-revalid...
javascript
{ "resource": "" }
q34329
yaml
train
function yaml(filename, callback) { try { const yamlString = (0, _fs.readFileSync)(filename, 'utf8'); callback(null, (0, _jsYaml.safeLoad)(yamlString, { filename })); } catch (e) { callback(e, {}); } }
javascript
{ "resource": "" }
q34330
pton6
train
function pton6(addr, dest, index = 0) { if (typeof addr !== 'string') { throw new TypeError('Argument 1 should be a string.') } if (addr.length <= 0) { einval() } const isbuffer = Buffer.isBuffer(dest) const endp = index + IPV6_OCTETS if (isbuffer) { if (endp > dest.length) { throw ne...
javascript
{ "resource": "" }
q34331
markdownToUnwrappedHTML
train
function markdownToUnwrappedHTML(markdown) { const html = (0, _trim2.default)(md.render(markdown)), { dom, children } = (0, _jsx.parseHTML)(html); if (1 !== children.length) { return html; } const [child] = children, { type, name } = child; return 'tag' === type && 'p' === name ? dom(chi...
javascript
{ "resource": "" }
q34332
markdownToJSX
train
function markdownToJSX(markdown = '') { markdown = (0, _trim2.default)(markdown); return markdown ? (0, _jsx.htmlToJSX)(markdownToUnwrappedHTML(markdown)) : []; }
javascript
{ "resource": "" }
q34333
_listbox
train
function _listbox() { at.write(VT_SAVE_CURSOR); // save at.write(CSI + (LAST + 2) + ';' + (AGAIN - 2) + 'r'); at.moveto(1, LAST + 2); //at.write(CSI + 'J'); // erase down KEYS.forEach(function(line, idx) { if (selected === idx) at.reverse(); var ll = line.substr(0, process.stdout.columns - 2); a...
javascript
{ "resource": "" }
q34334
Chart
train
function Chart(N) { logger.debug("Chart: " + N); this.N = N; this.outgoing_edges = new Array(N+1); this.incoming_edges = new Array(N+1); var i; for (i = 0; i <= N; i++) { this.outgoing_edges[i] = {}; this.incoming_edges[i] = {}; } }
javascript
{ "resource": "" }
q34335
visualManager
train
function visualManager (records) { let nodes, node; records.forEach(record => { nodes = record.removedNodes; if (!nodes || !nodes.length) return; for (let i=0; i<nodes.length; ++i) { node = nodes[i]; if (node.querySelectorAll) { if (!node.__visua...
javascript
{ "resource": "" }
q34336
maximizeLargeWord
train
function maximizeLargeWord(word, hardBreakStr, maxWidth) { var availableWidth; var ch; var chWidth; var i; availableWidth = maxWidth - Format.width(hardBreakStr); for (i = 0; i < word.length; i++) { ch = word.charAt(i); chWidth = Format.width(ch); if (availableWidth >= ...
javascript
{ "resource": "" }
q34337
train
function (propType, values) { propType.info = Object.assign( propType.info ? propType.info : {}, values ); if (propType.isRequired) { propType.isRequired.info = Object.assign( propType.isRequired && propType.isRequired.info ? propType.isRequired.info : {}, values ); propType.isRequired.info.isRequ...
javascript
{ "resource": "" }
q34338
copy
train
function copy(copiesMap, projectsPath, buildPath) { return _.map(copiesMap, function(dstPath, srcPath) { if (/\/$/.test(dstPath)) { //copy directory return gulp.src(path.join(projectsPath, srcPath)) .pipe(gulp.dest(path.join(bui...
javascript
{ "resource": "" }
q34339
train
function() { let args = Array.prototype.slice.call(arguments), ErrorClass = args[0]; if (_.isObject(ErrorClass)) { args.shift(); } else { ErrorClass = errors.RuntimeError; } args.unshift(null); // the this arg for the .bind() call throw new (Function.prototype.bind.apply(ErrorClass, args));...
javascript
{ "resource": "" }
q34340
arrayAdapter
train
function arrayAdapter(to, from, merge) { // reset target array to.splice(0); // transfer actual values from.reduce(function(target, value, index) { // use `undefined` as always-override value target[index] = merge(undefined, value); return target; }, to); return to; }
javascript
{ "resource": "" }
q34341
weave
train
function weave(type, advised, advisedFunc, aopProxy) { let f, $execute, standalone = false, transfer = aopProxy.transfer, adviser = aopProxy.adviser; if (!advisedFunc) { standalone = true; $execute = advised; } else { $execute = advised[advisedFunc].bind(advised); ...
javascript
{ "resource": "" }
q34342
identityTranform
train
function identityTranform(idSelector) { idSelector = idSelector || function(x) { return x.id; }; var identityMap = {}; return function(input, output, instance) { var id; // Swap out the instance we are populating in the output transform chain if // we have a cached version of it, otherwise this will...
javascript
{ "resource": "" }
q34343
FakeTouches
train
function FakeTouches(element) { this.element = element; this.touches = []; this.touch_type = FakeTouches.TOUCH_EVENTS; this.has_multitouch = true; }
javascript
{ "resource": "" }
q34344
triggerTouch
train
function triggerTouch(type) { var event = document.createEvent('Event'); var touchlist = this._createTouchList(this.touches); event.initEvent('touch' + type, true, true); event.touches = touchlist; event.changedTouches = touchlist; return this.element.dispatchEvent(even...
javascript
{ "resource": "" }
q34345
triggerMouse
train
function triggerMouse(type) { var names = { start: 'mousedown', move: 'mousemove', end: 'mouseup' }; var event = document.createEvent('Event'); event.initEvent(names[type], true, true); var touchList = this._createTouchList(this.touches); ...
javascript
{ "resource": "" }
q34346
triggerPointerEvents
train
function triggerPointerEvents(type, pointerType) { var self = this; var names = { start: 'MSPointerDown', move: 'MSPointerMove', end: 'MSPointerUp' }; var touchList = this._createTouchList(this.touches); touchList.forEach(function(touch) { ...
javascript
{ "resource": "" }
q34347
plugin
train
function plugin(options){ options = options || {}; var from = options.from || 'markdown'; var to = options.to || 'html5'; var args = options.args || []; var opts = options.opts || {}; var pattern = options.pattern || '**/*.md'; var extension = options.ext || '.html'; if (to === 'docx' || to === 'pd...
javascript
{ "resource": "" }
q34348
Device
train
function Device(apple_id, password, display_name) { if (!(this instanceof Device)) return new Device(apple_id, password, display_name); this.apple_id = apple_id; this.password = password; this.display_name = display_name; this.devices = []; this.authenticated = false; }
javascript
{ "resource": "" }
q34349
addDevices
train
function addDevices(deviceArr) { deviceArr.forEach(function(el, i) { self.devices.push({ name: deviceArr[i]['name'], deviceId: deviceArr[i]['id'] }); }); }
javascript
{ "resource": "" }
q34350
train
function(res) { function addCookie(cookie) { try { cookieJar.setCookieSync(cookie, config.base_url); } catch (err) { throw err; } } if (Array.isArray(res.headers['set-cookie'])) { res.headers['set-cookie'].forEach(addCookie); } else { addCookie(res.headers['set-cookie']); } }
javascript
{ "resource": "" }
q34351
plugin
train
function plugin( _options ) { let options = _options || {}; return ( files, metalsmith, done ) => { let app = new Youtube( options, files ); app.parse( function() { done(); }); }; }
javascript
{ "resource": "" }
q34352
merge
train
function merge(to, from) { // if no suitable adapters found // just return overriding value var result = from , typeOf = getTypeOfAdapter.call(this) , type = typeOf(from) , adapter = getMergeByTypeAdapter.call(this, type) ; // if target object isn't the same type as the source object, //...
javascript
{ "resource": "" }
q34353
getMergeByTypeAdapter
train
function getMergeByTypeAdapter(type) { var adapter = adapters[type] || passThru; // only if usage of custom adapters is authorized // to prevent global context leaking in if (this.useCustomAdapters === behaviors.useCustomAdapters && typeof this[type] == 'function' ) { adapter = this[type]; } ret...
javascript
{ "resource": "" }
q34354
getInitialValue
train
function getInitialValue(type, adapter) { var value // should be either `window` or `global` , glob = typeof window == 'object' ? window : global // capitalize the first letter to make object constructor , objectType = type[0].toUpperCase() + type.substr(1) ; if (typeof adapter.initialVal...
javascript
{ "resource": "" }
q34355
train
function (filename) { if (!fs.existsSync(filename)) { logger.error({ method: "edit_add_cookbook_ids", filename: filename }, "file does not exist"); return; } var encoding = 'utf8'; var changed = false; var contents = fs.readFileSync(filename, encoding...
javascript
{ "resource": "" }
q34356
copy_row
train
function copy_row(nnz, offset, A, /*int* index, // const int* double* value, // const double* */ x) // x = sparseVector { for(var i=nnz-1; i>=0; --i) if(A.value[i + offset]){ x.push_front(new SparseEntry...
javascript
{ "resource": "" }
q34357
solcOutputLike
train
function solcOutputLike(obj) { let isSolcLike = false; Object.keys(obj).forEach((key) => { if (!isSolcLike && typeof obj[key] === 'object') { isSolcLike = (typeof obj[key].bytecode === 'string' && typeof obj[key].interface === 'string'); } }); return isSolcLike; }
javascript
{ "resource": "" }
q34358
Registry
train
function Registry(opt_options) { if (!(this instanceof Registry)) { return new Registry(opt_options); } opt_options = opt_options || {}; this.breakOnError = opt_options.breakOnError || false; this.depth = opt_options.depth || 10; // regex to match "$schema.*" this._match = /"\$id:[a-z0-9_-]*"/ig; ...
javascript
{ "resource": "" }
q34359
train
function (items, i, j) { var k = items[i]; items[i] = items[j]; items[j] = k; }
javascript
{ "resource": "" }
q34360
train
function (source, callback, context) { var results = []; var i = source.length; while (i--) { results[i] = callback.call(context || source, source[i], i); } return results; }
javascript
{ "resource": "" }
q34361
train
function (value, min, max) { var interval; if (min > max) { max = min + max; min = max - min; max = max - min; } interval = max - min; return min + ((value % interval) + interval) % interval; }
javascript
{ "resource": "" }
q34362
train
function (number, width) { number += ''; width -= number.length; if (width > 0) { return new Array(width + 1).join('0') + number; } return number + ''; }
javascript
{ "resource": "" }
q34363
fixHues
train
function fixHues(h1, h2) { var diff = Math.abs(NAMED_HUE_INDEX[h1] - NAMED_HUE_INDEX[h2]); if (diff !== 1 && diff !== 5) { return false; } var result = { h1: h1, h2: h2 }; if (h1 === 0 && h2 === 300) { result.h1 ...
javascript
{ "resource": "" }
q34364
parseNamedHues
train
function parseNamedHues(value) { var tokens = value.split(/\s+/); var l = tokens.length; if (l < 1 || l > 2) { return false; } var t1 = tokens[l - 1].toLowerCase(); if (!(t1 in BASE_HUE)) { return false; } var h1 =...
javascript
{ "resource": "" }
q34365
Octet
train
function Octet() { Channel.apply(this, arguments); this.dataType = INTEGER | PERCENT; this.cssType = INTEGER; this.range = [0, 255]; this.filter = CLAMP; this.initial = 255; }
javascript
{ "resource": "" }
q34366
Ratio
train
function Ratio() { Channel.apply(this, arguments); this.dataType = NUMBER | PERCENT; this.cssType = NUMBER; this.range = [0, 1]; this.filter = CLAMP; this.initial = 1; }
javascript
{ "resource": "" }
q34367
Hue
train
function Hue() { Channel.apply(this, arguments); this.dataType = NUMBER | HUE; this.cssType = NUMBER; this.range = [0, 360]; this.filter = MOD; this.initial = 0; }
javascript
{ "resource": "" }
q34368
ADD_ALPHA
train
function ADD_ALPHA() { var space = this.space(); var channels = SPACES[space].channels; var result = []; var l = channels.length; for (var i = 0; i < l; i++) { result.push(this[channels[i].name]()); } result.push(1); return new kolor...
javascript
{ "resource": "" }
q34369
REMOVE_ALPHA
train
function REMOVE_ALPHA() { var space = this.space(); var channels = SPACES[space].channels; var result = []; var l = channels.length; for (var i = 0; i < l - 1; i++) { result.push(this[channels[i].name]()); } return new kolor[space.slice(0, -1...
javascript
{ "resource": "" }
q34370
RGBA_TO_CMYK
train
function RGBA_TO_CMYK() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var black = 1 - Math.max(r, g, b); if (black === 0) { return kolor.cmyk(0, 0, 0, 0); } var c = (1 - r - black) / (1 - black); var m =...
javascript
{ "resource": "" }
q34371
RGBA_TO_HSLA
train
function RGBA_TO_HSLA() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var a = this.a(); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var diff = max - min; var sum = max + min; var h; var s;...
javascript
{ "resource": "" }
q34372
RGBA_TO_HSVA
train
function RGBA_TO_HSVA() { var r = this.r() / 255; var g = this.g() / 255; var b = this.b() / 255; var a = this.a(); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var diff = max - min; var h; var s; if (max === min) {...
javascript
{ "resource": "" }
q34373
HSLA_TO_RGBA
train
function HSLA_TO_RGBA() { var h = this.h(); var s = this.s(); var l = this.l(); var a = this.a(); var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; var hk = h / 360; var t = {}; var rgb = {}; t.r = hk + 1 / 3; ...
javascript
{ "resource": "" }
q34374
HSLA_TO_HSVA
train
function HSLA_TO_HSVA() { var h = this.h(); var s = this.s(); var l = this.l(); var a = this.a(); l *= 2; s *= (l <= 1) ? l : 2 - l; var v = (l + s) / 2; var sv = (2 * s) / (l + s); return kolor.hsva(h, sv, v, a); }
javascript
{ "resource": "" }
q34375
HSVA_TO_RGBA
train
function HSVA_TO_RGBA() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); var hi = Math.floor(h / 60); var f = h / 60 - hi; var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); var r...
javascript
{ "resource": "" }
q34376
HSVA_TO_HSLA
train
function HSVA_TO_HSLA() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); var l = (2 - s) * v; var sl = s * v; sl /= (l <= 1) ? l : 2 - l; sl = sl || 0; l /= 2; return kolor.hsla(h, sl, l, a); }
javascript
{ "resource": "" }
q34377
HSVA_TO_HWB
train
function HSVA_TO_HWB() { var h = this.h(); var s = this.s(); var v = this.v(); var a = this.a(); return kolor.hwb(h, (1 - s) * v, 1 - v, a); }
javascript
{ "resource": "" }
q34378
HWB_TO_HSVA
train
function HWB_TO_HSVA() { var h = this.h(); var w = this.w(); var b = this.b(); var a = this.a(); return kolor.hsva(h, 1 - w / (1 - b), 1 - b, a); }
javascript
{ "resource": "" }
q34379
GRAY_TO_RGBA
train
function GRAY_TO_RGBA() { var s = this.s(); var a = this.a(); return kolor.rgba(s, s, s, a); }
javascript
{ "resource": "" }
q34380
CMYK_TO_RGBA
train
function CMYK_TO_RGBA() { var c = this.c(); var m = this.m(); var y = this.y(); var black = this.b(); var r = 1 - Math.min(1, c * (1 - black) + black); var g = 1 - Math.min(1, m * (1 - black) + black); var b = 1 - Math.min(1, y * (1 - black) + black); ...
javascript
{ "resource": "" }
q34381
getConverters
train
function getConverters(from, to) { if (from === to) { return []; } if (CONVERTERS[from][to]) { return [to]; } var queue = [from]; var path = {}; path[from] = []; while (queue.length) { var v = queue.shif...
javascript
{ "resource": "" }
q34382
filterValue
train
function filterValue(value, channel) { var type; for (var key in DATATYPES) { type = DATATYPES[key]; if (type.flag & channel.dataType) { var val = type.parse(value); if (val !== false) { if (type.flag === PERCENT) { ...
javascript
{ "resource": "" }
q34383
train
function(event_name, fn, context, listener_args) { return this._addListener(event_name, fn, context, listener_args, this._listeners) }
javascript
{ "resource": "" }
q34384
train
function(event_name, fn, context, listener_args, listeners_by_event) { // otherwise, listener would be called on window object if (Lava.schema.DEBUG && !context) Lava.t('Listener was created without a context'); // note 1: member count for a plain object like this must not exceed 8 // otherwise, chrome will s...
javascript
{ "resource": "" }
q34385
train
function(listener, listeners_by_event) { var list = listeners_by_event[listener.event_name], index; if (list) { index = list.indexOf(listener); if (index != -1) { list.splice(index, 1); if (list.length == 0) { listeners_by_event[listener.event_name] = null; } } } }
javascript
{ "resource": "" }
q34386
train
function(listeners, event_args) { var copy = listeners.slice(), // cause they may be removed during the fire cycle i = 0, count = listeners.length, listener; for (; i < count; i++) { listener = copy[i]; listener.fn.call(listener.context, this, event_args, listener.listener_args); } }
javascript
{ "resource": "" }
q34387
train
function(properties_object) { if (Lava.schema.DEBUG && properties_object && properties_object.isProperties) Lava.t("setProperties expects a plain JS object as an argument, not a class"); for (var name in properties_object) { this.set(name, properties_object[name]); } }
javascript
{ "resource": "" }
q34388
train
function(config, target) { this.guid = Lava.guid++; if (config.duration) { this._duration = config.duration; } this._target = target; this._transition = config.transition || Lava.transitions[config.transition_name || 'linear']; this._config = config; }
javascript
{ "resource": "" }
q34389
train
function() { this._is_reversed = !this._is_reversed; if (this._is_running) { var now = new Date().getTime(), new_end = 2 * now - this._started_time; // it's possible in case of script lags. Must not allow negative transition values. if (now > this._end_time) { this._started_time = this._end_ti...
javascript
{ "resource": "" }
q34390
train
function(transition_value) { for (var i = 0, count = this._animators.length; i < count; i++) { this._animators[i].animate(this._target, transition_value); } }
javascript
{ "resource": "" }
q34391
train
function(now) { if (now < this._end_time) { this._callAnimators(this._transition((now - this._started_time) / this._duration)); } else { this._callAnimators(this._transition(1)); this._finish(); } }
javascript
{ "resource": "" }
q34392
train
function(config) { if (config) { if (config.check_property_names === false) this._check_property_names = false; } this._serializeFunction = (config && config.pretty_print_functions) ? this._serializeFunction_PrettyPrint : this._serializeFunction_Normal }
javascript
{ "resource": "" }
q34393
train
function(value, padding) { var type = Firestorm.getType(value), result; if (Lava.schema.DEBUG && !(type in this._callback_map)) Lava.t("Unsupported type for serialization: " + type); result = this[this._callback_map[type]](value, padding); return result; }
javascript
{ "resource": "" }
q34394
train
function(data, padding) { var tempResult = [], i = 0, count = data.length, child_padding = padding + "\t", result; if (count == 0) { result = '[]'; } else if (count == 1) { result = '[' + this._serializeValue(data[i], padding) + ']'; } else { for (; i < count; i++) { tempResult....
javascript
{ "resource": "" }
q34395
train
function(data, padding) { var tempResult = [], child_padding = padding + "\t", name, type, result, is_complex = false, only_key = null, is_empty = true; // this may be faster than using Object.keys(data), but I haven't done speed comparison yet. // Purpose of the following code: // 1) if ...
javascript
{ "resource": "" }
q34396
train
function(name, value, padding) { var type = Firestorm.getType(value); // if you serialize only Lava configs, then most likely you do not need this check, // cause the property names in configs are always valid. if (this._check_property_names && (!Lava.VALID_PROPERTY_NAME_REGEX.test(name) || Lava.JS_KEYWORDS.i...
javascript
{ "resource": "" }
q34397
train
function(data, padding) { var result = this._serializeFunction_Normal(data), lines = result.split(/\r?\n/), last_line = lines[lines.length - 1], tabs, num_tabs, i = 1, count = lines.length; if (/^\t*\}$/.test(last_line)) { if (last_line.length > 1) { // if there are tabs tabs = last_line....
javascript
{ "resource": "" }
q34398
train
function() { var old_uid = this._data_uids.pop(), old_value = this._data_values.pop(), old_name = this._data_names.pop(), count = this._count - 1; this._setLength(count); this._fire('items_removed', { uids: [old_uid], values: [old_value], names: [old_name] }); this._fire('collection_chan...
javascript
{ "resource": "" }
q34399
train
function(value) { var result = false, index = this._data_values.indexOf(value); if (index != -1) { this.removeAt(index); result = true; } return result; }
javascript
{ "resource": "" }