_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,... | 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) {
processNe... | 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 ... | 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: ... | 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() {
callba... | 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.installedMod... | 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, par... | 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, c... | 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, ... | 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... | 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 ... | 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... | 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);
}
retur... | 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) {
... | 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", fil... | 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){};
... | 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 sen... | 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;
}... | 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('N... | 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(funcN... | 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 t... | 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 ... | 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 (~[2... | 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 = tagsToD... | 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(..... | 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}`, {}), ... | 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 = {
disabl... | 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, stat... | 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])
}
... | 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 obje... | 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 functio... | 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});... | 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.permissi... | 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: 'pres@skroob.com'
}
}
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 || !... | 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... | 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 += c... | 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];
... | 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
/... | 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 ( !b... | 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 \`... | 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-ne... | 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.serializ... | 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 chi... | 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,... | 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;
// ... | 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;
... | 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 a... | 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)
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.