_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q49300 | train | function () {
var position = this._getCaretRelativePosition();
var offset = this.$el.offset();
// Calculate the left top corner of `this.option.appendTo` element.
var $parent = this.option.appendTo;
if ($parent) {
if (!($parent instanceof $)) { $parent = $($parent); }
va... | javascript | {
"resource": ""
} | |
q49301 | train | function (text, skipUnchangedTerm) {
if (!this.dropdown) { this.initialize(); }
text != null || (text = this.adapter.getTextFromHeadToCaret());
var searchQuery = this._extractSearchQuery(text);
if (searchQuery.length) {
var term = searchQuery[1];
// Ignore shift-key, ctrl-key and... | javascript | {
"resource": ""
} | |
q49302 | train | function (value, strategy, e) {
this._term = null;
this.adapter.select(value, strategy, e);
this.fire('change').fire('textComplete:select', value, strategy);
this.adapter.focus();
} | javascript | {
"resource": ""
} | |
q49303 | train | function (text) {
for (var i = 0; i < this.strategies.length; i++) {
var strategy = this.strategies[i];
var context = strategy.context(text);
if (context || context === '') {
var matchRegexp = $.isFunction(strategy.match) ? strategy.match(text) : strategy.match;
if (isS... | javascript | {
"resource": ""
} | |
q49304 | splitArgsFromString | train | function splitArgsFromString(argsString) {
let result = [];
const quoteSeparatedArgs = argsString.split(/(\x22[^\x22]*\x22)/).filter(x => x);
quoteSeparatedArgs.forEach(arg => {
if (arg.match('\x22')) {
result.push(arg.replace(/\x22/g, ''));
} else {
result = result.concat(arg.trim().split(' '... | javascript | {
"resource": ""
} |
q49305 | _request | train | function _request(url, opt) {
opt = opt || {};
opt.method = (opt.method || 'GET').toUpperCase();
opt.headers = opt.headers || {};
if (matchUrl(url) && matchMethod(opt.method)) {
const result = extend(true, {}, mockResult);
const response = {
status: result.status,
... | javascript | {
"resource": ""
} |
q49306 | train | function(data) {
const seq = data.model.get("seq");
const selection = this._getSelection(data.model);
// get the status of the upper and lower row
const getNextPrev= this._getPrevNextSelection(data.model);
const mPrevSel = getNextPrev[0];
const mNextSel = getNextPrev[1];
const boxWidth = th... | javascript | {
"resource": ""
} | |
q49307 | train | function(data) {
let xZero = data.xZero;
const yZero = data.yZero;
const n = data.n;
const k = data.k;
const selection = data.selection;
// and checks the prev and next row for selection -> no borders in a selection
const mPrevSel= data.mPrevSel;
const mNextSel = data.mNextSel;
//... | javascript | {
"resource": ""
} | |
q49308 | train | function(model) {
var maxLen = model.getMaxLength();
if (maxLen < 200 && model.length < 30) {
this.defaults.boxRectWidth = this.defaults.boxRectHeight = 5;
}
return this;
} | javascript | {
"resource": ""
} | |
q49309 | train | function(max) {
// TODO!
// make seqlogo height configurable
var val = this.getMaxAlignmentHeight();
if (max !== undefined && max > 0) {
val = Math.min(val, max);
}
return this.set("alignmentHeight", val);
} | javascript | {
"resource": ""
} | |
q49310 | main | train | async function main({ isFragment, needsHelp, showVersion, useTabs }) {
/* eslint-disable no-console */
const stdin = await getStdin()
if (showVersion) {
return console.log(version)
}
if (needsHelp || !stdin) {
return console.log(help)
}
const pug = html2pug(stdin, { isFragment, useTabs })
ret... | javascript | {
"resource": ""
} |
q49311 | laravelLocalizationLoader | train | function laravelLocalizationLoader(source) {
var isPHP = ~source.indexOf('<?php')
if (isPHP) {
return phpArrayLoader(source)
} else {
return jsonLoader(source)
}
} | javascript | {
"resource": ""
} |
q49312 | createTile | train | function createTile(coords, done) {
let key = this._tileCoordsToKey(coords);
// console.log('Need:', key);
if ( key in this._freshTiles ) {
let tile = this._freshTiles[ key ].pop();
if ( !this._freshTiles[ key ].length ) {
delete this._freshTiles[ key ];
}
L.Util.request... | javascript | {
"resource": ""
} |
q49313 | createTile | train | function createTile(coords, done) {
let key = this._tileCoordsToKey(coords);
let tileContainer = L.DomUtil.create("div");
tileContainer.dataset.pending = this._imagesPerTile;
for ( let i = 0; i < this._imagesPerTile; i++ ) {
let key2 = key + "/" + i;
if ( key2 in this._freshTiles )... | javascript | {
"resource": ""
} |
q49314 | performGssapiCanonicalizeHostName | train | function performGssapiCanonicalizeHostName(canonicalizeHostName, host, callback) {
if (!canonicalizeHostName) return callback();
// Attempt to resolve the host name
dns.resolveCname(host, (err, r) => {
if (err) return callback(err);
// Get the first resolve host id
if (Array.... | javascript | {
"resource": ""
} |
q49315 | defineOperation | train | function defineOperation(fn, paramDefs) {
return function() {
const args = Array.prototype.slice.call(arguments);
const params = [];
for (let i = 0, argIdx = 0; i < paramDefs.length; ++i, ++argIdx) {
const def = paramDefs[i];
let arg = args[argIdx];
if (def.hasOwnProperty('default') && ... | javascript | {
"resource": ""
} |
q49316 | decrypt | train | function decrypt(env, callback) {
if (!env.AWS_DEFAULT_REGION) return callback(new Error('AWS_DEFAULT_REGION env var must be set'));
var kms = new AWS.KMS({
region: env.AWS_DEFAULT_REGION,
maxRetries: 10
});
var q = queue();
for (var key in env) {
if (!(/^secure:/).test(env[key])) continue;
q.... | javascript | {
"resource": ""
} |
q49317 | configurePackageDir | train | function configurePackageDir(pkgs, currentPackages, dir) {
var i, location, pkgObj;
for (i = 0; (pkgObj = currentPackages[i]); i++) {
pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
location = pkgObj.location;
//Add dir to the path, but avoid paths ... | javascript | {
"resource": ""
} |
q49318 | isPriorityDone | train | function isPriorityDone() {
var priorityDone = true,
priorityWait = config.priorityWait,
priorityName, i;
if (priorityWait) {
for (i = 0; (priorityName = priorityWait[i]); i++) {
if (!loaded[priorityName]) {
... | javascript | {
"resource": ""
} |
q49319 | updateNormalizedNames | train | function updateNormalizedNames(pluginName) {
var oldFullName, oldModuleMap, moduleMap, fullName, callbacks,
i, j, k, depArray, existingCallbacks,
maps = normalizedWaiting[pluginName];
if (maps) {
for (i = 0; (oldModuleMap = maps[i]); i++) {
... | javascript | {
"resource": ""
} |
q49320 | FlatToNested | train | function FlatToNested(config) {
this.config = config = config || {};
this.config.id = config.id || 'id';
this.config.parent = config.parent || 'parent';
this.config.children = config.children || 'children';
this.config.options = config.options || { deleteParent: true };
} | javascript | {
"resource": ""
} |
q49321 | train | function (input) {
if (typeof input === 'string') {
return farmhash.Hash32String(input);
}
if (Buffer.isBuffer(input)) {
return farmhash.Hash32Buffer(input);
}
throw new Error('Expected a String or Buffer for input');
} | javascript | {
"resource": ""
} | |
q49322 | train | function (input) {
if (typeof input === 'string') {
return farmhash.Fingerprint32String(input);
}
if (Buffer.isBuffer(input)) {
return farmhash.Fingerprint32Buffer(input);
}
throw new Error('Expected a String or Buffer for input');
} | javascript | {
"resource": ""
} | |
q49323 | runSuite | train | function runSuite() {
execFile(flow, [ 'status', '--color', 'always' ], (err, stdout) => {
process.stdout.write('\x1Bc')
/* eslint-disable no-console */
console.log(stdout)
/* eslint-enable no-console */
})
} | javascript | {
"resource": ""
} |
q49324 | create_gamma_table | train | function create_gamma_table(steps, gamma, warning) {
// used to build a gamma table for a particular value
if (! warning && gamma == GAMMA_DEFAULT && ! global.IS_TEST_MODE) {
console.info("INFO: Default gamma behaviour is changing");
console.info("0.9 - gamma=1.0 - consistent with pre-gamma val... | javascript | {
"resource": ""
} |
q49325 | colorWheel | train | function colorWheel( WheelPos ){
var r,g,b;
WheelPos = 255 - WheelPos;
if ( WheelPos < 85 ) {
r = 255 - WheelPos * 3;
g = 0;
b = WheelPos * 3;
} else if (WheelPos < 170) {
WheelPos -= 85;
r = 0;
g = WheelPos * 3;
... | javascript | {
"resource": ""
} |
q49326 | renameOrDelete | train | async function renameOrDelete(srcPath, targetPath) {
if (srcPath === targetPath) {
return;
}
const srcExists = await fs.exists(srcPath);
if (!srcExists) {
return;
}
const targetExists = await fs.exists(targetPath);
// if target file exists, then throw
// because the target file always be renamed... | javascript | {
"resource": ""
} |
q49327 | train | function(a, b) {
var z = new Complex(a, b);
// Infinity + Infinity = NaN
if (this['isInfinite']() && z['isInfinite']()) {
return Complex['NAN'];
}
// Infinity + z = Infinity { where z != Infinity }
if (this['isInfinite']() || z['isInfinite']()) {
return Complex['IN... | javascript | {
"resource": ""
} | |
q49328 | train | function(a, b) {
var z = new Complex(a, b);
// Infinity * 0 = NaN
if ((this['isInfinite']() && z['isZero']()) || (this['isZero']() && z['isInfinite']())) {
return Complex['NAN'];
}
// Infinity * z = Infinity { where z != 0 }
if (this['isInfinite']() || z['isInfinite']()) {... | javascript | {
"resource": ""
} | |
q49329 | train | function(a, b) {
var z = new Complex(a, b);
// 0 / 0 = NaN and Infinity / Infinity = NaN
if ((this['isZero']() && z['isZero']()) || (this['isInfinite']() && z['isInfinite']())) {
return Complex['NAN'];
}
// Infinity / 0 = Infinity
if (this['isInfinite']() || z['isZero']())... | javascript | {
"resource": ""
} | |
q49330 | train | function(a, b) {
var z = new Complex(a, b);
a = this['re'];
b = this['im'];
if (z['isZero']()) {
return Complex['ONE'];
}
// If the exponent is real
if (z['im'] === 0) {
if (b === 0 && a >= 0) {
return new Complex(Math.pow(a, z['re']), 0);
... | javascript | {
"resource": ""
} | |
q49331 | train | function() {
var a = this['re'];
var b = this['im'];
var r = this['abs']();
var re, im;
if (a >= 0) {
if (b === 0) {
return new Complex(Math.sqrt(a), 0);
}
re = 0.5 * Math.sqrt(2.0 * (r + a));
} else {
re = Math.abs(b) / Math.sqrt(2 * (r... | javascript | {
"resource": ""
} | |
q49332 | train | function() {
var tmp = Math.exp(this['re']);
if (this['im'] === 0) {
//return new Complex(tmp, 0);
}
return new Complex(
tmp * Math.cos(this['im']),
tmp * Math.sin(this['im']));
} | javascript | {
"resource": ""
} | |
q49333 | train | function() {
/**
* exp(a + i*b) - 1
= exp(a) * (cos(b) + j*sin(b)) - 1
= expm1(a)*cos(b) + cosm1(b) + j*exp(a)*sin(b)
*/
var a = this['re'];
var b = this['im'];
return new Complex(
Math.expm1(a) * Math.cos(b) + cosm1(b),
Math.exp(a) * Ma... | javascript | {
"resource": ""
} | |
q49334 | train | function() {
var a = this['re'];
var b = this['im'];
if (b === 0 && a > 0) {
//return new Complex(Math.log(a), 0);
}
return new Complex(
logHypot(a, b),
Math.atan2(b, a));
} | javascript | {
"resource": ""
} | |
q49335 | train | function() {
// sin(c) = (e^b - e^(-b)) / (2i)
var a = this['re'];
var b = this['im'];
return new Complex(
Math.sin(a) * cosh(b),
Math.cos(a) * sinh(b));
} | javascript | {
"resource": ""
} | |
q49336 | train | function() {
// asin(c) = -i * log(ci + sqrt(1 - c^2))
var a = this['re'];
var b = this['im'];
var t1 = new Complex(
b * b - a * a + 1,
-2 * a * b)['sqrt']();
var t2 = new Complex(
t1['re'] - b,
t1['im'] + a)['log']();
retu... | javascript | {
"resource": ""
} | |
q49337 | train | function() {
// acos(c) = i * log(c - i * sqrt(1 - c^2))
var a = this['re'];
var b = this['im'];
var t1 = new Complex(
b * b - a * a + 1,
-2 * a * b)['sqrt']();
var t2 = new Complex(
t1['re'] - b,
t1['im'] + a)['log']();
re... | javascript | {
"resource": ""
} | |
q49338 | train | function() {
// atan(c) = i / 2 log((i + x) / (i - x))
var a = this['re'];
var b = this['im'];
if (a === 0) {
if (b === 1) {
return new Complex(0, Infinity);
}
if (b === -1) {
return new Complex(0, -Infinity);
}
}
var d = a * ... | javascript | {
"resource": ""
} | |
q49339 | train | function() {
// acot(c) = i / 2 log((c - i) / (c + i))
var a = this['re'];
var b = this['im'];
if (b === 0) {
return new Complex(Math.atan2(1, a), 0);
}
var d = a * a + b * b;
return (d !== 0)
? new Complex(
a / d,
... | javascript | {
"resource": ""
} | |
q49340 | train | function() {
// asec(c) = -i * log(1 / c + sqrt(1 - i / c^2))
var a = this['re'];
var b = this['im'];
if (a === 0 && b === 0) {
return new Complex(0, Infinity);
}
var d = a * a + b * b;
return (d !== 0)
? new Complex(
a / d,
... | javascript | {
"resource": ""
} | |
q49341 | train | function() {
// acsc(c) = -i * log(i / c + sqrt(1 - 1 / c^2))
var a = this['re'];
var b = this['im'];
if (a === 0 && b === 0) {
return new Complex(Math.PI / 2, Infinity);
}
var d = a * a + b * b;
return (d !== 0)
? new Complex(
a ... | javascript | {
"resource": ""
} | |
q49342 | train | function() {
// atanh(c) = log((1+c) / (1-c)) / 2
var a = this['re'];
var b = this['im'];
var noIM = a > 1 && b === 0;
var oneMinus = 1 - a;
var onePlus = 1 + a;
var d = oneMinus * oneMinus + b * b;
var x = (d !== 0)
? new Complex(
... | javascript | {
"resource": ""
} | |
q49343 | train | function() {
// acoth(c) = log((c+1) / (c-1)) / 2
var a = this['re'];
var b = this['im'];
if (a === 0 && b === 0) {
return new Complex(0, Math.PI / 2);
}
var d = a * a + b * b;
return (d !== 0)
? new Complex(
a / d,
... | javascript | {
"resource": ""
} | |
q49344 | train | function() {
// acsch(c) = log((1+sqrt(1+c^2))/c)
var a = this['re'];
var b = this['im'];
if (b === 0) {
return new Complex(
(a !== 0)
? Math.log(a + Math.sqrt(a * a + 1))
: Infinity, 0);
}
var d = a * a + b * b;
retu... | javascript | {
"resource": ""
} | |
q49345 | train | function() {
// asech(c) = log((1+sqrt(1-c^2))/c)
var a = this['re'];
var b = this['im'];
if (this['isZero']()) {
return Complex['INFINITY'];
}
var d = a * a + b * b;
return (d !== 0)
? new Complex(
a / d,
-b... | javascript | {
"resource": ""
} | |
q49346 | train | function(places) {
places = Math.pow(10, places || 0);
return new Complex(
Math.floor(this['re'] * places) / places,
Math.floor(this['im'] * places) / places);
} | javascript | {
"resource": ""
} | |
q49347 | train | function(a, b) {
var z = new Complex(a, b);
return Math.abs(z['re'] - this['re']) <= Complex['EPSILON'] &&
Math.abs(z['im'] - this['im']) <= Complex['EPSILON'];
} | javascript | {
"resource": ""
} | |
q49348 | train | function() {
var a = this['re'];
var b = this['im'];
var ret = '';
if (this['isNaN']()) {
return 'NaN';
}
if (this['isZero']()) {
return '0';
}
if (this['isInfinite']()) {
return 'Infinity';
}
if (a !== 0) {
ret += a;
... | javascript | {
"resource": ""
} | |
q49349 | Accepts | train | function Accepts (req) {
if (!(this instanceof Accepts)) {
return new Accepts(req)
}
this.headers = req.headers
this.negotiator = new Negotiator(req)
} | javascript | {
"resource": ""
} |
q49350 | someAsyncFunction | train | function someAsyncFunction(file, callback) {
// Here we just wrap the function body to make it synchronous inside
// Sync will execute first argument 'fn' in synchronous way
// and call second argument 'callback' when function returns
// it also calls callback if exception will be thrown inside of 'fn'
... | javascript | {
"resource": ""
} |
q49351 | asyncFunction | train | function asyncFunction(a, b, callback) {
process.nextTick(function(){
callback(null, a + b);
})
} | javascript | {
"resource": ""
} |
q49352 | train | function (callbackError, callbackResult, otherArgs) {
// forbid to call twice
if (syncCallback.called) return;
syncCallback.called = true;
if (callbackError) {
err = callbackError;
}
else if (otherArgs) {
// Support multiple callback resul... | javascript | {
"resource": ""
} | |
q49353 | SyncFuture | train | function SyncFuture(timeout)
{
var self = this;
this.resolved = false;
this.fiber = Fiber.current;
this.yielding = false;
this.timeout = timeout;
this.time = null;
this._timeoutId = null;
this._result = undefined;
this._error = null;
this._start = +new Date;
Sy... | javascript | {
"resource": ""
} |
q49354 | smix | train | function smix (B, Bi, r, N, V, XY) {
var Xi = 0
var Yi = 128 * r
var i
B.copy(XY, Xi, Bi, Bi + Yi)
for (i = 0; i < N; i++) {
XY.copy(V, i * Yi, Xi, Xi + Yi)
blockmix_salsa8(XY, Xi, Yi, r)
if (tickCallback) tickCallback()
}
for (i = 0; i < N; i++) {
var offset = Xi... | javascript | {
"resource": ""
} |
q49355 | _arrayProperties | train | function _arrayProperties (arr, mask) {
var obj = _properties({_: arr}, {_: {
type: 'array',
properties: mask
}})
return obj && obj._
} | javascript | {
"resource": ""
} |
q49356 | padEnd | train | function padEnd (string, targetLength) {
if (typeof string !== 'string' ||
typeof targetLength !== 'number') {
return string
}
/* istanbul ignore next */
const fn = typeof String.prototype.padEnd === 'function'
? String.prototype.padEnd
: polyfill
return fn.call(string, targetLength)
} | javascript | {
"resource": ""
} |
q49357 | install | train | function install (presetName) {
debug('run install from scripts, arguments: %o', arguments)
const name = presetName || tryRequire(/elint-preset-/)[0]
if (!name) {
debug('can not fount preset, return')
return
}
const nodeModulesDir = getNodeModulesDir()
const keep = process.env.npm_config_keep || ... | javascript | {
"resource": ""
} |
q49358 | reverse | train | function reverse(patch, previous, idx) {
const op = patch.op;
const path = patch.path;
if (op === "copy" || (op === "add" && previous === undefined)) {
if (idx === undefined) return { op: "remove", path: path };
// for item pushed to array with -
const tokens = decode(path);
tokens[tokens.length... | javascript | {
"resource": ""
} |
q49359 | apply | train | function apply(doc, patch, options) {
if (!Array.isArray(patch))
throw new Error("Invalid argument, patch must be an array");
const done = [];
for (let i = 0, len = patch.length; i < len; i++) {
const p = patch[i];
let r;
try {
r = run(doc, p);
} catch (err) {
// restore documen... | javascript | {
"resource": ""
} |
q49360 | Blob | train | function Blob(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q49361 | BlobHeader | train | function BlobHeader(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q49362 | HeaderBlock | train | function HeaderBlock(properties) {
this.requiredFeatures = [];
this.optionalFeatures = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] ... | javascript | {
"resource": ""
} |
q49363 | HeaderBBox | train | function HeaderBBox(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q49364 | PrimitiveBlock | train | function PrimitiveBlock(properties) {
this.primitivegroup = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q49365 | PrimitiveGroup | train | function PrimitiveGroup(properties) {
this.nodes = [];
this.ways = [];
this.relations = [];
this.changesets = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] ... | javascript | {
"resource": ""
} |
q49366 | DenseInfo | train | function DenseInfo(properties) {
this.version = [];
this.timestamp = [];
this.changeset = [];
this.uid = [];
this.userSid = [];
this.visible = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.... | javascript | {
"resource": ""
} |
q49367 | ChangeSet | train | function ChangeSet(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q49368 | Node | train | function Node(properties) {
this.keys = [];
this.vals = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
... | javascript | {
"resource": ""
} |
q49369 | DenseNodes | train | function DenseNodes(properties) {
this.id = [];
this.lat = [];
this.lon = [];
this.keysVals = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
... | javascript | {
"resource": ""
} |
q49370 | Way | train | function Way(properties) {
this.keys = [];
this.vals = [];
this.refs = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = pr... | javascript | {
"resource": ""
} |
q49371 | Relation | train | function Relation(properties) {
this.keys = [];
this.vals = [];
this.rolesSid = [];
this.memids = [];
this.types = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (pro... | javascript | {
"resource": ""
} |
q49372 | inquire | train | function inquire(moduleName) {
try {
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
if (mod && (mod.length || Object.keys(mod).length))
return mod;
} catch (e) {} // eslint-disable-line no-empty
return null;
} | javascript | {
"resource": ""
} |
q49373 | merge | train | function merge(dst, src, ifNotSet) { // used by converters
for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
if (dst[keys[i]] === undefined || !ifNotSet)
dst[keys[i]] = src[keys[i]];
return dst;
} | javascript | {
"resource": ""
} |
q49374 | toProtoBuf | train | function toProtoBuf (node) {
const pbn = {}
if (node.data && node.data.length > 0) {
pbn.Data = node.data
} else {
pbn.Data = null // new Buffer(0)
}
if (node.links.length > 0) {
pbn.Links = node.links.map((link) => {
return {
Hash: link.hash,
Name: link.name,
Tsize... | javascript | {
"resource": ""
} |
q49375 | bindIndicators | train | function bindIndicators(indicator) {
// Parent process will send three type of data
const collectorHandler = {
'process': function (value) {
indicator.rss = value.rss;
indicator.heapTotal = value.heapTotal;
indicator.heapUsed = value.heapUsed;
},
'os':... | javascript | {
"resource": ""
} |
q49376 | bindSocket | train | function bindSocket(io, indicator) {
Object.keys(indicator.watch).forEach((key) => {
let eventName = indicator.watch[key];
indicator.on(eventName, (msg) => io.emit(eventName, msg));
});
} | javascript | {
"resource": ""
} |
q49377 | train | function(opacity) {
return function(g, i) {
gEnter.selectAll(".chord")
.filter(function(d) {
return d.source.index != i && d.target.index != i;
})
.transition()
.style("opacity", opacity);
var groups = [];
gEnter... | javascript | {
"resource": ""
} | |
q49378 | Wayfarer | train | function Wayfarer (dft) {
if (!(this instanceof Wayfarer)) return new Wayfarer(dft)
var _default = (dft || '').replace(/^\//, '')
var _trie = trie()
emit._trie = _trie
emit.on = on
emit.emit = emit
emit.match = match
emit._wayfarer = true
return emit
// define a route
// (str, fn) -> obj
fun... | javascript | {
"resource": ""
} |
q49379 | bumpVersion | train | function bumpVersion(files, bumpType) {
status('Bump', bumpType, 'version to files:', files.join(' '));
if (config.dryRun) return '[not available in dry run]';
var newVersion;
var originalVersion;
files.forEach(function(fileName) {
var filePath = path.join(projectRoot, fileName);
v... | javascript | {
"resource": ""
} |
q49380 | askForTableName | train | function askForTableName() {
if (this.force) {
return;
}
const validateTableName = dbh.validateTableName;
const done = this.async();
this.prompt([
{
type: 'input',
name: 'dbhTableName',
validate: ((input) => {
const prodDatabaseTy... | javascript | {
"resource": ""
} |
q49381 | askForColumnsName | train | function askForColumnsName() {
// Don't ask columns name if there aren't any field
// Or option --force
if (this.fields === undefined || this.fields.length === 0 || this.force) {
return;
}
this.log(chalk.green(`Asking column names for ${this.fields.length} field(s)`));
const done = this... | javascript | {
"resource": ""
} |
q49382 | askForRelationshipsId | train | function askForRelationshipsId() {
// Don't ask relationship id if there aren't any relationship
// Or option --force
if (this.relationships === undefined || this.relationships.length === 0 || this.force) {
return;
}
// work only on owner relationship
this.relationshipsPile = this.relat... | javascript | {
"resource": ""
} |
q49383 | loadTranslation | train | function loadTranslation(localeFilePath) {
if(typeof localeFilePath == "undefined"){
messages = defaultMessages;
return null;
}
let fp = path.join(__dirname, localeFilePath);
messages = require('jsonfile').readFileSync("." + fp);
return messages;
} | javascript | {
"resource": ""
} |
q49384 | shallowWithIntl | train | function shallowWithIntl(node, options = { context: {}}) {
const intlProvider = new IntlProvider({locale: locale, messages }, {});
const { intl } = intlProvider.getChildContext();
return shallow(React.cloneElement(node, { intl }), { ...options, context: { ...options.context, intl } });
} | javascript | {
"resource": ""
} |
q49385 | mountWithIntl | train | function mountWithIntl (node, { context, childContextTypes } = {}) {
const intlProvider = new IntlProvider({locale: locale, messages }, {});
const { intl } = intlProvider.getChildContext();
return mount(React.cloneElement(node, { intl }), {
context: Object.assign({}, context, {intl}),
c... | javascript | {
"resource": ""
} |
q49386 | renderWithIntl | train | function renderWithIntl (node, { context, childContextTypes } = {}) {
const intlProvider = new IntlProvider({locale: locale, messages }, {});
const { intl } = intlProvider.getChildContext();
return render(React.cloneElement(node, { intl }), {
context: Object.assign({}, context, {intl}),
... | javascript | {
"resource": ""
} |
q49387 | getMarker | train | function getMarker(options, callback) {
// prevent .parsedTint from being attached to options
options = xtend({}, options);
if (options.tint) {
// Expand hex shorthand (3 chars) to 6, e.g. 333 => 333333.
// This is not done upstream in `node-tint` as some such
// shorthand cannot be ... | javascript | {
"resource": ""
} |
q49388 | loadMaki | train | function loadMaki(options, callback) {
var base = options.base + '-' + options.size + (options.retina ? '@2x' : ''),
size = options.size,
symbol = options.symbol + '-' + sizes[size] + (options.retina ? '@2x' : '');
if (!base || !size) {
return callback(errcode('Marker is invalid because... | javascript | {
"resource": ""
} |
q49389 | argsToArray | train | function argsToArray(args) {
if (_.isArray(args[0]))
return args[0];
else if (typeof args[0] == 'string' && args[0].indexOf(',') > -1)
return _.invoke(args[0].split(','), 'trim');
else
return _.toArray(args);
} | javascript | {
"resource": ""
} |
q49390 | formatString | train | function formatString(string, params) {
return string.replace(/{(\d+)}/g, function (match, number) {
return typeof params[number] !== undefined ? params[number] : match;
});
} | javascript | {
"resource": ""
} |
q49391 | tableHead | train | function tableHead () {
var args = arrayify(arguments)
var data = args.shift()
if (!data) return
args.pop()
var cols = args
var colHeaders = cols.map(function (col) {
var spl = col.split('|')
return spl[1] || spl[0]
})
cols = cols.map(function (col) {
return col.split('|')[0]
})
var toSp... | javascript | {
"resource": ""
} |
q49392 | tableRow | train | function tableRow () {
var args = arrayify(arguments)
var rows = args.shift()
if (!rows) return
var options = args.pop()
var cols = args
var output = ''
if (options.data) {
var data = handlebars.createFrame(options.data)
cols.forEach(function (col, index) {
var colNumber = index + 1
d... | javascript | {
"resource": ""
} |
q49393 | _groupBy | train | function _groupBy (identifiers, groupByFields) {
/* don't modify the input array */
groupByFields = groupByFields.slice(0)
groupByFields.forEach(function (group) {
var groupValues = identifiers
.filter(function (identifier) {
/* exclude constructors from grouping.. re-implement to work off a `n... | javascript | {
"resource": ""
} |
q49394 | kindInThisContext | train | function kindInThisContext (options) {
if (this.kind === 'function' && this.memberof) {
return 'method'
} else if (this.kind === 'member' && !this.isEnum && this.memberof) {
return 'property'
} else if (this.kind === 'member' && this.isEnum && this.memberof) {
return 'enum property'
} else if (this.... | javascript | {
"resource": ""
} |
q49395 | params | train | function params (options) {
if (this.params) {
var list = this.params.map(function (param) {
var nameSplit = param.name.split('.')
var name = nameSplit[nameSplit.length - 1]
if (nameSplit.length > 1) name = '.' + name
if (param.variable) name = '...' + name
if (param.optional) name =... | javascript | {
"resource": ""
} |
q49396 | identifier | train | function identifier (options) {
var result = ddata._identifier(options)
return result ? options.fn(result) : 'ERROR, Cannot find identifier.'
} | javascript | {
"resource": ""
} |
q49397 | class_ | train | function class_ (options) {
options.hash.kind = 'class'
var result = ddata._identifier(options)
return result ? options.fn(result) : 'ERROR, Cannot find class.'
} | javascript | {
"resource": ""
} |
q49398 | dmd | train | function dmd (templateData, options) {
options = new DmdOptions(options)
if (skipCache(options)) {
return generate(templateData, options)
} else {
const cached = dmd.cache.readSync([ templateData, options, dmdVersion ])
if (cached) {
return cached
} else {
return generate(templateData,... | javascript | {
"resource": ""
} |
q49399 | _globals | train | function _globals (options) {
options.hash.scope = 'global'
return _identifiers(options).filter(function (identifier) {
if (identifier.kind === 'external') {
return identifier.description && identifier.description.length > 0
} else {
return true
}
})
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.