_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q32800 | _setParams | train | function _setParams(params){
if(params){
// set the data collection params
if(params.defaultEvents){
for (let i = 0; i < params.defaultEvents.length; i++){
dataCollector.configureEventCollection(
params.defaultEvents[i].name,
pa... | javascript | {
"resource": ""
} |
q32801 | authedByUsername | train | function authedByUsername(username) {
return _.first(_.where(context.authed, { username: username}));
} | javascript | {
"resource": ""
} |
q32802 | httpRequest | train | function httpRequest(options, body, callback) {
// The `processResponse` callback should only be called once. The [http docs](http://nodejs.org/api/http.html#http_event_close_1)
// say that a 'close' event can be fired after the 'end' event has been fired. To ensure that the `processResponse` callback
// is calle... | javascript | {
"resource": ""
} |
q32803 | getEC2IAMRole | train | function getEC2IAMRole(callback) {
httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE}, null, function(error, role, httpResponse) {
callback(error, _.isString(role) ? role.trim() : role, httpResponse);
});
} | javascript | {
"resource": ""
} |
q32804 | getEC2IAMSecurityCredentials | train | function getEC2IAMSecurityCredentials(role, callback) {
httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE + role}, null, function(error, jsonStr, httpResponse) {
var credentials;
try {
credentials = JSON.parse(jsonStr);
} catch (parseError) {
if (!error) error = parseError;
... | javascript | {
"resource": ""
} |
q32805 | needsToLoadEC2IAMRoleCredentials | train | function needsToLoadEC2IAMRoleCredentials() {
if (!accessKey || !secretKey) return true;
if (credentialsExpiration === null) return false;
return (credentialsExpiration.getTime() - Date.now()) < CREDENTIALS_EXPIRATION_THRESHOLD;
} | javascript | {
"resource": ""
} |
q32806 | train | function (cb) {
this.reset();
var bundle = this.bundle;
var self = this;
async.waterfall([
function (wfCb) {
if (self.noclean) {
wfCb();
} else {
// Remove the output directory if it exists
existsCompat(self.outputTo, function (exists) {
if... | javascript | {
"resource": ""
} | |
q32807 | train | function (cb) {
this.reset();
var bundle = this.bundle;
var self = this;
async.waterfall([
function (wfCb) {
if (self.verbose) {
console.log('findAssets: starting discovery phase');
}
executePhase(self.phases.discovery, bundle, wfCb);
},
function (b, w... | javascript | {
"resource": ""
} | |
q32808 | train | function () {
var bundle = this.bundle;
var order = bundle.getProcessingOrder();
return order.map(function (file ) {
return bundle.getAsset(file).logicalPath;
});
} | javascript | {
"resource": ""
} | |
q32809 | train | function (storeOrEditor, path) {
debug('Checking if ' + path + ' exists in the in-memory store.');
var retv = false;
this.processInMemoryStore(storeOrEditor, file => {
debug('Evaluating ' + file.path + ' in state ' + file.state + ' with content length ' + (file && file.contents ? file.contents.length ... | javascript | {
"resource": ""
} | |
q32810 | train | function (storeOrEditor, from, to) {
debug('Performing inMemoryCopy from ' + from + ' to ' + to + '.');
var fromLen = from.length;
this.processInMemoryStore(storeOrEditor, (file, store) => {
var idx = file.path.indexOf(from);
if (idx === 0 && file.contents !== null && file.state !== 'deleted') {... | javascript | {
"resource": ""
} | |
q32811 | train | function (storeOrEditor, from, to) {
debug('Performing inMemoryMove from ' + from + ' to ' + to);
var store = (storeOrEditor && storeOrEditor.store ? storeOrEditor.store : storeOrEditor);
var memFsEditor = require('mem-fs-editor').create(store);
var fromLen = from.length;
store.each(function (file) ... | javascript | {
"resource": ""
} | |
q32812 | train | function (storeOrEditor, logFn) {
debug('Dumping contents of in-memory store.');
var logFunc = logFn || console.log;
this.processInMemoryStore(storeOrEditor, file => {
logFunc.call(this, file.path + ' [STATE:' + file.state + ']');
/*
logFunc.call(this, JSON.stringify(file, function (k, v)... | javascript | {
"resource": ""
} | |
q32813 | processReconcile | train | function processReconcile(field, toSet, setSep, reconcileSet) {
// process validated updates
if (reconcileSet) {
reconcileSet.forEach(function(t) {
var s = { uri: t.uri };
s[toSet] = t.setVal;
context.pubsub.item.save(s);
});
return;
}
} | javascript | {
"resource": ""
} |
q32814 | Questions | train | function Questions(options) {
if (!(this instanceof Questions)) {
return new Questions(options);
}
debug('initializing from <%s>', __filename);
Options.call(this, utils.omitEmpty(options || {}));
use(this);
this.initQuestions(this.options);
} | javascript | {
"resource": ""
} |
q32815 | ShareJSStream | train | function ShareJSStream(ws, options) {
options = options || {};
options.keepAlive = options.keepAlive !== undefined ?
options.keepAlive : KEEP_ALIVE;
this.debug = options.debug === true;
this.ws = ws;
this.headers = this.ws.upgradeReq.headers;
this.remoteAddress = this.ws.upgrad... | javascript | {
"resource": ""
} |
q32816 | loadSchema | train | function loadSchema(schemaBasePath, fullSchemaFileName) {
var scfPath = fullSchemaFileName.split('/');
var schemaFileName = scfPath[scfPath.length - 1];
var mainSchema = null;
// First, register() the main schemas you plan to use.
try {
mainSchema = _jsYaml2.default.load(_fs2.default.readFi... | javascript | {
"resource": ""
} |
q32817 | train | function(argv, context, callback) {
return MongoClient.connect(mongoHost, function(err, db) {
if (err) { return sg.die(err, callback, 'upsertPartner.MongoClient.connect'); }
var partnersDb = db.collection('partners');
var partnerId = argvGet(argv, 'partner-id,partner');
var item = {};
_.each... | javascript | {
"resource": ""
} | |
q32818 | train | function(service, credentials, accounts, keywords) {
Stream.call(this, service, credentials, accounts, keywords);
// Set up instagram-node-lib
Insta.set('client_id', credentials.client_id);
Insta.set('client_secret', credentials.client_secret);
// Set api endpoint URL for subscriber
this.api_end... | javascript | {
"resource": ""
} | |
q32819 | logError | train | function logError(message, err, context, event) {
var current_err = err;
while (current_err) {
var next_err = current_err._previous;
delete current_err._previous;
if (current_err.stack) {
console.error(current_err.stack);
} else {
console.error(current_err);
}
current_err = next_... | javascript | {
"resource": ""
} |
q32820 | Polyfill | train | function Polyfill(object, key) {
nodsl.check(typeof object === 'object', 'object must be an object; got ', object);
nodsl.check(typeof key === 'string', 'key must be a string; got ', key);
nodsl.check(typeof object[key] === 'string', 'object.', key, ' must be a string; got ', object[key]);
var that = this;
... | javascript | {
"resource": ""
} |
q32821 | _isArrayOfObjects | train | function _isArrayOfObjects(value) {
if (!Array.isArray(value)) {
return false;
}
var l = value.length;
var _type, cond;
for (var i = 0; i < l; i++) {
_type = typeof value[i];
cond = _type === 'function' || _type === 'object' && !!value[i];
if (!cond) {
return false;
}
}
return tr... | javascript | {
"resource": ""
} |
q32822 | _get | train | function _get(obj, path) {
var subpathes = path.split('.');
while (subpathes.length) {
var subpath = subpathes.shift();
obj = obj[subpath];
if (!obj) {
return obj;
}
}
return obj;
} | javascript | {
"resource": ""
} |
q32823 | _set | train | function _set(obj, path, value) {
var subpathes = path.split('.');
while (subpathes.length - 1) {
obj = obj[subpathes.shift()];
}
obj[subpathes.shift()] = value;
} | javascript | {
"resource": ""
} |
q32824 | _has | train | function _has(obj, path) {
var subpathes = path.split('.');
while (subpathes.length) {
var subpath = subpathes.shift();
if (!obj.hasOwnProperty(subpath)) {
return false;
}
obj = obj[subpath];
}
return true;
} | javascript | {
"resource": ""
} |
q32825 | exec | train | function exec() {
// NOTE: pardon this cli target to Couchpenter methods mapping,
// needed to preserve backward compatibility w/ v0.1.x
const FUNCTIONS = {
setup: 'setUp',
'setup-db': 'setUpDatabases',
'setup-doc': 'setUpDocuments',
'setup-doc-overwrite': 'setUpDocumentsOverwrite',
teardown:... | javascript | {
"resource": ""
} |
q32826 | use | train | function use(brand) {
return function branding(file) {
var branded = file.replace('{{brand}}', brand);
return fs.existsSync(branded) ? branded : file.replace('{{brand}}', 'nodejitsu');
};
} | javascript | {
"resource": ""
} |
q32827 | get | train | function get(done) {
this.define();
done(undefined, this.mixin({}, this.defaults, this.data, this.merge(
this.data,
this.queue.discharge(this.name)
)));
} | javascript | {
"resource": ""
} |
q32828 | use | train | function use(namespace, name, fn) {
name = name || this.name;
this.temper.require('handlebars').registerHelper(
namespace + '-' + name,
fn
);
return this;
} | javascript | {
"resource": ""
} |
q32829 | reduce | train | function reduce (m) {
if (Array.isArray(m)) {
try {
const module = m[0].module ? m[0].module : m[0]
_("register bind %o", module)
return require(module)
} catch (_) { return reduce(m.slice(1)) }
} else return reduce([m])
} | javascript | {
"resource": ""
} |
q32830 | teardown | train | function teardown(moduleName, e, moduleNames) {
var moduleNames = moduleNames || {};
if(disposeModule(moduleName, e, moduleNames)) {
// Delete the module and call teardown on its parents as well.
var parents = loader.getDependants(moduleName);
for(var i = 0, len = parents.length; i < len; i++) {
teardown(p... | javascript | {
"resource": ""
} |
q32831 | config_mail_box | train | function config_mail_box(config) {
imap = new Imap({
user:config.user,
password:config.password,
host:config.host,
port:config.port,
secure:config.secure
});
} | javascript | {
"resource": ""
} |
q32832 | get_new_followers | train | function get_new_followers(since, cb, cberr) {
get_inbox(since);
_callback = cb;
_callback_err = cberr;
} | javascript | {
"resource": ""
} |
q32833 | bundlerFactory | train | function bundlerFactory(loader, options) {
function bundlerDelegate(modules) {
return bundler(loader, options || {}, modules);
}
bundlerDelegate.bundle = function(names) {
return loader.fetch(names).then(bundlerDelegate);
};
return bundlerDelegate;
} | javascript | {
"resource": ""
} |
q32834 | bundler | train | function bundler(loader, options, modules) {
var stack = modules.slice(0);
var mods = [];
var finished = {};
function processModule(mod) {
if (finished.hasOwnProperty(mod.id)) {
return;
}
mod = loader.getModule(mod.id);
// browser pack chunk
var browserpack = {
id :... | javascript | {
"resource": ""
} |
q32835 | isCommentLine | train | function isCommentLine (line) {
var isCmnt = commentRE.test(line);
if (isCmnt) {
debug('removing comment: %s', line);
}
return !isCmnt;
} | javascript | {
"resource": ""
} |
q32836 | extractKeyValue | train | function extractKeyValue (line) {
var kv = {
key: undefined,
value: undefined,
};
var matches = kvRE.exec(line);
if (matches !== null && matches.length === 3) {
kv.key = matches[1];
kv.value = matches[2];
}
return kv;
} | javascript | {
"resource": ""
} |
q32837 | processLine | train | function processLine (instance, acc, line) {
debug('processing: %s', line);
// if previous line was continued then capture this line verbatim
// of course we need to handle if this is also a continuation too
if (instance.key) {
var hasCont = hasNewlineContinuation(line);
if (hasCont) {
debug('remo... | javascript | {
"resource": ""
} |
q32838 | unescape | train | function unescape (line) {
var retv = _.replace(line, propEscapeRE, '$1');
retv = _.replace(line, unicodeEscapeRE, function (m) {
return String.fromCharCode(parseInt(m, 16));
});
if (retv !== line) {
debug('removed escapes from: %s => %s', line, retv);
}
return retv;
} | javascript | {
"resource": ""
} |
q32839 | train | function(environment, mbaasConfig) {
if (!client) {
client = new MbaasClient(environment, mbaasConfig);
}
//Deprecated
module.exports.app = client.app;
module.exports.admin = client.admin;
} | javascript | {
"resource": ""
} | |
q32840 | getContext | train | function getContext(seneca) {
var transactionId = seneca.fixedargs.tx$;
var context = seneca.fixedargs.context$;
if (typeof context === 'undefined') {
try {
context = seneca.fixedargs.context$ = JSON.parse(URLSafeBase64.decode(transactionId).toString('utf8'));
debug('context loaded from tx$ and c... | javascript | {
"resource": ""
} |
q32841 | setContext | train | function setContext(seneca, context) {
seneca.fixedargs.tx$ = URLSafeBase64.encode(new Buffer(JSON.stringify(context)));
seneca.fixedargs.context$ = context;
debug('context saved', seneca.fixedargs.tx$, context);
} | javascript | {
"resource": ""
} |
q32842 | setElement | train | function setElement( targetElement ) {
// If the element has already been set,
// clear the transition classes from the old element.
if ( _dom ) {
remove();
animateOn();
}
_dom = targetElement;
_dom.classList.add( _classes.BASE_CLASS );
_transitionEndEvent = _getTransitionEndEven... | javascript | {
"resource": ""
} |
q32843 | halt | train | function halt() {
if ( !_isAnimating ) { return; }
_dom.style.webkitTransitionDuration = '0';
_dom.style.mozTransitionDuration = '0';
_dom.style.oTransitionDuration = '0';
_dom.style.transitionDuration = '0';
_dom.removeEventListener( _transitionEndEvent,
_transitio... | javascript | {
"resource": ""
} |
q32844 | _addEventListener | train | function _addEventListener() {
_isAnimating = true;
// If transition is not supported, call handler directly (IE9/OperaMini).
if ( _transitionEndEvent ) {
_dom.addEventListener( _transitionEndEvent,
_transitionCompleteBinded );
this.trigger( BaseTransition.BEGIN_EVEN... | javascript | {
"resource": ""
} |
q32845 | _flush | train | function _flush() {
for ( const prop in _classes ) {
if ( _classes.hasOwnProperty( prop ) &&
_classes[prop] !== _classes.BASE_CLASS &&
_dom.classList.contains( _classes[prop] ) ) {
_dom.classList.remove( _classes[prop] );
}
}
} | javascript | {
"resource": ""
} |
q32846 | remove | train | function remove() {
if ( _dom ) {
halt();
_dom.classList.remove( _classes.BASE_CLASS );
_flush();
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q32847 | train | function(handler, priority) {
if(handler && handler.constructor === Array) {
handler.forEach(function(layer) {
layer.priority = typeof layer.priority === 'undefined' ? 1 : layer.priority;
});
_list = _list.concat(handler);
} else {
handler.priority = p... | javascript | {
"resource": ""
} | |
q32848 | train | function(callback) {
var nextHandler;
var executionList = _list.slice(0).sort(function(a, b) {
return Math.max(-1, Math.min(1, b.priority - a.priority));
});
nextHandler = function() {
$rootScope.$evalAsync(function() {
var handler = executionList.shift()... | javascript | {
"resource": ""
} | |
q32849 | isSpecs | train | function isSpecs(opt) {
//logger.debug('???');
//logger.debug(`${opt.cacheDir}`);
//let b:any = opt.cacheDir instanceof(String)
if (!path.isAbsolute(opt.cacheDir)) {
logger.error('cacheDir parameter must be an absolute path');
return false;
}
if ('cacheDir' in opt && 'tcp' in opt... | javascript | {
"resource": ""
} |
q32850 | pushMS | train | function pushMS(data, socket) {
logger.debug(`newJob Packet arrived w/ ${util.format(data)}`);
logger.silly(` Memory size vs nWorker :: ${liveMemory.size()} <<>> ${nWorker}`);
if (liveMemory.size("notBound") >= nWorker) {
logger.debug("must refuse packet, max pool size reached");
jmServer.bo... | javascript | {
"resource": ""
} |
q32851 | addFileResource | train | function addFileResource(cmd, file, params, callback) {
if( !file ) return callback({error:true,message:"no file provided"});
if( !fs.existsSync(file) ) return callback({error:true,message:"no file found: "+file});
if( !fs.statSync(file).isFile() ) return callback({error:true,message:"not a file: "+file});
... | javascript | {
"resource": ""
} |
q32852 | train | function(locale) {
this.intCol = (Intl && Intl.Collator) ? new Intl.Collator(locale) : new CollatorPolyfill(locale);
} | javascript | {
"resource": ""
} | |
q32853 | giveAnswer | train | function giveAnswer(answeringPlayer, answer) {
if(answeringPlayer === seller) return;
if(answer <= currentBid) return;
buyer = answeringPlayer;
currentBid = answer;
resetTimer();
notify(false);
} | javascript | {
"resource": ""
} |
q32854 | hoistingOptions | train | function hoistingOptions( target ) {
if ( !target.hasOwnProperty( '_options' ) ) {
let options;
if ( undefined === target._options ) {
options = {};
} else {
// Create copy with descriptors
options = Object.create(
null,
Ob... | javascript | {
"resource": ""
} |
q32855 | markCells | train | function markCells(cells, adj, edges) {
//Initialize active/next queues and flags
var flags = new Array(cells.length)
var constraint = new Array(3*cells.length)
for(var i=0; i<3*cells.length; ++i) {
constraint[i] = false
}
var active = []
var next = []
for(var i=0; i<cells.length; ++i) {
var ... | javascript | {
"resource": ""
} |
q32856 | arrayHasAny | train | function arrayHasAny(values, array) {
error_if_not_array_1.errorIfNotArray(values);
var i = -1;
while (++i < values.length) {
if (arrayHas_1.arrayHas(values[i], array))
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q32857 | setJSHint | train | function setJSHint(path, done) {
var opts = JSON.parse(fs.readFileSync(path, 'utf8'));
jsHintOptions.config = opts;
done();
} | javascript | {
"resource": ""
} |
q32858 | checkJSHint | train | function checkJSHint(done) {
if(!options.jshint) {
options.jshint = path.join(__dirname, '.jshintrc');
}
checkPath(options.jshint, setJSHint, done);
} | javascript | {
"resource": ""
} |
q32859 | setFilesets | train | function setFilesets(path, done) {
var config = JSON.parse(fs.readFileSync(path, 'utf8'));
/* jshint sub: true */
var includeFiles = config['includeFiles'];
var excludeFiles = config['excludeFiles'];
var filterFiles = config['lintOnly'];
/* jshint sub: false */
if (filterFiles && !Array.is... | javascript | {
"resource": ""
} |
q32860 | runReports | train | function runReports(err) {
if (err) { console.log(chalk.red('Error running reports: %s'), err); }
var excludes = filesets.platoExcludes();
if (excludes) {
platoOptions.exclude = excludes;
}
jsHintOptions.ignore = filesets.jshintExcludes();
jsHintOptions.reporter = reporter.reporter;
... | javascript | {
"resource": ""
} |
q32861 | getHistoricalClosePrices | train | function getHistoricalClosePrices(options = {}) {
const { index, currency, start, end, yesterday } = options
return request(`/historical/close.json`, {
index,
currency,
start: start && end && formatDate(start) || undefined,
end: start && end && formatDate(end) || undefined,
for: yesterday ? 'ye... | javascript | {
"resource": ""
} |
q32862 | fileReader | train | function fileReader(moduleMeta) {
// Read file from disk and return a module meta
return pstream(readFile(moduleMeta.path))
.then(function(text) {
return {
source: text
};
}, log2console);
} | javascript | {
"resource": ""
} |
q32863 | train | function(guess, filename) {
var ct = guess;
// Someone else just defaulted to octet-stream?
if (!ct || ct === 'application/octet-stream') {
ct = sg.mimeType(filename) || ct;
}
return ct || 'application/octet-stream';
} | javascript | {
"resource": ""
} | |
q32864 | Module | train | function Module(options) {
options = options || {};
if (types.isString(options)) {
options = {
name: options
};
}
if (!types.isString(options.name) && !types.isString(options.source)) {
throw new TypeError("Must provide a name or source for the module");
}
this.deps = options.deps ? opt... | javascript | {
"resource": ""
} |
q32865 | train | function(doRecentCheck, req, res, next) {
var app = req.app;
var config = app.loadConfig('auth');
var failed = !req.isAuthenticated();
if (!failed && doRecentCheck && !req.session.impersonated) {
//skip recent check if login is impersonated
//note: loginTime maybe a string since sessions are serialized... | javascript | {
"resource": ""
} | |
q32866 | train | function (next) {
// index creation options
var body = {
settings: {
number_of_shards : 3,
number_of_replicas : 2,
analysis: {
// analyzer definitions go here
analyzer: {
... | javascript | {
"resource": ""
} | |
q32867 | train | function (next) {
self.count().exec(function (err, count) {
if (err) {
return next(err)
}
docsToIndex = count
return next()
})
} | javascript | {
"resource": ""
} | |
q32868 | train | function (next) {
// if no documents to index, skip population
if (!docsToIndex) {
return next()
}
// stream docs - and upload in batches of size BATCH_SIZE
var docStream = self.find().stream()
// elasticsearch commands to perform... | javascript | {
"resource": ""
} | |
q32869 | train | function (next) {
var reqOpts = {
method: 'GET',
url: helpers.makeAliasUri(options)
}
if(options.auth) {
reqOpts.auth = {
user: options.auth.user,
pass: options.auth.password,
... | javascript | {
"resource": ""
} | |
q32870 | addPlayer | train | function addPlayer(userId, callbacks) {
let player = factory.addPlayer();
if(!player) return null;
self._callbacks.set(player, callbacks);
// If the game didn't have an owner, it does now
// This should only happen when the game is first created
// and the initial playe... | javascript | {
"resource": ""
} |
q32871 | slice | train | function slice (args, start, end) {
var len = args.length;
start = start > 0 ? start : 0;
end = end >= 0 && end < len ? end : len;
var n = end - start;
if (n <= 0) return [];
var ret = new Array(n);
for (var i = 0; i < n; ++i) {
ret[i] = args[i + start];
}
return ret;
} | javascript | {
"resource": ""
} |
q32872 | read | train | function read (stream, opts, db, cb) {
var schema = new exports.Schema;
if (opts.onType) {
schema.onType = opts.onType;
}
stream.once('error', function (err) {
debug('aborting with error: ' + err);
db.close(cb.bind(err));
});
stream.on('data', function (doc) {
var err = schema.consume(doc... | javascript | {
"resource": ""
} |
q32873 | abort | train | function abort (err, stream, db, cb) {
debug('aborting with error: ' + err);
stream.destroy();
db.close(function () {
cb(err);
})
} | javascript | {
"resource": ""
} |
q32874 | validate | train | function validate (uri, collection, cb) {
if ('function' != typeof cb) {
throw new TypeError('cb must be a function');
}
if ('string' != typeof collection) {
throw new TypeError('collection must be a string');
}
if ('string' != typeof uri) {
throw new TypeError('uri must be a string');
}
} | javascript | {
"resource": ""
} |
q32875 | train | function (texts, options, callback) {
if (typeof(options) === 'function') {
callback = options;
options = {};
}
if (Array.isArray(texts)) {
texts = texts.map(function (text, i) {
return textObj(text, i);
});
} else if (typ... | javascript | {
"resource": ""
} | |
q32876 | clickRegion | train | function clickRegion( e ) {
let pos = {
x : e.clientX,
y : e.clientY
},
region = '',
dividant = 4,
right = window.innerWidth - (window.innerWidth / dividant),
left = (window.innerWidth / dividant),
top = (window.innerHeight / dividant),
bottom = window.innerHeight - (window.innerHeight /... | javascript | {
"resource": ""
} |
q32877 | getContextPlugin | train | function getContextPlugin(options) {
var seneca = this;
var plugin = 'get-context';
seneca.wrap(options.pin, function (message, done) {
var seneca = this;
message.context$ = getContext(seneca);
seneca.prior(message, done);
});
return {name: plugin};
} | javascript | {
"resource": ""
} |
q32878 | build | train | function build() {
console.log('Creating an optimized production build...\n');
webpack(config)
.run((err, stats) => {
if (err) {
printErrors('Failed to compile.', [err]);
process.exit(1);
}
if (stats.compilation.errors.length) {
printErrors('Failed to compile.', stats... | javascript | {
"resource": ""
} |
q32879 | addToFooter | train | function addToFooter(schema, path, unwind) {
Object.keys(schema).forEach(function(name) {
if (name.slice(0,2) == '__')
return true;
if (!path && (name == 'id' || name == '_id'))
return;
if (model.schema.nested[path+name]) {
addToFooter(schema[name], path+name+'.', '')
... | javascript | {
"resource": ""
} |
q32880 | diffContentItems | train | function diffContentItems(lhs, rhs) {
var d = diff(lhs, rhs, function(key, value) {
return value === 'visitors' || value === 'headers';
});
return d;
} | javascript | {
"resource": ""
} |
q32881 | extractContent | train | function extractContent(desc) {
/*
// search all possible matches, returning first find
var founds = sites.findMatch(desc.uri);
if (founds.length) {
var $ = cheerio.load(desc.content);
// use first found extractor
founds.forEach(function(found) {
if ($(found.selector)) {
var content = $... | javascript | {
"resource": ""
} |
q32882 | getTitle | train | function getTitle(content, tag) {
if (!content) {
return;
}
var ts = content.indexOf(tag);
if (ts < 0) {
return;
}
var te = content.indexOf('>', ts);
var cs = content.indexOf('<', te + 1);
var title = content.substring(te + 1, cs);
return title.trim();
} | javascript | {
"resource": ""
} |
q32883 | train | function() {
var i = Math.floor(_listing.length-1 * Math.random());
return $q.when(_listing[i]);
} | javascript | {
"resource": ""
} | |
q32884 | train | function(criteria) {
var results = [];
criteria = angular.isArray(criteria) ? criteria : [criteria];
// Search through each
criteria.forEach(function(q) {
if(q && q !== '') {
_listing.forEach(function(item) {
for(var name in item) {
... | javascript | {
"resource": ""
} | |
q32885 | partialWithArityOfOne | train | function partialWithArityOfOne(fn) {
var args = arguments;
return function(a) {
return partial.apply(this, args).apply(this, arguments);
};
} | javascript | {
"resource": ""
} |
q32886 | _getFileSet | train | function _getFileSet (fileSetElement) {
var filtered = utils.toBoolean(fileSetElement.getAttribute('filtered'), false);
var packaged = utils.toBoolean(fileSetElement.getAttribute('packaged'), false);
var encoding = fileSetElement.getAttribute('encoding');
var directory = domutils.getChild(fileSetElement... | javascript | {
"resource": ""
} |
q32887 | _getModule | train | function _getModule (moduleElement) {
var id = moduleElement.getAttribute('id');
var dir = moduleElement.getAttribute('dir');
var name = moduleElement.getAttribute('name');
var fileSets = domutils.getChild(moduleElement, 'desc', 'fileSets');
var modules = domutils.getChild(moduleElement, 'desc', 'mo... | javascript | {
"resource": ""
} |
q32888 | unload | train | function unload() {
u.each(opts.sources, function(source) {
if (source.src && source.src.unref) { source.src.unref(); }
if (source.cache && source.cache.unref) { source.cache.unref(); }
});
u.each(opts.outputs, function(output) {
if (output.output && output.output.cancel) { output.output.c... | javascript | {
"resource": ""
} |
q32889 | redirect | train | function redirect(url) {
var path = u.urlPath(url);
var params = u.urlParams(url);
var pg = generator.aliase$[path];
if (pg) return { status:301, url:pg._href + params };
pg = generator.redirect$[path];
if (pg) return { status:302, url:pg._href + params };
// customRedirects return params... | javascript | {
"resource": ""
} |
q32890 | UnloqApi | train | function UnloqApi(authObj) {
if(typeof authObj !== 'object' || authObj === null) {
throw new Error('Unloq.Api: First constructor argument must be an instance of unloq.Auth');
}
// If we receive only the object with configuration, we try and create the auth object.
if(authObj.__type !== 'auth') {
... | javascript | {
"resource": ""
} |
q32891 | registerApi | train | function registerApi(isApp, apiObject) {
if (isApp) {
return function (req, res, next) {
res.__api = apiObject;
return next();
};
};
return function (req, res, next) {
res.__modelAPI = apiObject;
return next();
};
} | javascript | {
"resource": ""
} |
q32892 | init | train | function init(){
frameUnixTime = utils.getUnixTimeInMilliseconds();
frameDuration = 0;
frameDurationClone = 0;
timeSinceStart = 0;
playTimeSinceStart = 0;
appActive = true;
appPlaying = true;
videoDuration = 0;
videoPlaying = false;
} | javascript | {
"resource": ""
} |
q32893 | tick | train | function tick(frameTime){
let newFrameUnixTime = utils.getUnixTimeInMilliseconds();
if (frameTime)
frameDuration = frameTime;
else
frameDuration = newFrameUnixTime - frameUnixTime;
// dont consider frame duration if app is not active
frameDurationClone = appActive ? frameDurat... | javascript | {
"resource": ""
} |
q32894 | init | train | function init(owner, field, layout, val, children) { // {{{2
/**
* Field wrapper constructor
*
* @param owner {Object} Owning wrap list
* @param field {Object} Field description object
* @param layout {Object} Layout
* @param val {*} Field value
*
* @method constructor
*/
this.owner = owner;
owner.fields... | javascript | {
"resource": ""
} |
q32895 | condenseify | train | function condenseify(file, options) {
if (/\.json$/.test(file)) return through();
var appendNewLine = true
, regex = /^[ \t]+$/
, isBlank = false
, eol ='\n';
options = options || {};
function transform(line, encoding, next) {
if (!line.length) {
isBlank = true;
return next();
... | javascript | {
"resource": ""
} |
q32896 | removezeros | train | function removezeros(bin){
var i = 0;
while((i < bin.length) && (!bin[i])){i++;}
if(i == bin.length){
return filledarray(false, 1);
}else{
return bin.slice(i);
}
} | javascript | {
"resource": ""
} |
q32897 | decinputtobin | train | function decinputtobin(decinput){
var len = decinput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array();
var digit = new Array(4);
for (var i = 0; i < len; i++){
switch (decinput[i]){
case '0': digit[0] = false; digit[1] = false; digit[2] = false; digit[3] = false; break;
ca... | javascript | {
"resource": ""
} |
q32898 | bininputtobin | train | function bininputtobin(bininput){
var len = bininput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array(len);
var j = 0;
for (var i = 0; i < len; i++){
switch (bininput[i]){
case '0': bin[j++] = false; break;
case '1': bin[j++] = true; break;
default: break;
}
}
re... | javascript | {
"resource": ""
} |
q32899 | octinputtobin | train | function octinputtobin(octinput){
var len = octinput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array(len * 3);
var j = 0;
for (var i = 0; i < len; i++){
switch (octinput[i]){
case '0': bin[j+0] = false; bin[j+1] = false; bin[j+2] = false; j+=3; break;
case '1': bin[j+0] = f... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.