_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q60700
|
runSession
|
validation
|
function runSession(evaluator, config) {
_session.signer = signers.create(config.signature_scheme, config.key);
_session.io = createSocket('pub', config.ip, config.iopub_port);
_session.shell = createSocket('xrep', config.ip, config.shell_port, messageHandler);
_session.control = createSocket('xrep', config.ip, config.control_port, messageHandler);
_session.evaluator = evaluator;
_session.handlers = handlers.create(_session);
createSocket('rep', config.ip, config.hb_port, heartbeatHandler);
}
|
javascript
|
{
"resource": ""
}
|
q60701
|
inspectCommand
|
validation
|
function inspectCommand(shell, args, data, evaluationId) {
if (args.names) {
args.names.forEach(function(n) {
console.log(n + ':');
console.dir(shell.state[n]);
console.log();
});
}
}
|
javascript
|
{
"resource": ""
}
|
q60702
|
addMessage
|
validation
|
function addMessage(message) {
var text = message.content ? message.content.code.trim() : '';
if (!text) {
return;
}
message.content.code = text;
_messages.push(message);
// If there is no message already being processed, go ahead and process this message
// immediately.
if (_idle) {
processNextMessage();
}
}
|
javascript
|
{
"resource": ""
}
|
q60703
|
textCommand
|
validation
|
function textCommand(shell, args, data, evaluationId) {
return dataCommand(shell, args, data, evaluationId, function(value) {
return value;
});
}
|
javascript
|
{
"resource": ""
}
|
q60704
|
jsonCommand
|
validation
|
function jsonCommand(shell, args, data, evaluationId) {
return dataCommand(shell, args, data, evaluationId, function(value) {
return JSON.parse(value);
});
}
|
javascript
|
{
"resource": ""
}
|
q60705
|
createGlobals
|
validation
|
function createGlobals(shell) {
var globals = {
Buffer: Buffer,
console: console,
clearImmediate: clearImmediate,
clearInterval: clearInterval,
clearTimeout: clearTimeout,
setImmediate: setImmediate,
setInterval: setInterval,
setTimeout: setTimeout,
_: ijsrt
};
globals.global = globals;
return globals;
}
|
javascript
|
{
"resource": ""
}
|
q60706
|
Shell
|
validation
|
function Shell(config) {
this.config = config;
this.commands = {};
this.runtime = ijsrt;
this.state = vm.createContext(createGlobals(this));
this.code = '';
require('../../node_modules/tern/plugin/node.js');
var ternOptions = {
defs: [require('../../node_modules/tern/defs/ecma5.json')],
plugins: { node: {} }
};
this.ternServer = new tern.Server(ternOptions);
}
|
javascript
|
{
"resource": ""
}
|
q60707
|
createShell
|
validation
|
function createShell(config, callback) {
var shell = new Shell(config);
modules.initialize(shell);
extensions.initialize(shell);
require('./commands').initialize(shell);
require('./displayCommands').initialize(shell);
require('./dataCommands').initialize(shell);
process.nextTick(function() {
callback(shell);
});
}
|
javascript
|
{
"resource": ""
}
|
q60708
|
moduleCommand
|
validation
|
function moduleCommand(shell, args, data, evaluationId) {
var deferred = shell.runtime.q.defer();
installer.install(args.name, shell.config.userPath, /* quiet */ false, function(error) {
if (error) {
deferred.reject(shell.createError('Could not install module'));
}
else {
shell.installedModules[args.name] = true;
deferred.resolve();
}
});
return deferred.promise;
}
|
javascript
|
{
"resource": ""
}
|
q60709
|
modulesCommand
|
validation
|
function modulesCommand(shell, args, data, evaluationId) {
var names = [];
for (var n in shell.installedModules) {
names.push(n);
}
console.log(names.join('\n'));
}
|
javascript
|
{
"resource": ""
}
|
q60710
|
initialize
|
validation
|
function initialize(shell) {
shell.requiredModules = {};
shell.installedModules = {};
shell.state.require = function(name) {
return customRequire(shell, name);
};
shell.registerCommand('module', moduleCommand);
shell.registerCommand('modules', modulesCommand);
}
|
javascript
|
{
"resource": ""
}
|
q60711
|
createMessage
|
validation
|
function createMessage(identities, header, parentHeader, metadata, content) {
return {
identities: identities,
header: header,
parentHeader: parentHeader,
metadata: metadata,
content: content
};
}
|
javascript
|
{
"resource": ""
}
|
q60712
|
createKernelInfoResponseMessage
|
validation
|
function createKernelInfoResponseMessage(parentMessage) {
var content = {
language: 'javascript',
language_version: [1,0],
protocol_version: [4,1]
};
return newMessage(_messageNames.kernelInfoResponse, parentMessage, content);
}
|
javascript
|
{
"resource": ""
}
|
q60713
|
createExecuteErrorResponseMessage
|
validation
|
function createExecuteErrorResponseMessage(parentMessage, executionCount, error, traceback) {
var content = {
status: 'error',
execution_count: executionCount,
ename: error.constructor.name,
evalue: error.toString(),
traceback: traceback
};
return newMessage(_messageNames.executeResponse, parentMessage, content);
}
|
javascript
|
{
"resource": ""
}
|
q60714
|
createExecuteSuccessResponseMessage
|
validation
|
function createExecuteSuccessResponseMessage(parentMessage, executionCount, metadata) {
var content = {
status: 'ok',
execution_count: executionCount,
payload: [],
user_variables: {},
user_expressions: {}
};
return newMessage(_messageNames.executeResponse, parentMessage, content, metadata);
}
|
javascript
|
{
"resource": ""
}
|
q60715
|
createCompleteInfoResponseMessage
|
validation
|
function createCompleteInfoResponseMessage(parentMessage, matchedText, matches, metadata) {
var content = {
status: 'ok',
matched_text: matchedText,
matches: matches
};
return newMessage(_messageNames.completeResponse, parentMessage, content, metadata);
}
|
javascript
|
{
"resource": ""
}
|
q60716
|
createDataMessage
|
validation
|
function createDataMessage(parentMessage, representations) {
var content = {
data: representations
};
return newMessage(_messageNames.displayData, parentMessage, content);
}
|
javascript
|
{
"resource": ""
}
|
q60717
|
readMessage
|
validation
|
function readMessage(socketData, signer) {
var identities = socketData[0];
var signature = socketData[2].toString();
var header = socketData[3];
var parentHeader = socketData[4];
var metadata = socketData[5];
var content = socketData[6];
if (!signer.validate(signature, [ header, parentHeader, metadata, content ])) {
return null;
}
return createMessage(identities,
JSON.parse(header),
JSON.parse(parentHeader),
JSON.parse(metadata),
JSON.parse(content));
}
|
javascript
|
{
"resource": ""
}
|
q60718
|
writeMessage
|
validation
|
function writeMessage(message, socket, signer) {
var header = JSON.stringify(message.header);
var parentHeader = JSON.stringify(message.parentHeader);
var metadata = JSON.stringify(message.metadata);
var content = JSON.stringify(message.content);
var signature = signer.sign([ header, parentHeader, metadata, content ]);
var socketData = [
message.identities,
'<IDS|MSG>',
signature,
header,
parentHeader,
metadata,
content
];
socket.send(socketData);
}
|
javascript
|
{
"resource": ""
}
|
q60719
|
htmlCommand
|
validation
|
function htmlCommand(shell, args, data, evaluationId) {
return shell.runtime.data.html(data);
}
|
javascript
|
{
"resource": ""
}
|
q60720
|
scriptCommand
|
validation
|
function scriptCommand(shell, args, data, evaluationId) {
return shell.runtime.data.script(data);
}
|
javascript
|
{
"resource": ""
}
|
q60721
|
kernelInfoHandler
|
validation
|
function kernelInfoHandler(message) {
var infoMessage = messages.kernelInfoResponse(message);
messages.write(infoMessage, _session.shell, _session.signer);
}
|
javascript
|
{
"resource": ""
}
|
q60722
|
createHandlers
|
validation
|
function createHandlers(session) {
_session = session;
_queue = queue.create(session);
var handlers = {};
handlers[messages.names.kernelInfoRequest] = kernelInfoHandler;
handlers[messages.names.shutdownRequest] = shutdownHandler;
handlers[messages.names.executeRequest] = executeHandler;
handlers[messages.names.completeRequest] = completeHandler;
return handlers;
}
|
javascript
|
{
"resource": ""
}
|
q60723
|
setupOutline
|
validation
|
function setupOutline() {
var markup = '<select id="tocDropDown" style="float: right"><option>Outline</option></select>';
IPython.toolbar.element.append(markup);
var tocDropDown = $('#tocDropDown');
tocDropDown.change(function(e) {
var index = tocDropDown.val();
if (index.length === '') {
return false;
}
var scrollTop = IPython.notebook.get_cell(0).element.position().top -
IPython.notebook.get_cell(parseInt(index)).element.position().top;
IPython.notebook.element.animate({ scrollTop: -scrollTop }, 250, 'easeInOutCubic');
tocDropDown.blur();
tocDropDown.find('option').get(0).selected = true;
return false;
});
function createOption(title, value, level) {
var prefix = level > 1 ? new Array(level + 1).join(' ') : '';
var text = prefix + IPython.utils.escape_html(title);
return '<option value="' + value + '">' + text + '</option>';
}
function updateOutline() {
var content = [];
content.push(createOption('Table of Contents', '', 0));
var cells = IPython.notebook.get_cells();
cells.forEach(function(c, i) {
if ((c.cell_type == 'heading') && (c.level <= 3)) {
var cell = $(c.element);
var header = cell.find('h' + c.level);
// Retrieve the title and strip off the trailing paragraph marker
var title = header.text();
title = title.substring(-1, title.length - 1);
if (title == 'Type Heading Here') {
// New cells have this placeholder text in them
return;
}
content.push(createOption(title, i, c.level));
}
});
var markup = content.join('');
tocDropDown.html(markup);
}
updateOutline();
$([IPython.events]).on('set_dirty.Notebook', function(event, data) {
updateOutline();
});
$([IPython.events]).on('command_mode.Cell', function(event, data) {
updateOutline();
});
}
|
javascript
|
{
"resource": ""
}
|
q60724
|
main
|
validation
|
function main() {
var parser = nomnom();
parser.script('ijs')
.nocolors()
.printer(function(s, code) {
console.log(s);
if (code) {
process.exit(code);
}
})
.option('version', {
abbr: 'v',
flag: true,
help: 'print version and exit',
callback: function() {
console.log('0.1.0');
process.exit(0);
}
})
.option('userPath', {
abbr: 'u',
full: 'userPath',
metavar: 'path',
type: 'string',
required: true,
help: 'path that will contain installed node modules',
callback: function(userPath) {
if (!fs.existsSync(userPath) || !fs.statSync(userPath).isDirectory()) {
return 'expected an existing directory for the userPath option';
}
return null;
}
})
.option('connectionFile', {
position: 0,
required: true,
help: 'path to file containing kernel connection information'
});
var options = parser.parse(process.argv.slice(2));
if (options) {
var shellConfig = {
userPath: options.userPath
};
var connectionConfig = JSON.parse(fs.readFileSync(options.connectionFile,
{ encoding: 'utf8' }));
Shell.create(shellConfig, function(shell) {
Session.run(shell, connectionConfig);
});
}
}
|
javascript
|
{
"resource": ""
}
|
q60725
|
computeSignature
|
validation
|
function computeSignature(values, signatureScheme, signatureKey) {
var hmac = crypto.createHmac(signatureScheme, signatureKey);
values.forEach(function(v) {
hmac.update(v);
});
return hmac.digest('hex');
}
|
javascript
|
{
"resource": ""
}
|
q60726
|
createSigner
|
validation
|
function createSigner(signatureScheme, signatureKey) {
if (signatureKey) {
// Create a SHA256-based signer that generates and validates signatures
signatureScheme = signatureScheme || 'sha256';
if (signatureScheme.indexOf('hmac-') === 0) {
signatureScheme = signatureScheme.substr(5);
}
return {
sign: function(values) {
return computeSignature(values, signatureScheme, signatureKey);
},
validate: function(signature, values) {
return signature === computeSignature(values, signatureScheme, signatureKey);
}
}
}
else {
// Create a no-op signer
return {
sign: function() { return ''; },
validate: function() { return true; }
}
}
}
|
javascript
|
{
"resource": ""
}
|
q60727
|
createError
|
validation
|
function createError() {
var e = new Error(util.format.apply(null, arguments));
e.trace = false;
return e;
}
|
javascript
|
{
"resource": ""
}
|
q60728
|
extensionCommand
|
validation
|
function extensionCommand(shell, args, data, evaluationId) {
var deferred = shell.runtime.q.defer();
var name = args.name;
var moduleName = 'ijs.ext.' + name;
var modulePath = args.path || moduleName;
installer.install(modulePath, shell.config.userPath, /* quiet */ true, function(error) {
if (error) {
deferred.reject(shell.createError('Unable to install extension module "%s"', moduleName));
}
else {
var extensionPath = path.join(shell.config.userPath, 'node_modules', moduleName);
var extension = require(extensionPath);
try {
extension.initialize(shell, function(error, result) {
if (error) {
deferred.reject(shell.createError('Error initializing extension'));
}
else {
shell.loadedExtensions[name] = true;
deferred.resolve(result);
}
});
}
catch(e) {
deferred.reject(shell.createError('Error initializing extension'));
}
}
})
return deferred.promise;
}
|
javascript
|
{
"resource": ""
}
|
q60729
|
extensionsCommand
|
validation
|
function extensionsCommand(shell, args, data, evaluationId) {
var names = [];
for (var n in shell.loadedExtensions) {
names.push(n);
}
console.log(names.join('\n'));
}
|
javascript
|
{
"resource": ""
}
|
q60730
|
initialize
|
validation
|
function initialize(shell) {
shell.loadedExtensions = {};
shell.registerCommand('extension', extensionCommand);
shell.registerCommand('extensions', extensionsCommand);
}
|
javascript
|
{
"resource": ""
}
|
q60731
|
validation
|
function (dest) {
if (grunt.util._.endsWith(dest, '/') || grunt.util._.endsWith(dest, '\\')) {
return 'directory';
} else {
return 'file';
}
}
|
javascript
|
{
"resource": ""
}
|
|
q60732
|
findFile
|
validation
|
function findFile(name, dir) {
dir = dir || process.cwd();
var filename = path.normalize(path.join(dir, name));
if (findFileResults[filename] !== undefined) {
return findFileResults[filename];
}
var parent = path.resolve(dir, "../");
if (shjs.test("-e", filename)) {
findFileResults[filename] = filename;
return filename;
}
if (dir === parent) {
findFileResults[filename] = null;
return null;
}
return findFile(name, parent);
}
|
javascript
|
{
"resource": ""
}
|
q60733
|
validation
|
function (view, offset, length) {
var trmOffset = lib.locateStrTrm.iso(view, offset, length);
if (trmOffset !== -1) { length = trmOffset - offset; }
return lib.readStr.iso(view, offset, length);
}
|
javascript
|
{
"resource": ""
}
|
|
q60734
|
validation
|
function (view, offset, length) {
var trmOffset = lib.locateStrTrm.ucs(view, offset, length);
if (trmOffset !== -1) { length = trmOffset - offset; }
return lib.readStr.ucs(view, offset, length);
}
|
javascript
|
{
"resource": ""
}
|
|
q60735
|
Mailto
|
validation
|
function Mailto(form, options){
/**
*
* @type {HTMLElement}
*/
this.form = null;
/**
*
* @type {boolean}
*/
this.preventDefault = true;
/**
*
* @type {Function}
*/
this.formatter = Mailto.defaultFormatter;
/**
*
* @type {Function}
*/
this.onSubmit = function(m){};
this.initFormObject(form);
this.initOptions(options);
this.initFormHandler();
}
|
javascript
|
{
"resource": ""
}
|
q60736
|
getMailtoUrl
|
validation
|
function getMailtoUrl(to, fields){
this.form.action.match(/mailto:([^\?&]+)/);
to = to || RegExp.$1 || '';
fields = fields || {
subject: this.form.getAttribute('data-subject') || '',
body: this.getBody()
};
if (!to && !fields.to){
throw new Error('Could not find any person to send an email to.');
}
return 'mailto:'+to+'?'+Object.keys(fields).reduce(function(a, b, i){
return a +
(i > 0 ? '&' : '') +
encodeURIComponent(b) + '=' +
encodeURIComponent(fields[b]).replace(/%0A(?!%)/g, '%0D%0A') + // fixing *nix line break encoding to follow RFC spec
(b === 'body' ? '%0D%0A' : '')
}, '');
}
|
javascript
|
{
"resource": ""
}
|
q60737
|
getFormData
|
validation
|
function getFormData(){
var form = this.form;
var selector = ['input', 'select', 'textarea'].join(',');
return [].slice.call(form.querySelectorAll(selector))
.filter(Mailto.formDataFilter)
.map(Mailto.formDataMapper(form));
}
|
javascript
|
{
"resource": ""
}
|
q60738
|
getData
|
validation
|
function getData(){
var data = {};
this.getFormData().forEach(function(d){
if (Array.isArray(data[d.name])){
data[d.name].push(d.value);
}
else if (data[d.name] !== undefined){
data[d.name] = [data[d.name], d.value];
}
else {
data[d.name] = d.value;
}
});
return data;
}
|
javascript
|
{
"resource": ""
}
|
q60739
|
getSerialisedData
|
validation
|
function getSerialisedData(){
var data = this.getFormData();
return data.length === 0 ? '' : '?' + data.map(function(f){
return encodeURIComponent(f.name) + '=' + encodeURIComponent(f.value);
}).join('&');
}
|
javascript
|
{
"resource": ""
}
|
q60740
|
registerXDiv
|
validation
|
function registerXDiv() {
// Create our 'x-div' Web Component Prototype
var xProto = Object.create(HTMLElement.prototype);
// Create methods for its lifecycle
xProto.attachedCallback = function () {
var scriptEl = document.createElement('script');
if (!this.dataset.controller) {
console.error('No controller specified for x-div.');
return;
}
scriptEl.src = getControllerSrc(this.dataset.controller);
scriptEl.async = true;
this.appendChild(scriptEl);
};
// Register the Element
document.registerElement('x-div', {
prototype: xProto
});
}
|
javascript
|
{
"resource": ""
}
|
q60741
|
processCondition
|
validation
|
function processCondition(condition, errorMessage) {
if (!condition) {
var completeErrorMessage = '';
var re = /at ([^\s]+)\s\(/g;
var stackTrace = new Error().stack;
var stackFunctions = [];
var funcName = re.exec(stackTrace);
while (funcName && funcName[1]) {
stackFunctions.push(funcName[1]);
funcName = re.exec(stackTrace);
}
// Number 0 is processCondition itself,
// Number 1 is assert,
// Number 2 is the caller function.
if (stackFunctions[2]) {
completeErrorMessage = stackFunctions[2] + ': ' + completeErrorMessage;
}
completeErrorMessage += errorMessage;
return completeErrorMessage;
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
q60742
|
Credulous
|
validation
|
function Credulous(options) {
var i
;
if (!this) {
return new Credulous(options);
}
options = validateOptions(options);
this.labels = options.labels;
this.dataLength = options.dataLength;
// For the label
this.trainArgumentsLength = this.dataLength + 1;
// TODO: make the data store more modular
this.dataStore = [];
setUpDataStore(this.dataStore, this.labels, this.dataLength);
this.instancesTrained = 0;
}
|
javascript
|
{
"resource": ""
}
|
q60743
|
setUpDataStore
|
validation
|
function setUpDataStore(dataStore, labels, dataLength) {
var i
;
for (i = 0; i < dataLength; i++) {
dataStore[i] = {
words: {}
, labels: {}
};
labels.forEach(function (label) {
dataStore[i].labels[label] = 0;
});
}
}
|
javascript
|
{
"resource": ""
}
|
q60744
|
argMax
|
validation
|
function argMax(array) {
var maxIndex = 0
, i
;
for (i = 0; i < array.length; i++) {
if (array[i] > array[maxIndex]) {
maxIndex = i;
}
}
return maxIndex;
}
|
javascript
|
{
"resource": ""
}
|
q60745
|
processDataItems
|
validation
|
function processDataItems(items) {
var processedItems = []
;
// TODO: do stemming here
items.forEach(function (item, i) {
processedItems[i] = processString(item);
});
return processedItems;
}
|
javascript
|
{
"resource": ""
}
|
q60746
|
addLabel
|
validation
|
function addLabel(label, self) {
if (!(label in self.labels)) {
self.labels[label] = 1;
}
else {
self.labels[label]++;
}
}
|
javascript
|
{
"resource": ""
}
|
q60747
|
fromFile
|
validation
|
function fromFile(filename, callback) {
var configFile = filename || '../config/winston-config.json';
fs.exists(configFile, function (exists) {
if (exists) {
var winstonConf = require(configFile).logging;
fromJson(winstonConf, callback);
} else {
callback(new Error('No config file found (at least provide a config/winston-config.json) with winston configuration'), winston);
}
});
}
|
javascript
|
{
"resource": ""
}
|
q60748
|
Debug
|
validation
|
function Debug(...rest) {
if (new.target) {
/**
* @param id
* @param stats
* @param rest
*/
this.debug = (id, stats, ...rest) => {
debug(id)(...rest);
};
return;
}
return new Debug(...rest);
}
|
javascript
|
{
"resource": ""
}
|
q60749
|
log
|
validation
|
function log(ctx, start, len, err, event) {
// get the status code of the response
const status = err ? (err.status || 500) : (ctx.status || 404);
// set the color of the status code;
const s = status / 100 | 0;
const color = colorCodes[s];
// get the human readable response length
let length;
if (~[204, 205, 304].indexOf(status)) {
length = "";
} else if (null == len) {
length = "-";
} else {
length = bytes(len);
}
const upstream = err ? chalk.red("xxx")
: event === "end" ? chalk.yellow("-x-")
: chalk.gray("-->");
logger.debug(`${upstream} ${chalk.bold(ctx.method)} ${chalk.gray(ctx.originalUrl)} ${chalk[color](status)} ${chalk.gray(time(start))} ${chalk.gray(length)}`);
}
|
javascript
|
{
"resource": ""
}
|
q60750
|
sendMessage
|
validation
|
function sendMessage(id, level, fallbackToLog, ...rest) {
const levelMethod = level.toLowerCase();
const options = buildMessageOptions(id);
const tagsToDisable = get(configRegistry, 'tags.disable', []);
const namespaceTags = get(configRegistry, `namespaces.${id}.tags`, []);
const containsDisabledTag = tagsToDisable.some((element) => {
return namespaceTags.indexOf(element) > -1;
});
if (options.disable.indexOf(level) > -1 ||
containsDisabledTag) {
// if global or logger's setting is saying to disable logging, proceed silently
if (!!configRegistry.verbose) {
console.log(`Level ${level} or namespace ID ${id} has been disabled. skipping...`);
}
return;
}
const [, , stats, ...args] = applyPlugins(pluginsRegistry, id, level, calcStats(), ...rest);
wrappers.concat(options.wrappers)
.forEach((wrapper) => {
const restOrArgs = equalsWrapperOptValue(wrapper, 'passInitialArguments', true) ? rest : args;
const plugins = extractWrapperPlugins(wrapper);
const [, , wrapperStats, ...wrapperArgs] = applyPlugins(plugins, id, level, stats, ...restOrArgs);
if (typeof wrapper[levelMethod] === 'function') {
// use specific logging method if exists, for example, wrapper.info()
return wrapper[levelMethod](id, wrapperStats, ...wrapperArgs);
} else if (typeof wrapper.log === 'function' && !!fallbackToLog) {
// use generic log method, if fallbackToLog === true. It is always equal to TRUE for standard levels
return wrapper.log(id, level, wrapperStats, ...wrapperArgs);
}
if (!!configRegistry.verbose) {
console.log(`Wrapper has no valid logging method. fallbackToLog is equal ${fallbackToLog}. skipping...`);
}
});
}
|
javascript
|
{
"resource": ""
}
|
q60751
|
calcStats
|
validation
|
function calcStats() {
return {
maxIdLength: Math.max(...Object.keys(loggers).map((l) => l.length))
};
}
|
javascript
|
{
"resource": ""
}
|
q60752
|
createLogger
|
validation
|
function createLogger(id) {
let log = (level, fallbackToLog, ...rest) => sendMessage(id, level, fallbackToLog, ...rest);
return {
get id() {
return id;
},
silly(...rest) {
log(LEVELS.SILLY, true, ...rest);
},
debug(...rest) {
log(LEVELS.DEBUG, true, ...rest);
},
info(...rest) {
log(LEVELS.INFO, true, ...rest);
},
warn(...rest) {
log(LEVELS.WARN, true, ...rest);
},
error(...rest) {
log(LEVELS.ERROR, true, ...rest);
},
// CAUTION: experimental feature
send(level, ...rest) {
log(level, false, ...rest);
}
}
}
|
javascript
|
{
"resource": ""
}
|
q60753
|
getLogger
|
validation
|
function getLogger(id, { disable = [], wrappers = [], tags = [] } = {}) {
let config = {
disable: normalizeArray(disable).map(v => v + ''),
wrappers: normalizeArray(wrappers),
tags: normalizeArray(tags)
};
set(configRegistry, `namespaces.${id}`, deepmerge(get(configRegistry, `namespaces.${id}`, {}), config, deepMergeOptions));
return loggers[id] || (loggers[id] = createLogger(id));
}
|
javascript
|
{
"resource": ""
}
|
q60754
|
configure
|
validation
|
function configure({ useGlobal = true, disable = [], namespaces = {}, tags = {}, verbose = false } = {}, override = false) {
const config = Object.create(null);
config.useGlobal = !!useGlobal;
config.disable = normalizeArray(disable).map(v => v + '');
config.namespaces = namespaces;
config.tags = {
disable: normalizeArray(get(tags, 'disable', []))
};
config.verbose = verbose;
configRegistry = override ? config : deepmerge(configRegistry, config, deepMergeOptions);
}
|
javascript
|
{
"resource": ""
}
|
q60755
|
addPlugin
|
validation
|
function addPlugin(useLevel, fn) {
let pluginFn = fn;
if (typeof fn === 'undefined' && typeof useLevel === 'function') {
pluginFn = useLevel;
}
if (typeof pluginFn !== 'function') {
throw new Error('Plugin must be a function!');
}
if (typeof useLevel === 'string') {
pluginFn = (id, level, stats, ...rest) => {
if (level === useLevel.toUpperCase()) {
return fn(id, level, stats, ...rest);
}
return [id, level, stats, ...rest];
};
}
pluginsRegistry.push(pluginFn);
}
|
javascript
|
{
"resource": ""
}
|
q60756
|
validation
|
function(objects, options) {
var self = this
objects.forEach(function(object) {
self.cache[object._id] = object
})
return objects
}
|
javascript
|
{
"resource": ""
}
|
|
q60757
|
validation
|
function(options) {
var self = this
var result = []
if (options._id) {
var id = Array.isArray(options._id) ? options._id : [options._id]
id.forEach(function(id) {
if (self.cache[id]) {
result.push(self.cache[id])
}
})
} else {
result = Object.keys(this.cache).map(function(k) {
return self.cache[k]
}).sort(function(count1, count2) {
return count1._id - count2._id
})
if (options.skip || options.limit) {
var skip = options.skip || 0
var limit = options.limit || 0
return result.slice(skip, skip + limit)
}
}
return result
}
|
javascript
|
{
"resource": ""
}
|
|
q60758
|
validation
|
function(objects, options) {
var idSet = new Set(objects.map(function(object) {
return object._id
}))
if (idSet.length < objects.length) {
throw new this.getService().errors.BadRequest('Duplicate IDs')
}
this.cache = objects
return objects
}
|
javascript
|
{
"resource": ""
}
|
|
q60759
|
validation
|
function(object, options) {
var created = typeof this.cache[object._id] === 'undefined'
this.cache[object._id] = object
return {
created: created,
val: object
}
}
|
javascript
|
{
"resource": ""
}
|
|
q60760
|
validation
|
function(update, options) {
var count = 0
for (var id in this.cache) {
count += 1
if (update.$inc) {
this.cache[id].count += update.$inc
} else {
this.cache[id].count -= update.$dec
}
}
return count
}
|
javascript
|
{
"resource": ""
}
|
|
q60761
|
validation
|
function(options) {
var objects = []
for (var id in this.cache) {
objects.push(this.cache[id])
}
this.cache = {}
return objects
}
|
javascript
|
{
"resource": ""
}
|
|
q60762
|
validation
|
function(update, options) {
var count = 0
for (var id in this.cache) {
this.cache[id].count += update.n
count += 1
}
// demonstrate full return type
return {val: count, created: false}
}
|
javascript
|
{
"resource": ""
}
|
|
q60763
|
validation
|
function(object, options) {
return this.collection.findOneAndReplace(
{_id: object._id}, object, {returnOriginal: false}).value
}
|
javascript
|
{
"resource": ""
}
|
|
q60764
|
addHandler
|
validation
|
function addHandler(cls, replacer, reviver) {
if (typeof cls !== "function") {
throw new TypeError("'cls' must be class/function");
}
if (typeof replacer !== "function") {
throw new TypeError("'replacer' must be function");
}
if (typeof reviver !== "function") {
throw new TypeError("'reviver' must be function");
}
__handlers[cls.name] = {
cls: cls,
replacer: replacer,
reviver: reviver
};
}
|
javascript
|
{
"resource": ""
}
|
q60765
|
ifStatusOk
|
validation
|
function ifStatusOk(response, fulfill, reject) {
var responseCode = response.code;
if (isClientError(responseCode)) {
reject({name : "ClientErrorException", message : response.body});
} else if (isServerError(responseCode)) {
reject({name : "ServerErrorException", message : response.error});
} else if (isOtherErrorResponse(responseCode)) {
reject({name : "OtherCommunicationException", message : response.error});
} else {
fulfill(response.body)
}
}
|
javascript
|
{
"resource": ""
}
|
q60766
|
validation
|
function(endpoint, all) {
if (!_.isNil(endpoint)) {
all = _.assignIn(
_.clone(allEndpointParameters(endpoint.parent, endpoint.parameters)),
all || {})
}
return all
}
|
javascript
|
{
"resource": ""
}
|
|
q60767
|
AposGroups
|
validation
|
function AposGroups(options) {
var self = this;
aposSchemas.addFieldType({
name: 'a2Permissions',
displayer: function(snippet, name, $field, $el, field, callback) {
_.each(apos.data.aposGroups.permissions, function(permission) {
$el.findByName(permission.value).val(_.contains(snippet.permissions || [], permission.value) ? '1' : '0');
});
return callback();
},
converter: function(data, name, $field, $el, field, callback) {
_.each(apos.data.aposGroups.permissions, function(permission) {
data[permission.value] = $el.findByName(permission.value).val();
});
return callback();
}
});
aposSchemas.addFieldType({
name: 'a2People',
displayer: function(snippet, name, $field, $el, field, callback) {
var source = aposPages.getType('people')._action + '/autocomplete';
$.jsonCall(source, {
values: _.map(snippet.people || [], function(person) {
return person._id;
})
}, function(results) {
var labelMap = {};
_.each(results, function(result) {
labelMap[result.value] = result.label;
});
$el.find('[data-name="people"]').selective({
sortable: options.peopleSortable,
extras: field.extras,
source: source,
data: _.map(snippet._people || [], function(person) {
var label = labelMap[person._id];
var data = { label: label, value: person._id };
if (person.groupExtras && person.groupExtras[snippet._id]) {
$.extend(true, data, person.groupExtras[snippet._id]);
}
return data;
})
});
return callback();
});
},
converter: function(data, name, $field, $el, field, callback) {
data._peopleInfo = $el.find('[data-name="people"]').selective('get', { incomplete: true });
return callback();
}
});
AposSnippets.call(self, options);
self.addingToManager = function($el, $snippet, snippet) {
$snippet.find('[data-published]').val(snippet.published ? 'Yes' : 'No');
};
}
|
javascript
|
{
"resource": ""
}
|
q60768
|
validation
|
function(p){
var isRollLeft = roll==null || roll.getDepth()>=1
if(roll){
roll.up()
}
if(isRollLeft){
next()
}else{
callback(null, null, resultStatus)//could not be found
//fail()
}
}
|
javascript
|
{
"resource": ""
}
|
|
q60769
|
figureOutWhoUserIs
|
validation
|
function figureOutWhoUserIs(req) {
// just stubbing this out here
var username = req.query.username
if (username === 'skroob') {
return {
username: username,
email: '[email protected]'
}
}
throw new HttpErrors.Unauthorized()
}
|
javascript
|
{
"resource": ""
}
|
q60770
|
tryApplyUpdates
|
validation
|
function tryApplyUpdates(onHotUpdateSuccess) {
if (!module.hot) {
// HotModuleReplacementPlugin is not in Webpack configuration.
window.location.reload();
return;
}
if (!isUpdateAvailable() || !canApplyUpdates()) {
return;
}
function handleApplyUpdates(err, updatedModules) {
if (err || !updatedModules) {
window.location.reload();
return;
}
if (typeof onHotUpdateSuccess === 'function') {
// Maybe we want to do something.
onHotUpdateSuccess();
}
if (isUpdateAvailable()) {
// While we were updating, there was a new update! Do it again.
tryApplyUpdates();
}
}
// https://webpack.github.io/docs/hot-module-replacement.html#check
var result = module.hot.check(/* autoApply */true, handleApplyUpdates);
// // Webpack 2 returns a Promise instead of invoking a callback
if (result && result.then) {
result.then(
function(updatedModules) {
handleApplyUpdates(null, updatedModules);
},
function(err) {
handleApplyUpdates(err, null);
}
);
}
}
|
javascript
|
{
"resource": ""
}
|
q60771
|
logMessage
|
validation
|
function logMessage (message, data) {
if (!message) return
render(message, data, function (err, res) {
if (err) {
console.error('\n Error when rendering template complete message: ' + err.message.trim())
} else {
console.log(`\nTo get started:`)
console.log('')
console.log(`${chalk.gray(' ------------------')}`)
console.log(' ' + res.split(/\r?\n/g).map(function (line) {
return `${chalk.blue(line)}`
}).join('\n'))
console.log(`${chalk.gray(' ------------------')}`)
console.log('')
console.log(`More infomation: ${chalk.blue.underline('fe -h')}`)
}
})
}
|
javascript
|
{
"resource": ""
}
|
q60772
|
interceptWriteStream
|
validation
|
function interceptWriteStream(writeStream) {
return new Promise((resolve, reject) => {
let response = "";
let writeBkp = writeStream.write;
let sendBkp = writeStream.send; // For express response streams
let endBkp = writeStream.end;
writeStream.write = function(chunk, encoding, callback) {
response += chunk;
if(typeof encoding == "function") {
encoding();
} else if(callback) {
callback();
}
return true;
};
writeStream.send = function(body) {
writeStream.end(body);
};
writeStream.end = function(chunk, encoding, callback) {
if(chunk) {
response += chunk;
}
writeStream.write = writeBkp;
writeStream.send = sendBkp;
writeStream.end = endBkp;
if(typeof encoding == "function") {
writeStream.once("finish", encoding);
} else if(callback) {
writeStream.once("finish", encoding);
}
resolve(response);
};
});
}
|
javascript
|
{
"resource": ""
}
|
q60773
|
getRandomMusic
|
validation
|
function getRandomMusic(queue, msg) {
fs.readFile('./data/autoplaylist.txt', 'utf8', function(err, data) {
if (err) throw err;
con('OK: autoplaylist.txt');
var random = data.split('\n');
var num = getRandomInt(random.length);
con(random[num])
var url = random[num];
msg.author.username = "AUTOPLAYLIST";
play(msg, queue, url)
});
}
|
javascript
|
{
"resource": ""
}
|
q60774
|
formatMessage
|
validation
|
function formatMessage(message) {
var lines = message.split('\n');
// line #0 is filename
// line #1 is the main error message
if (!lines[0] || !lines[1]) {
return message;
}
// Remove webpack-specific loader notation from filename.
// Before:
// ./~/css-loader!./~/postcss-loader!./src/App.css
// After:
// ./src/App.css
if (lines[0].lastIndexOf('!') !== -1) {
lines[0] = lines[0].substr(lines[0].lastIndexOf('!') + 1);
}
// Cleans up verbose "module not found" messages for files and packages.
if (lines[1].indexOf('Module not found: ') === 0) {
lines = [
lines[0],
// Clean up message because "Module not found: " is descriptive enough.
lines[1].replace(
'Cannot resolve \'file\' or \'directory\' ', ''
).replace(
'Cannot resolve module ', ''
).replace(
'Error: ', ''
),
// Skip all irrelevant lines.
// (For some reason they only appear on the client in browser.)
'',
lines[lines.length - 1] // error location is the last line
]
}
// Cleans up syntax error messages.
if (lines[1].indexOf('Module build failed: ') === 0) {
// For some reason, on the client messages appear duplicated:
// https://github.com/webpack/webpack/issues/3008
// This won't happen in Node but since we share this helpers,
// we will dedupe them right here. We will ignore all lines
// after the original error message text is repeated the second time.
var errorText = lines[1].substr('Module build failed: '.length);
var cleanedLines = [];
var hasReachedDuplicateMessage = false;
// Gather lines until we reach the beginning of duplicate message.
lines.forEach(function(line, index) {
if (
// First time it occurs is fine.
index !== 1 &&
// line.endsWith(errorText)
line.length >= errorText.length &&
line.indexOf(errorText) === line.length - errorText.length
) {
// We see the same error message for the second time!
// Filter out repeated error message and everything after it.
hasReachedDuplicateMessage = true;
}
if (
!hasReachedDuplicateMessage ||
// Print last line anyway because it contains the source location
index === lines.length - 1
) {
// This line is OK to appear in the output.
cleanedLines.push(line);
}
});
// We are clean now!
lines = cleanedLines;
// Finally, brush up the error message a little.
lines[1] = lines[1].replace(
'Module build failed: SyntaxError:',
friendlySyntaxErrorLabel
);
}
// Reassemble the message.
message = lines.join('\n');
// Internal stacks are generally useless so we strip them
message = message.replace(
/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, ''
); // at ... ...:x:y
return message;
}
|
javascript
|
{
"resource": ""
}
|
q60775
|
resolveBot
|
validation
|
function resolveBot(bot) {
let isWaterfall = ("function" == typeof bot) || Array.isArray(bot);
if (isWaterfall) {
let dialog = bot;
let connector = new TestConnector();
bot = new builder.UniversalBot(connector);
bot.dialog('/', dialog);
} else if (bot instanceof builder.UniversalBot) {
if ( !bot.connector()) {
bot.connector('console', new TestConnector());
}
} else {
throw new Error(`Unknown type of bot/dialog. Error: ${JSON.stringify(bot)}`);
}
return bot;
}
|
javascript
|
{
"resource": ""
}
|
q60776
|
BlockSerializer
|
validation
|
function BlockSerializer(props) {
const {node, serializers, options, isInline, children} = props
const blockType = node._type
const serializer = serializers.types[blockType]
if (!serializer) {
throw new Error(
`Unknown block type "${blockType}", please specify a serializer for it in the \`serializers.types\` prop`
)
}
return h(serializer, {node, options, isInline}, children)
}
|
javascript
|
{
"resource": ""
}
|
q60777
|
SpanSerializer
|
validation
|
function SpanSerializer(props) {
const {mark, children} = props.node
const isPlain = typeof mark === 'string'
const markType = isPlain ? mark : mark._type
const serializer = props.serializers.marks[markType]
if (!serializer) {
// @todo Revert back to throwing errors?
// eslint-disable-next-line no-console
console.warn(
`Unknown mark type "${markType}", please specify a serializer for it in the \`serializers.marks\` prop`
)
return h(props.serializers.markFallback, null, children)
}
return h(serializer, props.node, children)
}
|
javascript
|
{
"resource": ""
}
|
q60778
|
ListSerializer
|
validation
|
function ListSerializer(props) {
const tag = props.type === 'bullet' ? 'ul' : 'ol'
return h(tag, null, props.children)
}
|
javascript
|
{
"resource": ""
}
|
q60779
|
ListItemSerializer
|
validation
|
function ListItemSerializer(props) {
const children =
!props.node.style || props.node.style === 'normal'
? // Don't wrap plain text in paragraphs inside of a list item
props.children
: // But wrap any other style in whatever the block serializer says to use
h(props.serializers.types.block, props, props.children)
return h('li', null, children)
}
|
javascript
|
{
"resource": ""
}
|
q60780
|
BlockTypeSerializer
|
validation
|
function BlockTypeSerializer(props) {
const style = props.node.style || 'normal'
if (/^h\d/.test(style)) {
return h(style, null, props.children)
}
return style === 'blockquote'
? h('blockquote', null, props.children)
: h('p', null, props.children)
}
|
javascript
|
{
"resource": ""
}
|
q60781
|
serializeSpan
|
validation
|
function serializeSpan(span, serializers, index, options) {
if (span === '\n' && serializers.hardBreak) {
return h(serializers.hardBreak, {key: `hb-${index}`})
}
if (typeof span === 'string') {
return serializers.text ? h(serializers.text, {key: `text-${index}`}, span) : span
}
let children
if (span.children) {
children = {
children: span.children.map((child, i) =>
options.serializeNode(child, i, span.children, true)
)
}
}
const serializedNode = objectAssign({}, span, children)
return h(serializers.span, {
key: span._key || `span-${index}`,
node: serializedNode,
serializers
})
}
|
javascript
|
{
"resource": ""
}
|
q60782
|
validation
|
function () {
var el = this.el;
this.lastPosition = el.getAttribute('position');
this.lastRotation = el.getAttribute('rotation');
this.lastScale = el.getAttribute('scale');
this.lerpingPosition = false;
this.lerpingRotation = false;
this.lerpingScale = false;
this.timeOfLastUpdate = 0;
}
|
javascript
|
{
"resource": ""
}
|
|
q60783
|
validation
|
function (time, deltaTime) {
var progress;
var now = this.now();
var obj3d = this.el.object3D;
this.checkForComponentChanged();
// Lerp position
if (this.lerpingPosition) {
progress = (now - this.startLerpTimePosition) / this.duration;
obj3d.position.lerpVectors(this.startPosition, this.targetPosition, progress);
// console.log("new position", obj3d.position);
if (progress >= 1) {
this.lerpingPosition = false;
}
}
// Slerp rotation
if (this.lerpingRotation) {
progress = (now - this.startLerpTimeRotation) / this.duration;
THREE.Quaternion.slerp(this.startRotation, this.targetRotation, obj3d.quaternion, progress);
if (progress >= 1) {
this.lerpingRotation = false;
}
}
// Lerp scale
if (this.lerpingScale) {
progress = (now - this.startLerpTimeScale) / this.duration;
obj3d.scale.lerpVectors(this.startScale, this.targetScale, progress);
if (progress >= 1) {
this.lerpingScale = false;
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q60784
|
validation
|
function(datamodel, variables) {
traverse(datamodel).forEach(function(path) {
//console.log(path);
if (this.isLeaf && objectPath.has(variables, path)) {
this.update(objectPath.get(variables, path));
}
});
return datamodel;
}
|
javascript
|
{
"resource": ""
}
|
|
q60785
|
validation
|
function(element) {
this.el = element;
this.core = window.lgData[this.el.getAttribute('lg-uid')];
// Execute only if items are above 1
if (this.core.items.length < 2) {
return false;
}
this.core.s = Object.assign({}, autoplayDefaults, this.core.s);
this.interval = false;
// Identify if slide happened from autoplay
this.fromAuto = true;
// Identify if autoplay canceled from touch/drag
this.canceledOnTouch = false;
// save fourceautoplay value
this.fourceAutoplayTemp = this.core.s.fourceAutoplay;
// do not allow progress bar if browser does not support css3 transitions
if (!this.core.doCss()) {
this.core.s.progressBar = false;
}
this.init();
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q60786
|
bufferContents
|
validation
|
function bufferContents(file, enc, cb) {
// ignore empty files
if (file.isNull()) {
return cb();
}
// no streams
if (file.isStream()) {
this.emit('error', new PluginError('gulp-livingcss', 'Streaming not supported'));
return cb();
}
files.push(file.path);
cb();
}
|
javascript
|
{
"resource": ""
}
|
q60787
|
two
|
validation
|
function two(context, next) {
setTimeout(function() {
context.two = 'Hello';
console.log('Hello from two', context);
return next();
}, 1000);
}
|
javascript
|
{
"resource": ""
}
|
q60788
|
next
|
validation
|
function next() {
var middleware = chain.shift();
if (middleware && typeof middleware === 'function') {
middleware.call(this, context, next);
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
q60789
|
one
|
validation
|
function one(context, next) {
setTimeout(function() {
context.one = 'Hello';
console.log('Hello from one', context);
return next();
}, 1000);
console.log('Hi from one', context);
}
|
javascript
|
{
"resource": ""
}
|
q60790
|
two
|
validation
|
function two(context, next) {
context.two = 'Hello';
console.log('Hello from two', context);
console.log('Hi from two', context);
return next();
}
|
javascript
|
{
"resource": ""
}
|
q60791
|
three
|
validation
|
function three(context, next) {
console.log('Hi from three', context);
setTimeout(function() {
context.three = 'Hello';
console.log('Hello from three', context);
}, 1000);
}
|
javascript
|
{
"resource": ""
}
|
q60792
|
two
|
validation
|
function two(context, next) {
setTimeout(function() {
context.two = 'Hello';
console.log('Hello from two', context);
chain({ nested: 'Hello' }, [ one, three ]);
return next();
}, 1000);
}
|
javascript
|
{
"resource": ""
}
|
q60793
|
ExpressView
|
validation
|
function ExpressView(view) {
this.render = (options, callback) => {
const variables = { ...options._locals, ...options };
callback(null, view(variables));
};
this.path = view.id;
}
|
javascript
|
{
"resource": ""
}
|
q60794
|
tryMatchSequence
|
validation
|
function tryMatchSequence(key) {
seq.keys.push(key.name);
// remember when last key was entered so we can decide if it counts as sequence or not
var m = vim.map.matchInsert(seq.keys)
// assume we'll match no complete sequence and therefore will want to print keyed char
, passThru = true;
if (!m) {
// in case we buffered some keys hoping for a complete sequence, loose hope now
self.clearSequence();
} else if (m === true) {
// we hope for a future match
} else if (matchSequence(m)) {
// we matched our sequence and therefore will not print the char
passThru = false;
}
if (passThru) seq.last = new Date();
return passThru;
}
|
javascript
|
{
"resource": ""
}
|
q60795
|
mat3from4
|
validation
|
function mat3from4(out, mat4x4) {
out[0][0] = mat4x4[0]
out[0][1] = mat4x4[1]
out[0][2] = mat4x4[2]
out[1][0] = mat4x4[4]
out[1][1] = mat4x4[5]
out[1][2] = mat4x4[6]
out[2][0] = mat4x4[8]
out[2][1] = mat4x4[9]
out[2][2] = mat4x4[10]
}
|
javascript
|
{
"resource": ""
}
|
q60796
|
filter
|
validation
|
function filter(fn, ctx) {
assert.equal(typeof fn, 'function')
return function(val) {
val = Array.isArray(val) ? val : [val]
return Promise.resolve(val.filter(fn, ctx))
}
}
|
javascript
|
{
"resource": ""
}
|
q60797
|
validation
|
function(rawValue) {
const value = stringifyInput(rawValue);
if (!value.match(FORMAT)) {
throw new Error('Invalid data format; expecting: \'' + FORMAT + '\', found: \'' + value + '\'');
}
return mod97(value);
}
|
javascript
|
{
"resource": ""
}
|
|
q60798
|
sendMessage
|
validation
|
async function sendMessage(
app,
context,
title,
message,
{update = '', updateAfterDays = 7, owner, repo} = {}
) {
if (!app || !context || !title || !message) {
throw new Error('Required parameter missing');
}
if (!owner || !repo) {
({owner, repo} = context.repo());
}
const appGh = await app.auth();
const {name: appName, html_url: appUrl} = (await appGh.apps.get({})).data;
const {data: issues} = await context.github.issues.getForRepo({
owner,
repo,
state: 'open',
creator: `app/${appName}`,
per_page: 100
});
message = message.replace(/{appName}/, appName).replace(/{appUrl}/, appUrl);
const messageHash = crypto
.createHash('sha256')
.update(message)
.digest('hex');
const messageHashRx = new RegExp(`<!--${messageHash}-->`);
for (const issue of issues) {
if (!messageHashRx.test(issue.body)) {
continue;
}
let commentId = null;
if (
update &&
!issue.locked &&
Date.now() - Date.parse(issue.updated_at) >=
updateAfterDays * 24 * 60 * 60 * 1000
) {
update = update.replace(/{appName}/, appName).replace(/{appUrl}/, appUrl);
const {data: commentData} = await context.github.issues.createComment({
owner,
repo,
number: issue.number,
body: update
});
commentId = commentData.id;
}
return new Message(owner, repo, issue.number, commentId, false);
}
title = title.replace(/{appName}/, appName).replace(/{appUrl}/, appUrl);
const {data: issueData} = await context.github.issues.create({
owner,
repo,
title,
body: `${message}\n<!--${messageHash}-->`
});
return new Message(owner, repo, issueData.number, null, true);
}
|
javascript
|
{
"resource": ""
}
|
q60799
|
packageStatesSerialize
|
validation
|
function packageStatesSerialize () {
if (atom.packages.serialize != null) {
return atom.packages.serialize()
}
atom.packages.getActivePackages().forEach((pack) => {
var state
if (pack.serialize != null) state = pack.serialize()
if (state) {
atom.packages.setPackageState(pack.name, state)
}
})
return atom.packages.packageStates
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.