_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q39200 | parseArguments | train | function parseArguments(options, callback) {
if (_.isUndefined(options) && _.isUndefined(callback)) { // No params
return [{}, undefined];
}
if (!_.isUndefined(options) && _.isFunction(options)) { // Only callback param
callback = options;
options = {};
}
return [options, cal... | javascript | {
"resource": ""
} |
q39201 | http | train | function http(tick, args) {
let url = 'https://www.tickspot.com/' + tick.subscriptionID + '/api/v2/';
url += args.paths.join('/') + '.json';
if (args.query) {
url += '?';
url += _.pairs(args.query).map(p => p.join('=')).join('&');
}
return url;
} | javascript | {
"resource": ""
} |
q39202 | extractPage | train | function extractPage(options) {
let page = 1;
if (options && options.page) {
page = options.page;
delete options.page;
}
return page;
} | javascript | {
"resource": ""
} |
q39203 | parseCookie | train | function parseCookie(str) {
var obj = {},
pairs = str.split(/[;,] */);
for (var pair,eqlIndex,key,val,i=0; i < pairs.length; i++) {
pair = pairs[i];
eqlIndex = pair.indexOf('=');
key = pair.substr(0, eqlIndex).trim().toLowerCase();
val = pair.substr(++eqlIndex, pair.length).trim();
if ('"' ... | javascript | {
"resource": ""
} |
q39204 | getRequestCookies | train | function getRequestCookies(req) {
if (req.headers.cookie != null) {
try {
return parseCookie(req.headers.cookie);
} catch (e) {
this.log(req.urlData.pathname, "Error parsing cookie header: " + e.toString());
return {};
}
} else {
return {};
}
} | javascript | {
"resource": ""
} |
q39205 | train | function(a,b){
if(b[0]=="my-id") {
var fakeResult = [];
return fakeResult;
}else return document.getElementById.apply(document,b);
} | javascript | {
"resource": ""
} | |
q39206 | gitPorcelainStatus | train | function gitPorcelainStatus() {
return git('status --porcelain -b', stdout => {
const status = gitUtil.extractStatus(stdout);
let parsedStatus = Object.values(status.index).concat(Object.values(status.workingTree));
// Flattened
parsedStatus = parsedStatus.reduce((a, b) => a.concat(b), []);
retu... | javascript | {
"resource": ""
} |
q39207 | train | function(args, fn, type) {
this.args = args;
this.fn = fn;
this.type = type;
this.id = prefix + _code_node_id_count++;
} | javascript | {
"resource": ""
} | |
q39208 | train | function() {
HelpDocument.apply(this, arguments);
this.useCustom = false;
this.sections = [
HelpDocument.SYNOPSIS,
HelpDocument.DESCRIPTION,
HelpDocument.COMMANDS,
HelpDocument.OPTIONS,
HelpDocument.BUGS
]
} | javascript | {
"resource": ""
} | |
q39209 | clean | train | function clean (callback) {
if (this._clobber) {
rimraf(path.join(destination, this._clobberGlob), callback);
}
else {
callback(null);
}
} | javascript | {
"resource": ""
} |
q39210 | discover | train | function discover (callback) {
glob(path.join(this._source, '/**/*.*'), function (err, filepaths) {
if (err) callback(err);
callback(null, filepaths);
});
} | javascript | {
"resource": ""
} |
q39211 | run | train | function run (files, callback) {
let self = this,
i = 0;
function next(err, files) {
let mw = self.middleware[i++];
if (mw) {
mw(files, self, next);
}
else {
callback(null, files);
}
};
next(null, files);
} | javascript | {
"resource": ""
} |
q39212 | writeFile | train | function writeFile (file, callback) {
fs.outputFile(path.resolve(this._destination, path.join(file.path.dir, file.path.name + file.path.ext)), file.content, function (err) {
if (err) callback(err);
callback(null);
});
} | javascript | {
"resource": ""
} |
q39213 | getRootChildren | train | function getRootChildren( root, libs, com ) {
var src = ( root.attribs.src || "" ).trim( );
if ( src.length > 0 ) {
if (!libs.fileExists( src )) {
libs.fatal( "File not found: \"" + src + "\"!" );
}
// Add a compilation dependency on the include file.
libs.addInclude( src );
var content = ... | javascript | {
"resource": ""
} |
q39214 | getPropertiesAndBindings | train | function getPropertiesAndBindings( root, libs, com, indent ) {
// Attributes can have post initialization, especially for data bindings.
var postInit = {};
var hasPostInit = false;
var key,
val,
values;
var bindings;
var slots;
for ( key in root.attribs ) {
if ( key.charAt( 0 ) == '$' ) {
... | javascript | {
"resource": ""
} |
q39215 | Resource | train | function Resource(attributes) {
this.engine = engine;
this.name = !this.name ? this.name : this.name.toLowerCase();
this.queryParams = {};
this.attributes = {};
this.load(attributes || {});
} | javascript | {
"resource": ""
} |
q39216 | daemonize | train | function daemonize(file, conf, args) {
/* istanbul ignore next: never parse argv in test env */
args = args || process.argv.slice(2);
args.unshift(file);
var logfile = conf.get(ConfigKey.LOGFILE) || '/dev/null'
//var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log'
, out = fs.openSync(logfile, 'a')
... | javascript | {
"resource": ""
} |
q39217 | write | train | function write(conf) {
var contents = process.pid + EOL
, file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
try {
fs.writeFileSync(file, contents);
log.notice('wrote pid %s to %s', process.pid, file);
}catch(e) {
log.warning('failed to write pid file (%s): %s'... | javascript | {
"resource": ""
} |
q39218 | remove | train | function remove(conf) {
var file = conf.get(ConfigKey.PIDFILE);
// can be the empty string
if(file) {
log.notice('removing pid file %s', file);
try {
fs.unlinkSync(file);
}catch(e) {
log.warning('failed to remove pid file (%s): %s', file, e.message);
}
}
} | javascript | {
"resource": ""
} |
q39219 | train | function(node, root) {
var pn = node.parentNode;
while (pn) {
if (pn == root) {
break;
}
pn = pn.parentNode;
}
return !!pn;
} | javascript | {
"resource": ""
} | |
q39220 | train | function(node, bag) {
if (!bag) {
return 1;
}
var id = _nodeUID(node);
if (!bag[id]) {
return bag[id] = 1;
}
return 0;
} | javascript | {
"resource": ""
} | |
q39221 | train | function(query, root) {
// NOTE: elementsById is not currently supported
// NOTE: ignores xpath-ish queries for now
//Set list constructor to desired value. This can change
//between calls, so always re-assign here.
if (!query) {
return [];
}
if (query.constructor == Array) {
... | javascript | {
"resource": ""
} | |
q39222 | Propagator | train | function Propagator(
constructor, transforms,
cancellable, signalCancelled) {
this._constructor = constructor || promise.Promise;
this._transforms = transforms;
this._cancellable = cancellable === true;
this._signalCancelled = signalCancelled;
this._state = INITIALIZED;
this._resolved = false;
th... | javascript | {
"resource": ""
} |
q39223 | nodeIsRenderedByOtherInstance | train | function nodeIsRenderedByOtherInstance(container) {
var rootEl = getReactRootElementInContainer(container);
return !!(rootEl && isReactNode(rootEl) && !ReactDOMComponentTree.getInstanceFromNode(rootEl));
} | javascript | {
"resource": ""
} |
q39224 | isReactNode | train | function isReactNode(node) {
return isValidContainer(node) && (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME));
} | javascript | {
"resource": ""
} |
q39225 | train | function (root, className) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
}
return all[0];
} | javascript | {
"resource": ""
} | |
q39226 | train | function (root, tagName) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
});
} | javascript | {
"resource": ""
} | |
q39227 | train | function (root, tagName) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
}
return all[0];
} | javascript | {
"resource": ""
} | |
q39228 | train | function (root, componentType) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
});
} | javascript | {
"resource": ""
} | |
q39229 | train | function (root, componentType) {
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
if (all.length !== 1) {
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
}
return all[0];
} | javascript | {
"resource": ""
} | |
q39230 | train | function (topLevelType, node, fakeNativeEvent) {
fakeNativeEvent.target = node;
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
} | javascript | {
"resource": ""
} | |
q39231 | matchesSelector | train | function matchesSelector(element, selector) {
var matchesImpl = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || function (s) {
return matchesSelector_SLOW(element, s);
};
return matchesImpl.call(element, selector);
} | javascript | {
"resource": ""
} |
q39232 | registerApp | train | function registerApp(name, description, permissions) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.register(name, description, permissions)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | javascript | {
"resource": ""
} |
q39233 | connectApp | train | function connectApp(token) {
const CONNECTION = new Connection();
return new Promise((resolve, reject) => {
CONNECTION.connect(token)
.then(() => resolve(new ConnectionHandler(CONNECTION)))
.catch((error) => reject(error));
});
} | javascript | {
"resource": ""
} |
q39234 | train | function(options) {
'use strict';
var client = this,
log = options.log,
socketHost = options.socketHost,
hubName = options.hubName,
hub;
/**
* open the public/private channels to begin exchanges
*/
this.subscribe = function(channelName, handler, callback) {
... | javascript | {
"resource": ""
} | |
q39235 | validateCache | train | function validateCache(path, cache) {
const
{mtime} = fs.statSync(path);
return {
mtime,
fromCache: Boolean(cache[path] && Sugar.Date.is(mtime, cache[path].mtime))
};
} | javascript | {
"resource": ""
} |
q39236 | getFile | train | function getFile(path) {
const
cache = validateCache(path, filesCache);
if (!cache.fromCache) {
filesCache[path] = {
mtime: cache.mtime,
content: fs.readFileSync(path, 'utf-8')
};
}
return filesCache[path].content;
} | javascript | {
"resource": ""
} |
q39237 | BulkChange | train | function BulkChange(model) {
this.model = model;
this.bulk = model.collection.initializeUnorderedBulkOp();
this.isChange = false;
} | javascript | {
"resource": ""
} |
q39238 | getMediaByBuffer | train | function getMediaByBuffer (uri, cert, mode, user, safe, bufferURI) {
var bufferPath = root
if (bufferURI) {
bufferPath += '/../' + url.parse(bufferURI).path
}
return new Promise(function (resolve, reject) {
// var bufferPath = __dirname + '/../data/buffer/image/'
debug('bufferPath', bufferPath)
... | javascript | {
"resource": ""
} |
q39239 | addMediaToBuffer | train | function addMediaToBuffer (uri, cert, mode, user, safe, bufferURI) {
// var bufferPath = root
// if (bufferURI) {
// bufferPath += '/../' + url.parse(bufferURI).path
// }
setTimeout(() => {
try {
// fs.unlinkSync(lastFile)
} catch (e) {
console.error(e)
}
var params = {}
para... | javascript | {
"resource": ""
} |
q39240 | copyMedia | train | function copyMedia (path, to, cert, callback) {
var hookPath = __dirname + '/../data/buffer/hook.sh'
debug('copyMedia', path, to, cert)
if (/^http/.test(to)) {
debug('using http')
var parsed = url.parse(to)
debug('parsed', parsed)
var domain = url.parse(to).domain
var file = url.parse(to).pa... | javascript | {
"resource": ""
} |
q39241 | getMediaByAPI | train | function getMediaByAPI (uri, cert, mode, user, safe, bufferURI) {
return new Promise(function (resolve, reject) {
balance(user).then((ret) => {
return ret
}).then(function (ret) {
if (ret >= algos.getRandomUnseenImage.cost) {
qpm_media.getRandomUnseenImage().then(function (row) {
... | javascript | {
"resource": ""
} |
q39242 | getMediaByHTTP | train | function getMediaByHTTP (uri, cert, mode, user, safe, bufferURI) {
return new Promise(function (resolve, reject) {
var cookiePath = __dirname + '/../data/cookie.json'
var cookies = readCookie(cookiePath)
if (cookies) {
options.headers['Set-Cookie'] = 'connect.sid=' + sid + '; Path=/; HttpOnly; Sec... | javascript | {
"resource": ""
} |
q39243 | getNextFile | train | function getNextFile (files, type) {
for (var i = 0; i < files.length; i++) {
var file = files[i]
if (/.ttl$/.test(file)) {
continue
}
return file
}
} | javascript | {
"resource": ""
} |
q39244 | f_todo_secildi | train | function f_todo_secildi(_uyari) {
l.info("f_todo_secildi");
//bu uyarı için atanmış kullanıcı id lerini çek
var kullanici_idleri = f_uye_id_array(_uyari);
return _uyari.RENDER.Sonuc.Data.map(function (_elm) {
var detay = f_detay_olustur(schema.SABIT.UYARI.TODO,... | javascript | {
"resource": ""
} |
q39245 | getProp | train | function getProp (obj, path, isArray) {
var next;
path = _.isString(path) ? path.split('.') : path;
// We have more traversing to do
if (path.length > 1) {
next = path.shift();
if (_.isArray(obj[next])) {
isArray = true;
var arr = _.compact(_.flatten(obj[next].map(function (el, i) {
... | javascript | {
"resource": ""
} |
q39246 | train | function () {
var dest = path.join(options.dest, themes[count]);
// deletes theme is already exists.
if (fs.exists(dest)) {
fs.rmdir(dest);
}
mv(path.join(options.themes, themes[count], 'dist'), dest, {mkdirp: true}, function() {
... | javascript | {
"resource": ""
} | |
q39247 | search | train | function search(root, expression, maxDepth) {
var length = root.children.length;
var depth = null;
var lookingForToc = expression !== null;
var map = [];
var headingIndex;
var closingIndex;
if (!lookingForToc) {
headingIndex = -1;
}
slugs.reset();
/*
* Visit all h... | javascript | {
"resource": ""
} |
q39248 | colorErrors | train | function colorErrors(stdLine) {
// lazy load chalk
if (chalk === undefined) {
chalk = require("chalk");
}
return colorErrorPatterns.reduce((op, pattern) => {
const matches = pattern.exec(op);
if (matches !== null && matches.length > 0) {
op = op.replace(pattern, chalk.red(matches[0]));
}... | javascript | {
"resource": ""
} |
q39249 | writeError | train | function writeError(chunk) {
// in production give the output as-is
if (NODE_ENV === "production") {
return this.queue(chunk);
}
clearTimeout(errorTimer);
errorChunks.push(chunk.toString());
errorTimer = setTimeout(() => {
this.queue(formatErrors(errorChunks.join("")));
}, 10);
... | javascript | {
"resource": ""
} |
q39250 | respawn | train | function respawn() {
if (isNil(proc) === false) {
proc.stderr.removeAllListeners();
proc.stderr.end();
proc.stderr.unpipe();
proc.stdout.removeAllListeners();
proc.stdout.end();
proc.stdout.unpipe();
proc.removeAllListeners();
proc.kill();
}
const { env } = p... | javascript | {
"resource": ""
} |
q39251 | promisify | train | function promisify(data, prevent = false) {
let promisified;
if (typeof data === 'function') {
promisified = (...args) => new Promise((resolve, reject) => {
data.call(data, ...args.concat((error, ...args) => {
error ? reject(error) : resolve.call(data, ...args);
}));
});
} else if (ty... | javascript | {
"resource": ""
} |
q39252 | Decoder | train | function Decoder(conf, options, file) {
Transform.call(this);
this._writableState.objectMode = true;
this._readableState.objectMode = true;
this.eol = options.eol;
this.conf = conf;
this.file = file;
this.lineNumber = 0;
} | javascript | {
"resource": ""
} |
q39253 | _transform | train | function _transform(chunk, encoding, cb) {
this.emit('lines', chunk);
try {
this.parse(chunk);
}catch(e) {
this.emit('error', e);
}
cb();
} | javascript | {
"resource": ""
} |
q39254 | parse | train | function parse(lines) {
var i, line, key, parts, values;
for(i = 0;i < lines.length;i++) {
line = lines[i];
this.lineNumber++;
// ignore comments and whitespace lines
if(COMMENT.test(line) || WHITESPACE.test(line)) {
continue;
// got something to parse
}else{
// strip empty en... | javascript | {
"resource": ""
} |
q39255 | BaseMiddleware | train | function BaseMiddleware (Model, key) {
// constructor
var instance = function (req, res, next) {
return instance.exec()(req, res, next);
};
instance.Model = Model;
instance.methodChain = [];
instance.__proto__ = this.__proto__;
instance.setKey = function (key) {
key = key || Model.modelName.toLo... | javascript | {
"resource": ""
} |
q39256 | train | function (url, site, ctx, loadFunc) {
return $.Deferred(function (dfd) {
ctx = ctx || SP.ClientContext.get_current();
site = site || ctx.get_site();
var web = (url) ? (typeof url == "string") ? site.openWeb(url) : url : ctx.get_web();
var res = loadFunc && loadFunc(web) || ctx.load(web);
ctx.executeQ... | javascript | {
"resource": ""
} | |
q39257 | execute | train | function execute(req, res) {
req.conn.watch(req.args, req.db);
res.send(null, Constants.OK);
} | javascript | {
"resource": ""
} |
q39258 | getPlatformDetailsFromDir | train | function getPlatformDetailsFromDir(dir, platformIfKnown){
var libDir = path.resolve(dir);
var platform;
var version;
try {
var pkg = require(path.join(libDir, 'package'));
platform = platformFromName(pkg.name);
version = pkg.version;
} catch(e) {
// Older platforms d... | javascript | {
"resource": ""
} |
q39259 | hostSupports | train | function hostSupports(platform) {
var p = platforms[platform] || {},
hostos = p.hostos || null;
if (!hostos)
return true;
if (hostos.indexOf('*') >= 0)
return true;
if (hostos.indexOf(process.platform) >= 0)
return true;
return false;
} | javascript | {
"resource": ""
} |
q39260 | mixSpecIntoComponent | train | function mixSpecIntoComponent(Constructor, spec) {
if (!spec) {
if (false) {
var typeofSpec = typeof spec;
var isMixinValid = typeofSpec === 'object' && spec !== null;
process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either n... | javascript | {
"resource": ""
} |
q39261 | train | function (event) {
var dispatchConfig = event.dispatchConfig;
if (dispatchConfig.registrationName) {
return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
}
if (dispatchConfig.phasedRegistrationNames !== undefined) {
// pulling phasedRegistrationN... | javascript | {
"resource": ""
} | |
q39262 | train | function () {
eventPluginOrder = null;
for (var pluginName in namesToPlugins) {
if (namesToPlugins.hasOwnProperty(pluginName)) {
delete namesToPlugins[pluginName];
}
}
EventPluginRegistry.plugins.length = 0;
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDi... | javascript | {
"resource": ""
} | |
q39263 | asap | train | function asap(callback, context) {
!batchingStrategy.isBatchingUpdates ? false ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context whereupdates are not being batched.') : _prodInvariant('125') : void 0;
asapCallbackQueue.enqueue(callback, context);
asapEnqueued = true;
} | javascript | {
"resource": ""
} |
q39264 | unmountComponentFromNode | train | function unmountComponentFromNode(instance, container, safely) {
if (false) {
ReactInstrumentation.debugTool.onBeginFlush();
}
ReactReconciler.unmountComponent(instance, safely);
if (false) {
ReactInstrumentation.debugTool.onEndFlush();
}
if (container.nodeType === DOC_NODE_TYPE) {
co... | javascript | {
"resource": ""
} |
q39265 | train | function (nextElement, container, shouldReuseMarkup, context) {
// Various parts of our code (such as ReactCompositeComponent's
// _renderValidatedComponent) assume that calls to render aren't nested;
// verify that that's the case.
false ? warning(ReactCurrentOwner.current == null, '_renderNewRoot... | javascript | {
"resource": ""
} | |
q39266 | dispatch | train | function dispatch(action) {
if (!(0, _isPlainObject2['default'])(action)) {
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
}
if (typeof action.type === 'undefined') {
throw new Error('Actions may not have an undefined "type" property. ' + ... | javascript | {
"resource": ""
} |
q39267 | Configuration | train | function Configuration(options, parent) {
options = options || {};
this.options = options;
// delimiter used to split and join lines
this.options.eol = options.eol || EOL;
// parent reference - used by includes
this._parent = parent;
// file path to primary configuration file loaded
this._file = null... | javascript | {
"resource": ""
} |
q39268 | get | train | function get(key, stringify) {
var val = this._data[key] ? this._data[key].value :
(DEFAULTS[key] !== undefined ? DEFAULTS[key] : undefined);
if(val === undefined) return null;
if(stringify) {
val = this.encode(key, val, true);
}
return val;
} | javascript | {
"resource": ""
} |
q39269 | validate | train | function validate(key, values) {
var typedef, value;
if(!~Keys.indexOf(key)) {
throw new Error('unknown configuration key: ' + key);
}
// retrieve the type definition
typedef = Types[key];
// validate on the typedef
try {
value = typedef.validate(key, values);
}catch(e) {
// got a more sp... | javascript | {
"resource": ""
} |
q39270 | onLoad | train | function onLoad() {
var k, o, v;
for(k in this._data) {
o = this._data[k];
v = o.value;
try {
this.verify(k, v);
if(k === Types.SLAVEOF) {
if(this.get(Types.CLUSTER_ENABLED) && v) {
throw new Error('slaveof directive not allowed in cluster mode');
}
}
}ca... | javascript | {
"resource": ""
} |
q39271 | set | train | function set(key, value, lineno, child) {
// keys can be passed as buffers
// we need a string
key = '' + key;
//console.error('%s=%s', key, value);
var typedef = Types[key]
, exists = this._data[key]
, val = exists || {value: null, lineno: !child ? lineno : undefined}
, changed = false;
if(!l... | javascript | {
"resource": ""
} |
q39272 | directives | train | function directives(def) {
// mock line number for error messages
var lineno = 1
, k
, v
// inline directive, not from a file
, file = 'directive override (argv)';
function addDirective(k, v) {
// must be strings split into an array
// they are parsed and validated
v = ('' + v).split(... | javascript | {
"resource": ""
} |
q39273 | load | train | function load(opts, cb) {
if(typeof opts === 'function') {
cb = opts;
opts = undefined;
}
if(typeof opts === 'string') {
file = opts;
}else if(typeof opts === 'object') {
file = opts.file;
}
if(file === undefined) file = DEFAULT_FILE;
var sync = typeof cb !== 'function'
, stream
... | javascript | {
"resource": ""
} |
q39274 | write | train | function write(file, cb) {
if(file === undefined) file = this._file;
if(file === DEFAULT_FILE) {
return this.emit(
'error', new Error('cannot write to default configuration'));
}
var sync = typeof cb !== 'function'
, stream
, save
, encoder = new Encoder(this.options)
, lines = this.... | javascript | {
"resource": ""
} |
q39275 | writeLines | train | function writeLines() {
var chunk = lines.slice(i * size, (i * size) + size);
// all done
if(!chunk.length) {
return encoder.end();
}
// ensure we get correct line break between
// line chunks, the encoder joins lines on EOL
// this means that the last line in the chunk array
// ... | javascript | {
"resource": ""
} |
q39276 | handleFailure | train | function handleFailure(err) {
// Respond back to SWF failing the workflow
winston.log('error', 'An problem occured in the execution of workflow: %s, failing due to: ', self.name, err.stack);
decisionTask.response.fail('Workflow failed', err, function (err) {
if (err) {
winston.log('error', 'Un... | javascript | {
"resource": ""
} |
q39277 | handleSuccess | train | function handleSuccess() {
// If any activities failed, we need to fail the workflow
if (context.failed()) {
winston.log('warn', 'One of more activities failed in workflow: %s, marking workflow as failed', self.name);
// Respond back to SWF failing the workflow
decisionTask.response.fail('Ac... | javascript | {
"resource": ""
} |
q39278 | train | function (opts) {
opts = opts || {}
opts = defaults(opts, {
nodeModulesDir: path.resolve(process.cwd(), 'node_modules'),
package: rpkg.gen(opts.package)
})
fs.mkdirpSync(path.resolve(opts.nodeModulesDir, opts.package.name))
fs.writeFileSync(
path.resolve(opts.nodeModulesDir, opts.p... | javascript | {
"resource": ""
} | |
q39279 | train | function (opts) {
var name
if (opts && opts.name) name = opts.name
if (opts && opts.package && opts.package.name) name = opts.package.name
if (!name) throw new TypeError('package name missing')
opts = defaults(opts, {
nodeModulesDir: path.resolve(process.cwd(), 'node_modules')
})
fs.re... | javascript | {
"resource": ""
} | |
q39280 | SortedSet | train | function SortedSet(source) {
HashMap.call(this);
this._rtype = TYPE_NAMES.ZSET;
if(source) {
for(var k in source) {
this.setKey(k, source[k]);
}
}
} | javascript | {
"resource": ""
} |
q39281 | zadd | train | function zadd(members) {
var i
, c = 0
, score
, member;
for(i = 0;i < members.length;i+=2) {
score = members[i];
if(INFINITY[score] !== undefined) {
score = INFINITY[score];
}
member = members[i + 1];
if(this.zrank(member) === null) {
c++;
}
// this will add or u... | javascript | {
"resource": ""
} |
q39282 | zrem | train | function zrem(members) {
var i
, c = 0;
for(i = 0;i < members.length;i++) {
c += this.delKey(members[i]);
}
return c;
} | javascript | {
"resource": ""
} |
q39283 | zrank | train | function zrank(member) {
if(this._data[member] === undefined) return null;
for(var i = 0;i < this._keys.length;i++) {
if(this.memberEqual(member, this._keys[i].m)) {
return i;
}
}
return null;
} | javascript | {
"resource": ""
} |
q39284 | zincrby | train | function zincrby(increment, member) {
var score = parseFloat(this._data[member]) || 0;
score += parseFloat(increment);
this.setKey(member, score);
return score;
} | javascript | {
"resource": ""
} |
q39285 | set | train | function set(req, res) {
var key = '' + req.args[0]
, value = req.args[1];
// already validated the config key/value so should be ok
// to update the in-memory config, some config verification
// methods perform side-effects, eg: dir
this.conf.set(key, value);
res.send(null, Constants.OK);
if(key ===... | javascript | {
"resource": ""
} |
q39286 | rewrite | train | function rewrite(req, res) {
/* istanbul ignore next: tough to mock fs write error */
function onError(err) {
this.conf.removeAllListeners('error');
this.conf.removeAllListeners('write');
res.send(err);
}
function onWrite() {
this.conf.removeAllListeners('error');
this.conf.removeAllListen... | javascript | {
"resource": ""
} |
q39287 | resetstat | train | function resetstat(req, res) {
this.stats.reset();
res.send(null, Constants.OK);
} | javascript | {
"resource": ""
} |
q39288 | validate | train | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var sub = info.command.sub
, cmd = '' + sub.cmd
, args = sub.args
, key
, val
, verified;
if(cmd === Constants.SUBCOMMAND.config.set.name) {
key = '' + args[0];
val = '' + args[1];
// ... | javascript | {
"resource": ""
} |
q39289 | registerSchema | train | function registerSchema(schema) {
var typename = getTypenameFromSchemaID(schema.id);
var registered_schema = tv4.getSchema(schema.id);
if (registered_schema == null) {
var is_draft_schema = (schema.id === exports.DRAFT_SCHEMA_ID);
if (!is_draft_schema) {
i... | javascript | {
"resource": ""
} |
q39290 | tv4_validate | train | function tv4_validate(typename, query) {
var id = getSchemaIDFromTypename(typename);
var schema = tv4.getSchema(id);
if (schema == null) {
var error = { code: 0, message: 'Schema not found', dataPath: '', schemaPath: id };
return { valid: false, missing: [], errors: [erro... | javascript | {
"resource": ""
} |
q39291 | tv4_validateSchema | train | function tv4_validateSchema(schema) {
var is_draft_schema = (schema.id === exports.DRAFT_SCHEMA_ID);
var draft_schema = (is_draft_schema) ? schema : tv4.getSchema(exports.DRAFT_SCHEMA_ID);
var report = tv4.validateMultiple(schema, draft_schema);
return report;
} | javascript | {
"resource": ""
} |
q39292 | mutateJsonFile | train | function mutateJsonFile(targetPath, source, mutator) {
if (!mutator) {
mutator = source;
source = null;
}
let sourceConfig = source;
try {
// console.log('targetPath', targetPath);
let targetConfig = readJson(targetPath);
// console.log('source', source);
if (typeof source === 'string'... | javascript | {
"resource": ""
} |
q39293 | detree | train | function detree(items, children, parent_id) {
var item,
i;
for (i = 0; i < children.length; i++) {
item = children[i];
if (parent_id) {
item.parent = parent_id;
}
items.push(item);
if (item.children) {
detree(items, item.children, item.id);
}
delete item.children;
}
} | javascript | {
"resource": ""
} |
q39294 | _getTags | train | function _getTags(pelem, tag, platform, transform) {
var platformTag = pelem.find('./platform[@name="' + platform + '"]');
var tagsInRoot = pelem.findall(tag);
tagsInRoot = tagsInRoot || [];
var tagsInPlatform = platformTag ? platformTag.findall(tag) : [];
var tags = tagsInRoot.concat(tagsInPlatform... | javascript | {
"resource": ""
} |
q39295 | hasOwnValue | train | function hasOwnValue(object, value) {
assertType(object, 'object', false, 'Invalid object specified');
for (let k in object) {
if (object.hasOwnProperty(k) && (object[k] === value)) return true;
}
return false;
} | javascript | {
"resource": ""
} |
q39296 | render | train | function render() {
var framework = this._bigpipe._framework
, bootstrap = this
, data;
data = this.keys.reduce(function reduce(memo, key) {
memo[key] = bootstrap[key];
return memo;
}, {});
//
// Adds initial HTML headers to the queue. The first flush will
// push out t... | javascript | {
"resource": ""
} |
q39297 | contentTypeHeader | train | function contentTypeHeader(type) {
if (this._res.headersSent) return this.debug(
'Headers already sent, ignoring content type change: %s', contentTypes[type]
);
this.contentType = contentTypes[type];
this._res.setHeader('Content-Type', this.contentType);
} | javascript | {
"resource": ""
} |
q39298 | queue | train | function queue(name, parent, data) {
this.length--;
//
// Object was queued, transform the response type to application/json.
//
if ('object' === typeof data && this._contentType !== contentTypes.json) {
this.emit('contentType', 'json');
}
this._queue.push({
parent: parent,
... | javascript | {
"resource": ""
} |
q39299 | join | train | function join() {
var pagelet = this
, result = this._queue.map(function flatten(fragment) {
if (!fragment.name || !fragment.view) return '';
return fragment.view;
});
try {
result = this._contentType === contentTypes.json
? JSON.stringify(result.shift())
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.