_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q33100 | bubbleEvent | train | function bubbleEvent(eventName, toEmitter) {
this.on(eventName, (event) => {
toEmitter.emit(eventName, event.data, event);
});
} | javascript | {
"resource": ""
} |
q33101 | getListeners | train | function getListeners(eventName, handler, context, args) {
if (!this.__listeners || !this.__listeners[eventName]) {
return null;
}
return this.__listeners[eventName]
.map((config) => {
if (handler !== undefined && config.fn !== handler) {
return false;
... | javascript | {
"resource": ""
} |
q33102 | init | train | function init(shard, eid) { // {{{2
/**
* Entry constructor
*
* @param shard {Object} Entry owner shard instance
* @param eid {Number|String} Entry id
*
* @method constructor
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.shard =... | javascript | {
"resource": ""
} |
q33103 | train | function(key) {
if (arguments.length === 0) {
// reset all values, including non-enumerable and readonly properties
this.key_list.forEach(function(key) {
this._reset(key);
}, this);
} else {
this._reset(key);
}
} | javascript | {
"resource": ""
} | |
q33104 | train | function(key) {
var attr = this.__attrs[key];
if (!attr) {
return;
}
var value = attr.value = attr._origin;
var setup = attr.type.setup;
if (setup) {
setup.call(this.host, value, key, this);
}
} | javascript | {
"resource": ""
} | |
q33105 | resolve | train | function resolve(ref, context) {
if (typeof ref !== 'string') return ref;
if (/^#/.test(ref)) { ref = (context._href || '/') + ref; }
return generator.fragment$[ref];
} | javascript | {
"resource": ""
} |
q33106 | pageLang | train | function pageLang(page) {
return page.lang ||
opts.lang ||
(opts.langDirs && !u.isRootLevel(page._href) && u.topLevel(page._href)) ||
'en';
} | javascript | {
"resource": ""
} |
q33107 | defaultFragmentHtml | train | function defaultFragmentHtml(fragmentName, faMarkdown, html, frame) {
var f = generator.fragment$[fragmentName];
if (f) return fragmentHtml(f);
if (faMarkdown && u.find(opts.pkgs, function(pkg) {
return ('pub-pkg-font-awesome' === pkg.pkgName);
})) {
return fragmentHtml( { _txt:faMarkdown,... | javascript | {
"resource": ""
} |
q33108 | el | train | function el(tag, attrs) {
var n = el.air(create(tag));
if(attrs && n.attr) {
return n.attr(attrs);
}
return n;
} | javascript | {
"resource": ""
} |
q33109 | Repo | train | function Repo(name, username) {
this.name = name;
this.username = username;
this.isLoaded = Deferred();
this.isCloned = Deferred();
this.isClonning = false;
this.branch = null;
} | javascript | {
"resource": ""
} |
q33110 | Route | train | function Route(topic, fns, options) {
options = options || {};
this.topic = topic;
this.fns = fns;
this.regexp = pattern.parse(topic
, this.keys = []
, options.sensitive
, options.strict);
} | javascript | {
"resource": ""
} |
q33111 | train | function() {
var current = $state.current();
if(current && current.url) {
var path;
path = current.url;
// Add parameters or use default parameters
var params = current.params || {};
var query = {};
for(var name in params) {
var re = new RegExp(':'+name, 'g');
... | javascript | {
"resource": ""
} | |
q33112 | train | function (str) {
for (var bytes = [], i = 0; i < str.length; i++)
bytes.push(str.charCodeAt(i) & 0xFF);
return bytes;
} | javascript | {
"resource": ""
} | |
q33113 | train | function (bytes) {
for (var str = [], i = 0; i < bytes.length; i++)
str.push(String.fromCharCode(bytes[i]));
return str.join("");
} | javascript | {
"resource": ""
} | |
q33114 | train | function () {
// p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
var p = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
var a = BigInteger.ZERO;
var b = ec.fromHex("7");
var n = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
var h = ... | javascript | {
"resource": ""
} | |
q33115 | train | function (input) {
var bi = BigInteger.fromByteArrayUnsigned(input);
var chars = [];
while (bi.compareTo(B58.base) >= 0) {
var mod = bi.mod(B58.base);
chars.unshift(B58.alphabet[mod.intValue()]);
bi = bi.subtract(mod).divide(B58.base);
}
chars.unshift(B58.alphabet[bi.intValue()]);
// Con... | javascript | {
"resource": ""
} | |
q33116 | train | function (len, val) {
var array = [];
var i = 0;
while (i < len) {
array[i++] = val;
}
return array;
} | javascript | {
"resource": ""
} | |
q33117 | train | function (i) {
if (i < 0xfd) {
// unsigned char
return [i];
} else if (i <= 1 << 16) {
// unsigned short (LE)
return [0xfd, i >>> 8, i & 255];
} else if (i <= 1 << 32) {
// unsigned int (LE)
return [0xfe].concat(Crypto.util.wordsToBytes([i]));
} else {
// unsigned long long (LE)
... | javascript | {
"resource": ""
} | |
q33118 | train | function (valueBuffer) {
var value = this.valueToBigInt(valueBuffer).toString();
var integerPart = value.length > 8 ? value.substr(0, value.length - 8) : '0';
var decimalPart = value.length > 8 ? value.substr(value.length - 8) : value;
while (decimalPart.length < 8) decimalPart = "0" + decimalPart;
decim... | javascript | {
"resource": ""
} | |
q33119 | train | function (valueString) {
// TODO: Detect other number formats (e.g. comma as decimal separator)
var valueComp = valueString.split('.');
var integralPart = valueComp[0];
var fractionalPart = valueComp[1] || "0";
while (fractionalPart.length < 8) fractionalPart += "0";
fractionalPart = fractionalPart.re... | javascript | {
"resource": ""
} | |
q33120 | removeColon | train | function removeColon(protocol) {
return protocol && protocol.length && protocol[protocol.length - 1] === ':'
? protocol.substring(0, protocol.length - 1) : protocol;
} | javascript | {
"resource": ""
} |
q33121 | VegaWrapper | train | function VegaWrapper(wrapperOpts) {
var self = this;
// Copy all options into this object
self.objExtender = wrapperOpts.datalib.extend;
self.objExtender(self, wrapperOpts);
self.validators = {};
self.datalib.load.loader = function (opt, callback) {
var error = callback || function (e) ... | javascript | {
"resource": ""
} |
q33122 | _prepareViews | train | function _prepareViews( actionData, paramData )
{
let linkedTranssModules = actionData.linkedVTransModules, // look into slice speed over creating new array
ViewsModuleLength = linkedTranssModules.length,
promises = [],
preparedViews = [],
actionDataClone = null,
viewCache = {},
i ... | javascript | {
"resource": ""
} |
q33123 | _fetchViews | train | function _fetchViews( viewsToPrepare, actionDataClone, promises, viewCache )
{
const views = viewsToPrepare,
viewManager = _options.viewManager,
length = views.length,
currentViewID = actionDataClone.currentViewID,
nextViewID = actionDataClone.nextViewID;
let i = 0,
_deferred,
view... | javascript | {
"resource": ""
} |
q33124 | _viewRef | train | function _viewRef( ref, comparisonViews ) {
var index = comparisonViews.indexOf( ref );
return (index === -1 )? null : ['currentView', 'nextView'][ index ];
} | javascript | {
"resource": ""
} |
q33125 | _getCached | train | function _getCached( cached, data )
{
if( !data ){ return cached; }
let i = -1, len = cached.length;
while (++i < len) {
cached[i].data = data;
}
return cached;
} | javascript | {
"resource": ""
} |
q33126 | _cloneViewState | train | function _cloneViewState( actionData, transitionObject, paramData ) {
return {
data : paramData,
currentViewID : actionData.currentView, // optional
nextViewID : actionData.nextView, // optional
views : {},
transitionType : transitionObject.transitionType
};
} | javascript | {
"resource": ""
} |
q33127 | parserOnHeaders | train | function parserOnHeaders(headers, url) {
// Once we exceeded headers limit - stop collecting them
if (this.maxHeaderPairs <= 0 ||
this._headers.length < this.maxHeaderPairs) {
this._headers = this._headers.concat(headers);
}
this._url += url;
} | javascript | {
"resource": ""
} |
q33128 | throwIf | train | function throwIf (target /*, illegal... */) {
Array.prototype.slice.call(arguments, 1).forEach(function (name) {
if (options[name]) {
throw new Error('Cannot set ' + name + ' and ' + target + 'together');
}
});
} | javascript | {
"resource": ""
} |
q33129 | train | function()
{
this.appendView
(
new ns.MyLoadedView(this.context.addTo({templateUrl:'template-2.html'})),
new ns.MyOtherView(this.context.addTo({template:'This is an internal template using <b>options.template</b> that hates <span cb-style="favoriteColor:color">{{favoriteColor}}</span>'}))
);
... | javascript | {
"resource": ""
} | |
q33130 | Log | train | function Log() {
var args = CopyArguments(arguments);
var level = args.shift();
args.unshift("[Thread] <"+threadId+">");
args.unshift(level);
process.send({name: "thread-log", args: SerializeForProcess(args)});
} | javascript | {
"resource": ""
} |
q33131 | ConvertArgs | train | function ConvertArgs(args, baseResponse) {
var baseResponse = Object.assign({}, baseResponse);
args.forEach(function(arg, i) {
if (typeof(arg) == "object" && arg._classname == "SerializedFunction") {
var idRemoteFunction = arg.id;
args[i] = function() {
process.se... | javascript | {
"resource": ""
} |
q33132 | finalizeRequestDone | train | function finalizeRequestDone() {
if (PendingRequests.length) {
// If we have queued requests, we execute the next one
currentRequest = PendingRequests.shift();
Log(3, "Executing request", currentRequest.id);
executeRequest(currentRequest);
} else {
// We set a timeout in ... | javascript | {
"resource": ""
} |
q33133 | _includeCSSInternal | train | function _includeCSSInternal (css) {
var head,
style = document.getElementById(_stylesheetTagID);
if (!style) {
// there's no our styles tag - create
style = document.createElement('style');
style.setAttribute('id', _stylesheetTagID);
style.setAttribute('type', 'text/css');
head = document.getEle... | javascript | {
"resource": ""
} |
q33134 | train | function (css, name) {
if (typeof css === "function") { css = css(); }
if (!css) { return; }
if (!name) {
_includeCSSInternal(css);
} else if (!_stylesheetFiles[name]) {
_includeCSSInternal(css);
_stylesheetFiles[name] = true;
}
} | javascript | {
"resource": ""
} | |
q33135 | clear | train | function clear() {
timeouts.forEach((callback, timeout) => {
clearTimeout(timeout);
// reject Promise or execute callback which returns Error
callback();
});
const length = size();
cache.clear();
return length;
} | javascript | {
"resource": ""
} |
q33136 | put | train | function put(key, value, timeout, callback) {
// key type is incorrect
if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'boolean') {
throw new TypeError(`key can be only: string | number | boolean instead of ${typeof key}`);
}
// check if key is not NaN
if (typeof key === 'number' ... | javascript | {
"resource": ""
} |
q33137 | Option | train | function Option(flags, description) {
this.flags = flags;
this.required = ~flags.indexOf('<');
this.optional = ~flags.indexOf('[');
this.bool = !~flags.indexOf('-no-');
flags = flags.split(/[ ,|]+/);
if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
this.long = flags.shift();
... | javascript | {
"resource": ""
} |
q33138 | train | function() {
// Reset views
var resetPromised = {};
angular.forEach(_activeSet, function(view, id) {
resetPromised[id] = $q.when(view.reset());
});
// Empty active set
_activeSet = {};
return $q.all(resetPromised);
} | javascript | {
"resource": ""
} | |
q33139 | train | function(id, view, data, controller) {
return _getTemplate(data).then(function(template) {
// Controller
if(controller) {
var current = $state.current();
return view.render(template, controller, current.locals);
// Template only
} else {
return view.render(template)... | javascript | {
"resource": ""
} | |
q33140 | train | function(callback) {
// Activate current
var current = $state.current();
if(current) {
// Reset
_resetActive().then(function() {
// Render
var viewsPromised = {};
var templates = current.templates || {};
var controllers = current.controllers || {};
angu... | javascript | {
"resource": ""
} | |
q33141 | train | function(id, view) {
// No id
if(!id) {
throw new Error('View requires an id.');
// Require unique id
} else if(_viewHash[id]) {
throw new Error('View requires a unique id');
// Add
} else {
_viewHash[id] = view;
}
// Check if view is currently active
var current... | javascript | {
"resource": ""
} | |
q33142 | read | train | function read (req, res, next, parse, debug, options) {
var length
var opts = options || {}
var stream
// flag as parsed
req._body = true
// read options
var encoding = opts.encoding !== null
? opts.encoding || 'utf-8'
: null
var verify = opts.verify
try {
// get the content stream
... | javascript | {
"resource": ""
} |
q33143 | contentstream | train | function contentstream (req, debug, inflate) {
var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
var length = req.headers['content-length']
var stream
debug('content-encoding "%s"', encoding)
if (inflate === false && encoding !== 'identity') {
throw createError(415, 'content e... | javascript | {
"resource": ""
} |
q33144 | setErrorStatus | train | function setErrorStatus (error, status) {
if (!error.status && !error.statusCode) {
error.status = status
error.statusCode = status
}
} | javascript | {
"resource": ""
} |
q33145 | syncContents | train | function syncContents(file, val) {
switch (utils.typeOf(val)) {
case 'buffer':
file._contents = val;
file._content = val.toString();
break;
case 'string':
file._contents = new Buffer(val);
file._content = val;
break;
case 'stream':
file._contents = val;
file... | javascript | {
"resource": ""
} |
q33146 | createElement | train | function createElement(nodeName) {
var elem = document.createElement(nodeName);
elem.className = [].join.call(arguments, ' ');
return elem;
} | javascript | {
"resource": ""
} |
q33147 | createSliderElement | train | function createSliderElement(slidesCount) {
var sliderElement = createElement('div', Layout.SLIDER);
for (var i = 0; i < slidesCount; ++i) {
sliderElement.appendChild(createElement('div', Layout.SLIDE));
}
return sliderElement;
} | javascript | {
"resource": ""
} |
q33148 | OPTICS | train | function OPTICS(dataset, epsilon, minPts, distanceFunction) {
this.tree = null;
/** @type {number} */
this.epsilon = 1;
/** @type {number} */
this.minPts = 1;
/** @type {function} */
this.distance = this._euclideanDistance;
// temporary variables used during computation
/** @type {... | javascript | {
"resource": ""
} |
q33149 | createElement | train | function createElement(filePath, props) {
if (!filePath || typeof filePath !== 'string' || filePath.length === 0) {
throw new Error('Expected filePath to be a string');
}
// clear the require cache if we have already imported the file (if we are watching it)
if (require.cache[filePath]) {
delete requir... | javascript | {
"resource": ""
} |
q33150 | transformForIn | train | function transformForIn(node, path) {
var label = node.$label;
delete node.$label;
var idx = ident(generateSymbol("idx"));
var inArray = ident(generateSymbol("in"));
var declVars = parsePart("var $0,$1 = [];for ($0 in $2) $1.push($0)", [idx,
inArray,node.right]).body;... | javascript | {
"resource": ""
} |
q33151 | iterizeForOf | train | function iterizeForOf(node, path) {
if (node.body.type !== 'BlockStatement') {
node.body = {
type: 'BlockStatement',
body: [node.body]
};
}
var index, iterator, initIterator = parsePart("[$0[Symbol.iterator]()]", [node.right]).expr;
... | javascript | {
"resource": ""
} |
q33152 | mappableLoop | train | function mappableLoop(n) {
return n.type === 'AwaitExpression' && !n.$hidden || inAsyncLoop && (n.type === 'BreakStatement' || n.type === 'ContinueStatement') && n.label;
} | javascript | {
"resource": ""
} |
q33153 | train | function (label) {
return {
type: 'ReturnStatement',
argument: {
type: 'UnaryExpression',
operator: 'void',
prefix: true,
argument: {
... | javascript | {
"resource": ""
} | |
q33154 | checkRequiredFiles | train | function checkRequiredFiles() {
const indexHtmlExists = fse.existsSync(paths.indexHtml);
const indexJsExists = fse.existsSync(paths.indexJs);
if (!indexHtmlExists || !indexJsExists) {
logError('\nSome required files couldn\'t be found. Make sure these all exist:\n');
logError(`\t- ${paths.indexHtml}`);
... | javascript | {
"resource": ""
} |
q33155 | printErrors | train | function printErrors(summary, errors) {
logError(`${summary}\n`);
errors.forEach(err => {
logError(`\t- ${err.message || err}`);
});
console.log();
} | javascript | {
"resource": ""
} |
q33156 | changeAnnotationState | train | function changeAnnotationState(combo, username) {
combo.annotations.forEach(function(anno) {
anno.state = combo.state;
});
contentLib.indexContentItem({uri: combo.uri}, { member: username , annotations: combo.annotations} );
} | javascript | {
"resource": ""
} |
q33157 | publishUpdate | train | function publishUpdate(combo) {
GLOBAL.svc.indexer.retrieveByURI(combo.uri, function(err, res) {
if (!err && res && res._source) {
res = res._source;
combo.selector = 'body';
combo.text = res.text;
combo.content = res.content;
fayeClient.publish('/item/annotations/annotat... | javascript | {
"resource": ""
} |
q33158 | debounceUpdate | train | function debounceUpdate(combo) {
bouncedUpdates[combo.uri] = combo;
if (Object.keys(bouncedUpdates).length < bounceHold) {
clearTimeout(bounceTimeout);
bounceTimeout = setTimeout(function() {
var toDebounce = Object.keys(bouncedUpdates).map(function(b) { return bouncedUpdates[b]; }... | javascript | {
"resource": ""
} |
q33159 | adjureAnnotators | train | function adjureAnnotators(uris, annotators) {
GLOBAL.info('/item/annotations/adjure annotators'.yellow, uris, JSON.stringify(annotators));
uris.forEach(function(uri) {
annotators.forEach(function(member) {
publishUpdate({ uri: uri, member: member});
});
});
} | javascript | {
"resource": ""
} |
q33160 | adjureAnnotations | train | function adjureAnnotations(uris, annotations, username) {
GLOBAL.info('/item/annotations/adjure annotations'.yellow, username.blue, uris, annotations.length);
try {
var user = GLOBAL.svc.auth.getUserByUsername(username);
if (!user) {
throw new Error("no user " + username);
}
uris... | javascript | {
"resource": ""
} |
q33161 | publish | train | function publish(channel, data, clientID) {
if (clientID) {
channel += '/' + clientID;
}
fayeClient.publish(channel, data);
} | javascript | {
"resource": ""
} |
q33162 | MbaasClient | train | function MbaasClient(envId, mbaasConf) {
this.envId = envId;
this.mbaasConfig = mbaasConf;
this.setMbaasUrl();
this.app = {};
this.admin = {};
proxy(this.app, app, this.mbaasConfig);
proxy(this.admin, admin, this.mbaasConfig);
} | javascript | {
"resource": ""
} |
q33163 | roundRat | train | function roundRat (f) {
var a = f[0]
var b = f[1]
if (a.cmpn(0) === 0) {
return 0
}
var h = a.abs().divmod(b.abs())
var iv = h.div
var x = bn2num(iv)
var ir = h.mod
var sgn = (a.negative !== b.negative) ? -1 : 1
if (ir.cmpn(0) === 0) {
return sgn * x
}
if (x) {
var s = ctz(x) + 4
... | javascript | {
"resource": ""
} |
q33164 | train | function(req, token, refreshToken, profile, done) {
// asynchronous
process.nextTick(function() {
var User = app.userModel;
// find the user in the database based on their facebook id
User.findOne({ 'facebook.id' : profile.id }, function(err, user) {
... | javascript | {
"resource": ""
} | |
q33165 | listNotifications | train | function listNotifications(params, cb) {
params.resourcePath = config.addURIParams(constants.NOTIFICATIONS_BASE_PATH, params);
params.method = 'GET';
params.data = params.data || {};
mbaasRequest.admin(params, cb);
} | javascript | {
"resource": ""
} |
q33166 | boot | train | function boot(containerElement) {
check(containerElement, 'containerElement').is.anInstanceOf(Element)();
var containerOptions = getEnabledOptions(containerElement);
var sliderElems = concatUnique(
[].slice.call(containerElement.querySelectorAll('.'+ Layout.SLIDER)),
[].slice.call(containerElement.qu... | javascript | {
"resource": ""
} |
q33167 | getEnabledOptions | train | function getEnabledOptions(element) {
var retVal = [];
Object.values(Option).forEach(function(option) {
if (element.classList.contains(option)) {
retVal.push(option);
}
});
return retVal;
} | javascript | {
"resource": ""
} |
q33168 | publisher | train | function publisher(port) {
var socket = zeromq.socket('pub');
socket.identity = 'pub' + process.pid;
socket.connect(port);
console.log('publisher connected to ' + port);
// lets count messages / sec
var totalMessages=0;
setInterval(function() {
console.log('total messages sent = '+totalMessages);
... | javascript | {
"resource": ""
} |
q33169 | subscriber | train | function subscriber(port) {
var socket = zeromq.socket('sub');
socket.identity = 'sub' + process.pid;
// have to subscribe, otherwise nothing would show up
// subscribe to everything
socket.subscribe('');
var totalMessages=0;
// receive messages
socket.on('message', function(data) {
//console.log... | javascript | {
"resource": ""
} |
q33170 | forwarder | train | function forwarder(frontPort, backPort) {
var frontSocket = zeromq.socket('sub'),
backSocket = zeromq.socket('pub');
frontSocket.identity = 'sub' + process.pid;
backSocket.identity = 'pub' + process.pid;
frontSocket.subscribe('');
frontSocket.bind(frontPort, function (err) {
console.log('bound', f... | javascript | {
"resource": ""
} |
q33171 | createComponent | train | function createComponent(loader, obj) {
const entitySet = loader.entitySet;
// determine whether any attributes are refering to marked pois
obj = resolveMarkReferences(loader, obj);
// the alternative form is to use @uri
if (obj[CMD_COMPONENT_URI]) {
obj[CMD_COMPONENT] = obj[CMD_COMPONENT_... | javascript | {
"resource": ""
} |
q33172 | retrieveEntityByAttribute | train | async function retrieveEntityByAttribute(
entitySet,
componentID,
attribute,
value
) {
// Log.debug('[retrieveEntityByAttribute]', componentID, 'where', attribute, 'equals', value);
const query = Q => [
Q.all(componentID).where(Q.attr(attribute).equals(value)),
Q.limit(1)
];
... | javascript | {
"resource": ""
} |
q33173 | train | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Callback function to receive the result of the closeSessions operation.
* @callback module:api/SessionApi~closeSessionsCallback
* @param {String} error Error message, if any.
* @param {module:model/RestOK} data T... | javascript | {
"resource": ""
} | |
q33174 | relativePathTo | train | function relativePathTo(from, to, strip) {
var relPath = path.relative(from.replace(path.basename(from), ''), to);
if (relPath.match(/^\.\.?(\/|\\)/) === null) { relPath = './' + relPath; }
if (strip) { return relPath.replace(/((\/|\\)index\.js|\.js)$/, ''); }
return relPath;
} | javascript | {
"resource": ""
} |
q33175 | filterFile | train | function filterFile(template) {
// Find matches for parans
var filterMatches = template.match(/\(([^)]+)\)/g);
var filters = [];
if (filterMatches) {
filterMatches.forEach(function(filter) {
filters.push(filter.replace('(', '').replace(')', ''));
template = template.replace(filter, '');
});
... | javascript | {
"resource": ""
} |
q33176 | templateIsUsable | train | function templateIsUsable(self, filteredFile) {
var filters = self.config.get('filters');
var enabledFilters = [];
for (var key in filters) {
if (filters[key]) { enabledFilters.push(key); }
}
var matchedFilters = self._.intersection(filteredFile.filters, enabledFilters);
// check that all filters on fil... | javascript | {
"resource": ""
} |
q33177 | format | train | function format(obj) {
var parameters = obj.parameters
var type = obj.type
if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
throw new TypeError('invalid type')
}
// start with normalized type
var string = String(type).toLowerCase()
// append parameters
if (parameters && typeof ... | javascript | {
"resource": ""
} |
q33178 | pencode | train | function pencode(char) {
var hex = String(char)
.charCodeAt(0)
.toString(16)
.toUpperCase()
return hex.length === 1
? '%0' + hex
: '%' + hex
} | javascript | {
"resource": ""
} |
q33179 | Contour | train | function Contour(options) {
var contour = this
, assets;
this.fuse();
//
// Add the pagelets of the required framework.
//
options = options || {};
//
// Load and optimize the pagelets, extend contour but acknowledge external
// listeners when all pagelets have been fully initialized.
//
as... | javascript | {
"resource": ""
} |
q33180 | defaultGetCallingScript | train | function defaultGetCallingScript(offset = 0) {
const stack = (new Error).stack.split(/$/m);
const line = stack[(/^Error/).test(stack[0]) + 1 + offset];
const parts = line.split(/@(?![^/]*?\.xpi)|\(|\s+/g);
return parts[parts.length - 1].replace(/:\d+(?::\d+)?\)?$/, '');
} | javascript | {
"resource": ""
} |
q33181 | next | train | function next(exp) {
exp.lastIndex = index;
const match = exp.exec(code)[0];
index = exp.lastIndex;
return match;
} | javascript | {
"resource": ""
} |
q33182 | Assets | train | function Assets(brand, mode) {
var readable = Assets.predefine(this, Assets.predefine.READABLE)
, enumerable = Assets.predefine(this, { configurable: false })
, self = this
, i = 0
, files;
/**
* Callback to emit optimized event after all Pagelets have been optimized.
*
* @param {Error} er... | javascript | {
"resource": ""
} |
q33183 | next | train | function next(error) {
if (error) return self.emit('error', error);
if (++i === files.length) self.emit('optimized');
} | javascript | {
"resource": ""
} |
q33184 | getIn | train | function getIn (client, from, nodes, callback, remove) {
remove = remove || [];
const outNodes = [];
const nodeIndex = {};
const fromIndex = {};
if (from instanceof Array) {
from.forEach((node) => {fromIndex[node] = true});
} else {
from = null;
}
nodes.forEach((node)... | javascript | {
"resource": ""
} |
q33185 | createPayment | train | function createPayment(data, callback) {
var client = new this.clients.Payments();
client.create(data, callback);
} | javascript | {
"resource": ""
} |
q33186 | getPaymentById | train | function getPaymentById(id, callback) {
var client = new this.clients.Payments();
client.getById(id, callback);
} | javascript | {
"resource": ""
} |
q33187 | getPaymentByNotificationToken | train | function getPaymentByNotificationToken(token, callback) {
var client = new this.clients.Payments();
client.getByNotificationToken(token, callback);
} | javascript | {
"resource": ""
} |
q33188 | refundPayment | train | function refundPayment(id, callback) {
var client = new this.clients.Payments();
client.refund(id, callback);
} | javascript | {
"resource": ""
} |
q33189 | train | function(trigger, job){
this.trigger = this.decodeTrigger(trigger);
this.nextTime = this.nextExcuteTime(Date.now());
this.job = job;
} | javascript | {
"resource": ""
} | |
q33190 | timeMatch | train | function timeMatch(value, cronTime){
if(typeof(cronTime) == 'number'){
if(cronTime == -1)
return true;
if(value == cronTime)
return true;
return false;
}else if(typeof(cronTime) == 'object' && cronTime instanceof Array){
if(value < cronTime[0] || value > cronTime[cronTime.length -1])
... | javascript | {
"resource": ""
} |
q33191 | decodeRangeTime | train | function decodeRangeTime(map, timeStr){
let times = timeStr.split('-');
times[0] = Number(times[0]);
times[1] = Number(times[1]);
if(times[0] > times[1]){
console.log("Error time range");
return null;
}
for(let i = times[0]; i <= times[1]; i++){
map[i] = i;
}
} | javascript | {
"resource": ""
} |
q33192 | decodePeriodTime | train | function decodePeriodTime(map, timeStr, type){
let times = timeStr.split('/');
let min = Limit[type][0];
let max = Limit[type][1];
let remind = Number(times[0]);
let period = Number(times[1]);
if(period==0)
return;
for(let i = min; i <= max; i++){
if(i%period == remind)
map[i] = i;
}
} | javascript | {
"resource": ""
} |
q33193 | checkNum | train | function checkNum(nums, min, max){
if(nums == null)
return false;
if(nums == -1)
return true;
for(let i = 0; i < nums.length; i++){
if(nums[i]<min || nums[i]>max)
return false;
}
return true;
} | javascript | {
"resource": ""
} |
q33194 | setupCronInput | train | function setupCronInput(val) {
$('input.cron').jqCron({
enabled_minute: true,
multiple_dom: true,
multiple_month: true,
multiple_mins: true,
multiple_dow: true,
multiple_time_hours: true,
multiple_time_minutes: true,
default_period: 'week',
default_value: val ||... | javascript | {
"resource": ""
} |
q33195 | getSearchInput | train | function getSearchInput() {
var cronValue = $('#scheduleSearch').prop('checked') ? $('input.cron').val() : null, searchName = $('#searchName').val(), targetResults = $('#targetResults').val(), input = $('#searchInput').val(), searchContinue = $('#searchContinue').val(), searchCategories = $('#searchCategories').val... | javascript | {
"resource": ""
} |
q33196 | submitSearch | train | function submitSearch() {
var searchInput = getSearchInput();
// FIXME: SUI validation for select2 field
if (!searchInput.valid) {
alert('Please select team members');
return;
}
console.log('publishing', searchInput);
$('.search.message').html('Search results:');
$('.search.mes... | javascript | {
"resource": ""
} |
q33197 | Loader | train | function Loader(options) {
if (!(this instanceof Loader)) {
return new Loader(options);
}
this.options = options || {};
this.cache = this.options.helpers || {};
} | javascript | {
"resource": ""
} |
q33198 | deepClone | train | function deepClone(inputDict){
if (!inputDict)
return null;
const clonedDict = {};
for (let key in inputDict){
if (typeof(inputDict[key]) == 'object'){
clonedDict[key] = deepClone(inputDict[key]);
}
else{
clonedDict[key] = inputDict[key]... | javascript | {
"resource": ""
} |
q33199 | setCookie | train | function setCookie(cookieName, value, validity, useAppPrefix = true){
const appPrefix = useAppPrefix ? _getAppPrefix() : '';
const cookieString = appPrefix + cookieName + '=' + value + ';' + 'expires=' +
validity.toUTCString();
document.cookie = cookieString;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.