_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q27400 | clientCoreData | train | function clientCoreData(opt) {
var self = {
__TYPE__ : MessageType.CS_CORE,
rdpVersion : new type.UInt32Le(VERSION.RDP_VERSION_5_PLUS),
desktopWidth : new type.UInt16Le(1280),
desktopHeight : new type.UInt16Le(800),
colorDepth : new type.UInt16Le(ColorDepth.RNS_UD_COLOR_8BPP),
sasSequence : new type.UInt16... | javascript | {
"resource": ""
} |
q27401 | settings | train | function settings(blocks, opt) {
var self = {
blocks : blocks || new type.Factory(function(s) {
self.blocks = new type.Component([]);
// read until end of stream
while(s.availableLength() > 0) {
self.blocks.obj.push(block().read(s));
}
}),
};
return new type.Component(self, opt);
} | javascript | {
"resource": ""
} |
q27402 | readConferenceCreateResponse | train | function readConferenceCreateResponse(s) {
per.readChoice(s);
if(!per.readObjectIdentifier(s, t124_02_98_oid)) {
throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_OBJECT_IDENTIFIER_T124');
}
per.readLength(s);
per.readChoice(s);
per.readInteger16(s, 1001);
per.readInteger(s);
per.readEnumerate... | javascript | {
"resource": ""
} |
q27403 | readConferenceCreateRequest | train | function readConferenceCreateRequest (s) {
per.readChoice(s);
if (!per.readObjectIdentifier(s, t124_02_98_oid)) {
throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_H221_SC_KEY');
}
per.readLength(s);
per.readChoice(s);
per.readSelection(s);
per.readNumericString(s, 1);
per.readPadding(s, 1);
if ... | javascript | {
"resource": ""
} |
q27404 | certBlob | train | function certBlob() {
var self = {
cbCert : new type.UInt32Le(function() {
return self.abCert.size();
}),
abCert : new type.BinaryString(null, { readLength : new type.CallableValue(function() {
return self.cbCert.value;
}) })
};
return new type.Component(self);
} | javascript | {
"resource": ""
} |
q27405 | x509CertificateChain | train | function x509CertificateChain() {
var self = {
__TYPE__ : CertificateType.CERT_CHAIN_VERSION_2,
NumCertBlobs : new type.UInt32Le(),
CertBlobArray : new type.Factory(function(s) {
self.CertBlobArray = new type.Component([]);
for(var i = 0; i < self.NumCertBlobs.value; i++) {
self... | javascript | {
"resource": ""
} |
q27406 | MCS | train | function MCS(transport, recvOpCode, sendOpCode) {
this.transport = transport;
this.recvOpCode = recvOpCode;
this.sendOpCode = sendOpCode;
this.channels = [{id : Channel.MCS_GLOBAL_CHANNEL, name : 'global'}];
this.channels.find = function(callback) {
for(var i in this) {
if(callback(this[i])) return this[i];
... | javascript | {
"resource": ""
} |
q27407 | Client | train | function Client(transport) {
MCS.call(this, transport, DomainMCSPDU.SEND_DATA_INDICATION, DomainMCSPDU.SEND_DATA_REQUEST);
// channel context automata
this.channelsConnected = 0;
// init gcc information
this.clientCoreData = gcc.clientCoreData();
this.clientNetworkData = gcc.clientNetworkData(new type.Compone... | javascript | {
"resource": ""
} |
q27408 | Server | train | function Server (transport) {
MCS.call(this, transport, DomainMCSPDU.SEND_DATA_REQUEST, DomainMCSPDU.SEND_DATA_INDICATION);
// must be readed from protocol
this.clientCoreData = null;
this.clientNetworkData = null;
this.clientSecurityData = null;
// init gcc information
this.serverCoreData = gcc.serverCoreDa... | javascript | {
"resource": ""
} |
q27409 | TPKT | train | function TPKT(transport) {
this.transport = transport;
// wait 2 bytes
this.transport.expect(2);
// next state is receive header
var self = this;
this.transport.once('data', function(s) {
self.recvHeader(s);
}).on('close', function() {
self.emit('close');
}).on('error', function (err) {
self.emit('error',... | javascript | {
"resource": ""
} |
q27410 | licenseBinaryBlob | train | function licenseBinaryBlob(blobType) {
blobType = blobType || BinaryBlobType.BB_ANY_BLOB;
var self = {
wBlobType : new type.UInt16Le(blobType, { constant : (blobType === BinaryBlobType.BB_ANY_BLOB)?false:true }),
wBlobLen : new type.UInt16Le(function() {
return self.blobData.size();
}),
... | javascript | {
"resource": ""
} |
q27411 | licensingErrorMessage | train | function licensingErrorMessage(opt) {
var self = {
__TYPE__ : MessageType.ERROR_ALERT,
dwErrorCode : new type.UInt32Le(),
dwStateTransition : new type.UInt32Le(),
blob : licenseBinaryBlob(BinaryBlobType.BB_ANY_BLOB)
};
return new type.Component(self, opt);
} | javascript | {
"resource": ""
} |
q27412 | productInformation | train | function productInformation() {
var self = {
dwVersion : new type.UInt32Le(),
cbCompanyName : new type.UInt32Le(function() {
return self.pbCompanyName.size();
}),
// may contain "Microsoft Corporation" from server microsoft
pbCompanyName : new type.BinaryString(new Buffer('Mi... | javascript | {
"resource": ""
} |
q27413 | licensePacket | train | function licensePacket(message) {
var self = {
bMsgtype : new type.UInt8(function() {
return self.licensingMessage.obj.__TYPE__;
}),
flag : new type.UInt8(Preambule.PREAMBLE_VERSION_3_0),
wMsgSize : new type.UInt16Le(function() {
return new type.Component(self).size();
}),
... | javascript | {
"resource": ""
} |
q27414 | requireProxy | train | function requireProxy(path) {
reset();
currentModule.require = nodeRequire;
return nodeRequire.call(currentModule, path); // node's require only works when "this" points to the module
} | javascript | {
"resource": ""
} |
q27415 | getImportGlobalsSrc | train | function getImportGlobalsSrc(ignore) {
var key,
value,
src = "",
globalObj = typeof global === "undefined"? window: global;
ignore = ignore || [];
// global itself can't be overridden because it's the only reference to our real global objects
ignore.push("global");
// ignore... | javascript | {
"resource": ""
} |
q27416 | detectStrictMode | train | function detectStrictMode(src) {
var singleLine;
var multiLine;
while ((singleLine = singleLineComment.test(src)) || (multiLine = multiLineComment.test(src))) {
if (singleLine) {
src = src.replace(singleLineComment, "");
}
if (multiLine) {
src = src.... | javascript | {
"resource": ""
} |
q27417 | internalRewire | train | function internalRewire(parentModulePath, targetPath) {
var targetModule,
prelude,
appendix,
src;
// Checking params
if (typeof targetPath !== "string") {
throw new TypeError("Filename must be a string");
}
// Resolve full filename relative to the parent module
... | javascript | {
"resource": ""
} |
q27418 | train | function () {
return _.map(groceries, item => {
const object = {
id: item.id,
name: item.name,
departmentsCount: item.departments.length
}
delete object.departments // @TODO ????
return object
})
} | javascript | {
"resource": ""
} | |
q27419 | train | function () {
const departments = []
// @TODO this is an example what should be updated. loooooks so bad and unreadable
_.forEach(_.range(0, groceries.length), value =>
departments.push(..._.map(groceries[value]['departments']))
)
return departments
} | javascript | {
"resource": ""
} | |
q27420 | createTreeListener | train | function createTreeListener({ handler, restPath }) {
const newHandler = function treeListener(changeEvent) {
const extendedChangeEvent = {
restPath,
...changeEvent
};
const { previousValue, value } = changeEvent;
// removes listener for all branches of the pa... | javascript | {
"resource": ""
} |
q27421 | defaultUpdateFunction | train | function defaultUpdateFunction(instance, data) {
if (instance.isMatreshkaArray) {
instance.recreate(data);
} else if (instance.isMatreshkaObject) {
instance.setData(data, { replaceData: true });
} else {
// for other objects just extend them with given data
nofn.assign(instan... | javascript | {
"resource": ""
} |
q27422 | createInstantiateMediator | train | function createInstantiateMediator({
UsedClass,
updateFunction
}) {
return function mediator(value, previousValue, key, object) {
if (previousValue instanceof UsedClass) {
updateFunction.call(object, previousValue, value, key);
return previousValue;
}
return ... | javascript | {
"resource": ""
} |
q27423 | shift | train | function shift(arr, index) {
for (let i = index; i < arr.length; i++) {
arr[i] = arr[i + 1];
}
delete arr[arr.length - 1];
arr.length -= 1;
} | javascript | {
"resource": ""
} |
q27424 | pullByValue | train | function pullByValue(arr, value) {
for (let i = 0; i < arr.length; i++) {
if (arr[i] === value) {
shift(arr, i);
return value;
}
}
return undefined;
} | javascript | {
"resource": ""
} |
q27425 | pullByIndex | train | function pullByIndex(arr, index) {
if (index < arr.length) {
const value = arr[index];
shift(arr, index);
return value;
}
return undefined;
} | javascript | {
"resource": ""
} |
q27426 | getNotListedKeys | train | function getNotListedKeys(inObject, fromObject) {
const result = [];
nofn.forOwn(inObject, (_, key) => {
if (!(key in fromObject)) {
result.push(key);
}
});
return result;
} | javascript | {
"resource": ""
} |
q27427 | createBindingHandlers | train | function createBindingHandlers({
fullEventName,
domEventHandler,
selector
}) {
return {
bindHandler(evt = {}) {
const { node } = evt;
if (node) {
dom.$(node).on(fullEventName, selector, domEventHandler);
}
},
unbindHandler(evt =... | javascript | {
"resource": ""
} |
q27428 | changeHandler | train | function changeHandler(eventOptions = {}) {
const { key, silent } = eventOptions;
const def = defs.get(this);
if (key && key in def.keys && !silent) {
triggerOne(this, 'set', eventOptions);
triggerOne(this, 'modify', eventOptions);
}
} | javascript | {
"resource": ""
} |
q27429 | createMediator | train | function createMediator({
object,
propDef,
key,
mediator
}) {
return function propMediator(value) {
// args: value, previousValue, key, object itself
return mediator.call(object, value, propDef.value, key, object);
};
} | javascript | {
"resource": ""
} |
q27430 | is | train | function is(node, selector) {
return (node.matches
|| node.webkitMatchesSelector
|| node.mozMatchesSelector
|| node.msMatchesSelector
|| node.oMatchesSelector).call(node, selector);
} | javascript | {
"resource": ""
} |
q27431 | delegateHandler | train | function delegateHandler(evt, selector, handler) {
const scopeSelector = `[${randomID}="${randomID}"] `;
const splittedSelector = selector.split(',');
let matching = '';
for (let i = 0; i < splittedSelector.length; i++) {
const sel = splittedSelector[i];
matching += `${i === 0 ? '' : '... | javascript | {
"resource": ""
} |
q27432 | createItemMediator | train | function createItemMediator({
arr,
mediator
}) {
return function itemMediator(value, index) {
// args: value, old value, index, array itself
return mediator.call(arr, value, index, arr);
};
} | javascript | {
"resource": ""
} |
q27433 | modelItemMediator | train | function modelItemMediator(item, index) {
const { Model } = this;
// if an item is already instance of Model
if (item instanceof Model) {
return item;
}
let itemData;
if (item && typeof item.toJSON === 'function') {
// if item is not falsy and if it has toJSON method
/... | javascript | {
"resource": ""
} |
q27434 | percentage | train | function percentage(target, context) {
if (target.slice(-1) === "%" || context.slice(-1) === "%") {
throw new Error(`Cannot calculate percentage; one or more units appear to
be %. Units must be rem or px.`);
}
if (target.slice(-1) !== context.slice(-1)) {
throw new Error("Cannot calculate percentag... | javascript | {
"resource": ""
} |
q27435 | gutter | train | function gutter(
math = settings.math,
columns = settings.columns,
multiplier = 1
) {
const gutterWidth = _calculateGutter(multiplier);
const containerWidth = _updateContext(
typeof columns === "string" ?
parseInt(columns, 10) :
columns
);
if (math === "static") {
return _staticCalculatio... | javascript | {
"resource": ""
} |
q27436 | visuallyHidden | train | function visuallyHidden(focusable) {
const focusableStyles = {
clip: "auto",
clipPath: "none",
height: "auto",
margin: 0,
overflow: "visible",
position: "static",
whiteSpace: "inherit",
width: "auto",
};
return Object.assign({}, {
border: 0,
clipPath: "inset(50%)",
dis... | javascript | {
"resource": ""
} |
q27437 | blueLink | train | function blueLink() {
return {
color: colors.linkPrimary,
textDecoration: "none",
transition: `color ${timing.fast} ease-in-out`,
":hover": {
color: colors.linkPrimaryHover,
},
":active": {
color: colors.linkPrimaryHover,
},
":focus": Object.assign({}, outline(), {
... | javascript | {
"resource": ""
} |
q27438 | underlinedLink | train | function underlinedLink(linkColor = colors.textPrimary) {
const underlineOffset = 2;
const underlineWeight = 1;
const backgroundColor = colors.bgPrimary;
const underlineColor = rgba(linkColor, 0.4);
return {
color: linkColor,
position: "relative",
textDecoration: "none",
transition: `color ${... | javascript | {
"resource": ""
} |
q27439 | config | train | function config(mode = 'production', assetDirs = [], moduleDirs = [], outputDir = false) {
const context = resolve(__dirname, '../../../node_modules');
const entry = _entry(Utils.castArray(assetDirs));
const output = outputDir ? { filename: '[name].js', path: outputDir } : {};
const removeFiles = _removeFiles(e... | javascript | {
"resource": ""
} |
q27440 | _removeFiles | train | function _removeFiles(entry) {
return Utils.reduce(entry, (memo, value, key) => {
if (value[0].match(/\.pack\.s[ac]ss/)) {
memo.push(`${key}.js`);
}
return memo;
}, []);
} | javascript | {
"resource": ""
} |
q27441 | _updatePjson | train | function _updatePjson(siteId) {
pjson.vapid.site = siteId;
writePkg.sync(pjsonPath, pjson);
} | javascript | {
"resource": ""
} |
q27442 | _generateManifest | train | function _generateManifest(siteChecksums, presignedPosts) {
return Utils.reduce(siteChecksums, (memo, checksum, path) => {
/* eslint-disable-next-line no-param-reassign */
memo[path] = presignedPosts[path].digest;
return memo;
}, {});
} | javascript | {
"resource": ""
} |
q27443 | _checksums | train | function _checksums(dir) {
const checksums = {};
glob.sync(resolve(dir, '**/!(*.pack.+(s[ac]ss|js))'), { mark: true }).forEach((file) => {
if (Utils.endsWith(file, '/')) { return; }
const relativePath = relative(dir, file);
checksums[relativePath] = Utils.checksum(file);
});
return checksums;
} | javascript | {
"resource": ""
} |
q27444 | _getPresignedPosts | train | async function _getPresignedPosts(siteId, checksums) {
const endpoint = url.resolve(apiURL, `/sites/${siteId}/presigned_posts`);
const body = { checksums };
const response = await got.post(endpoint, { body, json: true, headers: _bearer() });
return response.body.presignedPosts;
} | javascript | {
"resource": ""
} |
q27445 | _uploadFiles | train | async function _uploadFiles(dir, presignedPosts) {
const promises = [];
const limit = pLimit(5);
let uploaded = false;
Object.keys(presignedPosts).forEach(async (path) => {
const { post } = presignedPosts[path];
if (!post) {
Logger.tagged('exists', path, 'blue');
} else {
const filePat... | javascript | {
"resource": ""
} |
q27446 | _updateSite | train | async function _updateSite(siteId, tree, manifest, content) {
const endpoint = url.resolve(apiURL, `/sites/${siteId}`);
const body = { tree, content, manifest };
const response = await got.post(endpoint, { body, json: true, headers: _bearer() });
return response.body.site;
} | javascript | {
"resource": ""
} |
q27447 | _compileAssets | train | async function _compileAssets(wwwDir, tmpDir) {
const nodeDir = resolve(wwwDir, '../node_modules');
const moduleDirs = (function _moduleDirs() {
const dirs = [wwwDir];
if (fs.existsSync(nodeDir)) dirs.push(nodeDir);
return dirs;
}());
const config = webPackConfig('production', tmpDir, moduleDirs, t... | javascript | {
"resource": ""
} |
q27448 | addData | train | function addData(element, key, value) {
if (value === undefined) {
return element && element.h5s && element.h5s.data && element.h5s.data[key];
}
else {
element.h5s = element.h5s || {};
element.h5s.data = element.h5s.data || {};
element.h5s.data[key... | javascript | {
"resource": ""
} |
q27449 | train | function (config) {
if (typeof config !== 'object') {
throw new Error('You must provide a valid configuration object to the config setter.');
}
// combine config with default
var mergedConfig = Object.assign({}, config);
... | javascript | {
"resource": ""
} | |
q27450 | train | function (draggedElement, elementOffset, event) {
return {
element: draggedElement,
posX: event.pageX - elementOffset.left,
posY: event.pageY - elementOffset.top
};
} | javascript | {
"resource": ""
} | |
q27451 | _throttle | train | function _throttle (fn, threshold) {
var _this = this;
if (threshold === void 0) { threshold = 250; }
// check function
if (typeof fn !== 'function') {
throw new Error('You must provide a function as the first argument for throttle.');
}
// check threshold
... | javascript | {
"resource": ""
} |
q27452 | train | function (items) {
removeEventListener(items, 'dragstart');
removeEventListener(items, 'dragend');
removeEventListener(items, 'dragover');
removeEventListener(items, 'dragenter');
removeEventListener(items, 'drop');
removeEventListener(items, 'mouseenter');
remove... | javascript | {
"resource": ""
} | |
q27453 | train | function (draggedItem, sortable) {
var ditem = draggedItem;
if (store(sortable).getConfig('copy') === true) {
ditem = draggedItem.cloneNode(true);
addAttribute(ditem, 'aria-copied', 'true');
draggedItem.parentElement.appendChild(ditem);
ditem.style.display... | javascript | {
"resource": ""
} | |
q27454 | findDragElement | train | function findDragElement(sortableElement, element) {
var options = addData(sortableElement, 'opts');
var items = _filter(sortableElement.children, options.items);
var itemlist = items.filter(function (ele) {
return ele.contains(element);
});
return itemlist.length > 0... | javascript | {
"resource": ""
} |
q27455 | train | function (sortableElement) {
var opts = addData(sortableElement, 'opts') || {};
var items = _filter(sortableElement.children, opts.items);
var handles = _getHandles(items, opts.handle);
// remove event handlers & data from sortable
removeEventListener(sortableElement, 'dragover')... | javascript | {
"resource": ""
} | |
q27456 | train | function (sortableElement) {
var opts = addData(sortableElement, 'opts');
var items = _filter(sortableElement.children, opts.items);
var handles = _getHandles(items, opts.handle);
addAttribute(sortableElement, 'aria-dropeffect', 'move');
addData(sortableElement, '_disabled', 'fal... | javascript | {
"resource": ""
} | |
q27457 | train | function (sortableElement) {
var opts = addData(sortableElement, 'opts');
var items = _filter(sortableElement.children, opts.items);
var handles = _getHandles(items, opts.handle);
addAttribute(sortableElement, 'aria-dropeffect', 'none');
addData(sortableElement, '_disabled', 'tru... | javascript | {
"resource": ""
} | |
q27458 | train | function (e) {
var element = e.target;
var sortableElement = element.isSortable === true ? element : findSortable(element);
element = findDragElement(sortableElement, element);
if (!dragging || !_listsConnected(sortableElement, dragging.parentElement) || a... | javascript | {
"resource": ""
} | |
q27459 | find | train | function find(params = {}) {
const name = params.type;
if (Utils.has(availableDirectives, name)) {
return new availableDirectives[name](params);
}
// Only show warning if someone explicity enters a bad name
if (name) { Logger.warn(`Directive type '${name}' does not exist. Falling back to 'text'`); }
/... | javascript | {
"resource": ""
} |
q27460 | getProjectName | train | function getProjectName(protoPath) {
var
cordovaConfigPath = path.join(protoPath, 'config.xml'),
content = fs.readFileSync(cordovaConfigPath, 'utf-8');
return /<name>([\s\S]*)<\/name>/mi.exec(content)[1].trim();
} | javascript | {
"resource": ""
} |
q27461 | getOffsetWidth | train | function getOffsetWidth(el) {
var rect = el.getBoundingClientRect();
return rect.width || rect.right - rect.left;
} | javascript | {
"resource": ""
} |
q27462 | columnNum | train | function columnNum(){
var count;
var $headerColumns = $header.find(opts.headerCellSelector);
if(existingColGroup){
count = $tableColGroup.find('col').length;
} else {
count = 0;
$headerColumns.each(function () {
count += parseInt(($(this).attr('c... | javascript | {
"resource": ""
} |
q27463 | calculateScrollBarSize | train | function calculateScrollBarSize(){ //this should happen after the floating table has been positioned
if($scrollContainer.length){
if(opts.support && opts.support.perfectScrollbar && $scrollContainer.data().perfectScrollbar){
scrollbarOffset = {horizontal:0, vertical:0};
} else {
... | javascript | {
"resource": ""
} |
q27464 | train | function (options, callback) {
// build dataSource based with options
var resp = {
count: data.repeater.listData.length,
items: [],
page: options.pageIndex
};
// get start and end limits for JSON
var i, l;
resp.pages = Math.ceil(resp.count / (options.pageSize || 50));
i = options.page... | javascript | {
"resource": ""
} | |
q27465 | train | function (options, callback) {
var sampleImageCategories = ['abstract', 'animals', 'business', 'cats', 'city', 'food', 'nature', 'technics', 'transport'];
var numItems = 200;
// build dataSource based with options
var resp = {
count: numItems,
items: [],
pages: (Math.ceil(numItems / (options.pa... | javascript | {
"resource": ""
} | |
q27466 | train | function(...args) {
const cacheKey = keySelector(...args);
if (isValidCacheKey(cacheKey)) {
let cacheResponse = cache.get(cacheKey);
if (cacheResponse === undefined) {
cacheResponse = selectorCreator(...funcs);
cache.set(cacheKey, cacheResponse);
}
retu... | javascript | {
"resource": ""
} | |
q27467 | compressJS | train | function compressJS() {
let tasks = [];
Object.keys(config.tasks).forEach((key) => {
let val = config.tasks[key];
tasks.push(gulp.src(val.src)
.pipe(plumber({ errorHandler: handleErrors }))
.pipe(uglify())
.pipe(rename(config.rename))
.pipe(gulp.d... | javascript | {
"resource": ""
} |
q27468 | watchTask | train | function watchTask() {
gulp.watch(config.watchers.static, copyStaticFiles);
gulp.watch(config.watchers.css, gulp.series(lintCSS, compileSass));
gulp.watch(config.watchers.js, gulp.series(lintJS, concatJS, copyJS));
gulp.watch(config.watchers.drizzle, drizzleTask);
} | javascript | {
"resource": ""
} |
q27469 | compressCSS | train | function compressCSS() {
let tasks = [];
Object.keys(config.tasks).forEach((key) => {
let val = config.tasks[key];
tasks.push(gulp.src(val.src)
.pipe(cleanCSS({processImport: false}))
.pipe(rename(config.rename))
.pipe(gulp.dest(val.dest)));
});
retu... | javascript | {
"resource": ""
} |
q27470 | initEmailForm | train | function initEmailForm() {
var newsletterForm = document.getElementById('newsletter-form');
var submitButton = document.getElementById('newsletter-submit');
var formDetails = document.getElementById('newsletter-details');
var emailField = document.querySelector('.mzp-js-email-field');
... | javascript | {
"resource": ""
} |
q27471 | copyJS | train | function copyJS() {
let tasks = [];
Object.keys(config).forEach((key) => {
let val = config[key];
tasks.push(gulp.src(val.src).pipe(gulp.dest(val.dest)));
});
return merge(tasks);
} | javascript | {
"resource": ""
} |
q27472 | concatJS | train | function concatJS() {
let tasks = [];
Object.keys(config).forEach((key) => {
let val = config[key];
tasks.push(gulp.src(val.src)
.pipe(plumber({ errorHandler: handleErrors }))
.pipe(concat(key + '.js'))
.pipe(gulp.dest(val.dest)));
});
return merge(t... | javascript | {
"resource": ""
} |
q27473 | stripColons | train | function stripColons (str) {
var colonIndex = str.indexOf(':');
if (colonIndex > -1) {
// :emoji: (http://www.emoji-cheat-sheet.com/)
if (colonIndex === str.length - 1) {
str = str.substring(0, colonIndex);
return stripColons(str);
} else {
str = str.substr(colonIndex + 1);
retur... | javascript | {
"resource": ""
} |
q27474 | train | function() {
if (!this.resolved) {
throw new Error('Future must resolve before value is ready');
} else if (this.error) {
// Link the stack traces up
var error = this.error;
var localStack = {};
Error.captureStackTrace(localStack, Future.prototype.get);
var futureStack = Object.getOwnPropertyDescr... | javascript | {
"resource": ""
} | |
q27475 | train | function(value) {
if (this.resolved) {
throw new Error('Future resolved more than once');
}
this.value = value;
this.resolved = true;
var callbacks = this.callbacks;
if (callbacks) {
delete this.callbacks;
for (var ii = 0; ii < callbacks.length; ++ii) {
try {
var ref = callbacks[ii];
... | javascript | {
"resource": ""
} | |
q27476 | train | function(error) {
if (this.resolved) {
throw new Error('Future resolved more than once');
} else if (!error) {
throw new Error('Must throw non-empty error');
}
this.error = error;
this.resolved = true;
var callbacks = this.callbacks;
if (callbacks) {
delete this.callbacks;
for (var ii = 0; ii... | javascript | {
"resource": ""
} | |
q27477 | train | function(arg1, arg2) {
if (this.resolved) {
if (arg2) {
if (this.error) {
arg1.throw(this.error);
} else {
arg2(this.value);
}
} else {
arg1(this.error, this.value);
}
} else {
(this.callbacks = this.callbacks || []).push([arg1, arg2]);
}
return this;
} | javascript | {
"resource": ""
} | |
q27478 | train | function(futures) {
this.resolve(function(err) {
if (!err) {
return;
}
if (futures instanceof Array) {
for (var ii = 0; ii < futures.length; ++ii) {
futures[ii].throw(err);
}
} else {
futures.throw(err);
}
});
return this;
} | javascript | {
"resource": ""
} | |
q27479 | train | function() {
var that = this;
return new Promise(function(resolve, reject) {
that.resolve(function(err, val) {
if (err) {
reject(err);
} else {
resolve(val);
}
});
});
} | javascript | {
"resource": ""
} | |
q27480 | FiberFuture | train | function FiberFuture(fn, context, args) {
this.fn = fn;
this.context = context;
this.args = args;
this.started = false;
var that = this;
process.nextTick(function() {
if (!that.started) {
that.started = true;
Fiber(function() {
try {
that.return(fn.apply(context, args));
} catch(e) {
tha... | javascript | {
"resource": ""
} |
q27481 | afterBuild | train | function afterBuild() {
var targetPath = path.join(__dirname, 'build', debug ? 'Debug' : 'Release', 'fibers.node');
var installPath = path.join(__dirname, 'bin', modPath, 'fibers.node');
try {
fs.mkdirSync(path.join(__dirname, 'bin', modPath));
} catch (ex) {}
try {
fs.statSync(targetPath);
} catch (ex) {
... | javascript | {
"resource": ""
} |
q27482 | isArray | train | function isArray (arr) {
return Array.isArray
? Array.isArray(arr)
: Object.prototype.toString.call(arr) === '[object Array]'
} | javascript | {
"resource": ""
} |
q27483 | train | function (info) { return Object.keys(info).reduce(function (escaped, key) {
var ref = info.__dangerouslyDisableSanitizers;
var isDisabled = ref && ref.indexOf(key) > -1;
var val = info[key];
escaped[key] = val;
if (key === '__dangerouslyDisableSanitizers') {
return escaped
}
... | javascript | {
"resource": ""
} | |
q27484 | VueMeta | train | function VueMeta (Vue, options) {
if ( options === void 0 ) options = {};
// set some default options
var defaultOptions = {
keyName: VUE_META_KEY_NAME,
attribute: VUE_META_ATTRIBUTE,
ssrAttribute: VUE_META_SERVER_RENDERED_ATTRIBUTE,
tagIDKeyName: VUE_META_TAG_LIST_ID_KEY_NAME
};
// combine o... | javascript | {
"resource": ""
} |
q27485 | encodeURIComponentPretty | train | function encodeURIComponentPretty (str) {
return encodeURI(str).replace(/[\/?#]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
} | javascript | {
"resource": ""
} |
q27486 | ansiHTML | train | function ansiHTML (text) {
// Returns the text if the string has no ANSI escape code.
if (!_regANSI.test(text)) {
return text
}
// Cache opened sequence.
var ansiCodes = []
// Replace with markup.
var ret = text.replace(/\033\[(\d+)*m/g, function (match, seq) {
var ot = _openTags[seq]
if (ot)... | javascript | {
"resource": ""
} |
q27487 | race$1 | train | function race$1(entries) {
/*jshint validthis:true */
var Constructor = this;
if (!isArray(entries)) {
return new Constructor(function (_, reject) {
return reject(new TypeError('You must pass an array to race.'));
});
} else {
return new Constructor(function (resolve, reject) {
var leng... | javascript | {
"resource": ""
} |
q27488 | arrayEachRight | train | function arrayEachRight(array, iteratee) {
var length = array == null ? 0 : array.length;
while (length--) {
if (iteratee(array[length], length, array) === false) {
break;
}
}
return array;
} | javascript | {
"resource": ""
} |
q27489 | arrayEvery | train | function arrayEvery(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (!predicate(array[index], index, array)) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} |
q27490 | baseFindKey | train | function baseFindKey(collection, predicate, eachFunc) {
var result;
eachFunc(collection, function(value, key, collection) {
if (predicate(value, key, collection)) {
result = key;
return false;
}
});
return result;
} | javascript | {
"resource": ""
} |
q27491 | baseIndexOfWith | train | function baseIndexOfWith(array, value, fromIndex, comparator) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (comparator(array[index], value)) {
return index;
}
}
return -1;
} | javascript | {
"resource": ""
} |
q27492 | charsStartIndex | train | function charsStartIndex(strSymbols, chrSymbols) {
var index = -1,
length = strSymbols.length;
while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
} | javascript | {
"resource": ""
} |
q27493 | charsEndIndex | train | function charsEndIndex(strSymbols, chrSymbols) {
var index = strSymbols.length;
while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
return index;
} | javascript | {
"resource": ""
} |
q27494 | setToPairs | train | function setToPairs(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
result[++index] = [value, value];
});
return result;
} | javascript | {
"resource": ""
} |
q27495 | lazyClone | train | function lazyClone() {
var result = new LazyWrapper(this.__wrapped__);
result.__actions__ = copyArray(this.__actions__);
result.__dir__ = this.__dir__;
result.__filtered__ = this.__filtered__;
result.__iteratees__ = copyArray(this.__iteratees__);
result.__takeCount__ = this.__takeCou... | javascript | {
"resource": ""
} |
q27496 | arraySampleSize | train | function arraySampleSize(array, n) {
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
} | javascript | {
"resource": ""
} |
q27497 | baseConforms | train | function baseConforms(source) {
var props = keys(source);
return function(object) {
return baseConformsTo(object, source, props);
};
} | javascript | {
"resource": ""
} |
q27498 | baseConformsTo | train | function baseConformsTo(object, source, props) {
var length = props.length;
if (object == null) {
return !length;
}
object = Object(object);
while (length--) {
var key = props[length],
predicate = source[key],
value = object[key];
if ((value... | javascript | {
"resource": ""
} |
q27499 | baseFill | train | function baseFill(array, value, start, end) {
var length = array.length;
start = toInteger(start);
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = (end === undefined || end > length) ? length : toInteger(end);
if (end < 0) {
end += length;
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.