_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q35600
add
train
function add (obj, name, value) { const previous = obj[name] if (previous) { const arr = [].concat(previous) arr.push(value) return arr } else return value }
javascript
{ "resource": "" }
q35601
retrieveContextAtReceiver
train
function retrieveContextAtReceiver(req, res) { if(redirect(req.params.id, '', '', res)) { return; } switch(req.accepts(['json', 'html'])) { case 'html': res.sendFile(path.resolve(__dirname + '/../../web/response.html')); break; default: var options = { query: 'receivedStrong...
javascript
{ "resource": "" }
q35602
popContext
train
function popContext(state) { if (state.context) { var oldContext = state.context; state.context = oldContext.prev; return oldContext; } // we shouldn't be here - it means we didn't have a context to pop return null; }
javascript
{ "resource": "" }
q35603
isTokenSeparated
train
function isTokenSeparated(stream) { return stream.sol() || stream.string.charAt(stream.start - 1) == " " || stream.string.charAt(stream.start - 1) == "\t"; }
javascript
{ "resource": "" }
q35604
loadPackage
train
function loadPackage(target, location, section, options, done) { if(section == 'config') { options.dirname = path.resolve(location + '/' + section); } else { options.dirname = path.resolve(location + '/api/' + section); } buildDictionary.optional(options, function(err, modules) { if(err) return done(err); ...
javascript
{ "resource": "" }
q35605
train
function(sails, done) { sails.log.silly('Initializing Bulkhead packages...'); // Detach models from the Sails instance var bulkheads = Object.keys(Bulkhead), i = 0, detachedLoadModels = sails.modules.loadModels; /** * Reload event that loads each Bulkhead package's models */ var reloadedEvent = f...
javascript
{ "resource": "" }
q35606
train
function() { _.each(Bulkhead, function(bulkhead, bulkheadName) { // A registered Bulkhead package needs to be initiated, bound to the Sails instance, detached, and merged back into the Bulkhead _.each(bulkhead.models, function(model, index) { bulkhead.models[model.originalIdentity] = sails.models[model....
javascript
{ "resource": "" }
q35607
make
train
function make(x, options = {}) { var {debug = DEBUG_ALL} = options; var u; debug = DEBUG && debug; if (x === undefined) u = makeUndefined(); else if (x === null) u = makeNull(); else { u = Object(x); if (!is(u)) { add(u, debug); defineProperty(u, 'change', { value: change }); } }...
javascript
{ "resource": "" }
q35608
change
train
function change(x) { var u = this; var debug = u._upwardableDebug; if (x !== this.valueOf()) { u = make(x, { debug }); getNotifier(this).notify({object: this, newValue: u, type: 'upward'}); if (debug) { console.debug(...channel.debug("Replaced upwardable", this._upwardableId, "with", u._upward...
javascript
{ "resource": "" }
q35609
setQRstyle
train
function setQRstyle (dst, src, caller) { dst['qrpopup'] = src.qrpopup ? src.qrpopup : false dst['qrsize'] = src.qrsize > 0 ? src.qrsize : 128 dst['qrvoffset'] = src.qrvoffset >= 0 ? src.qrvoffset : 20 dst['qrpadding'] = src.qrpadding ? src.qrpadding : '1em' dst['qrposition'] = POSITIONS.includes(src.qrpositio...
javascript
{ "resource": "" }
q35610
convertData2Hexd
train
function convertData2Hexd (data) { if (!isHexString(data)) { var hex = '' for (var i = 0; i < data.length; i++) { hex += data.charCodeAt(i).toString(16) } return '0x' + hex } return data }
javascript
{ "resource": "" }
q35611
augmenter
train
function augmenter(object, subject, hookCb) { var unaugment, originalCb = object[subject]; unaugment = function() { // return everything back to normal object[subject] = originalCb; }; object[subject] = function() { var args = Array.prototype.slice.call(arguments) , result = originalCb...
javascript
{ "resource": "" }
q35612
step
train
function step() { var f = script.shift(); if(f) { f(stack, step); } else { return cb(null, stack.pop()); } }
javascript
{ "resource": "" }
q35613
train
function(ciphertext, key, iv, encoding) { var binary, bytes, hex; if (encoding == null) { encoding = "buffer"; } iv = this.toBuffer(iv); key = this.toBuffer(key); ciphertext = this.toBuffer(ciphertext); binary = Gibberish.rawDecrypt(ciphertext, key, iv, true); hex...
javascript
{ "resource": "" }
q35614
train
function(password, salt, iterations, keysize) { var bits, hmac, self; if (iterations == null) { iterations = 10000; } if (keysize == null) { keysize = 512; } self = this; hmac = (function() { function hmac(key) { this.key = sjcl.codec.bytes.fro...
javascript
{ "resource": "" }
q35615
train
function(data, key, keysize) { var input, mode; if (keysize == null) { keysize = 512; } data = this.toHex(data); key = this.toHex(key); mode = "SHA-" + keysize; input = new jsSHA(data, "HEX"); return input.getHMAC(key, "HEX", mode, "HEX"); }
javascript
{ "resource": "" }
q35616
train
function(data, keysize) { var input, mode; if (keysize == null) { keysize = 512; } data = this.toHex(data); mode = "SHA-" + keysize; input = new jsSHA(data, "HEX"); return input.getHash(mode, "HEX"); }
javascript
{ "resource": "" }
q35617
train
function(data) { var bytesToPad, padding; bytesToPad = BLOCKSIZE - (data.length % BLOCKSIZE); padding = this.randomBytes(bytesToPad); return this.concat([padding, data]); }
javascript
{ "resource": "" }
q35618
train
function(length) { var array, byte, _i, _len, _results; array = new Uint8Array(length); window.crypto.getRandomValues(array); _results = []; for (_i = 0, _len = array.length; _i < _len; _i++) { byte = array[_i]; _results.push(byte); } return _results; }
javascript
{ "resource": "" }
q35619
train
function(data, encoding) { if (encoding == null) { encoding = 'hex'; } if (Array.isArray(data)) { return data; } switch (encoding) { case 'base64': return Gibberish.base64.decode(data); case 'hex': return Gibberish.h2a(data); case...
javascript
{ "resource": "" }
q35620
train
function(hex) { var pow, result; result = 0; pow = 0; while (hex.length > 0) { result += parseInt(hex.substring(0, 2), 16) * Math.pow(2, pow); hex = hex.substring(2, hex.length); pow += 8; } return result; }
javascript
{ "resource": "" }
q35621
train
function(number, pad) { var endian, i, multiplier, padding, power, remainder, value, _i; if (pad == null) { pad = true; } power = Math.floor((Math.log(number) / Math.LN2) / 8) * 8; multiplier = Math.pow(2, power); value = Math.floor(number / multiplier); remainder = num...
javascript
{ "resource": "" }
q35622
train
function(dec) { var hex; hex = dec.toString(16); if (hex.length < 2) { hex = "0" + hex; } return hex; }
javascript
{ "resource": "" }
q35623
train
function(binary) { var char, hex, _i, _len; hex = ""; for (_i = 0, _len = binary.length; _i < _len; _i++) { char = binary[_i]; hex += char.charCodeAt(0).toString(16).replace(/^([\dA-F])$/i, "0$1"); } return hex; }
javascript
{ "resource": "" }
q35624
train
function(length) { var bytes, hex; if (length == null) { length = 32; } length /= 2; bytes = this.randomBytes(length); return hex = this.toHex(bytes).toUpperCase(); }
javascript
{ "resource": "" }
q35625
decorate
train
function decorate (Comp) { var component // instantiate classes if (typeof Comp === 'function') { component = new Comp() } else { // make sure we don't change the id on a cached component component = Object.create(Comp) } // components get a new id on render, // so we can clear the previous ...
javascript
{ "resource": "" }
q35626
cleanAttrNodes
train
function cleanAttrNodes ($container, includeParent) { var nodes = [].slice.call($container.querySelectorAll(durrutiElemSelector)) if (includeParent) { nodes.push($container) } nodes.forEach(($node) => { // cache component in node $node._durruti = getCachedComponent($node) // clean-up data att...
javascript
{ "resource": "" }
q35627
getComponentNodes
train
function getComponentNodes ($container, traverse = true, arr = []) { if ($container._durruti) { arr.push($container) } if (traverse && $container.children) { for (let i = 0; i < $container.children.length; i++) { getComponentNodes($container.children[i], traverse, arr) } } return arr }
javascript
{ "resource": "" }
q35628
extend
train
function extend(classDefinition, superclass, extraProperties) { var subclassName = className(classDefinition, 'Subclass'); // Find the right classDefinition - either the one provided, a new one or the one from extraProperties. var extraPropertiesHasConstructor = typeof extraProperties !== 'undefined' && extraProp...
javascript
{ "resource": "" }
q35629
mixin
train
function mixin(target, Mix) { assertArgumentOfType('function', target, ERROR_MESSAGES.NOT_CONSTRUCTOR, 'Target', 'mixin'); Mix = toFunction( Mix, new TypeError( msg( ERROR_MESSAGES.WRONG_TYPE, 'Mix', 'mixin', 'non-null object or function', Mix === null ? 'null' : typeof Mix ) ) ); ...
javascript
{ "resource": "" }
q35630
inherit
train
function inherit(target, parent) { assertArgumentOfType('function', target, ERROR_MESSAGES.NOT_CONSTRUCTOR, 'Target', 'inherit'); parent = toFunction( parent, new TypeError( msg( ERROR_MESSAGES.WRONG_TYPE, 'Parent', 'inherit', 'non-null object or function', parent === null ? 'null' : typeof...
javascript
{ "resource": "" }
q35631
implement
train
function implement(classDefinition, protocol) { doImplement(classDefinition, protocol); setTimeout(function() { assertHasImplemented(classDefinition, protocol); }, 0); return classDefinition; }
javascript
{ "resource": "" }
q35632
hasImplemented
train
function hasImplemented(classDefinition, protocol) { doImplement(classDefinition, protocol); assertHasImplemented(classDefinition, protocol); return classDefinition; }
javascript
{ "resource": "" }
q35633
isA
train
function isA(instance, parent) { if(instance == null) { assertArgumentNotNullOrUndefined(instance, ERROR_MESSAGES.NULL, 'Object', 'isA'); } // sneaky edge case where we're checking against an object literal we've mixed in or against a prototype of // something. if (typeof parent === 'object' && parent.hasOwnPr...
javascript
{ "resource": "" }
q35634
classFulfills
train
function classFulfills(classDefinition, protocol) { assertArgumentNotNullOrUndefined(classDefinition, ERROR_MESSAGES.NULL, 'Class', 'classFulfills'); assertArgumentNotNullOrUndefined(protocol, ERROR_MESSAGES.NULL, 'Protocol', 'classFulfills'); return fulfills(classDefinition.prototype, protocol); }
javascript
{ "resource": "" }
q35635
nonenum
train
function nonenum(object, propertyName, defaultValue) { var value = object[propertyName]; if (typeof value === 'undefined') { value = defaultValue; Object.defineProperty(object, propertyName, { enumerable: false, value: value }); } return value; }
javascript
{ "resource": "" }
q35636
toFunction
train
function toFunction(obj, couldNotCastError) { if (obj == null) { throw couldNotCastError; } var result; if (typeof obj === 'object') { if (obj.hasOwnProperty('constructor')) { if (obj.constructor.prototype !== obj) { throw couldNotCastError; } result = obj.constructor; } else { var EmptyIniti...
javascript
{ "resource": "" }
q35637
missingAttributes
train
function missingAttributes(classdef, protocol) { var result = [], obj = classdef.prototype, requirement = protocol.prototype; var item; for (item in requirement) { if (typeof obj[item] !== typeof requirement[item]) { result.push(item); } } for (item in protocol) { var protocolItemType = typeof protocol[i...
javascript
{ "resource": "" }
q35638
makeMethod
train
function makeMethod(func) { return function() { var args = [this].concat(slice.call(arguments)); return func.apply(null, args); }; }
javascript
{ "resource": "" }
q35639
getSandboxedFunction
train
function getSandboxedFunction(myMixId, Mix, func) { var result = function() { var mixInstances = nonenum(this, '__multiparentInstances__', []); var mixInstance = mixInstances[myMixId]; if (mixInstance == null) { if (typeof Mix === 'function') { mixInstance = new Mix(); } else { mixInstance = Object...
javascript
{ "resource": "" }
q35640
bnToBuffer
train
function bnToBuffer( bn ) { var hex = bn.toString( 16 ) hex = hex.length % 2 === 1 ? '0' + hex : hex return Buffer.from( hex, 'hex' ) }
javascript
{ "resource": "" }
q35641
extract
train
function extract( line, from, to ) { return line.substring( from, to ) .replace( /^\s+|\s+$/g, '' ) }
javascript
{ "resource": "" }
q35642
getCustomRepository
train
function getCustomRepository(RepositoryClass, knex, entityModel) { validate.inheritsFrom( RepositoryClass, EntityRepository, 'Custom repository class must inherit from EntityRepository' ); return memoizedGetCustomRepository(...arguments); }
javascript
{ "resource": "" }
q35643
FixedAgent
train
function FixedAgent(app, options) { if (!(this instanceof FixedAgent)) { return new FixedAgent(app, options); } Agent.call(this, app, options); }
javascript
{ "resource": "" }
q35644
fixedSaveCookies
train
function fixedSaveCookies(res) { const cookies = res.headers['set-cookie']; if (cookies) { const fixedCookies = cookies.reduce( (cookies, cookie) => cookies.concat(cookie.split(/,(?!\s)/)), [] ); this.jar.setCookies(fixedCookies); } }
javascript
{ "resource": "" }
q35645
writeFile
train
function writeFile(fs, p, content, method, cb) { fs.metadata(p) .then(function(metadata) { if (metadata.is_dir) { throw fs.error('EISDIR'); } }, function(e) { if (e.code === 'ENOENT') { var parent = path.dirname(p); return this.mkdir(parent); ...
javascript
{ "resource": "" }
q35646
copy
train
function copy(el, text) { var result, lastText; if (text) { lastText = el.value; el.value = text; } else { text = el.value; } el.value = multiLineTrim(text); try { el.select(); result = document.execCommand('copy'); } catch (err) { result = ...
javascript
{ "resource": "" }
q35647
update
train
function update(v, i, params, {oldValue}) { switch (i) { case 'children': _unobserveChildren(oldValue); _observeChildren(v); break; case 'attrs': _unobserveAttrs (oldValue); _observeAttrs (v); break; } }
javascript
{ "resource": "" }
q35648
report
train
function report(type, state, params) { var reporter = defaultReporter; // get rest of arguments params = Array.prototype.slice.call(arguments, 1); // `init` and `done` types don't have command associated with them if (['init', 'done'].indexOf(type) == -1) { // second (1) position is for command /...
javascript
{ "resource": "" }
q35649
stringifyCommand
train
function stringifyCommand(state, command) { var name; if (typeof command == 'function') { name = typeof command.commandDescription == 'function' ? command.commandDescription(state) : Function.prototype.toString.call(command) ; // truncate long functions name = name.split('\n'); ...
javascript
{ "resource": "" }
q35650
train
function() { if (this.parent) { var newListItem = document.createElement(CHILD_TAG); if (this.notesEl) { newListItem.appendChild(this.notesEl); } if (!this.keep) { var el = this.templates.get('removeButton'); el.ad...
javascript
{ "resource": "" }
q35651
parseHmtxTable
train
function parseHmtxTable(data, start, numMetrics, numGlyphs, glyphs) { var p, i, glyph, advanceWidth, leftSideBearing; p = new parse.Parser(data, start); for (i = 0; i < numGlyphs; i += 1) { // If the font is monospaced, only one entry is needed. This last entry applies to all subsequent glyphs. ...
javascript
{ "resource": "" }
q35652
iterator
train
function iterator(state, tasks, callback) { var keys , tasksLeft = tasks.length , task = tasks.shift() ; if (tasksLeft === 0) { return callback(null, state); } // init current task reference state._currentTask = {waiters: {}}; if (typeOf(task) == 'object') { // update state w...
javascript
{ "resource": "" }
q35653
execute
train
function execute(state, task, keys, callback) { var key , control , assignment = 'ASSIGNMENT' // get list of commands left for this iteration , commandsLeft = (keys || task).length , command = (keys || task).shift() // job id within given task , jobId = commandsLeft ...
javascript
{ "resource": "" }
q35654
cleanWaiters
train
function cleanWaiters(state) { var list = state._currentTask.waiters; Object.keys(list).forEach(function(job) { // prevent callback from execution // by modifying up `once`'s `called` property list[job].callback.called = true; // if called it will return false list[job].callback.value = fals...
javascript
{ "resource": "" }
q35655
recallInMap
train
function recallInMap(resMap, absPath) { if (resMap.has(absPath) && resMap.get(absPath).size > 0) { for (let keyPath of resMap.get(absPath)) { //update first forceUpdate(keyPath) recallInMap(resMap, keyPath) } } }
javascript
{ "resource": "" }
q35656
handle
train
function handle(event) { if(event.data.type == 1 || event.data.type == 3 || event.data.type == 7){ facade.models.login().findCreateFind({ where:{ uid: event.user.id, type: event.data.type, }, defaults: { uid: event.user.id, ...
javascript
{ "resource": "" }
q35657
get
train
function get ( keypath ) { if ( !keypath ) return this._element.parentFragment.findContext().get( true ); var model = resolveReference( this._element.parentFragment, keypath ); return model ? model.get( true ) : undefined; }
javascript
{ "resource": "" }
q35658
add$1
train
function add$1 ( keypath, value ) { if ( value === undefined ) value = 1; if ( !isNumeric( value ) ) throw new Error( 'Bad arguments' ); return set( this.ractive, build$1( this, keypath, value ).map( function ( pair ) { var model = pair[0], val = pair[1], value = model.get(); if ( !isNumeric( val ) || ...
javascript
{ "resource": "" }
q35659
train
function ( Parent, proto, options ) { if ( !options.css ) return; var id = uuid(); var styles = options.noCssTransform ? options.css : transformCss( options.css, id ); proto.cssId = id; addCSS( { id: id, styles: styles } ); }
javascript
{ "resource": "" }
q35660
makeQuotedStringMatcher
train
function makeQuotedStringMatcher ( okQuote ) { return function ( parser ) { var literal = '"'; var done = false; var next; while ( !done ) { next = ( parser.matchPattern( stringMiddlePattern ) || parser.matchPattern( escapeSequencePattern ) || parser.matchString( okQuote ) ); if ( ne...
javascript
{ "resource": "" }
q35661
getConditional
train
function getConditional ( parser ) { var start, expression, ifTrue, ifFalse; expression = readLogicalOr$1( parser ); if ( !expression ) { return null; } start = parser.pos; parser.allowWhitespace(); if ( !parser.matchString( '?' ) ) { parser.pos = start; return expression; } ...
javascript
{ "resource": "" }
q35662
truncateStack
train
function truncateStack ( stack ) { if ( !stack ) return ''; var lines = stack.split( '\n' ); var name = Computation.name + '.getValue'; var truncated = []; var len = lines.length; for ( var i = 1; i < len; i += 1 ) { var line = lines[i]; if ( ~line.indexOf( name ) ) { return truncated...
javascript
{ "resource": "" }
q35663
Ractive$teardown
train
function Ractive$teardown () { if ( this.torndown ) { warnIfDebug( 'ractive.teardown() was called on a Ractive instance that was already torn down' ); return Promise$1.resolve(); } this.torndown = true; this.fragment.unbind(); this.viewmodel.teardown(); this._observers.forEach( cancel ); ...
javascript
{ "resource": "" }
q35664
train
function(test, fromEnd) { var i; if (typeof test !== 'function') return undefined; if (fromEnd) { i = this.length; while (i--) { if (test(this[i], i, this)) { return this[i]; } } } else { i = 0; while (i < this.length) { ...
javascript
{ "resource": "" }
q35665
train
function(count, direction) { return direction ? this.concat(this.splice(0, count)) : this.splice(this.length - count).concat(this); }
javascript
{ "resource": "" }
q35666
promiseWrapper
train
function promiseWrapper (resolve, reject) { // Wait for the process to exit process.on ("exit", (code) => { // Did the process crash? if (code !== 0) reject (process.stderr.textContent); // Resolve resolve (process.stdout.textConte...
javascript
{ "resource": "" }
q35667
run
train
function run(params, command, callback) { var job; // decouple commands command = clone(command); // start command execution and get job reference job = executioner(command, stringify(extend(this, params)), this.options || {}, callback); // make ready to call task termination function return partial(ex...
javascript
{ "resource": "" }
q35668
stringify
train
function stringify(origin) { var i, keys, prepared = {}; keys = Object.keys(origin); i = keys.length; while (i--) { // skip un-stringable things if (typeOf(origin[keys[i]]) == 'function' || typeOf(origin[keys[i]]) == 'object') { continue; } // export it prepared[keys[i]]...
javascript
{ "resource": "" }
q35669
allocateAndFillSyncFunctionArgs
train
function allocateAndFillSyncFunctionArgs(functionInfo, funcArgs, userArgs) { functionInfo.requiredArgTypes.forEach(function(type, i) { var buf = ljTypeOps[type].allocate(userArgs[i]); buf = ljTypeOps[type].fill(buf, userArgs[i]); funcArgs.push(buf); }); }
javascript
{ "resource": "" }
q35670
parseAndStoreSyncFunctionArgs
train
function parseAndStoreSyncFunctionArgs(functionInfo, funcArgs, saveObj) { functionInfo.requiredArgTypes.forEach(function(type, i) { var buf = funcArgs[i]; var parsedVal = ljTypeOps[type].parse(buf); var argName = functionInfo.requiredArgNames[i]; saveObj[argName] = parsedVal; });...
javascript
{ "resource": "" }
q35671
createSyncFunction
train
function createSyncFunction(functionName, functionInfo) { return function syncLJMFunction() { if(arguments.length != functionInfo.args.length) { var errStr = 'Invalid number of arguments. Should be: '; errStr += functionInfo.args.length.toString() + '. '; errStr += 'Giv...
javascript
{ "resource": "" }
q35672
createAsyncFunction
train
function createAsyncFunction(functionName, functionInfo) { return function asyncLJMFunction() { var userCB; function cb(err, res) { if(err) { console.error('Error Reported by Async Function', functionName); } // Create an object to be ...
javascript
{ "resource": "" }
q35673
createSafeAsyncFunction
train
function createSafeAsyncFunction(functionName, functionInfo) { return function safeAsyncFunction() { // Define a variable to store the error string in. var errStr; // Check to make sure the arguments seem to be valid. if(arguments.length != (functionInfo.args.length + 1)) { ...
javascript
{ "resource": "" }
q35674
makeUnique
train
function makeUnique (boxes = []) { // boxes converted to string, for easier comparison const ref = []; const result = []; boxes.forEach((item) => { const item_string = item.toString(); if (ref.indexOf(item_string) === -1) { ref.push(item_string); result.push(item); } }); return res...
javascript
{ "resource": "" }
q35675
train
function(src) { var _deferred = $q.defer(); // Instance var _loadable = { src: src, // Loading completion flag isComplete: false, promise: _deferred.promise, // TODO switch to $document $element: document.createElement('script') }; // Build DOM element _...
javascript
{ "resource": "" }
q35676
train
function(src) { var loadable; // Valid state name required if(!src || src === '') { var error; error = new Error('Loadable requires a valid source.'); error.code = 'invalidname'; throw error; } // Already exists if(_loadableHash[src]) { loadable = _loadableHash[sr...
javascript
{ "resource": "" }
q35677
train
function() { var deferred = $q.defer(); var current = $state.current(); // Evaluate if(current) { var sources = (typeof current.load === 'string' ? [current.load] : current.load) || []; // Get promises $q.all(sources .map(function(src) { return _createLoadabl...
javascript
{ "resource": "" }
q35678
postToFirstAvailableServer
train
function postToFirstAvailableServer (destinationNode, signallingServers, path, message) { return new Promise(function (resolve, reject) { if (signallingServers.length === 0) { reject(new Utils.UnreachableError(createUnreachableErrorMessage(destinationNode))); } ...
javascript
{ "resource": "" }
q35679
pad
train
function pad( str, chr, n ) { return (chr.repeat( Math.max( n - str.length, 0 ) ) + str).substr(-n) }
javascript
{ "resource": "" }
q35680
train
function() { var block = this.rng.random() * this.discreteValues << 0 return pad( block.toString( this.base ), this.fill, this.blockSize ) }
javascript
{ "resource": "" }
q35681
train
function() { return this.timestamp().substr( -2 ) + this.count().toString( this.base ).substr( -4 ) + this._fingerprint[0] + this._fingerprint[ this._fingerprint.length - 1 ] + this.randomBlock().substr( -2 ) }
javascript
{ "resource": "" }
q35682
findPackage
train
function findPackage(config, match) { var map = getPackageMap(config.relativeTo, config.packages); return _.reduce(map, function (prev, pkg) { // Resolve using last priority. Priority: // 1. package is a file // 2. package granularity (done by file depth) if (pkg.regexp.test(match) && (!prev || (p...
javascript
{ "resource": "" }
q35683
matchDirective
train
function matchDirective($parse) { return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs, ctrl) { scope.$watch(function () { return [scope.$eval(attrs.match), ctrl.$viewValue]; }, function (values) { ctrl.$setValidity('match', values[0] === values[1])...
javascript
{ "resource": "" }
q35684
Base
train
function Base(client, endpoint) { var base = this; /** * Get a list of all records for the current API * * @method list * @param {Object} query - OPTIONAL querystring params * @param {Function} callback */ base.list = function() { return function(query, callback) { var q = ''; if (query && 'fun...
javascript
{ "resource": "" }
q35685
train
function(config) { this.events = new EventEmitter(); this.config = config || {}; // Allow someone to change the complete event label. if (!this.config.complete) { this.config.complete = '__complete'; } debug('Chain created with the following configuration: ' + JSON.stringify(this.config)); }
javascript
{ "resource": "" }
q35686
_validateIsModel
train
function _validateIsModel(model) { let parentClass = Object.getPrototypeOf(model); while (parentClass.name !== 'Model' && parentClass.name !== '') { parentClass = Object.getPrototypeOf(parentClass); } validationUtils.booleanTrue( parentClass.name === 'Model', 'Parameter is not an Objection.js model'...
javascript
{ "resource": "" }
q35687
doNativeWasm
train
function doNativeWasm(global, env, providedBuffer) { if (typeof WebAssembly !== 'object') { err('no native wasm support detected'); return false; } // prepare memory import if (!(Module['wasmMemory'] instanceof WebAssembly.Memory)) { err('no native wasm Memory in use'); return fa...
javascript
{ "resource": "" }
q35688
train
function(event) { var e = event || window.event; JSEvents.fillMouseEventData(JSEvents.wheelEvent, e, target); HEAPF64[(((JSEvents.wheelEvent)+(72))>>3)]=e["deltaX"]; HEAPF64[(((JSEvents.wheelEvent)+(80))>>3)]=e["deltaY"]; HEAPF64[(((JSEvents.wheelEvent)+(88))>>3)]=e["de...
javascript
{ "resource": "" }
q35689
get
train
function get(city, _options) { extend(options, _options, {city: city}); getWeather = $q.when(getWeather || angular.copy(getCache()) || getWeatherFromServer(city)); // Clear the promise cached, after resolve or reject the promise. Permit access to the cache data, when // the promise excecution ...
javascript
{ "resource": "" }
q35690
getWeatherFromServer
train
function getWeatherFromServer(city) { var deferred = $q.defer(); var url = openweatherEndpoint; var params = { q: city, units: 'metric', APPID: Config.openweather.apikey || '' }; $http({ method: 'GET', url: url, params: params, withou...
javascript
{ "resource": "" }
q35691
startRefreshWeather
train
function startRefreshWeather() { interval = $interval(getWeatherFromServer(options.city), options.delay); localforage.setItem('aw.refreshing', true); }
javascript
{ "resource": "" }
q35692
prepareWeather
train
function prepareWeather(weatherData) { return { temperature: weatherData.main.temp, icon: (angular.isDefined(weatherIcons[weatherData.weather[0].icon])) ? weatherData.weather[0].icon : weatherData.weather[0].id, description: weatherData.weather[0].description } }
javascript
{ "resource": "" }
q35693
func$withContext
train
function func$withContext(fn, item, i, ctx) { // eslint-disable-line max-params return fn.call(ctx, item, i) }
javascript
{ "resource": "" }
q35694
getNeighbor
train
function getNeighbor(owner, item, dataPropertyName) { const data = validateAttached(owner) return obtainTrueValue(item[data[dataPropertyName]]) }
javascript
{ "resource": "" }
q35695
CalendarList
train
function CalendarList(_super) { _super(this, { flexGrow: 1, alignSelf: FlexLayout.AlignSelf.STRETCH, backgroundColor: Color.GREEN, }); this.init(); }
javascript
{ "resource": "" }
q35696
validateMeta
train
function validateMeta( meta, errBuf ) { var supportedLocales = 'ar,am,bg,bn,ca,cs,da,de,el,en,en_GB,en_US,es,es_419,et,' + 'fa,fi,fil,fr,gu,he,hi,hr,hu,id,it,ja,kn,ko,lt,lv,ml,mr,' + 'ms,nl,no,pl,pt_BR,pt_PT,ro,ru,sk,sl,sr,sv,sw,ta,te,th,' + 'tr,uk,vi,zh_CN,zh_TW'.split(','), isFormatValid = true, isIm...
javascript
{ "resource": "" }
q35697
listen
train
function listen(next) { listenSocket = dgram.createSocket({ type: 'udp4', reuseAddr: true }); listenSocket.on('message', function(payload, rinfo) { var message = parseMessage(payload, rinfo); if (message) { if (message.id != id) { if (message...
javascript
{ "resource": "" }
q35698
createMessage
train
function createMessage(status) { var message = []; message.push(broadcastIdentifier); message.push(compabilityVersion); message.push(netId); message.push(id); message.push(name); message.push(self.port); message.push(status); //message.push(mode)...
javascript
{ "resource": "" }
q35699
Request
train
function Request(Safe, uri, method) { if (!this) return new Request(Safe, uri, method); this.Safe = Safe; this.uri = uri; this.method = method; this._needAuth = false; this._returnMeta = false; }
javascript
{ "resource": "" }