_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q39600 | getNew | train | function getNew(body) {
// If we haven't already cleared the callback (we got the body, then the
// message on the subscriber)
if (timer) {
// If the new body is present (say, if it wasn't deleted)
if (body) {
// Calculate the new Etag
ourEtag = '"' + sha1hex(body) ... | javascript | {
"resource": ""
} |
q39601 | setOverrideHeader | train | function setOverrideHeader(res, name, value) {
if (res._headers && res._headers[name] !== undefined) {
return true;
}
res.setHeader(name, value);
return true;
} | javascript | {
"resource": ""
} |
q39602 | setWritableHeader | train | function setWritableHeader(res, name, value) {
if (res._headerSent && res.finished) {
return false;
}
res.setHeader(name, value);
return true;
} | javascript | {
"resource": ""
} |
q39603 | train | function (options) {
/** call event emitter */
events.EventEmitter.call(this);
/** module default configuration */
var defaults = {
idSelector: 'linotype',
start: 0,
currentSection: 0,
delay: 300,
easingdelay: 700,
easing: false,
isMoving: false,
keyboardScrolling: true,
touchevents: true,
mous... | javascript | {
"resource": ""
} | |
q39604 | train | function (e) {
var touchEvents = getEventsPage(e);
touchStartY = touchEvents.y;
touchStartX = touchEvents.x;
if (e.touches) {
touchMoveStartY = e.touches[0].screenY;
touchMoveStartX = e.touches[0].screenX;
}
} | javascript | {
"resource": ""
} | |
q39605 | describeFailure | train | function describeFailure(ex) {
return ex.stack? [' ---'
,' type: ' + ex.name
,' message: >'
, pad(6, ex.message)
,' stack: | '
, pad(6, ex.stack)
... | javascript | {
"resource": ""
} |
q39606 | TwistFilter | train | function TwistFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/twist.frag', 'utf8'),
// custom uniforms
{
radius: { type: '1f', value: 0.5 },
angle: { type: '1f', value: ... | javascript | {
"resource": ""
} |
q39607 | lintScripts | train | function lintScripts(conf, undertaker) {
const jsSrc = path.join(conf.themeConfig.root, conf.themeConfig.js.src, '**', '*.js');
// Lint theme scripts with ESLint. This won't touch any TypeScript files.
return undertaker.src(jsSrc)
.pipe(eslint())
.pipe(eslint.format())
.pipe(gulpIf(conf.productionMo... | javascript | {
"resource": ""
} |
q39608 | switchState | train | function switchState(started, pkg) {
pkg.started = started;
//add available port back into port range
if (!started && pkg.env && pkg.env.PORT)
ports.push(pkg.env.PORT);
console.log((started ? 'Started' : 'Stopped') + ' application ' + pkg.user + '/' + pkg.name);
logInfo('info', 'Application... | javascript | {
"resource": ""
} |
q39609 | switchAndClear | train | function switchAndClear(pkg) {
switchState(false, pkg);
//unload proxy routes
proxy.deleteBy(app.config.get('public-port'), {user: pkg.user, appid: pkg.name});
} | javascript | {
"resource": ""
} |
q39610 | findSwitchAndClear | train | function findSwitchAndClear(uid) {
if (uid) {
droneModel.getProcessed({uid: uid}, function(err, result) {
if (!err && result && result.length == 1) {
switchAndClear(result[0]);
}
});
}
} | javascript | {
"resource": ""
} |
q39611 | startDrone | train | function startDrone(pkg, userid, appid, callback) {
var drone_port = getPort();
if (drone_port) {
pkg.env = pkg.env || {};
pkg.env['PORT'] = drone_port;
//ensure package user and name match internally
pkg.user = userid;
pkg.name = appid;
drone.start(pkg, function(err, resu... | javascript | {
"resource": ""
} |
q39612 | stopDrone | train | function stopDrone(userid, appid, callback) {
droneModel.getProcessed({user: userid, name: appid}, function(err, result) {
if (err)
return callback(err);
if (result.length == 1) {
if (!result[0].started) {
callback({message: 'Drone is already stopped'});
}else{
... | javascript | {
"resource": ""
} |
q39613 | sendDrones | train | function sendDrones(filter, res) {
droneModel.getProcessed(filter, function(err, result) {
if (err)
return haibu.sendResponse(res, 500, err);
haibu.sendResponse(res, 200, {drones: result});
});
} | javascript | {
"resource": ""
} |
q39614 | train | function(ethereumAddress, ethereumDataDir, ethereumAccountPassword, cb = null){
if(isFunction(cb)){
try {
keythereum.importFromFile(ethereumAddress, ethereumDataDir, function(keyObject){
keythereum.recover(ethereumAccountPassword, keyObject, function(privateKey){
... | javascript | {
"resource": ""
} | |
q39615 | train | function(privateKey, cb = null){
if(isFunction(cb)){
try {
return cb(null, ethUtils.privateToPublic(privateKey))
}
catch(err){
return cb(err)
}
} else {
try {
return ethUtils.privateToPublic(priva... | javascript | {
"resource": ""
} | |
q39616 | train | function(message, signatureObject, cb = null){
var result = false
var ethSig = toEthUtilsSignature(signatureObject)
try {
var isSigValid = ethUtils.isValidSignature(ethSig.v, ethSig.r, ethSig.s)
var isPubKeyValid = ethUtils.isValidPublic(signatureObject.publicKey)
... | javascript | {
"resource": ""
} | |
q39617 | train | function(signatureObject, publicKey, bufferEncoding = DEFAULT_ENCODING, cb = null){
var clonedSignatureObj = {
signature: signatureObject.signature,
recovery: signatureObject.recovery,
publicKey: publicKey
}
bufferEncoding = getEncodingOrDefault(bufferEncoding... | javascript | {
"resource": ""
} | |
q39618 | train | function(base64String, bufferEncoding = DEFAULT_ENCODING, cb = null){
bufferEncoding = getEncodingOrDefault(bufferEncoding)
var decodedObj = JSON.parse(Buffer.from(base64String, 'base64').toString())
var result = {}
if('signature' in decodedObj && 'recovery' in decodedObj){
r... | javascript | {
"resource": ""
} | |
q39619 | getConnection | train | function getConnection (config) {
var sequelize
var defaultStorage = 'store.db'
var logging = config.logging || false
if (config.dialect === 'sqlite') {
if (!config.storage) {
config.storage = defaultStorage
}
sequelize = new Sequelize(config.database, config.username, config.password, {
... | javascript | {
"resource": ""
} |
q39620 | runSQL | train | function runSQL (sql, config, conn, replacements) {
return new Promise(function (resolve, reject) {
if (!config && !conn) {
reject('Must set config or connection')
}
if (!sql) {
reject('Need some sql')
}
if (!conn) {
conn = getConnection(config)
}
replacements = replac... | javascript | {
"resource": ""
} |
q39621 | _checkCircular | train | function _checkCircular (opts, obj) {
var key
if (util.isObject(obj)) {
if (~opts._visited.indexOf(obj)) {
return true
}
opts._visited.push(obj)
for (key in obj) {
if (obj.hasOwnProperty(key) && _checkCircular(opts, obj[key])) {
return true
}
}
}
return false
} | javascript | {
"resource": ""
} |
q39622 | merge | train | function merge () {
var args = [].slice.call(arguments)
args.unshift({})
return mergeExt.apply(null, args)
} | javascript | {
"resource": ""
} |
q39623 | _segment | train | function _segment (char) {
var tmp
char = char || '.'
return function (k) {
if (tmp) {
tmp += char + k
if (CLOSE.test(k)) {
k = tmp
tmp = ''
} else {
return
}
} else if (OPEN.test(k)) {
tmp = k
if (CLOSE.test(k)) {
tmp = ''
} else {... | javascript | {
"resource": ""
} |
q39624 | _splitPath | train | function _splitPath (keys) {
var out
if (util.isString(keys)) {
out = []
keys
.split('.')
.map(_segment('.'))
.forEach(function (k) {
k = (k || ' ').trim()
.replace(/^([^[]+)\[(["']?)(.+)\2\]$/, function (m, m1, m2, m3) {
if (m1 && m3) {
out.pus... | javascript | {
"resource": ""
} |
q39625 | _splitProps | train | function _splitProps (props) {
var test = {}
if (util.isString(props)) {
props = props
.split(',')
.map(_segment(','))
.filter(function (k) {
return k
})
}
if (util.isArray(props)) {
props.forEach(function (key) {
test[key] = 1
})
return test
}
return {... | javascript | {
"resource": ""
} |
q39626 | pick | train | function pick (obj, props) {
var key
var val
var out
var test = _splitProps(props)
if (util.isObject(obj)) {
out = {}
for (key in test) {
val = get(obj, key)
if (val !== undefined && val !== null) {
set(out, key, val)
}
}
}
return out
} | javascript | {
"resource": ""
} |
q39627 | omit | train | function omit (obj, props) {
var key
var out
var test = _splitProps(props)
if (util.isObject(obj)) {
out = clone(obj)
for (key in test) {
if ((get(obj, key))) {
set(out, key, null)
}
}
}
return out
} | javascript | {
"resource": ""
} |
q39628 | get | train | function get (obj, keys, _default) {
var i
var key
var tmp = obj || {}
keys = _splitPath(keys)
if (!keys || keys.length === 0) {
return _default
}
for (i = 0; i < keys.length; i++) {
key = keys[i]
if (tmp && tmp.hasOwnProperty(key)) {
tmp = tmp[key]
} else {
return _default
... | javascript | {
"resource": ""
} |
q39629 | set | train | function set (obj, keys, value) {
var i
var key
var last
var tmp = obj || {}
keys = _splitPath(keys)
if (!keys || keys.length === 0) {
return
}
last = keys.pop()
for (i = 0; i < keys.length; i++) {
key = keys[i]
if (!tmp[key]) {
tmp[key] = {}
}
if (tmp.hasOwnProperty(key)... | javascript | {
"resource": ""
} |
q39630 | arrayIndexOf | train | function arrayIndexOf (array, val) {
// Use native indexOf
if (Array.prototype.indexOf) {
return array.indexOf(val);
}
// Use loop/if for environments without native indexOf
var i, len = array.length;
for (i = 0; i < len; len += 1) {
if (array[i]... | javascript | {
"resource": ""
} |
q39631 | train | function (type, handler) {
// Validate arguments
if (typeof type !== 'string') {
throw new Error('Type must be a string');
}
if (typeof handler !== 'function') {
throw new Error('Handler must be a function');
}
// ... | javascript | {
"resource": ""
} | |
q39632 | train | function (type, handler) {
// Validate arguments
if (typeof type !== 'undefined' && typeof type !== 'string') {
throw new Error('Type must be a string or undefined');
}
if (typeof handler !== 'undefined' && typeof handler !== 'function') {
... | javascript | {
"resource": ""
} | |
q39633 | train | function (type, event) {
// Validate arguments
if (typeof type !== 'string') {
throw new Error('Type must be a string');
}
// Check for presence of event store
if (!this._events || !this._events[type]) { return; }
// Get handlers... | javascript | {
"resource": ""
} | |
q39634 | Store | train | function Store(options) {
if (!(this instanceof Store)) {
return new Store(options);
}
if (typeof options === 'string') {
options = { name: options };
}
options = options || {};
var name = options.name || 'macros';
this.store = options.store || new utils.Store(name);
} | javascript | {
"resource": ""
} |
q39635 | _createProxyMethod | train | function _createProxyMethod(proxyMethodName, mixinMethodName, hostObject) {
hostObject = hostObject || this._hostObject;
// Mixin class does not allow shadowing methods that exist on the host object
if (hostObject[proxyMethodName])
throw new Error('method ' + proxyMethodName +
... | javascript | {
"resource": ""
} |
q39636 | _createProxyMethods | train | function _createProxyMethods(proxyMethods, hostObject) {
check(proxyMethods, Match.Optional(Match.OneOf([String], Match.ObjectHash(String))));
// creating and binding proxy methods on the host object
if (Array.isArray(proxyMethods))
proxyMethods.forEach(function(methodName) {
// method ... | javascript | {
"resource": ""
} |
q39637 | Mixin_setInstanceKey | train | function Mixin_setInstanceKey(hostClass, method, instanceKey) {
check(hostClass, Function);
check(instanceKey, Match.IdentifierString);
var prop = INSTANCE_PROPERTIES_MAP,
instanceKeys = hostClass[prop] = hostClass[prop] || {};
if (instanceKeys[method.name])
throw new Error('Mixin: ins... | javascript | {
"resource": ""
} |
q39638 | Mixin_addMethod | train | function Mixin_addMethod(hostClass, instanceKey, mixinMethodName, hostMethodName) {
var method = this.prototype[mixinMethodName];
check(method, Function);
var wrappedMethod = _wrapMixinMethod.call(this, method);
Object.defineProperty(hostClass.prototype, hostMethodName, {
value: wrappedMethod,... | javascript | {
"resource": ""
} |
q39639 | _wrapMixinMethod | train | function _wrapMixinMethod(method) {
return function() { // ,... arguments
var mixinInstance = _getMixinInstance.call(this, method.name);
return method.apply(mixinInstance || this, arguments);
};
} | javascript | {
"resource": ""
} |
q39640 | Mixin$$useWith | train | function Mixin$$useWith(hostClass, instanceKey, mixinMethods) {
check(mixinMethods, Match.Optional(Match.OneOf([String], Match.ObjectHash(String))));
if (Array.isArray(mixinMethods)) {
mixinMethods.forEach(function(methodName) {
Mixin_addMethod.call(this, hostClass, instanceKey, methodName,... | javascript | {
"resource": ""
} |
q39641 | boundClass | train | function boundClass(target) {
// (Using reflect to get all keys including symbols)
let keys
// Use Reflect if exists
if (typeof Reflect !== 'undefined' && typeof Reflect.ownKeys === 'function') {
keys = Reflect.ownKeys(target.prototype)
} else {
keys = Object.getOwnPropertyNames(targ... | javascript | {
"resource": ""
} |
q39642 | boundMethod | train | function boundMethod(target, key, descriptor) {
// console.log('target, key, descriptor', target, key, descriptor)
let fn = descriptor.value
if (typeof fn !== 'function') {
throw new Error(`@autobind decorator can only be applied to methods not: ${typeof fn}`)
}
// In IE11 calling Object.d... | javascript | {
"resource": ""
} |
q39643 | configureStreamProcessingWithSettings | train | function configureStreamProcessingWithSettings(context, settings, standardSettings, standardOptions, event, awsContext,
forceConfiguration, validateConfiguration) {
// Configure all of the stream processing dependencies if not configured by configuring the given context as a
// standard context with stage handli... | javascript | {
"resource": ""
} |
q39644 | useStreamEventRecordAsMessage | train | function useStreamEventRecordAsMessage(record, batch, extractMessageFromRecord, context) {
if (!record || typeof record !== 'object') {
context.warn(`Adding invalid record (${record}) as an unusable record`);
return Promise.resolve([{unusableRec: batch.addUnusableRecord(record, undefined, `invalid record (${r... | javascript | {
"resource": ""
} |
q39645 | disableSourceStreamEventSourceMapping | train | function disableSourceStreamEventSourceMapping(batch, context) {
const functionName = tracking.getInvokedFunctionNameWithAliasOrVersion(context);
const batchKey = batch.key;
const sourceStreamName = (batchKey && batchKey.components && batchKey.components.streamName) ||
(tracking.getSourceStreamNames(batch.re... | javascript | {
"resource": ""
} |
q39646 | sendEvents | train | function sendEvents() {
logger.logEnter('sendEvents with eventCount ' + eventCount);
if (eventCount > 0) {
// If there are fewer than 10 events, we wait for more to arrive
// before sending them. Only delay sending them once so they
// don't get too old.
if (eventCount < 10 && canDel... | javascript | {
"resource": ""
} |
q39647 | validate | train | function validate() {
logger.logEnter('validate');
for (var i = 0; i < buffer.length; i++) {
var eventData = buffer[i],
typeName = eventData[0],
typeKeys = eventTypes[typeName];
if (!typeKeys) {
emitter.emit('error', typeName + ' is not a known event type.');
//... | javascript | {
"resource": ""
} |
q39648 | validEvent | train | function validEvent(eventKeys, typeKeys, emitter, typeName) {
if (eventKeys.length > typeKeys.length) {
emitter.emit('error', 'An event has more properties than its type, ' + typeName +
'. Event properties: [' + eventKeys + ']. ' + typeName + ' properties: [' + typeKeys + '].');
return false;
... | javascript | {
"resource": ""
} |
q39649 | createLogRequest | train | function createLogRequest(logger, utils, path, environment, emitter, failureCallback) {
'use strict';
logger.logEnter('createLogRequest ' + path);
var options = environment.elasticsearchOptions('POST', path);
var respConsumer = utils.responseConsumer(logger, 'after posting events', 200, failureCallback ? fa... | javascript | {
"resource": ""
} |
q39650 | fetchPackage | train | function fetchPackage(packageName, packageVersion) {
// Get the latest matching version from NPM if a version range is specified
return JudMarket.info(packageName).then(function(data){
//todo Market-Injection
return util.getLatestMatchingNpmVersion(data.fullname, packageVersion).then(
functi... | javascript | {
"resource": ""
} |
q39651 | cachePackage | train | function cachePackage(packageName, packageVersion) {
//todo Market-Injection
// WEEK_HOOK
if(packageName !== "judpack-android" && packageName !== "judpack-ios") {
packageName = JudMarket.info(packageName)
}
else {
packageName = { fullname: packageName}
}
return Q(packageName).then(function (d... | javascript | {
"resource": ""
} |
q39652 | evalRequiredError | train | function evalRequiredError(condition, required, type, name) {
if (condition) {
return new Error('Required argument <' + required + '> missing for ' + type + ': \'' + name + '\'');
}
return null;
} | javascript | {
"resource": ""
} |
q39653 | SocketServices | train | function SocketServices( options ){
options = options || {};
var self = this;
this.logger = Logger.createLogger( 'socket', {'socket-services': VERSION}, options.logger );
self.server = options.server || { };
this.messageValidator = options.messageValidator || isCommunication;
this.channel = options.channel |... | javascript | {
"resource": ""
} |
q39654 | createOnAuthStateChangedChannel | train | function createOnAuthStateChangedChannel() {
const auth = this.app.auth();
const channel = eventChannel(emit =>
auth.onAuthStateChanged(user => emit({ user })),
);
return channel;
} | javascript | {
"resource": ""
} |
q39655 | DropShadowFilter | train | function DropShadowFilter()
{
core.AbstractFilter.call(this);
this.blurXFilter = new BlurXFilter();
this.blurYTintFilter = new BlurYTintFilter();
this.defaultFilter = new core.AbstractFilter();
this.padding = 30;
this._dirtyPosition = true;
this._angle = 45 * Math.PI / 180;
this._dis... | javascript | {
"resource": ""
} |
q39656 | validate | train | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var offset = 2
, arg
, expires;
// need string args (except for key, value)
args.forEach(function(a, i, arr) {
if(i > 1) {
arr[i] = '' + a;
}
})
if(args.length > 7) {
throw new Command... | javascript | {
"resource": ""
} |
q39657 | ServerFacet | train | function ServerFacet($logs, $options, container) {
if (!(this instanceof ServerFacet)) {
return new ServerFacet($logs, $options, container);
}
this.name = ServerFacet.facetname;
this.container = container;
this.log = $logs.get('sit:jsonrpc:server#' + this.name);
this.options = _.assign({... | javascript | {
"resource": ""
} |
q39658 | train | function () {
var self = this;
_.each(_.clone(self._subscriptions), function (sub, id) {
// Avoid killing the autoupdate subscription so that developers
// still get hot code pushes when writing tests.
//
// XXX it's a hack to encode knowledge about autoupdate here,
// but it doesn... | javascript | {
"resource": ""
} | |
q39659 | _polarRadian | train | function _polarRadian(xyCenter, xyPointsArray) {
// simplify the math by moving the computed circle center to [0, 0]
var xAdj = 0 - xyCenter[0],
yAdj = 0 - xyCenter[1];
return _.map(xyPointsArray, function(xy){
// reposition x and y relative to adjusted [0, 0] center
var x = xy[0] + xAdj;
var y... | javascript | {
"resource": ""
} |
q39660 | _rotateRadian | train | function _rotateRadian(radiansRaw, radialAdj) {
radialAdj %= TWOPI;
return _.map(radiansRaw, function(r){
r += radialAdj;
// for radial positions that cross the baseline, recompute
if(r > TWOPI) { return r -= TWOPI; }
if(r < 0) { return r += TWOPI; }
return r;
});
} | javascript | {
"resource": ""
} |
q39661 | Messenger | train | function Messenger(namespace, options) {
if (!(this instanceof Messenger)) {
return new Messenger(namespace, options);
}
if (!namespace) {
throw new Error('Cannot create Messenger without a namespace');
}
events.EventEmitter.call(this);
this.namespace = namespace;
this.options = merge(Object.cr... | javascript | {
"resource": ""
} |
q39662 | train | function(object, propertyMeta, property) {
var that = this;
object['_' + property] = undefined;
// Adjust property 'type' and 'default fields
if (_.isArray(propertyMeta)) {
propertyMeta = propertyMeta.length === 3 || !_.isSimpleObject(propertyMeta[1])
? { ty... | javascript | {
"resource": ""
} | |
q39663 | _writeJSONFile | train | function _writeJSONFile (file, data, callback, replacer, space) {
if ("undefined" === typeof file) {
throw new ReferenceError("missing \"file\" argument");
}
else if ("string" !== typeof file) {
throw new TypeError("\"file\" argument is not a string");
}
else if ("" === file.trim()) {
t... | javascript | {
"resource": ""
} |
q39664 | createContext | train | function createContext(params, onNext) {
var context = function defaultCall(err) {
return context.next(err);
};
//additional parameters that are in effect beyond the object itself
context.params = params || {};
//keep us from calling next after a failure
context.failed = false;
... | javascript | {
"resource": ""
} |
q39665 | hasGit | train | function hasGit(){
var checkGit;
try {
which.sync('git');
checkGit = true;
} catch (ex) {
checkGit = false;
}
return checkGit;
} | javascript | {
"resource": ""
} |
q39666 | loadScopes | train | function loadScopes(scopes) {
var scopeMapping = {};
if (typeof scopes === 'object') {
for (var s in scopes) {
var routes = [];
var entries = scopes[s];
debug('Scope: %s routes: %j', s, entries);
if (Array.isArray(entries)) {
for (var j = 0, k = entries.length; j < k; j++) {
... | javascript | {
"resource": ""
} |
q39667 | getChild | train | function getChild() {
let element = undefined;
let name = undefined;
let recursive = undefined;
let arg1 = arguments[0];
if ((arg1 === window) || (arg1 === document) || (arg1 instanceof Node) || (arg1 === null) || (arg1 === undefined))
element = arg1;
else if (typeof arg1 === 'string')
name = arg1;... | javascript | {
"resource": ""
} |
q39668 | refcount | train | function refcount(req, res) {
var obj = req.db.getKey(req.args[0], req);
if(obj === undefined) return res.send(null, null);
res.send(null, -1);
} | javascript | {
"resource": ""
} |
q39669 | idletime | train | function idletime(req, res) {
var obj = req.db.getRawKey(req.args[0], req)
, diff;
if(obj === undefined) return res.send(null, null);
diff = Date.now() - obj.t;
diff = Math.round(diff / 1000);
res.send(null, diff);
} | javascript | {
"resource": ""
} |
q39670 | encoding | train | function encoding(req, res) {
var obj = req.db.getRawKey(req.args[0], req);
if(obj === undefined) return res.send(null, null);
res.send(null, getEncoding(
req.db.getType(req.args[0]), obj.v, this.state.conf));
} | javascript | {
"resource": ""
} |
q39671 | train | function () {
if (!this.enabled || this.enabling) {
return;
}
var err, cjsModule,
id = this.map.id,
depExports = this.depExports,
exports = this.exports,
factory = this.fa... | javascript | {
"resource": ""
} | |
q39672 | parseGroupExpression | train | function parseGroupExpression() {
var expr, expressions, startToken, isValidArrowParameter = true;
expect('(');
if (match(')')) {
lex();
if (!match('=>')) {
expect('=>');
}
return {
type: PlaceHolders.ArrowParamete... | javascript | {
"resource": ""
} |
q39673 | parseStatementListItem | train | function parseStatementListItem() {
if (lookahead.type === Token.Keyword) {
switch (lookahead.value) {
case 'const':
case 'let':
return parseLexicalDeclaration();
case 'function':
return parseFunctionDeclaration(new Node());
... | javascript | {
"resource": ""
} |
q39674 | includeFinished | train | function includeFinished(value) {
//If a sync build environment, check for errors here, instead of
//in the then callback below, since some errors, like two IDs pointed
//to same URL but only one anon ID will leave the loader in an
//unresolved state since a setTimeout ca... | javascript | {
"resource": ""
} |
q39675 | registerDriver | train | function registerDriver(Driver, name, options) {
if (this.drivers[name]) {
log.error(new Error('Driver "' + name + '" is already registered.'));
return;
}
if (!Driver || !Driver.prototype || typeof Driver.prototype.send !== 'function') {
log.error(new Error('Driver "' + name + '" should implement "sen... | javascript | {
"resource": ""
} |
q39676 | getDriver | train | function getDriver(name) {
if (!this.drivers[name]) {
log.error(new Error('Driver "' + name + '" is not registered.'));
return null;
}
return this.drivers[name];
} | javascript | {
"resource": ""
} |
q39677 | registerTask | train | function registerTask(Task, name, options) {
if (this.tasks[name]) {
log.error(new Error('Task "' + name + '" is already registered.'));
return;
}
if (!Task || !Task.prototype || typeof Task.prototype.run !== 'function') {
log.error(new Error('Task "' + name + '" should implement "run" method.'));
... | javascript | {
"resource": ""
} |
q39678 | getTask | train | function getTask(name) {
if (!this.tasks[name]) {
log.error(new Error('Task "' + name + '" is not registered.'));
return null;
}
return this.tasks[name];
} | javascript | {
"resource": ""
} |
q39679 | run | train | function run(task_name, options, driver_name) {
var task = this.tasks[task_name];
if (!task) {
log.error(new Error('Task "' + task_name + '" is not registered.'));
return;
}
var driver = this.drivers[driver_name];
if (!driver) {
log.error(new Error('Driver "' + driver_name + '" is not registered.'... | javascript | {
"resource": ""
} |
q39680 | nest | train | function nest(t, x, node, func, end) {
x.stmtStack.push(node);
var n = func(t, x);
x.stmtStack.pop();
end && t.mustMatch(end);
return n;
} | javascript | {
"resource": ""
} |
q39681 | NjsCompiler | train | function NjsCompiler(options) {
this.nodeSequence = 0;
this.options = options || {};
if (!this.options.runtime) {
this.options.runtime = 'njs';
}
this.parseBooleanOptions("exceptions", true);
} | javascript | {
"resource": ""
} |
q39682 | reader | train | function reader(str) {
var matched;
utils.some(rules, function (rule) {
return utils.some(rule.regex, function (regex) {
var match = str.match(regex),
normalized;
if (!match) {
return;
}
normalized = match[rule.idx || 0].replace(/\s*$/, '');
normalized = (rule.ha... | javascript | {
"resource": ""
} |
q39683 | build | train | function build(mode, system, cdef, out, cb) {
logger.info('building');
out.stdout('--> building');
builder.build(mode, system, cdef, out, function(err, specific) {
if (err) { logger.error(err); return cb(err); }
cb(err);
});
} | javascript | {
"resource": ""
} |
q39684 | needBuild | train | function needBuild(mode, system, cdef, out, cb) {
// TODO handle authentication and HTTPS registries
// also handle other registries than docker-registry-container
var cmds = commands(os.platform());
var tag = cmds.generateTag(config, system, cdef);
var baseUrl = 'http://' + config.registry + '/v1/... | javascript | {
"resource": ""
} |
q39685 | prepareAndGetExecutor | train | function prepareAndGetExecutor(target, out, operation) {
target.privateIpAddress = target.privateIpAddress || target.ipAddress || target.ipaddress;
var executor = platform.executor(config, target.privateIpAddress, os.platform(), logger);
logger.info(operation);
out.stdout(operation);
return executor... | javascript | {
"resource": ""
} |
q39686 | deploy | train | function deploy(mode, target, system, containerDef, container, out, cb) {
var executor = prepareAndGetExecutor(target, out, 'deploying');
executor.deploy(mode, target, system, containerDef, container, out, function(err) {
cb(err);
});
} | javascript | {
"resource": ""
} |
q39687 | hup | train | function hup(mode, target, system, containerDef, container, newConfig, out, cb) {
var executor = prepareAndGetExecutor(target, out, 'hup');
executor.hup(mode, target, system, containerDef, container, out, newConfig, function(err) {
cb(err);
});
} | javascript | {
"resource": ""
} |
q39688 | toFn | train | function toFn (value) {
if (typeof value === 'function') return value
var str = Array.isArray(value) ? value : String(value)
var obj = Object.create(null)
for (var i = 0; i < str.length; i++) {
obj[str[i]] = true
}
return function (char) {
return obj[char]
}
} | javascript | {
"resource": ""
} |
q39689 | trim | train | function trim (str, chars) {
var fn = toFn(chars || WHITESPACE_CHARS)
return trim.right(trim.left(str, fn), fn)
} | javascript | {
"resource": ""
} |
q39690 | processCsv | train | function processCsv (csvContent) {
UNSAFE_SYMBOLS.forEach(function (symbolParams) {
csvContent = csvContent.replace(symbolParams.pattern, symbolParams.replace);
});
return csvContent;
} | javascript | {
"resource": ""
} |
q39691 | createLocales | train | function createLocales (json, params, callback) {
var locales = registerLocales(json.shift());
var indexes = locales.indexes;
var messageName;
delete locales.indexes;
json.forEach(function (messageLine) {
var messageProp, lineValue, propPath;
for (var i = 0, len = messageLine.length; i < len; i++) ... | javascript | {
"resource": ""
} |
q39692 | parsePlaceholders | train | function parsePlaceholders (source) {
return source.match(/\([^\)]+\)/g).reduce(function (result, placeholder) {
placeholder = placeholder.replace(/^\(([^\)]+)\)$/, '$1');
var keyValue = placeholder.split(':');
result[keyValue[0]] = {
content: keyValue[1]
};
return result;
}, {});
} | javascript | {
"resource": ""
} |
q39693 | writeLocales | train | function writeLocales (locales, params, callback) {
try {
var jsonPath, json;
for (var key in locales) {
if (locales.hasOwnProperty(key)) {
json = locales[key];
jsonPath = path.join(params.dirPath, json.localeName, 'messages.json');
// remove empty messages
for (var msg_... | javascript | {
"resource": ""
} |
q39694 | registerLocales | train | function registerLocales (headers) {
var localesList = {
indexes: {}
};
var i = headers.length - 1;
var localeName;
while (i >= 2) {
localeName = headers[i].trim().split(/[\s\(]/)[0];
localesList[localeName] = {
localeName: localeName,
messages: {}
};
localesList.indexes[i] = ... | javascript | {
"resource": ""
} |
q39695 | processPath | train | function processPath (sourcePath, errorMessage) {
if (!sourcePath || typeof sourcePath !== 'string') {
throw new Error(errorMessage);
}
if (!path.isAbsolute(sourcePath)) {
sourcePath = path.join(process.cwd(), sourcePath);
}
return sourcePath;
} | javascript | {
"resource": ""
} |
q39696 | assertBoolean | train | function assertBoolean(value, name, description) {
if (!underscore.isBoolean(value)) {
throw new Error(
'<' + value + '> is not a boolean, ' + name + ': ' + description);
}
} | javascript | {
"resource": ""
} |
q39697 | assertValidBuildType | train | function assertValidBuildType(value, name, description) {
if ((value != common.DEBUG) && (value != common.RELEASE)) {
throw new Error('Invalid build type: <' + value + '>, must be ' +
'closureProBuild.DEBUG or closureProBuild.RELEASE');
}
} | javascript | {
"resource": ""
} |
q39698 | assertObjectMapOf | train | function assertObjectMapOf(valueValidatorFn, value, name, description) {
if (!underscore.isObject(value)) {
throw new Error(
'<' + value + '> is not an Object map, ' + name + ': ' + description);
}
// Check all values.
for (var key in value) {
valueValidatorFn(value[key], name + '[\'' + key + '... | javascript | {
"resource": ""
} |
q39699 | loadJspmConfig | train | function loadJspmConfig(opts) {
sh.echo('Loading jspm config...');
return new Promise(resolve => {
const loader = new jspm.Loader();
opts.config(loader);
resolve(loader);
});
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.