_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q50000 | _processData | train | function _processData(){
if(_.isEmpty($scope.mdtRow)) {
return;
}
//local search/filter
if (angular.isUndefined($scope.mdtRowPaginator)) {
$scope.$watch('mdtRow', function (mdtRow) {
... | javascript | {
"resource": ""
} |
q50001 | nutritionNameFilterCallback | train | function nutritionNameFilterCallback(names){
var arr = _.filter(nutritionList, function(item){
return item.fields.item_name.toLowerCase().indexOf(names.toLowerCase()) !== -1;
});
return $q.resolve(arr);
} | javascript | {
"resource": ""
} |
q50002 | serviceUnitsFilterCallback | train | function serviceUnitsFilterCallback(){
var arr = _.filter(nutritionList, function(item){
return item.fields.nf_serving_size_unit && item.fields.nf_serving_size_unit.toLowerCase();
});
arr = _.uniq(arr, function(item){ return item.fields.nf_serving_size_unit;});
... | javascript | {
"resource": ""
} |
q50003 | fatValuesCallback | train | function fatValuesCallback(){
return $q.resolve([
{
name: '> 50%',
comparator: function(val){ return val > 50;}
}, {
name: '<= 50%',
comparator: function(val){ return val <= 50;}
}... | javascript | {
"resource": ""
} |
q50004 | paginatorCallback | train | function paginatorCallback(page, pageSize, options){
console.log(options);
var filtersApplied = options.columnFilter;
var offset = (page-1) * pageSize;
var result = nutritionList;
if(filtersApplied[0].length) {
result = _.filter(nutritionList... | javascript | {
"resource": ""
} |
q50005 | extendsFromDeprecatedWidgetClassVersion | train | function extendsFromDeprecatedWidgetClassVersion(widgetClass) {
return Object.getPrototypeOf(widgetClass.prototype).constructor.version !== Widget.version;
} | javascript | {
"resource": ""
} |
q50006 | patchWidgetClass | train | function patchWidgetClass(widgetClass) {
const superWidgetClassPrototype = Object.getPrototypeOf(widgetClass.prototype);
// Patch subscribe method.
superWidgetClassPrototype.subscribe = Widget.prototype.subscribe;
// Patch publish method.
superWidgetClassPrototype.publish = Widget.prototype.publish;... | javascript | {
"resource": ""
} |
q50007 | reportNonMatchingComponentName | train | function reportNonMatchingComponentName(node, rawName, name, filename) {
context.report(
node,
'Component name ' + rawName + ' (' + name + ') does not match filename ' + filename
);
} | javascript | {
"resource": ""
} |
q50008 | client | train | function client(table) {
table = table || process.env.ProgressTable;
if (!table) throw new Error('ProgressTable environment variable is not set');
var dyno = module.exports.Dyno({
table: table.split(':')[5].split('/')[1],
region: table.split(':')[3],
endpoint: process.env.DynamoDbEndpoint
});
/*... | javascript | {
"resource": ""
} |
q50009 | train | function(node) {
if (utils.isExplicitComponent(node)) {
return true;
}
if (!node.superClass) {
return false;
}
return new RegExp('^(' + pragma + '\\.)?(Pure)?Component$').test(sourceCode.getText(node.superClass));
} | javascript | {
"resource": ""
} | |
q50010 | train | function(node) {
var comment = sourceCode.getJSDocComment(node);
if (comment === null) {
return false;
}
var commentAst = doctrine.parse(comment.value, {
unwrap: true,
tags: ['extends', 'augments']
});
var relevantTags = commentAst.tags.filter(function(tag)... | javascript | {
"resource": ""
} | |
q50011 | train | function (node) {
if (node.superClass) {
return new RegExp('^(' + pragma + '\\.)?PureComponent$').test(sourceCode.getText(node.superClass));
}
return false;
} | javascript | {
"resource": ""
} | |
q50012 | train | function(node) {
if (!node.value || !node.value.body || !node.value.body.body) {
return false;
}
var i = node.value.body.body.length - 1;
for (; i >= 0; i--) {
if (node.value.body.body[i].type === 'ReturnStatement') {
return node.value.body.body[i];
}
}
... | javascript | {
"resource": ""
} | |
q50013 | getTokenBeforeClosingBracket | train | function getTokenBeforeClosingBracket(node) {
var attributes = node.attributes;
if (attributes.length === 0) {
return node.name;
}
return attributes[attributes.length - 1];
} | javascript | {
"resource": ""
} |
q50014 | train | function (chunks, start, end) {
var soff=0, eoff=0, i=0, j=0;
for (i=0; i<chunks.length; i++) {
if (soff + chunks[i].length > start)
break;
soff += chunks[i].length;
}
var strs = [];
eoff = soff;
for (j=i; j<chunks.length; j++) {
strs.push(chunks[j]);
if (eoff + c... | javascript | {
"resource": ""
} | |
q50015 | minifyCodeEsprima | train | function minifyCodeEsprima(code,callback,description) {
if ((typeof esprima == "undefined") ||
(typeof esmangle == "undefined") ||
(typeof escodegen == "undefined")) {
console.warn("esprima/esmangle/escodegen not defined - not minifying")
return callback(code);
}
var code, synta... | javascript | {
"resource": ""
} |
q50016 | minifyCodeGoogle | train | function minifyCodeGoogle(code, callback, minificationLevel, description){
for (var i in minifyCache) {
var item = minifyCache[i];
if (item.code==code && item.level==minificationLevel) {
console.log("Found code in minification cache - using that"+description);
// move to front of cache
... | javascript | {
"resource": ""
} |
q50017 | initModule | train | function initModule(modName, mod) {
console.log("Initialising "+modName);
if (mod.init !== undefined)
mod.init();
} | javascript | {
"resource": ""
} |
q50018 | callProcessor | train | function callProcessor(eventType, data, callback) {
var p = processors[eventType];
// no processors
if (p===undefined || p.length==0) {
if (callback!==undefined) callback(data);
return;
}
// now go through all processors
var n = 0;
var cbCalled = false;
var cb = function(inDa... | javascript | {
"resource": ""
} |
q50019 | getSections | train | function getSections() {
var sections = [];
// add sections we know about
for (var name in builtinSections)
sections.push(builtinSections[name]);
// add other sections
for (var i in Espruino.Core.Config.data) {
var c = Espruino.Core.Config.data[i];
var found = false;
f... | javascript | {
"resource": ""
} |
q50020 | countBrackets | train | function countBrackets(str) {
var lex = getLexer(str);
var brackets = 0;
var tok = lex.next();
while (tok!==undefined) {
if (tok.str=="(" || tok.str=="{" || tok.str=="[") brackets++;
if (tok.str==")" || tok.str=="}" || tok.str=="]") brackets--;
tok = lex.next();
}
return bracke... | javascript | {
"resource": ""
} |
q50021 | getEspruinoPrompt | train | function getEspruinoPrompt(callback) {
if (Espruino.Core.Terminal!==undefined &&
Espruino.Core.Terminal.getTerminalLine()==">") {
console.log("Found a prompt... great!");
return callback();
}
var receivedData = "";
var prevReader = Espruino.Core.Serial.startListening(function (readD... | javascript | {
"resource": ""
} |
q50022 | executeExpression | train | function executeExpression(expressionToExecute, callback) {
var receivedData = "";
var hadDataSinceTimeout = false;
function getProcessInfo(expressionToExecute, callback) {
var prevReader = Espruino.Core.Serial.startListening(function (readData) {
var bufView = new Uint8Array(readData);
... | javascript | {
"resource": ""
} |
q50023 | isRecognisedBluetoothDevice | train | function isRecognisedBluetoothDevice(name) {
if (!name) return false;
var devs = recognisedBluetoothDevices();
for (var i=0;i<devs.length;i++)
if (name.substr(0, devs[i].length) == devs[i])
return true;
return false;
} | javascript | {
"resource": ""
} |
q50024 | stringToArrayBuffer | train | function stringToArrayBuffer(str) {
var buf=new Uint8Array(str.length);
for (var i=0; i<str.length; i++) {
var ch = str.charCodeAt(i);
if (ch>=256) {
console.warn("stringToArrayBuffer got non-8 bit character - code "+ch);
ch = "?".charCodeAt(0);
}
buf[i] = ch;
}
r... | javascript | {
"resource": ""
} |
q50025 | stringToBuffer | train | function stringToBuffer(str) {
var buf = new Buffer(str.length);
for (var i = 0; i < buf.length; i++) {
buf.writeUInt8(str.charCodeAt(i), i);
}
return buf;
} | javascript | {
"resource": ""
} |
q50026 | dataViewToArrayBuffer | train | function dataViewToArrayBuffer(str) {
var bufView = new Uint8Array(dv.byteLength);
for (var i = 0; i < bufView.length; i++) {
bufView[i] = dv.getUint8(i);
}
return bufView.buffer;
} | javascript | {
"resource": ""
} |
q50027 | moduleLoaded | train | function moduleLoaded(resolve, requires, modName, data, loadedModuleData, alreadyMinified){
// Check for any modules used from this module that we don't already have
var newRequires = getModulesRequired(data);
console.log(" - "+modName+" requires "+JSON.stringify(newRequires));
// if we need new modules... | javascript | {
"resource": ""
} |
q50028 | loadModules | train | function loadModules(code, callback){
var loadedModuleData = [];
var requires = getModulesRequired(code);
if (requires.length == 0) {
// no modules needed - just return
callback(code);
} else {
Espruino.Core.Status.setStatus("Loading modules");
// Kick off the module loading (eac... | javascript | {
"resource": ""
} |
q50029 | makeJobFile | train | function makeJobFile(config) {
var job = {"espruino":{}};
// assign commandline values
for (var key in args) {
switch (key) {
case 'job': // remove job itself, and others set internally from the results
case 'espruinoPrefix':
case 'espruinoPostfix':
break;
default: job[key] = a... | javascript | {
"resource": ""
} |
q50030 | getBoardList | train | function getBoardList(callback) {
var jsonDir = Espruino.Config.BOARD_JSON_URL;
// ensure jsonDir ends with slash
if (jsonDir.indexOf('/', jsonDir.length - 1) === -1) {
jsonDir += '/';
}
Espruino.Core.Utils.getJSONURL(jsonDir + "boards.json", function(boards){
// now load all the indiv... | javascript | {
"resource": ""
} |
q50031 | handler | train | function handler(opts) {
Object.assign(values, opts);
const configPath = path.join(os.homedir(), ".moleculer-templates.json");
return (
Promise.resolve()
//check for existing template alias config file
.then(() => {
return new Promise((resolve, reject) => {
fs.exists(configPath, exists => {
i... | javascript | {
"resource": ""
} |
q50032 | renderTemplate | train | function renderTemplate(skipInterpolation) {
skipInterpolation = typeof skipInterpolation === "string" ? [skipInterpolation] : skipInterpolation;
const handlebarsMatcher = /{{([^{}]+)}}/;
return function (files, metalsmith, done) {
const keys = Object.keys(files);
const metadata = metalsmith.metadata();
asyn... | javascript | {
"resource": ""
} |
q50033 | train | function (callback) {
const str = files[file].contents.toString();
if (!handlebarsMatcher.test(str)) {
return callback();
}
render(str, metadata, function (err, res) {
if (err) return callback(err);
files[file].contents = Buffer.from(res);
callback();
});
} | javascript | {
"resource": ""
} | |
q50034 | train | function (callback) {
if (!handlebarsMatcher.test(file)) {
return callback();
}
render(file, metadata, function (err, res) {
if (err) return callback(err);
// safety check to prevent file deletion in case filename doesn't change
if (file === res) return callback();
// safet... | javascript | {
"resource": ""
} | |
q50035 | train | function(chain_id) {
let i, len, network, network_name, ref;
ref = Object.keys(_this.networks);
for (i = 0, len = ref.length; i < len; i++) {
network_name = ref[i];
network = _this.networks[network_name];
if (network.chain_id === chain_id) {
... | javascript | {
"resource": ""
} | |
q50036 | train | function(msg) {
var event = _getEvent.apply(this, arguments);
var data = {event: event};
// Add agent info if required
if (_pageInfo !== 'never') {
if (!_sentPageInfo || _pageInfo === 'per-entry') {
_sentPageInfo = true;
... | javascript | {
"resource": ""
} | |
q50037 | Logger | train | function Logger(options) {
var logger;
// Default values
var dict = {
ssl: true,
catchall: false,
trace: true,
page_info: 'never',
print: false,
endpoint: null,
token: null
};
if (typeof options... | javascript | {
"resource": ""
} |
q50038 | _copyPackageJson | train | function _copyPackageJson(from, to) {
return new Promise((resolve, reject) => {
const origin = path.join(from, 'package.json');
const destination = path.join(to, 'package.json');
let data = JSON.parse(fs.readFileSync(origin, 'utf-8'));
delete data.engines;
delete data.scripts;
delete data.devD... | javascript | {
"resource": ""
} |
q50039 | getRandomNumber | train | function getRandomNumber(min, max) {
return Math.round(Math.random() * (max - min) + min);
} | javascript | {
"resource": ""
} |
q50040 | addLabelsToResource | train | async function addLabelsToResource (config, resourceList) {
return resourceList.map((resource) => {
const baseLabel = {
project: config.projectName,
version: config.projectVersion,
provider: 'nodeshift'
};
resource.metadata.labels = _.merge({}, baseLabel, resource.metadata.labels);
... | javascript | {
"resource": ""
} |
q50041 | loadEnrichers | train | function loadEnrichers () {
// find all the js files in the resource-enrichers directory
const enrichers = fs.readdirSync(`${__dirname}/resource-enrichers`).reduce((loaded, file) => {
const filesSplit = file.split('.');
if (filesSplit[1] === 'js') {
const mod = require(`./resource-enrichers/${file}`);... | javascript | {
"resource": ""
} |
q50042 | defaultService | train | function defaultService (config) {
const serviceConfig = _.merge({}, baseServiceConfig);
// Apply MetaData
serviceConfig.metadata = objectMetadata({
name: config.projectName,
namespace: config.namespace.name
});
serviceConfig.spec.selector = {
project: config.projectName,
provider: 'nodeshif... | javascript | {
"resource": ""
} |
q50043 | Client | train | function Client(options) {
this.options = {
host: options.host || '127.0.0.1',
port: options.port || '8983',
core: options.core || '',
rootPath: options.rootPath || 'solr',
protocol: options.protocol || 'http'
};
// Optional Authentication
if (options.user && options.password) {
this.opt... | javascript | {
"resource": ""
} |
q50044 | train | function() {
// Q* := Q / |Q|
// unrolled Q.scale(1 / Q.norm())
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var norm = Math.sqrt(w * w + x * x + y * y + z * z);
if (norm < Quaternion['EPSILON']) {
return Quaternion['ZERO'];
... | javascript | {
"resource": ""
} | |
q50045 | train | function(w, x, y, z) {
parse(P, w, x, y, z);
// Q1 * Q2 = [w1 * w2 - dot(v1, v2), w1 * v2 + w2 * v1 + cross(v1, v2)]
// Not commutative because cross(v1, v2) != cross(v2, v1)!
var w1 = this['w'];
var x1 = this['x'];
var y1 = this['y'];
var z1 = this['z'];
var w2 = P[... | javascript | {
"resource": ""
} | |
q50046 | train | function(w, x, y, z) {
parse(P, w, x, y, z);
// dot(Q1, Q2) := w1 * w2 + dot(v1, v2)
return this['w'] * P['w'] + this['x'] * P['x'] + this['y'] * P['y'] + this['z'] * P['z'];
} | javascript | {
"resource": ""
} | |
q50047 | train | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var vNorm = Math.sqrt(x * x + y * y + z * z);
var wExp = Math.exp(w);
var scale = wExp / vNorm * Math.sin(vNorm);
if (vNorm === 0) {
//return new Quaternion(wExp * Math.cos... | javascript | {
"resource": ""
} | |
q50048 | train | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
if (y === 0 && z === 0) {
return new Quaternion(
logHypot(w, x),
Math.atan2(x, w), 0, 0);
}
var qNorm2 = x * x + y * y + z * z + w * w;
var ... | javascript | {
"resource": ""
} | |
q50049 | train | function(w, x, y, z) {
parse(P, w, x, y, z);
if (P['y'] === 0 && P['z'] === 0) {
if (P['w'] === 1 && P['x'] === 0) {
return this;
}
if (P['w'] === 0 && P['x'] === 0) {
return Quaternion['ONE'];
}
// Check if we can operate in C
// Borr... | javascript | {
"resource": ""
} | |
q50050 | train | function(w, x, y, z) {
parse(P, w, x, y, z);
var eps = Quaternion['EPSILON'];
// maybe check for NaN's here?
return Math.abs(P['w'] - this['w']) < eps
&& Math.abs(P['x'] - this['x']) < eps
&& Math.abs(P['y'] - this['y']) < eps
&& Math.abs(P['z'] - thi... | javascript | {
"resource": ""
} | |
q50051 | train | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var ret = '';
if (isNaN(w) || isNaN(x) || isNaN(y) || isNaN(z)) {
return 'NaN';
}
// Alternative design?
// '(%f, [%f %f %f])'
ret = numToStr(w, '', ret);
... | javascript | {
"resource": ""
} | |
q50052 | train | function(d2) {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var n = w * w + x * x + y * y + z * z;
var s = n === 0 ? 0 : 2 / n;
var wx = s * w * x, wy = s * w * y, wz = s * w * z;
var xx = s * x * x, xy = s * x * y, xz = s * x * z;
v... | javascript | {
"resource": ""
} | |
q50053 | train | function(v) {
// [0, v'] = Q * [0, v] * Q'
// Q
var w1 = this['w'];
var x1 = this['x'];
var y1 = this['y'];
var z1 = this['z'];
// [0, v]
var w2 = 0;
var x2 = v[0];
var y2 = v[1];
var z2 = v[2];
// Q * [0, v]
var w3 = /*w1 * w2*/ -x1 * x2... | javascript | {
"resource": ""
} | |
q50054 | createPrototype | train | function createPrototype (type, options) {
return new DuckType({
name: options && options.name || null,
test: function test (object) {
return (object instanceof type);
}
});
} | javascript | {
"resource": ""
} |
q50055 | createCombi | train | function createCombi (types, options) {
var tests = types.map(function (type) {
return ducktype(type).test;
});
return new DuckType({
name: options && options.name || null,
test: function test (object) {
for (var i = 0, ii = tests.length; i < ii; i++) {
if (tests[i](obje... | javascript | {
"resource": ""
} |
q50056 | createFunction | train | function createFunction (test, options) {
return new DuckType({
name: options && options.name || null,
test: test
});
} | javascript | {
"resource": ""
} |
q50057 | createRegExp | train | function createRegExp (regexp, options) {
return new DuckType({
name: options && options.name || null,
test: function (object) {
return ((object instanceof String) || typeof(object) === 'string') && regexp.test(object);
}
});
} | javascript | {
"resource": ""
} |
q50058 | isUrl | train | function isUrl(string){
if (typeof string !== 'string') {
return false;
}
var match = string.match(protocolAndDomainRE);
if (!match) {
return false;
}
var everythingAfterProtocol = match[1];
if (!everythingAfterProtocol) {
return false;
}
return localhostDomainRE... | javascript | {
"resource": ""
} |
q50059 | MediaType | train | function MediaType (type, subtype, suffix) {
this.type = type
this.subtype = subtype
this.suffix = suffix
} | javascript | {
"resource": ""
} |
q50060 | checkAudioCodec | train | function checkAudioCodec(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('OPUS|PCMU|RAW'))
throw SyntaxError(key+' param is not one of [OPUS|PCMU|RAW] ('+value+')');
} | javascript | {
"resource": ""
} |
q50061 | checkRTCStatsIceCandidatePairState | train | function checkRTCStatsIceCandidatePairState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('frozen|waiting|inprogress|failed|succeeded|cancelled'))
throw SyntaxError(key+' param is not one of [frozen|waiting|inprogress|faile... | javascript | {
"resource": ""
} |
q50062 | checkGstreamerDotDetails | train | function checkGstreamerDotDetails(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('SHOW_MEDIA_TYPE|SHOW_CAPS_DETAILS|SHOW_NON_DEFAULT_PARAMS|SHOW_STATES|SHOW_FULL_PARAMS|SHOW_ALL|SHOW_VERBOSE'))
throw SyntaxError(key+' param ... | javascript | {
"resource": ""
} |
q50063 | checkRTCStatsIceCandidateType | train | function checkRTCStatsIceCandidateType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('host|serverreflexive|peerreflexive|relayed'))
throw SyntaxError(key+' param is not one of [host|serverreflexive|peerreflexive|relayed] ('... | javascript | {
"resource": ""
} |
q50064 | checkConnectionState | train | function checkConnectionState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('DISCONNECTED|CONNECTED'))
throw SyntaxError(key+' param is not one of [DISCONNECTED|CONNECTED] ('+value+')');
} | javascript | {
"resource": ""
} |
q50065 | checkRTCDataChannelState | train | function checkRTCDataChannelState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('connecting|open|closing|closed'))
throw SyntaxError(key+' param is not one of [connecting|open|closing|closed] ('+value+')');
} | javascript | {
"resource": ""
} |
q50066 | checkMediaState | train | function checkMediaState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('DISCONNECTED|CONNECTED'))
throw SyntaxError(key+' param is not one of [DISCONNECTED|CONNECTED] ('+value+')');
} | javascript | {
"resource": ""
} |
q50067 | checkMediaFlowState | train | function checkMediaFlowState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('FLOWING|NOT_FLOWING'))
throw SyntaxError(key+' param is not one of [FLOWING|NOT_FLOWING] ('+value+')');
} | javascript | {
"resource": ""
} |
q50068 | AudioCaps | train | function AudioCaps(audioCapsDict){
if(!(this instanceof AudioCaps))
return new AudioCaps(audioCapsDict)
audioCapsDict = audioCapsDict || {}
// Check audioCapsDict has the required fields
//
// checkType('AudioCodec', 'audioCapsDict.codec', audioCapsDict.codec, {required: true});
//
// checkType('... | javascript | {
"resource": ""
} |
q50069 | RTCPeerConnectionStats | train | function RTCPeerConnectionStats(rTCPeerConnectionStatsDict){
if(!(this instanceof RTCPeerConnectionStats))
return new RTCPeerConnectionStats(rTCPeerConnectionStatsDict)
rTCPeerConnectionStatsDict = rTCPeerConnectionStatsDict || {}
// Check rTCPeerConnectionStatsDict has the required fields
//
// checkT... | javascript | {
"resource": ""
} |
q50070 | VideoCaps | train | function VideoCaps(videoCapsDict){
if(!(this instanceof VideoCaps))
return new VideoCaps(videoCapsDict)
videoCapsDict = videoCapsDict || {}
// Check videoCapsDict has the required fields
//
// checkType('VideoCodec', 'videoCapsDict.codec', videoCapsDict.codec, {required: true});
//
// checkType('... | javascript | {
"resource": ""
} |
q50071 | checkVideoCodec | train | function checkVideoCodec(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('VP8|H264|RAW'))
throw SyntaxError(key+' param is not one of [VP8|H264|RAW] ('+value+')');
} | javascript | {
"resource": ""
} |
q50072 | checkFilterType | train | function checkFilterType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('AUDIO|AUTODETECT|VIDEO'))
throw SyntaxError(key+' param is not one of [AUDIO|AUTODETECT|VIDEO] ('+value+')');
} | javascript | {
"resource": ""
} |
q50073 | checkMediaType | train | function checkMediaType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('AUDIO|DATA|VIDEO'))
throw SyntaxError(key+' param is not one of [AUDIO|DATA|VIDEO] ('+value+')');
} | javascript | {
"resource": ""
} |
q50074 | EndpointStats | train | function EndpointStats(endpointStatsDict){
if(!(this instanceof EndpointStats))
return new EndpointStats(endpointStatsDict)
endpointStatsDict = endpointStatsDict || {}
// Check endpointStatsDict has the required fields
//
// checkType('double', 'endpointStatsDict.audioE2ELatency', endpointStatsDict.aud... | javascript | {
"resource": ""
} |
q50075 | Fraction | train | function Fraction(fractionDict){
if(!(this instanceof Fraction))
return new Fraction(fractionDict)
fractionDict = fractionDict || {}
// Check fractionDict has the required fields
//
// checkType('int', 'fractionDict.numerator', fractionDict.numerator, {required: true});
//
// checkType('int', 'fr... | javascript | {
"resource": ""
} |
q50076 | checkMediaTranscodingState | train | function checkMediaTranscodingState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('TRANSCODING|NOT_TRANSCODING'))
throw SyntaxError(key+' param is not one of [TRANSCODING|NOT_TRANSCODING] ('+value+')');
} | javascript | {
"resource": ""
} |
q50077 | checkServerType | train | function checkServerType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('KMS|KCS'))
throw SyntaxError(key+' param is not one of [KMS|KCS] ('+value+')');
} | javascript | {
"resource": ""
} |
q50078 | ElementStats | train | function ElementStats(elementStatsDict){
if(!(this instanceof ElementStats))
return new ElementStats(elementStatsDict)
elementStatsDict = elementStatsDict || {}
// Check elementStatsDict has the required fields
//
// checkType('double', 'elementStatsDict.inputAudioLatency', elementStatsDict.inputAudioL... | javascript | {
"resource": ""
} |
q50079 | checkUriEndpointState | train | function checkUriEndpointState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('STOP|START|PAUSE'))
throw SyntaxError(key+' param is not one of [STOP|START|PAUSE] ('+value+')');
} | javascript | {
"resource": ""
} |
q50080 | RembParams | train | function RembParams(rembParamsDict){
if(!(this instanceof RembParams))
return new RembParams(rembParamsDict)
rembParamsDict = rembParamsDict || {}
// Check rembParamsDict has the required fields
//
// checkType('int', 'rembParamsDict.packetsRecvIntervalTop', rembParamsDict.packetsRecvIntervalTop);
//... | javascript | {
"resource": ""
} |
q50081 | train | function(page) {
if (this.output.name != 'website' || page.search === false) {
return page;
}
var text;
this.log.debug.ln('index page', page.path);
text = page.content;
// Decode HTML
text = Html.decode(tex... | javascript | {
"resource": ""
} | |
q50082 | train | function() {
if (this.output.name != 'website') return;
this.log.debug.ln('write search index');
return this.output.writeFile('search_plus_index.json', JSON.stringify(documentsStore));
} | javascript | {
"resource": ""
} | |
q50083 | toColor | train | function toColor(str, opacity) {
var rgb = [0, 0, 0, opacity || 0.75];
try {
for (var i = 0; i < str.length; i++) {
var v = str.charCodeAt(i);
var idx = v % 3;
rgb[idx] = (rgb[i % 3] + (13 * (v % 13))) % 20;
}
} finally {
return 'rgba(' +
rgb.map(function(c, idx) {
return idx... | javascript | {
"resource": ""
} |
q50084 | train | function(configStrategy) {
if (!configStrategy.hasOwnProperty('cache') || !configStrategy.cache.hasOwnProperty('engine')) {
throw 'CACHING_ENGINE parameter is missing.';
}
if (configStrategy.cache.engine === undefined) {
throw 'CACHING_ENGINE parameter is empty.';
}
// Grab the required details from ... | javascript | {
"resource": ""
} | |
q50085 | train | function(lifetimeInSec) {
lifetimeInSec = Number(lifetimeInSec);
if (isNaN(lifetimeInSec)) {
lifetimeInSec = 0;
}
let lifetime = lifetimeInSec * 1000;
if (lifetime <= 0) {
this.expires = Date.now();
} else {
this.expires = Date.now() + lifetime;
}
} | javascript | {
"resource": ""
} | |
q50086 | createTypedef | train | function createTypedef(context, typeName, value) {
if (value instanceof Reference) {
value = value.resolve(context);
}
context.results[typeName] = value;
return value;
} | javascript | {
"resource": ""
} |
q50087 | setSpaAlias | train | function setSpaAlias(alias, moduleName, path) {
let resolvedPath = spaPath(path);
if (!fs.existsSync(resolvedPath)) {
resolvedPath = outPath(path);
}
alias['sky-pages-internal/' + moduleName] = resolvedPath;
} | javascript | {
"resource": ""
} |
q50088 | resolve | train | function resolve(url, localUrl, chunks, skyPagesConfig) {
let host = skyPagesConfig.skyux.host.url;
let config = {
scripts: getScripts(chunks),
localUrl: localUrl
};
if (skyPagesConfig.skyux.app && skyPagesConfig.skyux.app.externals) {
config.externals = skyPagesConfig.skyux.app.externals;
}
/... | javascript | {
"resource": ""
} |
q50089 | getScripts | train | function getScripts(chunks) {
let scripts = [];
// Used when skipping the build, short-circuit to return metadata
if (chunks.metadata) {
return chunks.metadata;
}
sorter.dependency(chunks).forEach((chunk) => {
scripts.push({
name: chunk.files[0]
});
});
return scripts;
} | javascript | {
"resource": ""
} |
q50090 | WebpackPluginDone | train | function WebpackPluginDone() {
let launched = false;
this.plugin('done', (stats) => {
if (!launched) {
launched = true;
browser(argv, skyPagesConfig, stats, this.options.devServer.port);
}
});
} | javascript | {
"resource": ""
} |
q50091 | getRoutesForConfig | train | function getRoutesForConfig(routes) {
return routes.map(route => ({
routePath: route.routePath === '?' ? '' : route.routePath.replace(/\#/g, ''),
routeParams: route.routeParams
}));
} | javascript | {
"resource": ""
} |
q50092 | killServers | train | function killServers(exitCode) {
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s... | javascript | {
"resource": ""
} |
q50093 | spawnProtractor | train | function spawnProtractor(configPath, chunks, port, skyPagesConfig) {
logger.info('Running Protractor');
protractorLauncher.init(configPath, {
params: {
localUrl: `https://localhost:${port}`,
chunks: chunks,
skyPagesConfig: skyPagesConfig
}
});
process.on('exit', killServers);
} | javascript | {
"resource": ""
} |
q50094 | getChromeDriverVersion | train | function getChromeDriverVersion() {
return new Promise(resolve => {
const defaultVersion = 'latest';
matcher.getChromeDriverVersion()
.then(result => {
if (result.chromeDriverVersion) {
resolve(result.chromeDriverVersion);
} else {
resolve(defaultVersion);
}
... | javascript | {
"resource": ""
} |
q50095 | spawnSelenium | train | function spawnSelenium(configPath) {
const config = require(configPath).config;
return new Promise((resolve, reject) => {
logger.info('Spawning selenium...');
// Assumes we're running selenium ourselves, so we should prep it
if (config.seleniumAddress) {
logger.info('Installing Selenium...');
... | javascript | {
"resource": ""
} |
q50096 | spawnBuild | train | function spawnBuild(argv, skyPagesConfig, webpack) {
if (argv.build === false) {
logger.info('Skipping build step');
const file = 'dist/metadata.json';
if (!fs.existsSync(file)) {
logger.info(`Unable to skip build step. "${file}" not found.`);
} else {
return Promise.resolve({
m... | javascript | {
"resource": ""
} |
q50097 | e2e | train | function e2e(command, argv, skyPagesConfig, webpack) {
start = new Date().getTime();
process.on('SIGINT', killServers);
const specsPath = path.resolve(process.cwd(), 'e2e/**/*.e2e-spec.ts');
const specsGlob = glob.sync(specsPath);
const configPath = configResolver.resolve(command, argv);
if (specsGlob.len... | javascript | {
"resource": ""
} |
q50098 | bindServe | train | function bindServe() {
return new Promise((resolve, reject) => {
// Logging "warnings" but not rejecting test
webpackServer.stderr.on('data', data => log(data));
webpackServer.stdout.on('data', data => {
const dataAsString = log(data);
if (dataAsString.indexOf('webpack: Compiled successfully.... | javascript | {
"resource": ""
} |
q50099 | exec | train | function exec(cmd, args, opts) {
console.log(`Running command: ${cmd} ${args.join(' ')}`);
const cp = childProcessSpawn(cmd, args, opts);
cp.stdout.on('data', data => log(data));
cp.stderr.on('data', data => log(data));
return new Promise((resolve, reject) => {
cp.on('error', err => reject(log(err)));
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.