_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q41600 | _sendRequest | train | function _sendRequest(requestObj, callback) {
var Storage, ajaxConfig;
Storage = this;
ajaxConfig = {
url : requestObj.config.url,
type : requestObj.config.type || this.REQUEST_TYPE_GET,
contentType : requestObj.config.contentType || 'applicat... | javascript | {
"resource": ""
} |
q41601 | train | function (xhr, message, callback) {
var response;
switch (xhr.status) {
case this.RESPONSE_OK:
response = JSON.parse(xhr.responseText);
break;
case this.RESPONSE_UNPROCESSABLE_ENTITY:
response = JSON.parse(xhr.responseText);
... | javascript | {
"resource": ""
} | |
q41602 | create | train | function create(requestObj, callback) {
var i, requestConfig, storage;
storage = this;
callback = callback || function(){};
if ((typeof requestObj) === 'undefined' || requestObj === null) {
callback(null);
return this;
}
... | javascript | {
"resource": ""
} |
q41603 | update | train | function update(requestObj, callback) {
var i, found, storedData, storage;
storage = this;
callback = callback || function(){};
if ((typeof requestObj) === 'undefined' || requestObj === null) {
callback(null);
return this;
}... | javascript | {
"resource": ""
} |
q41604 | remove | train | function remove(requestObj, callback) {
var i, storage;
storage = this;
callback = callback || function(){};
if ((typeof requestObj) === 'undefined' || requestObj === null) {
callback(null);
return this;
}
reque... | javascript | {
"resource": ""
} |
q41605 | aleaRandom | train | function aleaRandom(min, max, floating) {
var gen = new Alea(uuid.v4());
if (floating && typeof floating !== 'boolean' && isIterateeCall(min, max, floating)) {
max = floating = undefined;
}
if (floating === undefined) {
if (typeof max === 'boolean') {
floating = max;
max = undefined;
}... | javascript | {
"resource": ""
} |
q41606 | _functionBelongsToObject | train | function _functionBelongsToObject(self, caller, target, protectedMode = false) {
if (!caller) return false;
// We are caching the results for better performance.
let cacheOfResultsForSelf = resultCache.get(self);
if (cacheOfResultsForSelf && cacheOfResultsForSelf.has(caller)) {
return cacheOfR... | javascript | {
"resource": ""
} |
q41607 | prepareProfileDir | train | function prepareProfileDir(profilesDir, nick) {
var nick = nick || '.tmp';
// Just in case `nick` has any funny business...
nick = nick.replace(/[^\w\d.]/g, '-').replace('..', '-');
var profileDir = path.join(profilesDir, util.format('vox-%s', nick));
debug('Ensuring directory at %s', profileDir);
mkdirp.sy... | javascript | {
"resource": ""
} |
q41608 | train | function(model) {
var _d = this._d; // quicker lookup
if (!_d.hasData) {
// if we've never rendered data yet, queue up a reset collection
// this probably means we just finished our very first fetch
// reset needed to clear out loading / no data state..
return this.resetCollection();
}
_d.modelChang... | javascript | {
"resource": ""
} | |
q41609 | train | function(id) {
var self = this;
this.collection.each(function(model) {
if (model.id == id || _(id).contains(model.id)) { return; }
// console.log("Unselecting model", model.id, id);
self.getStateModel(model).set({
selected: false
});
});
} | javascript | {
"resource": ""
} | |
q41610 | exportVis | train | function exportVis(url, dest, callback) {
if (dest === undefined) dest = '.';
(0, _mkdirp2['default'])(dest, function (err) {
if (err && callback) return callback(err);
if (!isVisUrl(url)) {
url = getVisUrl(url);
}
getVisJson(url, _path2['default'].join(dest, 'viz.js... | javascript | {
"resource": ""
} |
q41611 | getVisUrl | train | function getVisUrl(url) {
var match = /https?:\/\/(\S+)\.cartodb\.com\/viz\/(\S+)\/(?:public_)?map/.exec(url);
if (match) {
var user = match[1],
mapId = match[2];
return 'https://' + user + '.cartodb.com/api/v2/viz/' + mapId + '/viz.json';
}
} | javascript | {
"resource": ""
} |
q41612 | downloadVisualizationData | train | function downloadVisualizationData(_visJson, destDir, callback) {
if (destDir === undefined) destDir = '.';
withVisJson(_visJson, function (err, visJson) {
if (err && callback) return callback(err);
_async2['default'].forEachOf(visJson.layers, function (layer, layerIndex, callback) {
... | javascript | {
"resource": ""
} |
q41613 | downloadSublayerData | train | function downloadSublayerData(visJson, layerIndex, sublayerIndex, dest, callback) {
var layer = visJson.layers[layerIndex],
sublayer = layer.options.layer_definition.layers[sublayerIndex];
(0, _mkdirp2['default'])(_path2['default'].dirname(dest), function () {
var dataFile = _fs2['default'].cre... | javascript | {
"resource": ""
} |
q41614 | train | function(folder) {
var files,
modelName;
folder = folder || process.cwd() + '/test/fixtures';
files = fs.readdirSync(folder);
for (var i = 0; i < files.length; i++) {
if (getFileExtension(files[i]) === '.json') {
modelName = fileToModelName(files[i]);
this.objects[modelName] = require(path.joi... | javascript | {
"resource": ""
} | |
q41615 | train | function () {
var that = this,
independent,
dependencyNotRequired;
promiseIndependent = this.saveFixturesFromArray(independentFixtures);
promiseDelayedDependency = this.saveFixturesFromArray(delayedDependencyFixtures);
promise = Q.all([ promiseIndependent, promiseDelayedDependency ])
.then(fun... | javascript | {
"resource": ""
} | |
q41616 | crc32 | train | function crc32( buffer, seed, table ) {
var crc = seed ^ -1
var length = buffer.length - 15
var TABLE = table || crc32.TABLE.DEFAULT
var i = 0
while( i < length ) {
crc = ( crc >>> 8 ) ^ TABLE[ 0xFF & ( crc ^ buffer[ i++ ] ) ]
crc = ( crc >>> 8 ) ^ TABLE[ 0xFF & ( crc ^ buffer[ i++ ] ) ]
crc = (... | javascript | {
"resource": ""
} |
q41617 | normalizeTwitterData | train | function normalizeTwitterData(data,req,res){
var normalized = {
error: false,
error_message: '',
media: []
}
// console.dir(req.session.twitter)
if( isTwitterOverCapacity() ){
normalized.error = true
normalized.error_message = "It appears Twitter is over capacity. Try again."
}
... | javascript | {
"resource": ""
} |
q41618 | isPropTypesDeclaration | train | function isPropTypesDeclaration(context, node) {
// Special case for class properties
// (babel-eslint does not expose property name so we have to rely on tokens)
if (node.type === 'ClassProperty') {
const tokens = context.getFirstTokens(node, 2);
if (isTypesDecl(tokens[0].value) || isTypesDecl(tokens[1].... | javascript | {
"resource": ""
} |
q41619 | reduce | train | function reduce(reducingFn, initFn, enumerable, resultFn) {
if (isFunction(resultFn)) {
resultFn = pipe(unreduced, resultFn);
} else {
resultFn = unreduced;
}
let result;
const iter = iterator(enumerable);
if (!initFn) {
const [initValue] = iter;
initFn = lazy(in... | javascript | {
"resource": ""
} |
q41620 | Throwable | train | function Throwable(wrapped)
{
if (!(this instanceof Throwable))
{
return new Throwable(wrapped);
}
/* istanbul ignore if */
if (typeof wrapped !== 'object')
{
throw Error('Throwable should wrap an Error');
}
// Wrap the Er... | javascript | {
"resource": ""
} |
q41621 | _bundleEPUB | train | function _bundleEPUB(config, done) {
var epubconfig = config.akashacmsEPUB;
var archive = archiver('zip');
var output = fs.createWriteStream(config.akashacmsEPUB.bookmetadata.epub);
output.on('close', function() {
logger.info(archive.pointer() + ' total bytes');
... | javascript | {
"resource": ""
} |
q41622 | train | function(next) {
// Stylesheet and JavaScript files are listed in the config
config.headerScripts.stylesheets.forEach(function(cssentry) {
config.akashacmsEPUB.manifest.push({
id: cssentry.id,
type: "text/c... | javascript | {
"resource": ""
} | |
q41623 | waitAndSet | train | function waitAndSet() {
var i;
var times = [0,200,400,700,1000,1500,2000];
var len = times.length;
for ( i = 0; i < len; i++ ) {
$timeout(setParentHeight,times[i]);
}
} | javascript | {
"resource": ""
} |
q41624 | uploadIndexPages | train | function uploadIndexPages(pagePaths, config, options, callback) {
var requestOptions = {
method: 'POST',
url: options.airport + '/dev/' + config.appId + '/simulator',
form: {}
};
// Attach the files as multi-part
var request = api(config, requestOptions, callback);
var form = requ... | javascript | {
"resource": ""
} |
q41625 | write | train | function write(token, enc, next) {
var type = token[0], buf = token[1];
if(('rule_start' === type || 'atrule_start' === type))
depth++;
if(depth > 0 && !current)
current = {location: [line, column], buffers:[]};
if('rule_end' === type || 'atrule_end' === type)
depth--;
if... | javascript | {
"resource": ""
} |
q41626 | createPartial | train | function createPartial(func, bitmask, thisArg, partials) {
var isBind = bitmask & BIND_FLAG,
Ctor = createCtor(func);
function wrapper() {
var argsIndex = -1,
argsLength = arguments.length,
leftIndex = -1,
leftLength = partials.length,
args = Array(leftLength + argsLength)... | javascript | {
"resource": ""
} |
q41627 | deep_set | train | function deep_set(root, path, value) {
var twig = root;
path.split('/').forEach(function (branch, index, branches) {
if (branch) {
if (self.camelize) {
branch = branch.replace(/(\-([a-z]))/g, function (m) { return m[1].toUpperCase(); })
}
if (index < b... | javascript | {
"resource": ""
} |
q41628 | deep_get | train | function deep_get(root, path) {
var twig = root, result = undefined;
path.split('/').forEach(function (branch, index, branches) {
if (branch) {
if (self.camelize) {
branch = branch.replace(/(\-([a-z]))/g, function (m) { return m[1].toUpperCase(); })
}
... | javascript | {
"resource": ""
} |
q41629 | parse_date_strings | train | function parse_date_strings(root) {
for (key in root) {
if (!root.hasOwnProperty(key)) continue;
var value = root[key];
if (typeof(value) === 'object') {
parse_date_strings(value);
} else if (typeof(value) === 'string' && /\d{4}-?\d{2}-?\d{2}(T?\d{2}:?\d{2}:?\d{2}(Z)?)?/... | javascript | {
"resource": ""
} |
q41630 | getChoices | train | function getChoices() {
const name = choice => fp.padStart(MAX_DESC)(choice.value)
const desc = choice => wrap(choice.description, MAX)
return types.map(choice => {
if (choice.value === 'separator') return SEPARATOR
return {
name: `${name(choice)} ${choice.emoji} ${desc(choice)}`,
value: cho... | javascript | {
"resource": ""
} |
q41631 | createObj | train | function createObj( str ) {
if (!str || str.length == 0) {
return window;
}
var d = str.split("."), j, o = window;
for (j = 0; j < d.length; j = j + 1) {
o[d[j]] = o[d[j]] || {};
o = o[d[j]];
}
return o;
} | javascript | {
"resource": ""
} |
q41632 | addPrototypeBeforeCall | train | function addPrototypeBeforeCall( Class, isAbstract ) {
var constStatic = {},
currentState = {
Static: window.Static,
Abstract: window.Abstract,
Const: window.Const,
Private: window.Private
};
saveState.push(currentState);
window.Static = Class.prototype.Static = {Const:constStatic};... | javascript | {
"resource": ""
} |
q41633 | deleteAddedProtoTypes | train | function deleteAddedProtoTypes( Class ) {
delete Class.prototype.Static;
delete Class.prototype.Const;
delete Class.prototype.Private;
delete Class.prototype.Abstract;
var currentState = saveState.pop();
window.Private = currentState.Private;
window.Const = currentState.Const;
window... | javascript | {
"resource": ""
} |
q41634 | simpleExtend | train | function simpleExtend( from, to ) {
for ( var k in from) {
if (to[k] == undefined) {
to[k] = from[k];
}
}
return to;
} | javascript | {
"resource": ""
} |
q41635 | addAddedFileInnScript | train | function addAddedFileInnScript(key, path, dot_path){
dot_path = dot_path || path;
// checking if same file imported twice for same Class.
if(!dot_path) return;
var script = scriptArr[scriptArr.length - 1];
if( !script ){
return;
}
var arr = script[key] || (script[key] = []);
if( arr.indexOf... | javascript | {
"resource": ""
} |
q41636 | include | train | function include( path, isFromInclude, dot_path ) {
if(!path){
return;
}
all_paths.push(path)
if(isNode){
require(path);
listenFileChange(path);
if(isFromInclude){
fileLoadeManager.iamready(dot_path);
}
return;
}
if (fm.isConcatinated) {
fileLoadeManager.iamready(dot_p... | javascript | {
"resource": ""
} |
q41637 | getReleventClassInfo | train | function getReleventClassInfo( Class, fn, pofn ) {
/// this is script
addPrototypeBeforeCall(Class, this.isAbstract);
var tempObj, k, len;
tempObj = invoke(Class, this.args, pofn.base, this.ics, this.Package, pofn);
tempObj.setMe && tempObj.setMe(pofn);
tempObj.base = pofn.base;
delete tempObj.setM... | javascript | {
"resource": ""
} |
q41638 | checkAvailability | train | function checkAvailability( obj ) {
for ( var k = 1, len = arguments.length; k < len; k++) {
for ( var m in arguments[k]) {
if (obj.hasOwnProperty(m)) {
throw obj.getClass() + ": has " + m + " at more than one places";
}
}
}
} | javascript | {
"resource": ""
} |
q41639 | addTransient | train | function addTransient( internalObj, tempObj ) {
var temp = {}, k, tr = tempObj["transient"] || [];
tr.push("shortHand");
for (k = 0; k < tr.length; k++) {
(temp[tr[k]] = true);
}
eachPropertyOf(internalObj.Static, function( v, key ) {
temp[key] = true;
});
eachPropertyOf(internalObj.staticC... | javascript | {
"resource": ""
} |
q41640 | separeteMethodsAndFields | train | function separeteMethodsAndFields( obj ) {
var methods = [], fields = {};
eachPropertyOf(obj, function( v, k ) {
if (typeof v == 'function') {
methods.push(k + "");
}
else {
fields[k + ""] = v;
}
});
obj = undefined;
return {
methods : methods,
fields : fields
}... | javascript | {
"resource": ""
} |
q41641 | getAllImportClass | train | function getAllImportClass( imp ) {
var newImports = {}, splited;
for ( var k = 0; imp && k < imp.length; k++) {
splited = imp[k].split(".");
newImports[splited[splited.length - 1]] = fm.stringToObject(imp[k]);
}
return newImports;
} | javascript | {
"resource": ""
} |
q41642 | addExtras | train | function addExtras( currentObj, baseObj, fn ) {
// Return function name.
var clss = currentObj.getClass();
for ( var k in currentObj) {
if (currentObj.hasOwnProperty(k) && typeof currentObj[k] == 'function' && k != fn) {
currentObj[k] = currentObj[k].bind(currentObj);
currentObj[k].$name = k;
... | javascript | {
"resource": ""
} |
q41643 | train | function(opts) {
opts = opts || {};
this.heartbeat = null;
this.timeout = null;
this.disconnectOnTimeout = opts.disconnectOnTimeout;
if(opts.heartbeat) {
this.heartbeat = opts.heartbeat * 1000; // heartbeat interval
this.timeout = opts.timeout * 1000 || this.heartbeat * 2; // max heartbeat messa... | javascript | {
"resource": ""
} | |
q41644 | MemoryAdapter | train | function MemoryAdapter(initialFiles) {
if (!(this instanceof MemoryAdapter)) {
return new MemoryAdapter(initialFiles);
}
this.entries = new Map();
// load initial file buffers
if (typeof initialFiles === "object" && initialFiles) {
Object.keys(initialFiles).forEach((fileName) => {
... | javascript | {
"resource": ""
} |
q41645 | train | function (cmd, cwd, callback) {
var async = typeof callback === 'function';
var result = exec(
cmd,
{cwd: cwd},
async ? callback : undefined
);
return result.code !== 0 && !async ? result.stdout : undefined;
} | javascript | {
"resource": ""
} | |
q41646 | train | function () {
return [CORDOVA_PATH]
.concat(Array.prototype.map.call(arguments || [], function (arg) {
return '\'' + arg.replace("'", "\\'") + '\'';
})).join(' ');
} | javascript | {
"resource": ""
} | |
q41647 | moveRender | train | function moveRender (type) {
var method = type ? 'down' : 'up'
ui
.left(lastLen + 2)
.up(count - cur)
.write(' ')
// Each time move to right-bottom.
ui[method]()
.left(2)
.write(chalk.blue(pointer))
.left(2)
.down(count - (type ? ++cur : --cur))
... | javascript | {
"resource": ""
} |
q41648 | cancel | train | function cancel(callback) {
if (!deis._authenticated) {
return callback(new Error('You need to login first'));
}
commons.del(format('/%s/auth/cancel/', deis.version), function() {
deis.api.logout(callback);
});
} | javascript | {
"resource": ""
} |
q41649 | createProfile | train | function createProfile(done) {
if (self.closed) return done(null);
temp.mkdir('browser-controller', function(err, dirpath) {
if (err) return done(err);
self.userDir = dirpath;
done(null);
});
} | javascript | {
"resource": ""
} |
q41650 | closeChromium | train | function closeChromium(done) {
var child = self.process;
// remove error handlers
if (child) {
child.removeListener('error', handlers.relayError);
child.removeListener('exit', handlers.prematureExit);
child.stderr.removeListener('error... | javascript | {
"resource": ""
} |
q41651 | removePofile | train | function removePofile(done) {
if (!self.userDir) return done(null);
rimraf(self.userDir, done);
} | javascript | {
"resource": ""
} |
q41652 | SvcAws | train | function SvcAws (requestedSvc, options) {
if (this.constructor.name === 'Object') {
throw new Error('Must be instantiated using new')
} else if (this.constructor.name === 'SvcAws') {
throw new Error('Abstract class ' +
this.constructor.name + ' should not be instantiated')
}
EventEmitter.call(this... | javascript | {
"resource": ""
} |
q41653 | train | function(x,y,depth,maxDepth) {
if( depth >= maxDepth ) {
console.warn("MAXIMUM DEPTH REACHED: %d", maxDepth);
return;
}
if(!this.isCell(x,y)) { return; }
let dirs = this.getShuffledNeighborDirs( x, y );
for( var key in dirs )... | javascript | {
"resource": ""
} | |
q41654 | train | function(spec) {
spec = spec || {};
let aMask = spec.mask || [],
start = spec.start || {},
x = start.c || 0,
y = start.r || 0;
this.fill(0);
for( var mKey in aMask ) {
var mask = aMask[mKey];
... | javascript | {
"resource": ""
} | |
q41655 | invokeOnComplete | train | function invokeOnComplete(slinkerOptions) {
if (typeof slinkerOptions.onComplete === 'function' && slinkerOptions.modules.length === symlinksCreated.length) {
slinkerOptions.onComplete();
}
} | javascript | {
"resource": ""
} |
q41656 | checkPreconditions | train | function checkPreconditions(options) {
if (!options) {
throw Error("'options' must be specified!");
}
if (!(options.modules instanceof Array)) {
throw Error("'options.modules' must be an array!");
}
// If the modules array is empty, immediately call the onComplete() if it exists
... | javascript | {
"resource": ""
} |
q41657 | train | function() {
if (!(this instanceof clazz)) {
throw new Error("Use new keyword to create a new instance or call/apply class with right scope");
}
Class.onBeforeInstantiation && Class.onBeforeInstantiation(this);
// remember the current super property
var temp = ... | javascript | {
"resource": ""
} | |
q41658 | eatCharacter | train | function eatCharacter(stream) {
var first = stream.next();
// Read special literals: backspace, newline, space, return.
// Just read all lowercase letters.
if (first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
return;
}
// Read unicode character: \u1000 ... | javascript | {
"resource": ""
} |
q41659 | __typeCheck | train | function __typeCheck(type, valueToCheck, optional) {
var correct = typeof(valueToCheck) == type;
if(optional) {
// Exception if the variable is optional, than it also may be undefined or null
correct = correct || valueToCheck === undefined || valueToCheck === null;
}
if(!correct) {
... | javascript | {
"resource": ""
} |
q41660 | Queue | train | function Queue(client, channel){
EE.call(this);
this.client = client;
this.channel = channel;
this.id = channel.$getId();
return this;
} | javascript | {
"resource": ""
} |
q41661 | checkForAuths | train | function checkForAuths(){
$twitter.isAuthenticated = $body.attr('data-twitter-auth') === 'true' ? true : false
$facebook.isAuthenticated = $body.attr('data-facebook-auth') === 'true' ? true : false
$dropbox.isAuthenticated = $body.attr('data-dropbox-auth') === 'true' ? true : false
} | javascript | {
"resource": ""
} |
q41662 | wireDestinationClickHandlers | train | function wireDestinationClickHandlers(){
$twitter.isAuthenticated && $twitterDestination.bind('click', twitterDestinationClickHandler)
$facebook.isAuthenticated && $facebookDestination.bind('click', facebookDestinationClickHandler)
$dropbox.isAuthenticated && $dropboxDestination.bind('click', dropboxDestin... | javascript | {
"resource": ""
} |
q41663 | fetchImagesForFbGallery | train | function fetchImagesForFbGallery(id){
$
.get('/facebook/get_photos_from_album_id?id='+id)
.success(function(d, resp, x){
console.dir(d)
var thumbs = ""
if(d.message) thumbs += "<p>"+d.message+"</p>"
else{
d.data.forEach(function(el,i){
// console.dir(el)
... | javascript | {
"resource": ""
} |
q41664 | twitterOneUpClickHandler | train | function twitterOneUpClickHandler(e){
closeOneUp()
var standardResUrl = $(e.target).attr('data-standard-resolution') // e.target.dataset.standardResolution
var img = new Image()
$spin.show()
img.src = standardResUrl
img.onload = function(){
$spin.hide()
$one... | javascript | {
"resource": ""
} |
q41665 | wireOneUpHandlers | train | function wireOneUpHandlers(){
// Bind ESC key
$document.bind('keyup', function(e){
if (e.keyCode === 27) {
return closeOneUp()
}
}) // end keyup
// The "x" button on the one up, close it.
$closeOneUp.bind('click', closeOneUp )
// The overlay
$overlay.bind('click', c... | javascript | {
"resource": ""
} |
q41666 | wireUsePhotoHandlers | train | function wireUsePhotoHandlers(){
$usePhoto.bind('click submit', function(e){
if(e.target.id === 'facebook-use-photo'){
// We don't want to show the facebook option, because
// it is the source of the image.
$facebookDestination.hide()
_photoToUse = localS... | javascript | {
"resource": ""
} |
q41667 | _cleanseInput | train | function _cleanseInput(dirty){
var clean = ''
clean = dirty.replace('@', '')
clean = clean.replace('#', '')
clean = clean.replace(/\s/g, '')
return clean
} | javascript | {
"resource": ""
} |
q41668 | _failHandler | train | function _failHandler(e){
$spin.hide()
if(e.status === 400) alert(e.responseText || 'Bad request.')
if(e.status === 401) alert(e.responseText || 'Unauthorized request.')
if(e.status === 402) alert(e.responseText || 'Forbidden request.')
if(e.status === 403) alert(e.responseText ... | javascript | {
"resource": ""
} |
q41669 | _selectPhotoForPipe | train | function _selectPhotoForPipe(e){
var img = $('.one-up:visible').find('img')[0].src
localStorage.imageToPipe = img
closeOneUp()
window.location = "/instagram/pipe/to"
} | javascript | {
"resource": ""
} |
q41670 | positionFromTop | train | function positionFromTop(container, el){
var containerTop = container.position().top
, windowTop = $window.scrollTop()
if(containerTop > windowTop) return el.css('top', 0)
var pos = windowTop - containerTop
return el.css('top', pos)
} | javascript | {
"resource": ""
} |
q41671 | featureDetector | train | function featureDetector(){
// Check if client can access file sytem (from Modernizer)
var elem = document.createElement('input')
elem.type = 'file'
window.Photopipe.hasFileSystem = !elem.disabled
// Check if client has media capture access
window.Photopipe.hasMediaCapture = !!navigator.getU... | javascript | {
"resource": ""
} |
q41672 | train | function (listener,evtObj)
{
if (!_.isFunction(listener) || !_.isObject(evtObj))
return false;
var args = evtObj.arguments;
switch (args.length)
{
case 1:
listener(args[0]);
break;
case 2:
listener(args[0],args[1]);
break;
case 3:
listener(args[0],args[1],args[... | javascript | {
"resource": ""
} | |
q41673 | train | function (listener,prepend)
{
if ('function' !== typeof listener)
return false;
if (!_listeners)
_listeners=listener;
else if (typeof _listeners == 'object')
{
if (!prepend)
_listeners.push(listener);
else
_listeners.unshift(listener);
} else
{
if (!prepend)
_list... | javascript | {
"resource": ""
} | |
q41674 | train | function (listener, prepend) {
if ('function' === typeof listener)
{
var self = this,
g = function (e)
{
e.lastListeners--;
self.removeListener(g);
listener.apply(listener, arguments);
};
g.listener = listener;
this.addListener(g,prepend)
}
return this;
} | javascript | {
"resource": ""
} | |
q41675 | train | function (listener)
{
if ('function' !== typeof listener)
return false;
var list = _listeners;
var position = -1;
if (list === listener ||
(typeof list.listener === 'function' && list.listener === listener))
_listeners = undefined;
else if (typeof list === 'object')
{
for ... | javascript | {
"resource": ""
} | |
q41676 | train | function(b) {
if (b instanceof Model) {
if (this.constructor !== b.constructor) return false;
b = b.attributes;
}
return _.isEqual(this.attributes, b);
} | javascript | {
"resource": ""
} | |
q41677 | setInitalStyle | train | function setInitalStyle() {
document.body.style.margin = 0;
document.body.style.borderTopWidth = '10px';
document.body.style.borderTopStyle = 'solid';
} | javascript | {
"resource": ""
} |
q41678 | style | train | function style() {
var testsAre = 'pending';
if (failed > 0) {
testsAre = 'failing';
}
else if (passed > 0) {
testsAre = 'passing';
}
document.body.style.borderTopColor = richColors[testsAre];
faviconEl.setAttribute('href', favicons[testsAre]);
document.body.style.backgroundColor = colors[test... | javascript | {
"resource": ""
} |
q41679 | hijackLog | train | function hijackLog() {
var oldLog = console.log;
console.log = function (message) {
count(message);
style();
var match = (message + '').match(/^# #tapeworm-html(.*)/);
var isHtml = !!match;
if (match) {
var html = match[1];
var div = testResults.appendChild(document.createElement... | javascript | {
"resource": ""
} |
q41680 | infect | train | function infect(tape) {
if (!document) {
tape.Test.prototype.html = function () {};
return;
}
injectFavicon();
createTestResults();
setInitalStyle();
decorateTape(tape);
hijackLog();
style();
} | javascript | {
"resource": ""
} |
q41681 | train | function(angle) {
// TODO this clears any scale, should we care?
var a = Math.cos(angle);
var b = Math.sin(angle);
this.matrix[0] = this.matrix[3] = a;
this.matrix[1] = (0-b);
this.matrix[2] = b;
} | javascript | {
"resource": ""
} | |
q41682 | nextTickFn | train | function nextTickFn() {
// setImmediate allows to run task after already queued I/O callbacks
if (typeof setImmediate === 'function') {
return setImmediate;
} else if (typeof process !== 'undefined' && process.nextTick) {
return function(fn) {
process.nextTick(fn);
}
} else {
return functi... | javascript | {
"resource": ""
} |
q41683 | resolve | train | function resolve(val, i, isPath) {
val = val.replace('~', '');
return Promise.resolve(System.normalize(val))
.then(function(normalized) {
return System.locate({name: normalized, metadata: {}});
})
.then(function(address) {
if (isPath) {
options.includePaths.push(
path.re... | javascript | {
"resource": ""
} |
q41684 | resolveAll | train | function resolveAll(fileContent) {
var matches = [].concat(fileContent.match(regexFile)).filter(Boolean).map(extractFile);
var pathsMatches = [].concat(fileContent.match(regexPath)).filter(Boolean).map(extractFile);
if (matches.length === 0 && pathsMatches.length === 0) {
return new RSVP.Promise(func... | javascript | {
"resource": ""
} |
q41685 | Client | train | function Client(opts) {
this.opts = new clientOptions(opts)
this.streamData = {}
this.currentIndex = 0
this.cachedItems = new lru({maxSize: this.opts.maxCacheSize})
} | javascript | {
"resource": ""
} |
q41686 | create | train | function create(basedir, defaults) {
LOG.info("Initializing application configuration");
var config = defaults || {};
_loadConfigurationFiles(basedir, config);
_validateConfig(config);
if (config.DubBotBase.isConfigImmutable) {
_freezeConfig(config);
LOG.info("Configuration set up ... | javascript | {
"resource": ""
} |
q41687 | _copyConfigFromFile | train | function _copyConfigFromFile(filePath, config) {
LOG.info("Attempting to load configuration file '{}'", filePath);
var fileConfig = require(filePath);
_mergeConfig(config, fileConfig);
LOG.info("Successfully read configuration file '{}'", filePath);
} | javascript | {
"resource": ""
} |
q41688 | _freezeConfig | train | function _freezeConfig(config) {
Object.freeze(config);
for (var key in config) {
if (typeof config[key] === "object") {
_freezeConfig(config[key]);
}
}
} | javascript | {
"resource": ""
} |
q41689 | _mergeConfig | train | function _mergeConfig(base, override) {
for (var key in override) {
if (base[key] && typeof base[key] === "object" && typeof override[key] === "object") {
_mergeConfig(base[key], override[key]);
}
else {
base[key] = override[key];
}
}
} | javascript | {
"resource": ""
} |
q41690 | _validateConfig | train | function _validateConfig(config) {
for (var i = 0; i < REQUIRED_CONFIG_VARIABLES.length; i++) {
var key = REQUIRED_CONFIG_VARIABLES[i];
var value = config.DubBotBase[key];
if (!value || value === "UNSET") {
throw new Error("No value has been set in config for key: DubBotBase." + ... | javascript | {
"resource": ""
} |
q41691 | train | function () {
var value, c = input.charCodeAt(i);
if ((c > 57 || c < 45) || c === 47) return;
if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn|dpi|dpcm|dppx|rem|vw|vh|vmin|vm|ch)?/)) {
return new(tree.Dime... | javascript | {
"resource": ""
} | |
q41692 | train | function(srcUrl, dstW, dstH, callback){
// to compute the width/height while keeping aspect
var cpuScaleAspect = function(maxW, maxH, curW, curH){
var ratio = curH / curW;
if( curW >= maxW && ratio <= 1 ){
curW = maxW;
curH = maxW * ratio;
}else if(curH >= maxH){
curH = maxH;
curW = maxH /... | javascript | {
"resource": ""
} | |
q41693 | objectCreateComputedProp | train | function objectCreateComputedProp(obj, prop, setter, enumerable = true) {
let propValue;
let newValue;
let needsInitialization = true;
let allowSet = false;
let needsNewValue = true;
let isGeneratingNewValue = false;
const dependencyTracker = () => {
if (needsNewValue) {
... | javascript | {
"resource": ""
} |
q41694 | train | function( input, charset ) {
if( charset && !Buffer.isBuffer( input ) ) {
return MIME.Iconv.encode( input, charset )
} else {
return Buffer.isBuffer( input )
? input.toString( 'base64' )
: Buffer.from( input ).toString( 'base64' )
}
} | javascript | {
"resource": ""
} | |
q41695 | train | function( input, charset ) {
if( /iso-?2022-?jp/i.test( charset ) ) {
charset = 'shift_jis'
}
if( charset ) {
return MIME.Iconv.decode( Buffer.from( input, 'base64' ), charset )
} else {
return Buffer.from( input, 'base64' ).toString()
}
} | javascript | {
"resource": ""
} | |
q41696 | waitFor | train | function waitFor(checkFn, timeout, cb) {
var start = Date.now();
function runWaitFor() {
if (checkFn()) {
cb();
} else if ((Date.now() - start) <= timeout) {
setTimeout(runWaitFor, 100);
} else {
cb(new Error('Timeout of ' + timeout + 'ms reached. This usually means something went wron... | javascript | {
"resource": ""
} |
q41697 | train | function (set, receive) {
var values = setValues.call(set);
var next;
do {
next = values.next();
} while (!next.done && receive(next.value));
} | javascript | {
"resource": ""
} | |
q41698 | done | train | function done () {
that.fetchQueue.stopFetching(key, arguments);
that.store(key, arguments, callback);
} | javascript | {
"resource": ""
} |
q41699 | train | function(source, target) {
var linkedTarget = $(target);
clearLinkedData(target);
$.each(source, function(key, sourceValue) {
if (isInternal(key)) {
return;
}
var targetValue = null;
if ($.isPlainObject(sourceValue)) {
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.