_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q44800 | approveWallet | train | function approveWallet(wallet, xPubKey, account, arrWalletDefinitionTemplate, arrOtherCosigners, onDone){
var arrDeviceAddresses = getDeviceAddresses(arrWalletDefinitionTemplate);
device.addIndirectCorrespondents(arrOtherCosigners, function(){
addWallet(wallet, xPubKey, account, arrWalletDefinitionTemplate, functio... | javascript | {
"resource": ""
} |
q44801 | deleteWallet | train | function deleteWallet(wallet, rejector_device_address, onDone){
db.query("SELECT approval_date FROM extended_pubkeys WHERE wallet=? AND device_address=?", [wallet, rejector_device_address], function(rows){
if (rows.length === 0) // you are not a member device
return onDone();
if (rows[0].approval_date) // you'v... | javascript | {
"resource": ""
} |
q44802 | addNewAddress | train | function addNewAddress(wallet, is_change, address_index, address, handleError){
breadcrumbs.add('addNewAddress is_change='+is_change+', index='+address_index+', address='+address);
db.query("SELECT 1 FROM wallets WHERE wallet=?", [wallet], function(rows){
if (rows.length === 0)
return handleError("wallet "+walle... | javascript | {
"resource": ""
} |
q44803 | issueOrSelectNextAddress | train | function issueOrSelectNextAddress(wallet, is_change, handleAddress){
readNextAddressIndex(wallet, is_change, function(next_index){
if (next_index < MAX_BIP44_GAP)
return issueAddress(wallet, is_change, next_index, handleAddress);
readLastUsedAddressIndex(wallet, is_change, function(last_used_index){
if (last... | javascript | {
"resource": ""
} |
q44804 | readAddressInfo | train | function readAddressInfo(address, handleAddress){
db.query("SELECT address_index, is_change FROM my_addresses WHERE address=?", [address], function(rows){
if (rows.length === 0)
return handleAddress("address "+address+" not found");
handleAddress(null, rows[0]);
});
} | javascript | {
"resource": ""
} |
q44805 | sendPrivatePayments | train | function sendPrivatePayments(device_address, arrChains, bForwarded, conn, onSaved){
var body = {chains: arrChains};
if (bForwarded)
body.forwarded = true;
device.sendMessageToDevice(device_address, "private_payments", body, {
ifOk: function(){},
ifError: function(){},
onSaved: onSaved
}, conn);
} | javascript | {
"resource": ""
} |
q44806 | fixIsSpentFlag | train | function fixIsSpentFlag(onDone){
db.query(
"SELECT outputs.unit, outputs.message_index, outputs.output_index \n\
FROM outputs \n\
CROSS JOIN inputs ON outputs.unit=inputs.src_unit AND outputs.message_index=inputs.src_message_index AND outputs.output_index=inputs.src_output_index \n\
WHERE is_spent=0 AND type='... | javascript | {
"resource": ""
} |
q44807 | createLinkProof | train | function createLinkProof(later_unit, earlier_unit, arrChain, cb){
storage.readJoint(db, later_unit, {
ifNotFound: function(){
cb("later unit not found");
},
ifFound: function(objLaterJoint){
var later_mci = objLaterJoint.unit.main_chain_index;
arrChain.push(objLaterJoint);
storage.readUnitProps(db, o... | javascript | {
"resource": ""
} |
q44808 | getAppsDataDir | train | function getAppsDataDir(){
switch(process.platform){
case 'win32': return process.env.LOCALAPPDATA;
case 'linux': return process.env.HOME + '/.config';
case 'darwin': return process.env.HOME + '/Library/Application Support';
default: throw Error("unknown platform "+process.platform);
}
} | javascript | {
"resource": ""
} |
q44809 | replaceWitness | train | function replaceWitness(old_witness, new_witness, handleResult){
if (!ValidationUtils.isValidAddress(new_witness))
return handleResult("new witness address is invalid");
readMyWitnesses(function(arrWitnesses){
if (arrWitnesses.indexOf(old_witness) === -1)
return handleResult("old witness not known");
if (arr... | javascript | {
"resource": ""
} |
q44810 | sendSignature | train | function sendSignature(device_address, signed_text, signature, signing_path, address){
device.sendMessageToDevice(device_address, "signature", {signed_text: signed_text, signature: signature, signing_path: signing_path, address: address});
} | javascript | {
"resource": ""
} |
q44811 | train | function(){
console.log("handleOnlinePrivatePayment queued, will wait for "+key);
eventBus.once(key, function(bValid){
if (!bValid)
return cancelAllKeys();
assocValidatedByKey[key] = true;
if (bParsingComplete)
checkIfAllValidated();
else
console.log('parsing incom... | javascript | {
"resource": ""
} | |
q44812 | readFundedAndSigningAddresses | train | function readFundedAndSigningAddresses(
asset, wallet, estimated_amount, spend_unconfirmed, fee_paying_wallet,
arrSigningAddresses, arrSigningDeviceAddresses, handleFundedAndSigningAddresses)
{
readFundedAddresses(asset, wallet, estimated_amount, spend_unconfirmed, function(arrFundedAddresses){
if (arrFundedAddr... | javascript | {
"resource": ""
} |
q44813 | checkStability | train | function checkStability() {
db.query(
"SELECT is_stable, asset, SUM(amount) AS `amount` \n\
FROM outputs JOIN units USING(unit) WHERE address=? AND sequence='good' AND is_spent=0 GROUP BY asset ORDER BY asset DESC LIMIT 1",
[addrInfo.address],
function(rows){
if (rows.length === 0) {
cb("This te... | javascript | {
"resource": ""
} |
q44814 | claimBackOldTextcoins | train | function claimBackOldTextcoins(to_address, days){
db.query(
"SELECT mnemonic FROM sent_mnemonics LEFT JOIN unit_authors USING(address) \n\
WHERE mnemonic!='' AND unit_authors.address IS NULL AND creation_date<"+db.addTime("-"+days+" DAYS"),
function(rows){
async.eachSeries(
rows,
function(row, cb){
... | javascript | {
"resource": ""
} |
q44815 | CreateProfileRequest | train | function CreateProfileRequest(properties) {
this.profileType = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
... | javascript | {
"resource": ""
} |
q44816 | UpdateProfileRequest | train | function UpdateProfileRequest(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
... | javascript | {
"resource": ""
} |
q44817 | Deployment | train | function Deployment(properties) {
this.labels = {};
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[... | javascript | {
"resource": ""
} |
q44818 | ValueType | train | function ValueType(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q44819 | Sample | train | function Sample(properties) {
this.locationId = [];
this.value = [];
this.label = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
... | javascript | {
"resource": ""
} |
q44820 | Label | train | function Label(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q44821 | Mapping | train | function Mapping(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q44822 | Line | train | function Line(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q44823 | Function | train | function Function(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | {
"resource": ""
} |
q44824 | onTimeout | train | function onTimeout() {
const listenerCount = socket.listeners('timeout').length;
debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s',
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
getSocketTimeout(socket), listenerCount);
agent.time... | javascript | {
"resource": ""
} |
q44825 | runWithProgress | train | function runWithProgress(maybeTaskFn, inSuite)
{
return Task.asyncFunction(function(callback) {
var bjsSuite = new Benchmark.Suite;
var benchArray;
var retData = [];
var finalString = "";
var numCompleted = 0;
... | javascript | {
"resource": ""
} |
q44826 | getOverallBarChart | train | function getOverallBarChart(){
var contextMenuActions = [{
name: 'Explore windmill',
action: function(ae, splitBy, timestamp) {
explore(splitBy);
}
}]
var endDate = new Date(Math.floor((new Date()).valueOf()/(1000*60*60*24))*(1000*60*60*24));
var startDat... | javascript | {
"resource": ""
} |
q44827 | train | function (response) {
document.getElementById("windmillWeather").innerHTML = "<div>Current conditions</div>" + '<img class="icon" src="https://openweathermap.org/img/w/' + response.weather[0].icon + '.png' + '"><span>' + response.weather[0].main + ", Temp: " + response.main.temp + "'c, Wind: " + response.wind... | javascript | {
"resource": ""
} | |
q44828 | getUpdatedEmittedFiles | train | function getUpdatedEmittedFiles(emittedFiles, webpackRuntimeFiles) {
let fallbackFiles = [];
let hotHash;
if (emittedFiles.some(x => x.endsWith('.hot-update.json'))) {
let result = emittedFiles.slice();
const hotUpdateScripts = emittedFiles.filter(x => x.endsWith('.hot-update.js'));
... | javascript | {
"resource": ""
} |
q44829 | parseHotUpdateChunkName | train | function parseHotUpdateChunkName(name) {
const matcher = /^(.+)\.(.+)\.hot-update/gm;
const matches = matcher.exec(name);
return {
name: matches[1] || "",
hash: matches[2] || "",
};
} | javascript | {
"resource": ""
} |
q44830 | remove | train | function remove(id, callback) {
repo.contents(id).fetch({
ref: options.branch
}, function(err, info) {
if (err) return callback(err);
repo.contents(id).remove({
branch: options.branch,
sha: info.sha,
message: '-'
... | javascript | {
"resource": ""
} |
q44831 | get | train | function get(id, callback) {
_getSHA(id, function(err, sha) {
if (err) return callback(err);
repo.git.blobs(sha).fetch(function(err, res) {
if (err) return callback(err);
callback(err, JSON.parse(atob(res.content)));
});
});
} | javascript | {
"resource": ""
} |
q44832 | _getSHA | train | function _getSHA(id, callback) {
repo.contents("").fetch({
ref: options.branch
}, function(err, res) {
if (err) return callback(err);
var sha = res.reduce(function(previousValue, item) {
return item.name === id ? item.sha : previousValue;
}... | javascript | {
"resource": ""
} |
q44833 | processInput | train | function processInput(buffer, cb) {
if (buffer.length == 0) return buffer;
var split_char = '\n';
var lines = buffer.split(split_char);
// If there are any line splits, the below logic always works, but if there are none we need to detect this and skip
// any processing.
if (lines[0].length == b... | javascript | {
"resource": ""
} |
q44834 | handleProduceResponse | train | function handleProduceResponse(cb, err, res) {
num_responses += 1;
if (err) {
console.log("Error producing message: " + err);
} else {
num_messages_acked += 1;
}
// We can only indicate were done if stdin was closed and we have no outstanding messages.
checkSendingComplete(cb);
... | javascript | {
"resource": ""
} |
q44835 | getParts | train | function getParts (component, options) {
let {
modules = [],
package: pack,
path: packPath = COMPONENTS_DIRNAME,
transform,
fileName,
locale,
global = []
} = options
if (pack && fileName) {
modules.push({ package: pack, path: packPath, transform, fileName })
}
if (locale !== ... | javascript | {
"resource": ""
} |
q44836 | patchContent | train | function patchContent (content, parts) {
return Object.keys(parts).reduce((content, type) => {
let paths = parts[type].filter(({ valid }) => valid).map(({ path }) => path)
return patchType(content, type, paths)
}, content)
} | javascript | {
"resource": ""
} |
q44837 | pushPart | train | function pushPart (parts, file) {
let ext = getExtname(file.path)
let type = Object.keys(EXT_TYPES).find(key => {
return EXT_TYPES[key].includes(ext)
})
parts[type.toLowerCase()].push(file)
} | javascript | {
"resource": ""
} |
q44838 | patchType | train | function patchType (content, type, peerPaths) {
let normalizedPaths = peerPaths.map(path => slash(normalize(path)))
switch (type) {
case 'script':
let scriptImports = normalizedPaths.map(path => `import '${path}'\n`)
content = content.replace(RE_SCRIPT, match => {
return `${match}\n${scriptI... | javascript | {
"resource": ""
} |
q44839 | assurePath | train | async function assurePath (modulePath, resolve) {
if (resolveCache[modulePath] === false) {
return false
} else if (!(modulePath in resolveCache)) {
if (typeof resolve === 'function') {
try {
resolveCache[modulePath] = !!(await resolve(modulePath))
} catch (e) {
resolveCache[modu... | javascript | {
"resource": ""
} |
q44840 | assurePathSync | train | function assurePathSync (modulePath, resolveSync) {
if (resolveCache[modulePath] === false) {
return false
} else if (!(modulePath in resolveCache)) {
if (typeof resolveSync === 'function') {
try {
resolveCache[modulePath] = !!resolveSync(modulePath)
} catch (e) {
resolveCache[mo... | javascript | {
"resource": ""
} |
q44841 | getPeerFilename | train | function getPeerFilename (
name,
{ transform = 'kebab-case', template = '{module}.css' }
) {
if (!name) {
return null
}
switch (transform) {
case 'kebab-case':
name = kebabCase(name)
break
case 'camelCase':
name = camelCase(name)
break
case 'PascalCase':
name = p... | javascript | {
"resource": ""
} |
q44842 | GeoComplete | train | function GeoComplete(input, options) {
this.options = $.extend(true, {}, defaults, options);
// This is a fix to allow types:[] not to be overridden by defaults
// so search results includes everything
if (options && options.types) {
this.options.types = options.types;
}
this.input = in... | javascript | {
"resource": ""
} |
q44843 | train | function(){
if (!this.options.map){ return; }
if (typeof this.options.map.setCenter == "function"){
this.map = this.options.map;
return;
}
this.map = new google.maps.Map(
$(this.options.map)[0],
this.options.mapOptions
);
// add click event listener... | javascript | {
"resource": ""
} | |
q44844 | train | function(){
if (!this.map){ return; }
var options = $.extend(this.options.markerOptions, { map: this.map });
if (options.disabled){ return; }
this.marker = new google.maps.Marker(options);
google.maps.event.addListener(
this.marker,
'dragend',
$.proxy(this.marker... | javascript | {
"resource": ""
} | |
q44845 | train | function(){
// Indicates is user did select a result from the dropdown.
var selected = false;
var options = {
types: this.options.types,
bounds: this.options.bounds === true ? null : this.options.bounds,
componentRestrictions: this.options.componentRestrictions,
stric... | javascript | {
"resource": ""
} | |
q44846 | train | function(){
if (!this.options.details){ return; }
if(this.options.detailsScope) {
var $details = $(this.input).parents(this.options.detailsScope).find(this.options.details);
} else {
var $details = $(this.options.details);
}
var attribute = this.options.detailsAttribute,
... | javascript | {
"resource": ""
} | |
q44847 | train | function() {
var location = this.options.location, latLng;
if (!location) { return; }
if (typeof location == 'string') {
this.find(location);
return;
}
if (location instanceof Array) {
latLng = new google.maps.LatLng(location[0], location[1]);
}
if ... | javascript | {
"resource": ""
} | |
q44848 | train | function(request){
// Don't geocode if the requested address is empty
if (!request.address) {
return;
}
if (this.options.bounds && !request.bounds){
if (this.options.bounds === true){
request.bounds = this.map && this.map.getBounds();
} else {
request.... | javascript | {
"resource": ""
} | |
q44849 | train | function() {
//$(".pac-container").hide();
var selected = '';
// Check if any result is selected.
if ($(".pac-item-selected")[0]) {
selected = '-selected';
}
// Get the first suggestion's text.
var $span1 = $(".pac-container:visible .pac-item" + selected + ":first spa... | javascript | {
"resource": ""
} | |
q44850 | train | function(geometry){
if (geometry.viewport){
this.map.fitBounds(geometry.viewport);
if (this.map.getZoom() > this.options.maxZoom){
this.map.setZoom(this.options.maxZoom);
}
} else {
this.map.setZoom(this.options.maxZoom);
this.map.setCenter(geometry.location... | javascript | {
"resource": ""
} | |
q44851 | train | function(result){
var data = {},
geometry = result.geometry,
viewport = geometry.viewport,
bounds = geometry.bounds;
// Create a simplified version of the address components.
$.each(result.address_components, function(index, object){
var name = object.types[0];
... | javascript | {
"resource": ""
} | |
q44852 | train | function(){
this.marker.setPosition(this.data.location);
this.setDetail(this.details.lat, this.data.location.lat());
this.setDetail(this.details.lng, this.data.location.lng());
} | javascript | {
"resource": ""
} | |
q44853 | train | function(){
var place = this.autocomplete.getPlace();
this.selected = true;
if (!place.geometry){
if (this.options.autoselect) {
// Automatically selects the highlighted item or the first item from the
// suggestions list.
var autoSelection = this.selectFirstResu... | javascript | {
"resource": ""
} | |
q44854 | train | function(req, res) {
if (!searchIdx) return res();
var results = searchIdx.search(req.term)
.map(function(result) {
return {
label: files[result.ref].title,
value: files[result.ref]
};
});
res(results);
} | javascript | {
"resource": ""
} | |
q44855 | train | function(event, ui) {
search.val('');
window.location = ui.item.value.url.replace('_gh_pages', '');
return false;
} | javascript | {
"resource": ""
} | |
q44856 | plugin | train | function plugin(name) {
return function(app) {
var files = app.getViews(name);
for (var file in files) {
if (files[file].data.draft) delete files[file];
}
};
} | javascript | {
"resource": ""
} |
q44857 | handleError | train | function handleError(err) {
if (typeof err === 'string' && errors[err]) {
console.error(errors[err]);
} else {
if (argv.verbose) {
console.error(err.stack);
} else {
console.error(err.message);
}
}
process.exit(1);
} | javascript | {
"resource": ""
} |
q44858 | concat | train | function concat(app) {
var files = app.views.files;
var css = '';
for (var file in files) {
if ('.css' != path.extname(file)) continue;
css += files[file].contents.toString();
delete files[file];
}
css = myth(css);
app.files.addView('index.css', {
contents: new Buffer(css)
});
} | javascript | {
"resource": ""
} |
q44859 | rename | train | function rename(files) {
return function(file) {
var base = path.relative(path.resolve(file.cwd), file.base);
var destBase = files.options.destBase;
file.dirname = path.resolve(path.join(destBase, base));
return file.base;
};
} | javascript | {
"resource": ""
} |
q44860 | Assemble | train | function Assemble(options) {
if (!(this instanceof Assemble)) {
return new Assemble(options);
}
Core.call(this, options);
this.is('assemble');
this.initAssemble();
} | javascript | {
"resource": ""
} |
q44861 | ask | train | function ask(cb) {
return function(app) {
app.use(store('smithy'))
.use(questions())
.ask(function(err, answers) {
if (err) return cb(err);
cb.call(app, null, answers);
});
app.asyncHelper('ask', function(key, options, cb) {
app.questions.options.force = true;
a... | javascript | {
"resource": ""
} |
q44862 | throwEqualError | train | function throwEqualError( F, a, b ) {
if ( (F[a] || F[b]) && (F[a] === F[b]) ) {
throw new Error(a);
}
} | javascript | {
"resource": ""
} |
q44863 | toFixed | train | function toFixed ( value, decimals ) {
var scale = Math.pow(10, decimals);
return ( Math.round(value * scale) / scale).toFixed( decimals );
} | javascript | {
"resource": ""
} |
q44864 | formatTo | train | function formatTo ( decimals, thousand, mark, prefix, postfix, encoder, decoder, negativeBefore, negative, edit, undo, input ) {
var originalInput = input, inputIsNegative, inputPieces, inputBase, inputDecimals = '', output = '';
// Apply user encoder to the input.
// Expected outcome: number.
if ( encoder ) ... | javascript | {
"resource": ""
} |
q44865 | formatFrom | train | function formatFrom ( decimals, thousand, mark, prefix, postfix, encoder, decoder, negativeBefore, negative, edit, undo, input ) {
var originalInput = input, inputIsNegative, output = '';
// User defined pre-decoder. Result must be a non empty string.
if ( undo ) {
input = undo(input);
}
// Test the inp... | javascript | {
"resource": ""
} |
q44866 | validate | train | function validate ( inputOptions ) {
var i, optionName, optionValue,
filteredOptions = {};
for ( i = 0; i < FormatOptions.length; i+=1 ) {
optionName = FormatOptions[i];
optionValue = inputOptions[optionName];
if ( optionValue === undefined ) {
// Only default if negativeBefore isn't set.
i... | javascript | {
"resource": ""
} |
q44867 | passAll | train | function passAll ( options, method, input ) {
var i, args = [];
// Add all options in order of FormatOptions
for ( i = 0; i < FormatOptions.length; i+=1 ) {
args.push(options[FormatOptions[i]]);
}
// Append the input, then call the method, presenting all
// options as arguments.
args.push(input);
r... | javascript | {
"resource": ""
} |
q44868 | formatDate | train | function formatDate ( date ) {
return weekdays[date.getDay()] + ", " +
date.getDate() + nth(date.getDate()) + " " +
months[date.getMonth()] + " " +
date.getFullYear();
} | javascript | {
"resource": ""
} |
q44869 | train | function () {
function commons() {}
commons.attachParentSelector = function (parentSelector, defaultSelector) {
var customSelector = defaultSelector;
if (parentSelector !== '' && parentSelector.length > 0) {
if (parentSelector === defaultSelector) {
customSelector = defaultSelector;
} else if ($(paren... | javascript | {
"resource": ""
} | |
q44870 | _inherits | train | function _inherits(SubClass, SuperClass) {
if (typeof SuperClass !== "function" && SuperClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof SuperClass);
}
SubClass.prototype = new SuperClass();
} | javascript | {
"resource": ""
} |
q44871 | onNavBarToggle | train | function onNavBarToggle() {
$(Selector.NAVBAR_SIDEBAR).toggleClass(ClassName.OPEN);
if (($(Selector.NAVBAR_SIDEBAR).hasClass(ClassName.NAVBAR_SIDEBAR)) && $(Selector.NAVBAR_SIDEBAR).hasClass(ClassName.OPEN)) {
$(Selector.OVERLAY).addClass(ClassName.OVERLAY_ACTIVE);
$(Selector.BOD... | javascript | {
"resource": ""
} |
q44872 | onResizeWindow | train | function onResizeWindow(e) {
var options = e.data.param1;
var sideBarSelector=Selector.SIDEBAR;
$(sideBarSelector).each(function () {
var $this = $(this);
var sideBarId = $this.attr("id");
var isOpenWidth=$("a[data-target="+sideBarId+"]").attr("is-open-width");
if($(window).width()<isOpenWidth) {
... | javascript | {
"resource": ""
} |
q44873 | localMiddleware | train | function localMiddleware (req, res, next) {
// Tell the client what Socket.IO namespace to use,
// trim the leading slash because the cookie will turn it into a %2F
res.setHeader('uibuilder-namespace', node.ioNamespace)
res.cookie('uibuilder-namespace', tilib.trimSlashes(... | javascript | {
"resource": ""
} |
q44874 | train | function(msg, node, RED, io, ioNs, log) {
node.rcvMsgCount++
log.verbose(`[${node.url}] msg received via FLOW. ${node.rcvMsgCount} messages received`, msg)
// If the input msg is a uibuilder control msg, then drop it to prevent loops
if ( msg.hasOwnProperty('uibuilderCtrl') ) return nul... | javascript | {
"resource": ""
} | |
q44875 | validateChoices | train | function validateChoices(props, propName, componentName) {
const propValue = props[propName];
if (!propValue) {
return undefined;
}
if (!Array.isArray(propValue) || propValue.length !== 2) {
return new Error(`Invalid ${propName} supplied to \`${componentName}\`, expected exactly two Choice components.`... | javascript | {
"resource": ""
} |
q44876 | updatePseudoClassStyle | train | function updatePseudoClassStyle(styleId, properties, preventFocusStyleForTouchAndClick) {
let focusStyle;
if (preventFocusStyleForTouchAndClick) {
focusStyle = { outline: 0 };
} else {
focusStyle = {
...style.focusStyle,
...properties.focusStyle,
};
}
const styles = [
{
id: ... | javascript | {
"resource": ""
} |
q44877 | updatePseudoClassStyle | train | function updatePseudoClassStyle(styleId, properties, preventFocusStyleForTouchAndClick) {
const baseStyle = properties.primary ? buttonStyle.primaryStyle : buttonStyle.style;
const baseDisabledStyle = properties.primary ? buttonStyle.primaryDisabledStyle : buttonStyle.disabledStyle;
const disabledStyle = {
..... | javascript | {
"resource": ""
} |
q44878 | validateChildrenAreOptionsAndMaximumOnePlaceholder | train | function validateChildrenAreOptionsAndMaximumOnePlaceholder(props, propName, componentName) {
const validChildren = filterReactChildren(props[propName], (node) => (
(isOption(node) || isSeparator(node) || isPlaceholder(node))
));
if (React.Children.count(props[propName]) !== React.Children.count(validChildren... | javascript | {
"resource": ""
} |
q44879 | updatePseudoClassStyle | train | function updatePseudoClassStyle(styleId, properties) {
const hoverStyle = {
...style.hoverStyle,
...properties.hoverStyle,
};
const disabledHoverStyle = {
...style.disabledHoverStyle,
...properties.disabledHoverStyle,
};
const styles = [
{
id: styleId,
style: hoverStyle,
... | javascript | {
"resource": ""
} |
q44880 | updateStructure | train | function updateStructure(targetObject, object) {
for (const componentName in object) {
if (object.hasOwnProperty(componentName)) {
for (const styleName in object[componentName]) {
if (object[componentName].hasOwnProperty(styleName)) {
targetObject[componentName][styleName] = object[compone... | javascript | {
"resource": ""
} |
q44881 | flattenInternal | train | function flattenInternal(output, element) {
if (element) {
element.forEach((obj) => {
if (Array.isArray(obj)) {
flattenInternal(output, obj);
} else {
output.push(obj);
}
});
}
} | javascript | {
"resource": ""
} |
q44882 | createMarkupOnPseudoClass | train | function createMarkupOnPseudoClass(pseudoClasses, id, disabled) {
return mapObject(pseudoClasses, (style, pseudoClass) => {
if (style && Object.keys(style).length > 0) {
const styleString = CSSPropertyOperations.createMarkupForStyles(style);
const styleWithImportant = styleString.replace(/;/g, ' !impo... | javascript | {
"resource": ""
} |
q44883 | filterFunc | train | function filterFunc(inputValue, optionValue) {
if (inputValue && optionValue) {
return optionValue.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
}
return false;
} | javascript | {
"resource": ""
} |
q44884 | calculateStyling | train | function calculateStyling(node) {
const reactId = node.getAttribute('data-reactid');
// calculate the computed style only once it's not in the cache
if (!computedStyleCache[reactId]) {
// In order to work with legacy browsers the second paramter for pseudoClass
// has to be provided http://caniuse.com/#f... | javascript | {
"resource": ""
} |
q44885 | sanitizeChildProps | train | function sanitizeChildProps(properties) {
const childProps = omit(properties, Object.keys(textInputPropTypes));
if (typeof properties.valueLink === 'object') {
childProps.value = properties.valueLink.value;
}
return childProps;
} | javascript | {
"resource": ""
} |
q44886 | isBuffer | train | function isBuffer(obj) {
return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
} | javascript | {
"resource": ""
} |
q44887 | copyFromBuffer | train | function copyFromBuffer(n, list) {
var ret = Buffer.allocUnsafe(n);
var p = list.head;
var c = 1;
p.data.copy(ret);
n -= p.data.length;
while (p = p.next) {
var buf = p.data;
var nb = n > buf.length ? buf.length : n;
buf.copy(ret, ret.length - n, 0, nb);
n -= nb;
if (n === 0) ... | javascript | {
"resource": ""
} |
q44888 | Hash | train | function Hash (blockSize, finalSize) {
this._block = Buffer$4.alloc(blockSize);
this._finalSize = finalSize;
this._blockSize = blockSize;
this._len = 0;
} | javascript | {
"resource": ""
} |
q44889 | write | train | function write(buffer, offs) {
for (var i = 2; i < arguments.length; i++) {
for (var j = 0; j < arguments[i].length; j++) {
buffer[offs++] = arguments[i].charAt(j);
}
}
} | javascript | {
"resource": ""
} |
q44890 | crc32 | train | function crc32(png, offs, size) {
var crc = -1;
for (var i = 4; i < size-4; i += 1) {
crc = _crc32[(crc ^ png[offs+i].charCodeAt(0)) & 0xff] ^ ((crc >> 8) & 0x00ffffff);
}
write(png, offs+size-4, byte4(crc ^ -1));
} | javascript | {
"resource": ""
} |
q44891 | searchText | train | async function searchText(node, callback, query, limit) {
var cursor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
var desc = arguments[5];
var seen = {};
console.log('cursor', cursor, 'query', query, 'desc', desc);
var q = desc ? { '<': cursor, '-': desc } : { '>': cursor, '... | javascript | {
"resource": ""
} |
q44892 | MediumClient | train | function MediumClient(options) {
this._enforce(options, ['clientId', 'clientSecret'])
this._clientId = options.clientId
this._clientSecret = options.clientSecret
this._accessToken = ""
} | javascript | {
"resource": ""
} |
q44893 | getResults | train | function getResults () {
return getHtmls(URLS).then(htmls => {
return getScrapersResults(SCRAPERS, URLS, htmls).then(results => results)
})
} | javascript | {
"resource": ""
} |
q44894 | getScrapersResults | train | function getScrapersResults (SCRAPERS, urls, htmls) {
return Promise.all(
SCRAPERS.map(SCRAPER => {
return getScraperResults(SCRAPER, urls, htmls).then(results => {
return {
name: SCRAPER.name,
results: results
}
})
})
)
} | javascript | {
"resource": ""
} |
q44895 | getScraperResults | train | function getScraperResults (SCRAPER, urls, htmls) {
return Promise.all(
urls.map((url, i) => {
const html = htmls[i]
const name = SCRAPER.name
const Module = require(name)
return SCRAPER.scrape(Module, url, html).then(metadata => {
return SCRAPER.normalize(metadata)
})
})... | javascript | {
"resource": ""
} |
q44896 | getHtmls | train | function getHtmls (urls) {
return Promise.all(urls.map(url => got(url).then(res => res.body)))
} | javascript | {
"resource": ""
} |
q44897 | union | train | function union(xs, ys) {
var obj = {};
for (var i = 0; i < xs.length; i++) {
obj[xs[i]] = true;
}
for (var j = 0; j < ys.length; j++) {
obj[ys[j]] = true;
}
var keys = [];
for (var k in obj) {
if ({}.hasOwnProperty.call(obj, k)) {
keys.push(k);
}
}
keys.sort();
return keys;
} | javascript | {
"resource": ""
} |
q44898 | rangeFromIndexAndOffsets | train | function rangeFromIndexAndOffsets(i, before, after, length) {
return {
// Guard against the negative upper bound for lines included in the output.
from: i - before > 0 ? i - before : 0,
to: i + after > length ? length : i + after
};
} | javascript | {
"resource": ""
} |
q44899 | PREFIX | train | function PREFIX(operatorsParser, nextParser) {
let parser = P.lazy(() => {
return P.seq(operatorsParser, parser).or(nextParser);
});
return parser;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.