_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q35300 | train | function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
{
editor.addCommand( commandName, command );
// If the "menu" plugin is loaded, register the menu item.
editor.addMenuItem( commandName,
{
label : buttonLabel,
command : commandName,
group : menugroup... | javascript | {
"resource": ""
} | |
q35301 | handlePermissionUpdate | train | function handlePermissionUpdate() {
permissionArea.find("form").submit(function (e) {
e.preventDefault();
//console.log(e);
var form = e.currentTarget;
appendFormFields(form);
Rocket.Util.submitFormAsync(form, function (response... | javascript | {
"resource": ""
} |
q35302 | addManifest | train | function addManifest(file, options) {
file = file || '/app.manifest';
var stream = new Transform({objectMode: true});
var domains = {};
var hostProtocols = {};
stream._transform = function (page, _, callback) {
if (!(options && options.justManifests)) {
if (page.statusCode !== 404 || url.resolve(pa... | javascript | {
"resource": ""
} |
q35303 | report | train | function report(){
if(responses < 1) return;
var dt = new Date - starttime;
console.log(
'%s invokes per second, avg request time: %s ms, worst: %s ms, best: %s ms, invokes without response in queue: %s',
(responses/dt*1000).toFixed(2),
(totaltime/responses).toFixed(2),
maxtime,
mintime,
Obje... | javascript | {
"resource": ""
} |
q35304 | train | function (path) {
'use strict';
path = fs.realpathSync(path);
var config = require(path);
this.setData(config, false);
return this;
} | javascript | {
"resource": ""
} | |
q35305 | train | function (path) {
'use strict';
path = fs.realpathSync(path);
var updateConf = require(path);
this.setData(updateConf, true);
return this;
} | javascript | {
"resource": ""
} | |
q35306 | train | function (key) {
'use strict';
var value = conf[key];
if (!isStr(key)) {
throw new Error(confKeyStrMsg, 'config-manager');
}
if (key.indexOf('.') !== -1) {
value = getNestedValue(conf, key);
}
if (isObj(value)) {
if (isExtension... | javascript | {
"resource": ""
} | |
q35307 | train | function (key, value) {
'use strict';
var obj;
if (!isStr(key)) {
throw new Error(confKeyStrMsg, 'config-manager');
}
if (key.indexOf('.') === -1) {
conf[key] = value;
} else {
obj = getLastNodeKey(key, conf);
obj.node[obj.k... | javascript | {
"resource": ""
} | |
q35308 | formatStream | train | function formatStream(options) {
if (!_.isObject(options)) {
options = {};
}
var statsOptions = options.verbose === true ? _.defaults(options, DEFAULT_VERBOSE_STATS_OPTIONS) : _.defaults(options, DEFAULT_STATS_OPTIONS);
if (!gutil.colors.supportsColor) {
statsOptions.colors = false;
... | javascript | {
"resource": ""
} |
q35309 | parseString | train | function parseString(input) {
var stripped = input.substring(1, input.length - 1);
return stripped.replace(/\\(\w|\\)/gi, function(_, b) {
switch (b) {
case '\\r': return '\r';
case '\\n': return '\n';
case '\\t': return '\t';
case '\\0': return '\0';
... | javascript | {
"resource": ""
} |
q35310 | parseSwitchType | train | function parseSwitchType(lex) {
var start = lex.accept('switchtype');
if (!start) {
return null;
}
var expr = parseExpression(lex);
lex.assert('{');
var cases = [];
var end;
do {
let c = parseSwitchTypeCase(lex);
cases.push(c);
} while (!(end = lex.accept('}... | javascript | {
"resource": ""
} |
q35311 | parseSwitchTypeCase | train | function parseSwitchTypeCase(lex) {
var start = lex.assert('case');
var type = parseType(lex);
lex.assert('{');
var body = parseStatements(lex, '}', false);
var end = lex.assert('}');
return new nodes.SwitchTypeCaseNode(type, body, start.start, end.end);
} | javascript | {
"resource": ""
} |
q35312 | parseStatement | train | function parseStatement(lex, isRoot = false) {
return parseFunctionDeclaration(lex) ||
isRoot && parseOperatorStatement(lex) ||
isRoot && parseObjectDeclaration(lex) ||
parseIf(lex) ||
parseReturn(lex) ||
isRoot && parseExport(lex) ||
isRoot && parse... | javascript | {
"resource": ""
} |
q35313 | parseStatements | train | function parseStatements(lex, endTokens, isRoot) {
endTokens = Array.isArray(endTokens) ? endTokens : [endTokens];
var statements = [];
var temp = lex.peek();
while (endTokens.indexOf(temp) === -1 &&
(temp.type && endTokens.indexOf(temp.type) === -1)) {
var statement = parseStatement(... | javascript | {
"resource": ""
} |
q35314 | requestAsync | train | function requestAsync(resource, opts = {}) {
const settings = {
followRedirect: true,
encoding: null,
rejectUnauthorized: false
};
if (opts.user && opts.pass) {
settings.headers = {Authorization: 'Basic ' + token(opts.user, opts.pass)};
}
return new Bluebird((resolve, reject) => {
// Han... | javascript | {
"resource": ""
} |
q35315 | readAsync | train | function readAsync(resource) {
return fs.readFile(resource).then(body => {
const mimeType = mime.getType(resource);
debug('Fetched:', resource);
return Bluebird.resolve({
contents: body,
path: resource,
mime: mimeType
});
});
} | javascript | {
"resource": ""
} |
q35316 | checkMissingDir | train | function checkMissingDir(destinationFile) {
var filePath = path.dirname(destinationFile);
var pathAbsolute = path.isAbsolute(filePath);
var directories = filePath.split(path.sep);
return transversePath(directories);
} | javascript | {
"resource": ""
} |
q35317 | generateCache | train | function generateCache(filePath) {
var id = generateIdFromFilePath(filePath);
Debug._l(id);
fs.readFile(filePath, 'utf8', function (err, data) {
if (err) {
Debug._l("err: " + err);
return;
}
fs.stat(filePath, function (err, stat) {
setCache(id, {mo... | javascript | {
"resource": ""
} |
q35318 | train | function (options) {
if (!options) {
throw Error("Ajax options missing");
}
var that = this, util = Rocket.Util;
options.success = util.ajaxResponse(options.callback);
util.ajax(options);
} | javascript | {
"resource": ""
} | |
q35319 | train | function (msg, nodeId, ns, isShow) {
ns = ns || Rocket.Plugin.currentPlugin.namespace;
var node = $("#" + ns + "_" + nodeId),
msgSpan = node.find("span.message");
isShow ? node.removeClass("hide") && node.css("display", "block") : node.addClass("hide");
if... | javascript | {
"resource": ""
} | |
q35320 | train | function (msg, nodeId, ns) {
nodeId = nodeId || "errorFlash";
this.flashMessage(msg, nodeId, ns, true);
} | javascript | {
"resource": ""
} | |
q35321 | ErrorRenderer | train | function ErrorRenderer(err, req, res) {
PageRenderer.call(this, req, res);
Object.defineProperties(this, {
err: {
value: err || new Error()
}
});
req.attrs.isErrorPage = true;
} | javascript | {
"resource": ""
} |
q35322 | Strategy | train | function Strategy (options, verify) {
if (typeof options === 'function') {
verify = options
options = {}
} else {
if (options && options.log) {
log = options.log
}
}
if (!verify) {
throw new Error('apikey authentication strategy requires a verify function')
}
passport.Strategy.cal... | javascript | {
"resource": ""
} |
q35323 | CString | train | function CString(value, written, cond) {
this.value = value || '';
this.written = written || false;
this.cond = cond || false;
} | javascript | {
"resource": ""
} |
q35324 | train | function( event )
{
var keystroke = event && event.data.getKey(),
isModifierKey = keystroke in modifierKeyCodes,
isEditingKey = keystroke in editingKeyCodes,
wasEditingKey = this.lastKeystroke in editingKeyCodes,
sameAsLastEditingKey = isEditingKey && keystroke == this.lastKeystroke,
// ... | javascript | {
"resource": ""
} | |
q35325 | train | function( onContentOnly, image, autoFireChange )
{
var snapshots = this.snapshots;
// Get a content image.
if ( !image )
image = new Image( this.editor );
// Do nothing if it was not possible to retrieve an image.
if ( image.contents === false )
return false;
// Check if this ... | javascript | {
"resource": ""
} | |
q35326 | train | function( isUndo )
{
var snapshots = this.snapshots,
currentImage = this.currentImage,
image, i;
if ( currentImage )
{
if ( isUndo )
{
for ( i = this.index - 1 ; i >= 0 ; i-- )
{
image = snapshots[ i ];
if ( !currentImage.equals( image, true ) )
{
... | javascript | {
"resource": ""
} | |
q35327 | train | function()
{
if ( this.undoable() )
{
this.save( true );
var image = this.getNextImage( true );
if ( image )
return this.restoreImage( image ), true;
}
return false;
} | javascript | {
"resource": ""
} | |
q35328 | train | function()
{
if ( this.redoable() )
{
// Try to save. If no changes have been made, the redo stack
// will not change, so it will still be redoable.
this.save( true );
// If instead we had changes, we can't redo anymore.
if ( this.redoable() )
{
var image = this.getNextI... | javascript | {
"resource": ""
} | |
q35329 | create | train | function create(type, constructor) {
return function projection() {
var p = constructor();
p.type = type;
p.path = geoPath().projection(p);
p.copy = p.copy || function() {
var c = projection();
projectionProperties.forEach(function(prop) {
if (p.hasOwnProperty(prop)) c[prop](p[p... | javascript | {
"resource": ""
} |
q35330 | createObbFromRenderableShape | train | function createObbFromRenderableShape(params, physicsJob) {
const halfRangeX = params.scale[0] / 2;
const halfRangeY = params.scale[1] / 2;
const halfRangeZ = params.scale[2] / 2;
return new Obb(halfRangeX, halfRangeY, halfRangeZ, params.isStationary, physicsJob);
} | javascript | {
"resource": ""
} |
q35331 | createSphereFromRenderableShape | train | function createSphereFromRenderableShape(params, physicsJob) {
const radius = params.radius || vec3.length(params.scale) / Math.sqrt(3);
return new Sphere(0, 0, 0, radius, params.isStationary, physicsJob);
} | javascript | {
"resource": ""
} |
q35332 | createCapsuleFromRenderableShape | train | function createCapsuleFromRenderableShape(params, physicsJob) {
const scale = params.scale;
const capsuleEndPointsDistance = params.capsuleEndPointsDistance;
const isStationary = params.isStationary;
let radius = params.radius;
let halfDistance;
// There are two modes: either we use scale, or we use radiu... | javascript | {
"resource": ""
} |
q35333 | train | function( node, index )
{
isNaN( index ) && ( index = this.children.length );
var previous = index > 0 ? this.children[ index - 1 ] : null;
if ( previous )
{
// If the block to be appended is following text, trim spaces at
// the right of it.
if ( node._.isBlockLike && previous.type ... | javascript | {
"resource": ""
} | |
q35334 | train | function( writer, filter )
{
var isChildrenFiltered;
this.filterChildren = function()
{
var writer = new CKEDITOR.htmlParser.basicWriter();
this.writeChildrenHtml.call( this, writer, filter, true );
var html = writer.getHtml();
this.children = new CKEDITOR.htmlParser.fragment.fromHtml... | javascript | {
"resource": ""
} | |
q35335 | train | function(constructorFn, args) {
var newConstructorFn = function () {
constructorFn.apply(this, args);
};
newConstructorFn.prototype = constructorFn.prototype;
return new newConstructorFn();
} | javascript | {
"resource": ""
} | |
q35336 | getMasterPillarRow | train | function getMasterPillarRow( table )
{
var $rows = table.$.rows,
maxCells = 0, cellsCount,
$elected, $tr;
for ( var i = 0, len = $rows.length ; i < len; i++ )
{
$tr = $rows[ i ];
cellsCount = $tr.cells.length;
if ( cellsCount > maxCells )
{
maxCells = cellsCount;
$electe... | javascript | {
"resource": ""
} |
q35337 | catchErrors | train | function catchErrors() {
// don't use an arrow function, we need the `this` instance!
return plumber(function(err) {
if (!err.plugin) {
err.plugin = 'gulp-task-maker'
}
showError(err)
// keep watch tasks running
if (this && typeof this.emit === 'function') {
this.emit('end')
}
... | javascript | {
"resource": ""
} |
q35338 | dirToListItems | train | function dirToListItems( list )
{
var dir = list.getDirection();
if ( dir )
{
for ( var i = 0, children = list.getChildren(), child; child = children.getItem( i ), i < children.count(); i++ )
{
if ( child.type == CKEDITOR.NODE_ELEMENT && child.is( 'li' ) && !child.getDirection() )
child.se... | javascript | {
"resource": ""
} |
q35339 | Rorschach | train | function Rorschach(connectionString, options) {
EventEmitter.call(this);
options = options || {};
var retryPolicy = options.retryPolicy;
if (retryPolicy instanceof RetryPolicy) {
this.retryPolicy = retryPolicy;
}
else {
this.retryPolicy = new RetryPolicy(retryPolicy);
}
// Initial state
thi... | javascript | {
"resource": ""
} |
q35340 | initZooKeeper | train | function initZooKeeper(rorschach, connectionString, options) {
var error;
var zk = zookeeper.createClient(connectionString, options);
rorschach.zk = zk;
zk.connect();
zk.on('connected', onconnected);
zk.on('expired', setError);
zk.on('authenticationFailed', setError);
zk.on('disconnected', ondisconnec... | javascript | {
"resource": ""
} |
q35341 | updateComponents | train | function updateComponents (address, node, state, diff, bindings, renderResult,
relativeAddress, stateCallers, opts) {
// TODO pull these out to top level
const updateRecurse = ([ d, s ], k) => {
// TODO in updateRecurse functions where k can be null, there must be a
// nicer way t... | javascript | {
"resource": ""
} |
q35342 | treeGet | train | function treeGet (address, tree) {
return address.reduce((accum, val) => {
return checkType(NODE, accum) ? accum.children[val] : accum[val]
}, tree)
} | javascript | {
"resource": ""
} |
q35343 | treeSet | train | function treeSet (address, tree, value) {
if (address.length === 0) {
return value
} else {
const [ k, rest ] = head(address)
return (typeof k === 'string' ?
{ ...tree, [k]: treeSet(rest, treeGet([ k ], tree), value) } :
[ ...tree.slice(0, k), treeSet(rest, treeGet([ k ], tree), ... | javascript | {
"resource": ""
} |
q35344 | treeSetMutable | train | function treeSetMutable (address, tree, value) {
if (address.length === 0) {
return value
} else {
const [ rest, last ] = tail(address)
const parent = treeGet(rest, tree)
if (checkType(NODE, parent)) {
parent.children[last] = value
} else {
parent[last] = value
}
return tree
... | javascript | {
"resource": ""
} |
q35345 | diffWithModel | train | function diffWithModel (modelNode, state, lastState, address,
triggeringAddress) {
return match(modelNode, match_diffWithModel, null, modelNode, state,
lastState, address, triggeringAddress)
} | javascript | {
"resource": ""
} |
q35346 | singleOrAll | train | function singleOrAll (modelNode, address, minTreeAr) {
const getMin = indices => {
if (indices.length === 0) {
// If all elements in the array are null, return null.
return null
} else if (nonNullIndices.signals.length === 1) {
// If there is a single value, return that tree, with an updated... | javascript | {
"resource": ""
} |
q35347 | makeSignalsAPI | train | function makeSignalsAPI (signalNames, isCollection) {
return fromPairs(signalNames.map(name => {
return [ name, makeOneSignalAPI(isCollection) ]
}))
} | javascript | {
"resource": ""
} |
q35348 | runSignalSetup | train | function runSignalSetup (component, address, stateCallers) {
const signalsAPI = makeSignalsAPI(component.signalNames, false)
const childSignalsAPI = makeChildSignalsAPI(component.model)
const reducers = patchReducersWithState(address, component, stateCallers.callReducer)
const signals = patchSignals(address, co... | javascript | {
"resource": ""
} |
q35349 | makeCallSignal | train | function makeCallSignal (signals, opts) {
return (address, signalName, arg) => {
if (opts.verbose) {
console.log('Called signal ' + signalName + ' at [' + address.join(', ') +
'].')
}
signals.get(address).data.signals[signalName].call(arg)
}
} | javascript | {
"resource": ""
} |
q35350 | keyBy | train | function keyBy (arr, key) {
var obj = {}
arr.map(x => obj[x[key]] = x)
return obj
} | javascript | {
"resource": ""
} |
q35351 | isText | train | function isText (o) {
return (o && typeof o === 'object' && o !== null &&
o.nodeType === 3 && typeof o.nodeName === 'string')
} | javascript | {
"resource": ""
} |
q35352 | flattenElementsAr | train | function flattenElementsAr (ar) {
return ar.reduce((acc, el) => {
return isArray(el) ? [ ...acc, ...el ] : [ ...acc, el ]
}, []).filter(notNull) // null means ignore
} | javascript | {
"resource": ""
} |
q35353 | redirect | train | function redirect(e) {
if (e && e.preventDefault) e.preventDefault();
//
// Assume that the value in the $control_input is uptodate. If not get the
// value directly through the constructor. When the selectize is still
// loading results the `getValue()` will return an empty value. This is why
... | javascript | {
"resource": ""
} |
q35354 | load | train | function load(query, callback) {
if (!query.length) return callback();
pagelet.complete(query, function complete(err, results) {
if (err) return callback();
callback(results);
});
} | javascript | {
"resource": ""
} |
q35355 | render | train | function render(item, escape) {
return [
'<div class="completed">',
'<strong class="name">'+ escape(item.name) +'</strong>',
'string' === typeof item.desc ? '<span class="description">'+ escape(item.desc) +'</span>' : '',
'</div>'
].join('');
} | javascript | {
"resource": ""
} |
q35356 | customLog | train | function customLog(message) {
const trimmed = message.trim()
const limit = trimmed.indexOf('\n')
if (limit === -1) {
fancyLog(trimmed)
} else {
const title = trimmed.slice(0, limit).trim()
const details = trimmed.slice(limit).trim()
fancyLog(`${title}${('\n' + details).replace(/\n/g, '\n ')}`)
... | javascript | {
"resource": ""
} |
q35357 | toUniqueStrings | train | function toUniqueStrings(input) {
const list = (Array.isArray(input) ? input : [input])
.map(el => (typeof el === 'string' ? el.trim() : null))
.filter(Boolean)
return list.length > 1 ? Array.from(new Set(list)) : list
} | javascript | {
"resource": ""
} |
q35358 | removeSelectedOptions | train | function removeSelectedOptions( combo )
{
combo = getSelect( combo );
// Save the selected index
var iSelectedIndex = getSelectedIndex( combo );
// Remove all selected options.
for ( var i = combo.getChildren().count() - 1 ; i >= 0 ; i-- )
{
if ( combo.getChild( i ).$.selected )
combo.g... | javascript | {
"resource": ""
} |
q35359 | modifyOption | train | function modifyOption( combo, index, title, value )
{
combo = getSelect( combo );
if ( index < 0 )
return false;
var child = combo.getChild( index );
child.setText( title );
child.setValue( value );
return child;
} | javascript | {
"resource": ""
} |
q35360 | dir2TreeStr | train | function dir2TreeStr(){
argD = Type.isBoolean(argD) ? "./" : trimAndDelQuotes(argD);
let dirJson,djOpt;
try{
djOpt = {
// preChars:{
// directory: ":open_file_folder: ",
// file:":page_facing_up: "
// },
exclude:{
ou... | javascript | {
"resource": ""
} |
q35361 | VertexIterator | train | function VertexIterator(graph, startFrom) {
if (graph === undefined) {
throw new Error('Graph is required by VertexIterator');
}
this._graph = graph;
this._startFrom = startFrom;
this._currentIndex = 0;
this._allNodes = [];
this._initialized = false;
this._current = undefined;
} | javascript | {
"resource": ""
} |
q35362 | CacheStore | train | function CacheStore(options) {
if (!options.id) {
throw new IdNotDefinedError();
}
var storeType, _cache;
function parseKey(key) {
return key.replace(/[^a-z0-9]/gi, '_').replace(/^-+/, '').replace(/-+$/, '').toLowerCase();
}
/**
* Returns Cache Store object
* @returns... | javascript | {
"resource": ""
} |
q35363 | train | function(options) {
"use strict";
stream.Transform.call(this, options);
options = options || {};
this.probability = options.probability || 0;
this.deviation = Math.abs(options.deviation || 0);
this.whiteList = options.whiteList || [];
this.blackList = options.blackList || [];
this.func = options.func... | javascript | {
"resource": ""
} | |
q35364 | train | function(fileSrc, fileDst, probability, deviation, mode) {
"use strict";
var rstream = fs.createReadStream(fileSrc);
var woptions = mode ? { 'mode' : mode } : {};
var wstream = fs.createWriteStream(fileDst, woptions);
var gstream = new GlitchedStream({
'probability' : probability,
'deviation' : deviat... | javascript | {
"resource": ""
} | |
q35365 | CInt | train | function CInt(base, offset, isSet) {
this.base = base || 0;
this.offset = offset || 0;
this.isSet = isSet || false;
} | javascript | {
"resource": ""
} |
q35366 | VText | train | function VText(text, config) {
this.virtual = true;
extend(this, config);
// Non-overridable
this.text = [].concat(text);
this.textOnly = true;
this.simple = true;
} | javascript | {
"resource": ""
} |
q35367 | appendColorRow | train | function appendColorRow( rangeA, rangeB )
{
for ( var i = rangeA ; i < rangeA + 3 ; i++ )
{
var row = table.$.insertRow( -1 );
for ( var j = rangeB ; j < rangeB + 3 ; j++ )
{
for ( var n = 0 ; n < 6 ; n++ )
{
appendColorCell( row, '#' + aColors[j] + aColors[n] + a... | javascript | {
"resource": ""
} |
q35368 | CEntity | train | function CEntity(indexes, properties, states) {
CArray.call(this, indexes, properties);
this.states = {} || states;
this.uid = 0;
} | javascript | {
"resource": ""
} |
q35369 | attachMenu | train | function attachMenu(item) {
var menuType = item.find('a').hasClass(FOLDER_TYPE) ? "folderMenu" : "itemMenu";
item.contextMenu({
menu:menuType
},
function (action, el, pos) {
switch (action) {
case ADD_SUBFOLDER_MENU_COMMAND:
... | javascript | {
"resource": ""
} |
q35370 | injectStyle | train | function injectStyle(obj) {
if (!obj) return ''
var selectors = Object.keys(obj)
var styles = selectors.map(function(key) {
var selector = obj[key]
var style = inlineStyle(selector)
var inline = key.concat('{').concat(style).concat('}')
return inline
})
var results = styles.join('')
inser... | javascript | {
"resource": ""
} |
q35371 | fetchWithRetry | train | function fetchWithRetry(url, options) {
async function fetchWrapper() {
const response = await fetch(url, options);
// don't retry if status is 4xx
if (response.status >= 400 && response.status < 500) {
const contentType = response.headers.get('content-type');
if (con... | javascript | {
"resource": ""
} |
q35372 | hydrateDates | train | function hydrateDates(body) {
/**
* Hydrates a string date to a Date object. Mutates input.
* @param item object potentially containing a meta object
*/
function hydrateMeta(item) {
const meta = item.meta;
if (meta && meta.created) {
// parse ISO-8601 string to Date
... | javascript | {
"resource": ""
} |
q35373 | hydrateMeta | train | function hydrateMeta(item) {
const meta = item.meta;
if (meta && meta.created) {
// parse ISO-8601 string to Date
meta.created = new Date(meta.created);
}
} | javascript | {
"resource": ""
} |
q35374 | LeaderElection | train | function LeaderElection(client, path, id) {
EventEmitter.call(this);
/**
* Ref. to client.
*
* @type {Rorschach}
*/
this.client = client;
/**
* ZooKeeper path where participants' nodes exist.
*
* @type {String}
*/
this.path = path;
/**
* Id of participant. It's kept in node.
... | javascript | {
"resource": ""
} |
q35375 | handleStateChange | train | function handleStateChange(election, state) {
if (state === ConnectionState.RECONNECTED) {
reset(election, afterReset);
}
else if (state === ConnectionState.SUSPENDED ||
state === ConnectionState.LOST) {
setLeadership(election, false);
}
function afterReset(err) {
if (err) {
election.em... | javascript | {
"resource": ""
} |
q35376 | fileUploaded | train | function fileUploaded( error, response ) {
this.debug( 'File Uploaded' );
console.log( require( 'util' ).inspect( error || response, { showHidden: false, colors: true, depth: 4 } ) );
} | javascript | {
"resource": ""
} |
q35377 | train | function( writer, filter )
{
var text = this.value;
if ( filter && !( text = filter.onText( text, this ) ) )
return;
writer.text( text );
} | javascript | {
"resource": ""
} | |
q35378 | checkCircular | train | function checkCircular(obj){
let isCcl = false;
let cclKeysArr = [];
travelJson(obj,function(k,v,kp,ts,cpl,cd,isCircular){
if(isCircular){
isCcl = true;
cclKeysArr.push({
keyPath: kp,
circularTo: v.slice(11,-1),
key: k,
... | javascript | {
"resource": ""
} |
q35379 | BufferView | train | function BufferView(buffer, byteOffset, byteLength) {
if (typeof byteOffset === "undefined") byteOffset = 0;
if (typeof byteLength === "undefined") byteLength = buffer.length;
this._buffer = byteOffset === 0 && byteLength === buffer.length
? buffer
: buffer.slice(byteOffset, byteLength);
} | javascript | {
"resource": ""
} |
q35380 | train | function (message, data) {
var datastr = data === undefined ? "no-data" : inspect(data);
logfn(format(" [EMIT] %s %s", pad(message), datastr));
EEProto.emit.apply(this, arguments);
} | javascript | {
"resource": ""
} | |
q35381 | train | function( evaluator )
{
var next = this.$, retval;
do
{
next = next.nextSibling;
retval = next && new CKEDITOR.dom.node( next );
}
while ( retval && evaluator && !evaluator( retval ) )
return retval;
} | javascript | {
"resource": ""
} | |
q35382 | train | function( reference, includeSelf )
{
var $ = this.$,
name;
if ( !includeSelf )
$ = $.parentNode;
while ( $ )
{
if ( $.nodeName && ( name = $.nodeName.toLowerCase(), ( typeof reference == 'string' ? name == reference : name in reference ) ) )
return new CKEDITOR.dom.node( $ );... | javascript | {
"resource": ""
} | |
q35383 | train | function( preserveChildren )
{
var $ = this.$;
var parent = $.parentNode;
if ( parent )
{
if ( preserveChildren )
{
// Move all children before the node.
for ( var child ; ( child = $.firstChild ) ; )
{
parent.insertBefore( $.removeChild( child ), $ );
}
... | javascript | {
"resource": ""
} | |
q35384 | train | function()
{
if ( cssIsLoaded && jsIsLoaded )
{
// Mark the part as loaded.
part._isLoaded = 1;
// Call all pending callbacks.
for ( var i = 0 ; i < pending.length ; i++ )
{
if ( pending[ i ] )
pending[ i ]();
}
}
} | javascript | {
"resource": ""
} | |
q35385 | train | function( skinName, skinDefinition )
{
loaded[ skinName ] = skinDefinition;
skinDefinition.skinPath = paths[ skinName ]
|| ( paths[ skinName ] =
CKEDITOR.getUrl(
'_source/' + // @Packager.RemoveLine
'skins/' + skinName + '/' ) );
} | javascript | {
"resource": ""
} | |
q35386 | train | function( editor, skinPart, callback )
{
var skinName = editor.skinName,
skinPath = editor.skinPath;
if ( loaded[ skinName ] )
loadPart( editor, skinName, skinPart, callback );
else
{
paths[ skinName ] = skinPath;
CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( skinPath + 'skin.js'... | javascript | {
"resource": ""
} | |
q35387 | forOwnDeep | train | function forOwnDeep(object, callback, prefix) {
prefix = prefix ? prefix + '.' : '';
_.forOwn(object, function(value, key) {
if (_.isString(value)) {
callback(value, prefix + key);
} else {
forOwnDeep(value, callback, prefix + key);
}
});
} | javascript | {
"resource": ""
} |
q35388 | Lock | train | function Lock(client, basePath, lockName, lockDriver) {
if (lockName instanceof LockDriver) {
lockDriver = lockName;
lockName = null;
}
if (!lockName) {
lockName = Lock.LOCK_NAME;
}
if (!lockDriver) {
lockDriver = new LockDriver();
}
/**
* Keep ref to client as all the low-level opera... | javascript | {
"resource": ""
} |
q35389 | attemptLock | train | function attemptLock(lock, timeout, callback) {
var lockPath;
var sequenceNodeName;
var timerId = null;
var start = Date.now();
createNode(lock, afterCreate);
function afterCreate(err, nodePath) {
if (err) {
return exit(err);
}
lockPath = nodePath;
sequenceNodeName = nodePath.subst... | javascript | {
"resource": ""
} |
q35390 | createNode | train | function createNode(lock, callback) {
var nodePath = utils.join(lock.basePath, lock.lockName);
var client = lock.client;
client
.create()
.creatingParentsIfNeeded()
.withMode(CreateMode.EPHEMERAL_SEQUENTIAL)
.forPath(nodePath, callback);
} | javascript | {
"resource": ""
} |
q35391 | deleteNode | train | function deleteNode(lock, lockPath, callback) {
lock.client
.delete()
.guaranteed()
.forPath(lockPath, callback);
} | javascript | {
"resource": ""
} |
q35392 | dupBuffer | train | function dupBuffer(buf){
var cloned = new Buffer(buf.length);
buf.copy(cloned);
return cloned;
} | javascript | {
"resource": ""
} |
q35393 | compare | train | function compare(buf1, buf2){
if (buf1.length !== buf2.length)
return buf1.length - buf2.length;
for (var i = 0; i < buf1.length; i++)
if (buf1[i] !== buf2[i])
return buf1[i] - buf2[i];
return 0;
} | javascript | {
"resource": ""
} |
q35394 | strongify | train | function strongify(o) {
/**
* Cloning object.
*/
var params = _.clone(o);
/**
* Returns all object data.
*
* @return {object}
* @api public
*/
params.all = function() {
return params = _.omit(params, ['all', 'only', 'except', 'require', 'merge']);
}
/**
* Returns only listed... | javascript | {
"resource": ""
} |
q35395 | saveFileChanges | train | function saveFileChanges(themeId, folderName, fileName, text) {
io({
url:getURL("save") + "/" + themeId + "/" + folderName + "/" + fileName,
data:{
content:encodeURI(text)
},
callback:function (isSuccess, message, response) {
if (!i... | javascript | {
"resource": ""
} |
q35396 | initAceEditor | train | function initAceEditor(themeId, folderName, fileName, text, mode) {
hideImageHolder();
$("#" + editorId).show();
var doc = new Document(text);
var session = new EditSession(doc, "ace/mode/" + mode);
session.setUndoManager(new UndoManager());
editor.setSession(session);
... | javascript | {
"resource": ""
} |
q35397 | openFile | train | function openFile(themeId, folderName, fileName) {
if (themeId && folderName && fileName) {
//if image then display it
if (folderName === "images") {
showImage(themeId, folderName, fileName);
return;
}
var options = {
... | javascript | {
"resource": ""
} |
q35398 | renderThemeTree | train | function renderThemeTree(themeId, fileList, themeName) {
var getTreeNodes = function (arr) {
var ret = [];
_.each(arr, function (fileName) {
ret.push({title:fileName});
});
return ret;
};
var css = {title:validTitleName[0], isFolder... | javascript | {
"resource": ""
} |
q35399 | train | function (workingDirectory) {
var gitPath = getClosestGitPath(workingDirectory);
if (!gitPath) {
throw new Error('git-hooks must be run inside a git repository');
}
var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
var pathToGitHooks = path.join(path.relative(ho... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.