_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q47400 | train | function(action) {
//UR
if (!window.URL || !window.URL.createObjectURL) {
window.URL = window.URL || {};
window.URL.createObjectURL = function(obj) {
return obj;
};
}
if (_browser.supported) {
var newVideo = false;
navigator.getUserMedia = navigator.getUserMedia || navigator.oGetUse... | javascript | {
"resource": ""
} | |
q47401 | train | function() {
var link = document.getElementsByTagName('head')[0].getElementsByTagName('link');
for (var l = link.length, i = (l - 1); i >= 0; i--) {
if ((/(^|\s)icon(\s|$)/i).test(link[i].getAttribute('rel'))) {
return link[i];
}
}
return false;
} | javascript | {
"resource": ""
} | |
q47402 | train | function(word) {
var h = 0;
for (var i = 0; i < word.length; i++) {
h = word.charCodeAt(i) + ((h << 5) - h);
}
return h;
} | javascript | {
"resource": ""
} | |
q47403 | train | function(color, prc) {
var num = parseInt(color, 16),
amt = Math.round(2.55 * prc),
R = (num >> 16) + amt,
G = (num >> 8 & 0x00FF) + amt,
B = (num & 0x0000FF) + amt;
return (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
(B < 255 ? B <... | javascript | {
"resource": ""
} | |
q47404 | train | function(i) {
var color = ((i >> 24) & 0xFF).toString(16) +
((i >> 16) & 0xFF).toString(16) +
((i >> 8) & 0xFF).toString(16) +
(i & 0xFF).toString(16);
return color;
} | javascript | {
"resource": ""
} | |
q47405 | swaptitle | train | function swaptitle(title){
if(a.length===0){
a = [document.title];
}
a.push(title);
if(!iv){
iv = setInterval(function(){
// has document.title changed externally?
if(a.indexOf(document.title) === -1 ){
// update the default title
a[0] = document.title;
}
document.title... | javascript | {
"resource": ""
} |
q47406 | addEvent | train | function addEvent(el,name,func){
if(name.match(" ")){
var a = name.split(' ');
for(var i=0;i<a.length;i++){
addEvent( el, a[i], func);
}
}
if(el.addEventListener){
el.removeEventListener(name, func, false);
el.addEventListener(name, func, false);
}
else {
el.detachEvent('on'+name, func);... | javascript | {
"resource": ""
} |
q47407 | match | train | function match(word, array, caseSensitive) {
return $.grep(
array,
function(w) {
if (caseSensitive) {
return !w.indexOf(word);
} else {
return !w.toLowerCase().indexOf(word.toLowerCase());
}
}
);
} | javascript | {
"resource": ""
} |
q47408 | placeholder | train | function placeholder(word) {
var input = this;
var clone = input.prev(".hint");
input.css({
backgroundColor: "transparent",
position: "relative",
});
// Lets create a clone of the input if it does
// not already exist.
if (!clone.length) {
input.wrap(
$("<div>").css({position: "relative... | javascript | {
"resource": ""
} |
q47409 | select | train | function select(word) {
var input = this;
var value = input.val();
if (word) {
input.val(
value
+ word.substr(value.split(/ |\n/).pop().length)
);
// Select hint.
input[0].selectionStart = value.length;
}
} | javascript | {
"resource": ""
} |
q47410 | cacheTracksArray | train | function cacheTracksArray(self) {
self.tracksInOrder = Object.keys(self.playlist).map(trackById);
self.tracksInOrder.sort(asc);
self.tracksInOrder.forEach(function(track, index) {
track.index = index;
});
function asc(a, b) {
return operatorCompare(a.sortKey, b.sortKey);
}
function trackById(id) ... | javascript | {
"resource": ""
} |
q47411 | sortTracks | train | function sortTracks(tracks) {
var lib = new MusicLibraryIndex();
tracks.forEach(function(track) {
lib.addTrack(track);
});
lib.rebuildTracks();
var results = [];
lib.artistList.forEach(function(artist) {
artist.albumList.forEach(function(album) {
album.trackList.forEach(function(track) {
... | javascript | {
"resource": ""
} |
q47412 | train | function(r, n) {
/* the Raphael set is obligatory, containing all you want to display */
var set = r.set().push(
/* custom objects go here */
r.rect(n.point[0]-30, n.point[1]-13, 50, 50)
.attr({"fill": "#fa8", "stroke-width": 2, r: 9}))
.push(r.text(n.point[0], n.point[1] + 15, n.id)
.attr... | javascript | {
"resource": ""
} | |
q47413 | prefix | train | function prefix(p) {
/* pi contains the computed skip marks */
var pi = [0],
k = 0;
for (q = 1; q < p.length; q++) {
while (k > 0 && p.charAt(k) !== p.charAt(q)) {
k = pi[k - 1];
}if (p.charAt(k) === p.charAt(q)) {
k++;
}
pi[q] = k;
}
return pi;
} | javascript | {
"resource": ""
} |
q47414 | nextTile | train | function nextTile()
{
clog('nextTile');
rect.emit('tile', tile);
tile = {};
if (rect.tilex < rect.widthTiles)
{
rect.tilex++;
//clog([rect.tilex, rect.tiley]);
return cli.readHextileTile(rect, cb);
} else {
clog('=======... | javascript | {
"resource": ""
} |
q47415 | train | function(id, parentId, x, y, width, height, borderWidth, depth, _class, visual, values) {
if (borderWidth === undefined)
borderWidth = 0;
if (depth === undefined)
depth = 0;
if (_class === undefined)
_class = 0;
if (visual === und... | javascript | {
"resource": ""
} | |
q47416 | leftPad | train | function leftPad(n, prefix, maxN) {
const s = n.toString();
const nchars = Math.max(2, String(maxN).length) + 1;
const nspaces = nchars - s.length - 1;
return prefix + ' '.repeat(nspaces) + s;
} | javascript | {
"resource": ""
} |
q47417 | list | train | function list(delta = 5) {
return selectedFrame.list(delta)
.then(null, (error) => {
print('You can\'t list source code right now');
throw error;
});
} | javascript | {
"resource": ""
} |
q47418 | getRequiredModuleName | train | function getRequiredModuleName(node) {
var moduleName;
// node has arguments and first argument is string
if (node.arguments.length && isString(node.arguments[0])) {
var argValue = path.basename(node.arguments[0].value.trim());
// check if value is in required modules array
if (requiredM... | javascript | {
"resource": ""
} |
q47419 | intToBytes | train | function intToBytes(num) {
var bytes = [];
for(var i=7 ; i>=0 ; --i) {
bytes[i] = num & (255);
num = num >> 8;
}
return bytes;
} | javascript | {
"resource": ""
} |
q47420 | hexToBytes | train | function hexToBytes(hex) {
var bytes = [];
for(var c = 0, C = hex.length; c < C; c += 2) {
bytes.push(parseInt(hex.substr(c, 2), 16));
}
return bytes;
} | javascript | {
"resource": ""
} |
q47421 | addInlined | train | function addInlined(tagName, lang) {
var includedCdataInside = {}
includedCdataInside['language-' + lang] = {
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
lookbehind: true,
inside: Prism.languages[lang]
}
includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i
var in... | javascript | {
"resource": ""
} |
q47422 | train | function(env, language, placeholderPattern, replaceFilter) {
if (env.language !== language) {
return
}
var tokenStack = (env.tokenStack = [])
env.code = env.code.replace(placeholderPattern, function(match) {
if (typeof replaceFilter === 'function' && !repl... | javascript | {
"resource": ""
} | |
q47423 | train | function(env, language) {
if (env.language !== language || !env.tokenStack) {
return
}
// Switch the grammar back
env.grammar = Prism.languages[language]
var j = 0
var keys = Object.keys(env.tokenStack)
function walkTokens(tokens) {
... | javascript | {
"resource": ""
} | |
q47424 | WrappedTree | train | function WrappedTree(w, h, y, c = []) {
const me = this;
// size
me.w = w || 0;
me.h = h || 0;
// position
me.y = y || 0;
me.x = 0;
// children
me.c = c || [];
me.cs = c.length;
// modified
me.prelim = 0;
me.mod = 0;
me.shift = 0;
me.change = 0;
// left/right tree
me.tl =... | javascript | {
"resource": ""
} |
q47425 | sortedKeys | train | function sortedKeys(obj, orderedKeys) {
var keys = Object.keys(obj).sort();
var fresh = {};
orderedKeys.forEach(function (key) {
if (keys.indexOf(key) === -1) {
return;
}
fresh[key] = obj[key];
});
keys.forEach(function (key) {
if (orderedKeys.indexOf(k... | javascript | {
"resource": ""
} |
q47426 | bytes | train | function bytes(value, options) {
if (typeof value === 'string') {
return parse(value);
}
if (typeof value === 'number') {
return format(value, options);
}
return null;
} | javascript | {
"resource": ""
} |
q47427 | format | train | function format(value, options) {
if (!Number.isFinite(value)) {
return null;
}
var mag = Math.abs(value);
var thousandsSeparator = (options && options.thousandsSeparator) || '';
var unitSeparator = (options && options.unitSeparator) || '';
var decimalPlaces = (options && options.decimalPlaces !== unde... | javascript | {
"resource": ""
} |
q47428 | parse | train | function parse(val) {
if (typeof val === 'number' && !isNaN(val)) {
return val;
}
if (typeof val !== 'string') {
return null;
}
// Test if the string passed is valid
var results = parseRegExp.exec(val);
var floatValue;
var unit = 'b';
if (!results) {
// Nothing could be extracted from t... | javascript | {
"resource": ""
} |
q47429 | traverseChild | train | function traverseChild(node, childNode, childspec, result) {
if (childNode.nodeType === 3 && /^\s+$/.test(childNode.nodeValue)) {
// Whitespace... nothing to do.
return;
}
var localName = (0, _camelize2['default'])(childNode.localName, '-');
if (!(localName in childspec)) {
debug('Unexpected node o... | javascript | {
"resource": ""
} |
q47430 | co | train | function co(gen) {
var ctx = this;
var args = slice.call(arguments, 1)
// we wrap everything in a promise to avoid promise chaining,
// which leads to memory leak errors.
// see https://github.com/tj/co/issues/180
return new Promise(function(resolve, reject) {
if (typeof gen === 'function') gen = gen.a... | javascript | {
"resource": ""
} |
q47431 | ucs2encode | train | function ucs2encode(array) {
return map(array, function(value) {
var output = '';
if (value > 0xFFFF) {
value -= 0x10000;
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
value = 0xDC00 | value & 0x3FF;
}
output += stringFromCharCode(value);
return output;
}).join('');
} | javascript | {
"resource": ""
} |
q47432 | toUnicode | train | function toUnicode(input) {
return mapDomain(input, function(string) {
return regexPunycode.test(string)
? decode(string.slice(4).toLowerCase())
: string;
});
} | javascript | {
"resource": ""
} |
q47433 | toASCII | train | function toASCII(input) {
return mapDomain(input, function(string) {
return regexNonASCII.test(string)
? 'xn--' + encode(string)
: string;
});
} | javascript | {
"resource": ""
} |
q47434 | ProgressBar | train | function ProgressBar(progress) {
// Make it 50 characters length
progress = Math.min(100, progress)
var units = Math.round(progress / 2)
return chalk.dim('[') + chalk.blue('=').repeat(units) + ' '.repeat(50 - units) + chalk.dim('] ') + chalk.yellow(progress + '%')
} | javascript | {
"resource": ""
} |
q47435 | InstalationProgress | train | function InstalationProgress(library, step, finished) {
var fillSpaces = ' '.repeat(15 - library.length)
if (finished) {
return chalk.cyan.dim(' > ') + chalk.yellow.dim(library) + fillSpaces + chalk.green('Installed')
} else {
return chalk.cyan(' > ') + chalk.yellow(library) + fillSpaces+ chalk.blue(step)... | javascript | {
"resource": ""
} |
q47436 | negativeValues | train | function negativeValues(series) {
let i, j, data;
for (i = 0; i < series.length; i++) {
data = series[i].data;
for (j = 0; j < data.length; j++) {
if (data[j][1] < 0) {
return true;
}
}
}
return false;
} | javascript | {
"resource": ""
} |
q47437 | copySeries | train | function copySeries(series) {
let newSeries = [], i, j;
for (i = 0; i < series.length; i++) {
let copy = {};
for (j in series[i]) {
if (series[i].hasOwnProperty(j)) {
copy[j] = series[i][j];
}
}
newSeries.push(copy);
}
return newSeries;
} | javascript | {
"resource": ""
} |
q47438 | eyesIt | train | function eyesIt(_it, _itArgs, config) {
const {
windowSize,
specVersion,
enableSnapshotAtBrowserGet,
enableSnapshotAtEnd,
} = merge({}, defaultConfig, config);
const spec = _it.apply(this, _itArgs);
const hooked = spec.beforeAndAfterFns;
spec.beforeAndAfterFns = function() {
//TODO: are w... | javascript | {
"resource": ""
} |
q47439 | findProvidesModule | train | function findProvidesModule(directories, opts = {}) {
const options = Object.assign({}, defaultOpts, opts);
const modulesMap = {};
const walk = dir => {
const stat = fs.lstatSync(dir);
if (stat.isDirectory()) {
fs.readdirSync(dir).forEach(file => {
if (options.blacklist.indexOf(file) >= 0... | javascript | {
"resource": ""
} |
q47440 | reload | train | async function reload() {
const requestOptions = {
hostname: 'localhost',
port: 8081,
path: '/reloadapp',
method: 'HEAD',
};
const req = http.request(requestOptions, () => {
clear();
logger.done('Sent reload request');
req.end();
});
req.on('error', e => {
clear();
const ... | javascript | {
"resource": ""
} |
q47441 | extractClassName | train | function extractClassName(name) {
if (name.indexOf('(') === -1) {
return { entityName: name, tableName: _.snakeCase(name).toLowerCase() };
}
const split = name.split('(');
return {
entityName: split[0].trim(),
tableName: _.snakeCase(
split[1].slice(0, split[1].length - 1).trim()
).toLowerC... | javascript | {
"resource": ""
} |
q47442 | getXmlElementFromRawIndexes | train | function getXmlElementFromRawIndexes(root, indexInfo) {
let parentPackage = root;
for (let j = 0; j < indexInfo.path.length; j++) {
parentPackage = parentPackage.packagedElement[indexInfo.path[j]];
}
return parentPackage.packagedElement[indexInfo.index];
} | javascript | {
"resource": ""
} |
q47443 | generateEntities | train | function generateEntities(entityIdsToGenerate, classes, entityNamesToGenerate, options) {
if (shouldEntitiesBeGenerated(entityIdsToGenerate, entityNamesToGenerate, classes)) {
winston.info('No entity has to be generated.');
return;
}
displayEntitiesToGenerate(entityIdsToGenerate, entityNamesToGenerate, c... | javascript | {
"resource": ""
} |
q47444 | checkValidityOfAssociation | train | function checkValidityOfAssociation(association, sourceName, destinationName) {
if (!association || !association.type) {
throw new BuildException(
exceptions.NullPointer, 'The association must not be nil.');
}
switch (association.type) {
case cardinalities.ONE_TO_ONE:
checkOneToOne(association, so... | javascript | {
"resource": ""
} |
q47445 | getClassNames | train | function getClassNames(classes) {
if (!classes) {
throw new BuildException(
exceptions.NullPointer, 'The classes object cannot be nil.');
}
const object = {};
Object.keys(classes).forEach((classId) => {
object[classId] = classes[classId].name;
});
return object;
} | javascript | {
"resource": ""
} |
q47446 | detect | train | function detect(root) {
if (!root) {
throw new BuildException(
exceptions.NullPointer, 'The root element can not be null.');
}
if (root.eAnnotations && root.eAnnotations[0].$.source === 'Objing') {
winston.info('Parser detected: MODELIO.\n');
return modelio;
} else if (root.eAnnotations
&&... | javascript | {
"resource": ""
} |
q47447 | askConfirmation | train | function askConfirmation(args) {
let userAnswer = 'no-answer';
const merged = merge(DEFAULTS.CONFIRMATIONS, args);
inquirer.prompt([
{
type: DEFAULTS.QUESTION_TYPES.CONFIRM,
name: 'choice',
message: merged.question,
default: merged.defaultValue
}
]).then((answer) => {
userAns... | javascript | {
"resource": ""
} |
q47448 | selectMultipleChoices | train | function selectMultipleChoices(args) {
args.choices = args.choices || prepareChoices(args.classes);
let result = null;
const merged = merge(DEFAULTS.MULTIPLE_CHOICES, args);
inquirer.prompt([
{
type: DEFAULTS.QUESTION_TYPES.CHECKBOX,
name: 'answer',
message: merged.question,
choices:... | javascript | {
"resource": ""
} |
q47449 | toJDL | train | function toJDL(parsedData, options) {
assertParsedDataIsValid(parsedData);
const jdlObject = new JDLObject();
const jdlEnumArray = convertEnums(parsedData.enums);
addEnumsToJDLObject(jdlObject, jdlEnumArray);
const jdlEntityObject = convertClasses(parsedData);
addEntitiesToJDLObject(jdlObject, jdlEntityObje... | javascript | {
"resource": ""
} |
q47450 | createParser | train | function createParser(args) {
if (!args || !args.file || !args.databaseType) {
throw new BuildException(
exceptions.IllegalArgument,
'The file and the database type must be passed');
}
const types = initDatabaseTypeHolder(args.databaseType);
if (args.editor) {
const root = getRootElement(rea... | javascript | {
"resource": ""
} |
q47451 | checkForReservedClassName | train | function checkForReservedClassName(args) {
if (!args) {
return;
}
if (JHipsterCore.isReservedClassName(args.name)) {
if (args.shouldThrow) {
throw new BuildException(
exceptions.IllegalName,
`The passed class name '${args.name}' is reserved.`);
} else {
winston.warn(
... | javascript | {
"resource": ""
} |
q47452 | checkForReservedTableName | train | function checkForReservedTableName(args) {
if (!args) {
return;
}
if (args.databaseTypeName) {
checkTableName(args.name, args.databaseTypeName, args.shouldThrow);
} else {
for (let i = 0, types = Object.keys(DatabaseTypes); i < types.length; i++) {
if (typeof DatabaseTypes[types[i]] !== 'funct... | javascript | {
"resource": ""
} |
q47453 | checkForReservedFieldName | train | function checkForReservedFieldName(args) {
if (!args) {
return;
}
if (args.databaseTypeName) {
checkFieldName(args.name, args.databaseTypeName, args.shouldThrow);
} else {
for (let i = 0, types = Object.keys(DatabaseTypes); i < types.length; i++) {
checkFieldName(args.name, DatabaseTypes[types... | javascript | {
"resource": ""
} |
q47454 | train | function(){
if(this.$phase === 'digest' || this._mute) return;
this.$phase = 'digest';
var dirty = false, n =0;
while(dirty = this._digest()){
if((++n) > 20){ // max loop
throw Error('there may a circular dependencies reaches')
}
}
// stable watch is dirty
var stableDirt... | javascript | {
"resource": ""
} | |
q47455 | train | function(stable){
if(this._mute) return;
var watchers = !stable? this._watchers: this._watchersForStable;
var dirty = false, children, watcher, watcherDirty;
var len = watchers && watchers.length;
if(len){
var mark = 0, needRemoved=0;
for(var i =0; i < len; i++ ){
watcher = watch... | javascript | {
"resource": ""
} | |
q47456 | train | function(watcher){
var dirty = false;
if(!watcher) return;
var now, last, tlast, tnow,
eq, diff, keyOf, trackDiff
if(!watcher.test){
now = watcher.get(this);
last = watcher.last;
keyOf = watcher.keyOf
if(now !== last || watcher.force){
tlast = _.typeOf(l... | javascript | {
"resource": ""
} | |
q47457 | train | function(item){
var children,node, nodes;
if(!item) return;
if(typeof item.node === "function") return item.node();
if(typeof item.nodeType === "number") return item;
if(item.group) return combine.node(item.group)
item = item.children || item;
if( Array.isArray(item )){
var len = item... | javascript | {
"resource": ""
} | |
q47458 | ld | train | function ld(array1, array2, equalFn){
var n = array1.length;
var m = array2.length;
var equalFn = equalFn || equals;
var matrix = [];
for(var i = 0; i <= n; i++){
matrix.push([i]);
}
for(var j=1;j<=m;j++){
matrix[0][j]=j;
}
for(var i = 1; i <= n; i++){
for(var j = 1; j <= m; j++){
if... | javascript | {
"resource": ""
} |
q47459 | diffArray | train | function diffArray(arr2, arr1, diff, diffFn) {
if(!diff) return _.simpleDiff(arr2, arr1);
var matrix = ld(arr1, arr2, diffFn)
var n = arr1.length;
var i = n;
var m = arr2.length;
var j = m;
var edits = [];
var current = matrix[i][j];
while(i>0 || j>0){
// the last line
if (i === 0) {
edits... | javascript | {
"resource": ""
} |
q47460 | wrapSet | train | function wrapSet(set){
return function(context, value){
set.call( context, value, context.data );
return value;
}
} | javascript | {
"resource": ""
} |
q47461 | createFSM | train | function createFSM() {
return {
_stack: [],
enter: function(state) {
this._stack.push(state);
return this;
},
leave: function(state) {
var stack = this._stack;
// if state is falsy or state equals to last item in stack
if(!state || stack[stack.length-1] === state) {
... | javascript | {
"resource": ""
} |
q47462 | train | function(definition, options){
var prevRunning = env.isRunning;
env.isRunning = true;
var node, template, cursor, context = this, body, mountNode;
options = options || {};
definition = definition || {};
var dtemplate = definition.template;
if(env.browser) {
if( node = tryGetSelector( dtemplate ) ... | javascript | {
"resource": ""
} | |
q47463 | train | function(name, cfg){
if(!name) return;
var type = typeof name;
if(type === 'object' && !cfg){
for(var k in name){
if(name.hasOwnProperty(k)) this.directive(k, name[k]);
}
return this;
}
var directives = this._directives, directive;
if(cfg == null){
if( type === '... | javascript | {
"resource": ""
} | |
q47464 | train | function(name, value){
var needGenLexer = false;
if(typeof name === "object"){
for(var i in name){
// if you config
if( i ==="END" || i==='BEGIN' ) needGenLexer = true;
config[i] = name[i];
}
}
if(needGenLexer) Lexer.setup();
} | javascript | {
"resource": ""
} | |
q47465 | train | function(ast, options){
options = options || {};
if(typeof ast === 'string'){
ast = new Parser(ast).parse()
}
var preExt = this.__ext__,
record = options.record,
records;
if(options.extra) this.__ext__ = options.extra;
if(record) this._record();
var group = this._walk(a... | javascript | {
"resource": ""
} | |
q47466 | train | function(component, expr1, expr2){
var self = this;
// basic binding
if(!component || !(component instanceof Regular)) throw "$bind() should pass Regular component as first argument";
if(!expr1) throw "$bind() should pass as least one expression to bind";
if(!expr2) expr2 = expr1;
expr1 = p... | javascript | {
"resource": ""
} | |
q47467 | train | function(path, parent, defaults, ext){
if( path === undefined ) return undefined;
if(ext && typeof ext === 'object'){
if(ext[path] !== undefined) return ext[path];
}
// reject to get from computed, return undefined directly
// like { empty.prop }, empty equals undefined
// prop shou... | javascript | {
"resource": ""
} | |
q47468 | train | function(path, value, data , op, computed){
var computed = this.computed,
op = op || "=", prev,
computedProperty = computed? computed[path]:null;
if(op !== '='){
prev = computedProperty? computedProperty.get(this): data[path];
switch(op){
case "+=":
value = prev + val... | javascript | {
"resource": ""
} | |
q47469 | updateSimple | train | function updateSimple(newList, oldList, rawNewValue ){
var nlen = newList.length;
var olen = oldList.length;
var mlen = Math.min(nlen, olen);
updateRange(0, mlen, newList, rawNewValue)
if(nlen < olen){ //need add
removeRange(nlen, olen-nlen, children);
}else if(nlen > olen){
addRan... | javascript | {
"resource": ""
} |
q47470 | initText | train | function initText(elem, parsed, extra){
var param = extra.param;
var throttle, lazy = param.lazy
if('throttle' in param){
// <input throttle r-model>
if(param.throttle === true){
throttle = 400;
}else{
throttle = parseInt(param.throttle, 10)
}
}
var self = this;
var wc = this.$... | javascript | {
"resource": ""
} |
q47471 | mapResponse | train | function mapResponse(response) {
response.body = response.text;
response.statusCode = response.status;
return response;
} | javascript | {
"resource": ""
} |
q47472 | getScrollTop | train | function getScrollTop() {
// vue-jest ignore
if (!document) return;
if (document.scrollingElement) {
return document.scrollingElement.scrollTop;
}
if (document.body || window.pageXOffset) {
return document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset;
}
} | javascript | {
"resource": ""
} |
q47473 | discoverGateway | train | function discoverGateway(timeout = 10000) {
const mdns = createMDNSServer({
reuseAddr: true,
loopback: false,
noInit: true,
});
let timer;
const domain = "_coap._udp.local";
return new Promise((resolve, reject) => {
mdns.on("response", (resp) => {
const al... | javascript | {
"resource": ""
} |
q47474 | buildPropertyTransform | train | function buildPropertyTransform(kernel, options = {}) {
if (options.splitArrays == null)
options.splitArrays = true;
if (options.neverSkip == null)
options.neverSkip = false;
const ret = kernel;
ret.splitArrays = options.splitArrays;
ret.neverSkip = options.neverSkip;
return ret;... | javascript | {
"resource": ""
} |
q47475 | lookupKeyOrProperty | train | function lookupKeyOrProperty(target, keyOrProperty /*| keyof T*/) {
// get the class constructor
const constr = target.constructor;
// retrieve the current metadata
const metadata = Reflect.getMetadata(METADATA_ipsoKey, constr);
return metadata && metadata[keyOrProperty];
} | javascript | {
"resource": ""
} |
q47476 | isRequired | train | function isRequired(target, reference, property) {
// get the class constructor
const constr = target.constructor;
logger_1.log(`${constr.name}: checking if ${property} is required...`, "silly");
// retrieve the current metadata
const metadata = Reflect.getMetadata(METADATA_required, constr) || {};
... | javascript | {
"resource": ""
} |
q47477 | serializeWith | train | function serializeWith(kernel, options) {
const transform = buildPropertyTransform(kernel, options);
return (target, property) => {
// get the class constructor
const constr = target.constructor;
// retrieve the current metadata
const metadata = Reflect.getMetadata(METADATA_seria... | javascript | {
"resource": ""
} |
q47478 | getSerializer | train | function getSerializer(target, property /* | keyof T*/) {
// get the class constructor
const constr = target.constructor;
// retrieve the current metadata
const metadata = Reflect.getMetadata(METADATA_serializeWith, constr) || {};
if (metadata.hasOwnProperty(property))
return metadata[proper... | javascript | {
"resource": ""
} |
q47479 | deserializeWith | train | function deserializeWith(kernel, options) {
const transform = buildPropertyTransform(kernel, options);
return (target, property) => {
// get the class constructor
const constr = target.constructor;
// retrieve the current metadata
const metadata = Reflect.getMetadata(METADATA_des... | javascript | {
"resource": ""
} |
q47480 | isSerializable | train | function isSerializable(target, property) {
// get the class constructor
const constr = target.constructor;
// retrieve the current metadata
const metadata = Reflect.getMetadata(METADATA_doNotSerialize, constr) || {};
// if doNotSerialize is defined, don't serialize!
return !metadata.hasOwnPrope... | javascript | {
"resource": ""
} |
q47481 | getDeserializer | train | function getDeserializer(target, property /*| keyof T*/) {
// get the class constructor
const constr = target.constructor;
// retrieve the current metadata
const metadata = Reflect.getMetadata(METADATA_deserializeWith, constr) || {};
if (metadata.hasOwnProperty(property)) {
return metadata[p... | javascript | {
"resource": ""
} |
q47482 | parseNotificationDetails | train | function parseNotificationDetails(kvpList) {
const ret = {};
for (const kvp of kvpList) {
const parts = kvp.split("=");
ret[parts[0]] = parts[1];
}
return ret;
} | javascript | {
"resource": ""
} |
q47483 | normalizeResourcePath | train | function normalizeResourcePath(path) {
path = path || "";
while (path.startsWith("/"))
path = path.slice(1);
while (path.endsWith("/"))
path = path.slice(0, -1);
return path;
} | javascript | {
"resource": ""
} |
q47484 | createRGBProxy | train | function createRGBProxy(raw = false) {
function get(me, key) {
switch (key) {
case "color": {
if (typeof me.color === "string" && rgbRegex.test(me.color)) {
// predefined color, return it
return me.color;
}
e... | javascript | {
"resource": ""
} |
q47485 | setHashOrThrowError | train | function setHashOrThrowError(parseMap, routeObject) {
var route = routeObject.route;
var get = routeObject.get;
var set = routeObject.set;
var call = routeObject.call;
getHashesFromRoute(route).
map(function mapHashToString(hash) { return hash.join(','); }).
forEach(function forEach... | javascript | {
"resource": ""
} |
q47486 | decendTreeByRoutedToken | train | function decendTreeByRoutedToken(node, value, routeToken) {
var next = null;
switch (value) {
case Keys.keys:
case Keys.integers:
case Keys.ranges:
next = node[value];
if (!next) {
next = node[value] = {};
}
break;
d... | javascript | {
"resource": ""
} |
q47487 | getHashesFromRoute | train | function getHashesFromRoute(route, depth, hashes, hash) {
/*eslint-disable no-func-assign, no-param-reassign*/
depth = depth || 0;
hashes = hashes || [];
hash = hash || [];
/*eslint-enable no-func-assign, no-param-reassign*/
var routeValue = route[depth];
var isArray = Array.isArray(routeVa... | javascript | {
"resource": ""
} |
q47488 | createNamedVariables | train | function createNamedVariables(route, action) {
return function innerCreateNamedVariables(matchedPath) {
var convertedArguments;
var len = -1;
var restOfArgs = slice(arguments, 1);
var isJSONObject = !isArray(matchedPath);
// A set uses a json object
if (isJSONObject)... | javascript | {
"resource": ""
} |
q47489 | train | function(isInit) {
var containerWidth = self.$map.width();
if (self.paper.width !== containerWidth) {
var newScale = containerWidth / self.mapConf.width;
// Set new size
self.paper.setSize(containerWidth, self.mapConf.height * ... | javascript | {
"resource": ""
} | |
q47490 | train | function (elem) {
// Starts with hidden elements
elem.mapElem.attr({opacity: 0});
if (elem.textElem) elem.textElem.attr({opacity: 0});
// Set final element opacity
self.setElementOpacity(
elem,
(elem.... | javascript | {
"resource": ""
} | |
q47491 | pipe | train | function pipe(commands, input) {
if (!commands) {
return input;
}
return commands.reduce(function(input, cmd) {
return npmRun.sync(cmd, {
input: input
});
}, input);
} | javascript | {
"resource": ""
} |
q47492 | logError | train | function logError(e) {
var msg = typeof e === 'string' ? e : e.message;
// esprima.parse errors are in the format 'Line 123: Unexpected token &'
// we support both formats since users might replace the parser
if ((/Line \d+:/).test(msg)) {
// convert into "Error: <filepath>:<line> <error_message>"
msg ... | javascript | {
"resource": ""
} |
q47493 | recess | train | function recess(init, path, err) {
if (path = paths.shift()) {
return instances.push(new RECESS(path, options, recess))
}
// map/filter for errors
err = instances
.map(function (i) {
return i.errors.length && i.errors
})
.filter(function (i) {
return i
})
... | javascript | {
"resource": ""
} |
q47494 | train | function (def, err) {
def.errors = def.errors || []
err.message = err.message.cyan
def.errors.push(err)
} | javascript | {
"resource": ""
} | |
q47495 | RECESS | train | function RECESS(path, options, callback) {
this.path = path
this.output = []
this.errors = []
this.options = _.extend({}, RECESS.DEFAULTS, options)
path && this.read()
this.callback = callback
} | javascript | {
"resource": ""
} |
q47496 | train | function(event) {
var state = self.state();
for ( var i in self._callbacks ) {
self._callbacks[i].call(self._doc, event, state);
}
} | javascript | {
"resource": ""
} | |
q47497 | train | function () {
if ( self._init ) {
return;
}
var event = 'visibilitychange';
if ( self._doc.webkitVisibilityState ) {
event = 'webkit' + event;
}
var listener = function () {
self._change.apply(self,... | javascript | {
"resource": ""
} | |
q47498 | next | train | function next() {
counter = pending = 0;
// Check if there are no steps left
if (steps.length === 0) {
// Throw uncaught errors
if (arguments[0]) {
throw arguments[0];
}
return;
}
// Get the next step to execute
var fn = steps.shift();
results = [];
// ... | javascript | {
"resource": ""
} |
q47499 | seq | train | function seq() {
var fn;
var t = this;
for (var i = 0; i < arguments.length; i++) {
fn = arguments[i];
t = fn.call(t);
if (!t)
return false;
}
return this;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.