_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q31600 | train | function (text, value) {
var valueLength = value.length;
if (text.length < valueLength) {
return false;
}
return text.substring(0, valueLength) === value;
} | javascript | {
"resource": ""
} | |
q31601 | train | function (array, c, depth) {
var start = array.length - (array.length / Math.pow(2, depth));
for (var i = start, len = array.length; i < len; i += 1) {
array[i] += c;
}
} | javascript | {
"resource": ""
} | |
q31602 | train | function (array) {
var set = {};
var result = [];
for (var i = 0, len = array.length; i < len; i += 1) {
var item = array[i];
if (!Object.prototype.hasOwnProperty.call(set, item)) {
set[item] = true;
result.push(item);
}
... | javascript | {
"resource": ""
} | |
q31603 | train | function (routes) {
if (!Array.isArray(routes)) {
routes = [routes];
}
var result = [];
routes.forEach(function (route) {
if (route.indexOf('[') === -1) {
result.push(route);
return;
}
var immediateResult ... | javascript | {
"resource": ""
} | |
q31604 | train | function (bind, prefix) {
return function (path, callback) {
var prefixedPath = prefix + path;
validatePath(prefixedPath);
var innerMethods = spawn(escort.prototype, {
bind: function (routeName, route, descriptor) {
if (arguments.length ===... | javascript | {
"resource": ""
} | |
q31605 | train | function (req, res) {
return function (err) {
if (err) {
res.writeHead(500);
res.end(err.toString());
} else {
res.writeHead(404);
res.end();
}
};
} | javascript | {
"resource": ""
} | |
q31606 | train | function (object) {
ACCEPTABLE_METHODS.forEach(function (method) {
/**
* Bind the provided route with a specific method to the callback provided.
* Since you cannot specify a route more than once, it is required to use bind to provide multiple methods.
*
... | javascript | {
"resource": ""
} | |
q31607 | train | function (value, length) {
value = String(value);
var numMissing = length - value.length;
var prefix = "";
while (numMissing > 0) {
prefix += "0";
numMissing -= 1;
}
return prefix + value;
} | javascript | {
"resource": ""
} | |
q31608 | train | function (args) {
if (!args) {
args = {};
}
var fixedDigits = args.fixedDigits;
var min = args.min;
var max = args.max;
if (min === undefined) {
min = null;
}
if (max === undefine... | javascript | {
"resource": ""
} | |
q31609 | train | function () {
var args = Array.prototype.slice.call(arguments, 0);
if (args.length < 1) {
throw new Error("Must specify at least one argument to AnyConverter");
}
var values = {};
for (var i = 0, len = args.length; i < len; i += 1)... | javascript | {
"resource": ""
} | |
q31610 | train | function(state, datasetId, items, matchFound, nestingLevel, stopExpandingParents) {
// initialize whatever wasn't passed to a default value
datasetId = datasetId || 'default';
items = items || concealed.items[datasetId];
matchFound = matchFound || false;
nesti... | javascript | {
"resource": ""
} | |
q31611 | requirifyImageReference | train | function requirifyImageReference(markdownImageReference) {
const [, mdImageStart, mdImagePath, optionalMdTitle, mdImageEnd ] = imagePathRE.exec(markdownImageReference) || []
if (!mdImagePath) {
return JSON.stringify(markdownImageReference)
} else {
const imageRequest = loaderUtils.stringifyRequest(
... | javascript | {
"resource": ""
} |
q31612 | checkPointerDown | train | function checkPointerDown(e) {
if (config.clickOutsideDeactivates && !container.contains(e.target)) {
deactivate({ returnFocus: false });
}
} | javascript | {
"resource": ""
} |
q31613 | applyTransformers | train | function applyTransformers(options, state, file) {
var transformationSucceededAtLeastOnce = false;
if (options.transformations && state.ext == "js") {
options.transformations.forEach(function (transformation) {
transformationSucceededAtLeastOnce |= transformAndTest(transformation, options, s... | javascript | {
"resource": ""
} |
q31614 | TObject | train | function TObject(qname, meta) {
this.qname = qname;
this.properties = new Map;
this.modules = new Map;
this.calls = []
this.types = new Map;
this.supers = []
this.typeParameters = []
this.brand = null;
this.meta = {
kind: meta.kind,
origin: meta.origin,
isEnum: f... | javascript | {
"resource": ""
} |
q31615 | addModuleMember | train | function addModuleMember(member, moduleObject, qname) {
current_node = member;
var topLevel = qname === '';
if (member instanceof TypeScript.FunctionDeclaration) {
var obj = moduleObject.getMember(member.name.text())
if (obj instanceof TObject) {
obj.calls.push(parseFunctionType(member))
} el... | javascript | {
"resource": ""
} |
q31616 | resolveReference | train | function resolveReference(x, isModule) {
if (x instanceof TReference) {
if (isBuiltin(x.name))
return new TBuiltin(x.name)
if (x.resolution)
return x.resolution
if (x.resolving)
throw new TypeError("Cyclic reference involving " + x)
x.resolving = true
var t = lookupInScope(x.scope, x.... | javascript | {
"resource": ""
} |
q31617 | resolveType | train | function resolveType(x) {
if (x instanceof TReference) {
return resolveReference(x)
} else if (x instanceof TMember) {
return resolveReference(x)
} else if (x instanceof TObject) {
if (x.qname)
return new TQualifiedReference(x.qname) // can happen if a qname was synthesized by resolveReferenc... | javascript | {
"resource": ""
} |
q31618 | hasBrand | train | function hasBrand(value, brand) {
var ctor = lookupPath(brand, function() { return null })
if (!ctor || typeof ctor !== 'object')
return null;
var proto = lookupObject(ctor.key).propertyMap.get('prototype')
if (!proto || !proto.value || typeof proto.value !== 'object')
return null;
while (value && typeof value... | javascript | {
"resource": ""
} |
q31619 | getEnclosingFunction | train | function getEnclosingFunction(node) {
while (node.type !== 'FunctionDeclaration' &&
node.type !== 'FunctionExpression' &&
node.type !== 'Program') {
node = node.$parent;
}
return node;
} | javascript | {
"resource": ""
} |
q31620 | getEnclosingScope | train | function getEnclosingScope(node) {
while (node.type !== 'FunctionDeclaration' &&
node.type !== 'FunctionExpression' &&
node.type !== 'CatchClause' &&
node.type !== 'Program') {
node = node.$parent;
}
return node;
} | javascript | {
"resource": ""
} |
q31621 | isElement | train | function isElement(value) {
return isNonNullObject(value) && value.nodeType === 1 && toString.call(value).indexOf('Element') > -1;
} | javascript | {
"resource": ""
} |
q31622 | isVueComponent | train | function isVueComponent(value) {
return isPlainObject(value) && (isNonEmptyString(value.template) || isFunction(value.render) || isNonEmptyString(value.el) || isElement(value.el) || isVueComponent(value.extends) || isNonEmptyArray(value.mixins) && value.mixins.some(function (val) {
return isVueComponent(val);
}... | javascript | {
"resource": ""
} |
q31623 | initialize | train | function initialize() {
var flags = [];
Object.keys( levels ).forEach(function( type, level ) {
var method = type.toLowerCase();
exports[ method ] = log.bind( exports, type, level, false );
exports[ method ].json = log.bind( exports, type, level, true );
if ( new RegExp( '\\b' + type + '\\b', 'i' )... | javascript | {
"resource": ""
} |
q31624 | format | train | function format( type, args ) {
var now = new Date().toISOString(),
tmpl = '[%s] %s: %s\n',
msg;
msg = args[ 0 ] instanceof Error ? args[ 0 ].stack :
util.format.apply( util, args );
return util.format( tmpl, now, type, msg );
} | javascript | {
"resource": ""
} |
q31625 | readConfig | train | function readConfig() {
let options = {}
let cFile = ''
if (program.config) {
cFile = path.resolve(cwd, program.config)
if (fs.existsSync(cFile)) {
Object.assign(config, require(cFile))
} else {
console.warn(`Cannot find configuration file ${program.config}`)
process.exit()
}
... | javascript | {
"resource": ""
} |
q31626 | shutdown | train | function shutdown() {
var instance = this;
instance.active = false;
instance.transmitter = null;
instance.remoteTimeout = 0;
instance.localTimeout = 0;
instance.localComponents = {};
instance.remoteComponents = {};
instance.outbox.requests.length = 0;
instance.outbox.responses.length = 0;
instance.... | javascript | {
"resource": ""
} |
q31627 | confirmTransmit | train | function confirmTransmit(outpacket, err) {
if (this.active && err) {
// Roll it all back into outbox (which may not be empty anymore)
if (outpacket.responses.length > 0) {
Array.prototype.push.apply(this.outbox.responses, outpacket.responses);
}
if (outpacket.requests.length > 0) {
Array.p... | javascript | {
"resource": ""
} |
q31628 | receive | train | function receive(msg) {
var requests = [];
var responses = [];
if (!this.active) {
return this;
}
// If we got JSON, parse it
if (typeof msg === 'string') {
try {
msg = JSON.parse(msg);
} catch (e) {
// The specification doesn't force us to respond in error, ignoring
return t... | javascript | {
"resource": ""
} |
q31629 | upgrade | train | function upgrade() {
if (!this.active) {
return this;
}
return this.call(
'system.listComponents',
this.localComponents,
(function(err, result) {
if (!err && typeof result === 'object') {
this.remoteComponents = result;
this.remoteComponents['system._upgraded'] = true;
... | javascript | {
"resource": ""
} |
q31630 | call | train | function call(methodName, params, next) {
var request = {
jsonrpc: '2.0',
method : methodName
};
if (!this.active) {
return this;
}
if (typeof params === 'function') {
next = params;
params = null;
}
if (
'system._upgraded' in this.remoteComponents
&& !(methodName in this.re... | javascript | {
"resource": ""
} |
q31631 | deliverResponse | train | function deliverResponse(res) {
var err = false;
var result = null;
if (this.active && 'id' in res && res['id'] in this.outTimers) {
clearTimeout(this.outTimers[res['id']]); // Passing true instead of a timeout is safe
delete this.outTimers[res['id']];
} else {
// Silently ignoring second response... | javascript | {
"resource": ""
} |
q31632 | expose | train | function expose(subject, callback) {
var name;
if (!this.active) {
return this;
}
if (typeof subject === 'string') {
this.localComponents[subject] = true;
this.exposed[subject] = callback;
} else if (typeof subject === 'object') {
for (name in subject) {
if (subject.hasOwnProperty(name... | javascript | {
"resource": ""
} |
q31633 | serveRequest | train | function serveRequest(request) {
var id = null;
var params = null;
if (!this.active || typeof request !== 'object' || request === null) {
return;
}
if (!(typeof request.jsonrpc === 'string' && request.jsonrpc === '2.0')) {
return;
}
id = (typeof request.id !== 'undefined' ? request.id : null);
... | javascript | {
"resource": ""
} |
q31634 | sendResponse | train | function sendResponse(id, err, result) {
var response = {
jsonrpc: '2.0',
id : id
};
if (id === null) {
return;
}
if (this.active && id in this.localTimers) {
clearTimeout(this.localTimers[id]); // Passing true instead of a timeout is safe
delete this.localTimers[id];
} else {
... | javascript | {
"resource": ""
} |
q31635 | train | function (route, converters) {
var literals = route.literals;
var params = route.params;
var conv = [];
var fun = "";
fun += "var generate = function (params) {\n";
fun += " if (arguments.length === 1 && typeof params === 'object' && params.constructo... | javascript | {
"resource": ""
} | |
q31636 | train | function (routes, converters) {
var staticRoute, dynamicRoute;
// we traverse backwards because the beginning ones take precedence and thus can override.
for (var i = routes.length - 1; i >= 0; i -= 1) {
var route = routes[i];
if (route.path) {
... | javascript | {
"resource": ""
} | |
q31637 | getTempFileName | train | function getTempFileName(state) {
var fn = state.tmp_dir + "/delta_js_" + state.round + "." + state.ext;
state.round++;
return fn;
} | javascript | {
"resource": ""
} |
q31638 | copyToOut | train | function copyToOut(src, out, multiFileMode) {
try {
fs.copySync(src, out);
fs.statSync(out)
return out;
} catch (err) {
}
} | javascript | {
"resource": ""
} |
q31639 | train | function (method) {
var
str = '' + method,
i = str.indexOf(SUPER)
;
return i < 0 ?
false :
isBoundary(str.charCodeAt(i - 1)) &&
isBoundary(str.charCodeAt(i + 5));
} | javascript | {
"resource": ""
} | |
q31640 | addMixins | train | function addMixins(mixins, target, inherits, isNOTExtendingNative) {
for (var
source,
init = [],
i = 0; i < mixins.length; i++
) {
source = transformMixin(mixins[i]);
if (hOP.call(source, INIT)) {
init.push(source[INIT]);
}
copyOwn(source, target, inherits, fals... | javascript | {
"resource": ""
} |
q31641 | copyMerged | train | function copyMerged(source, target) {
for (var
key, descriptor, value, tvalue,
names = oK(source),
i = 0; i < names.length; i++
) {
key = names[i];
descriptor = gOPD(source, key);
// target already has this property
if (hOP.call(target, key)) {
// verify the des... | javascript | {
"resource": ""
} |
q31642 | copyOwn | train | function copyOwn(source, target, inherits, publicStatic, allowInit, isNOTExtendingNative) {
for (var
key,
noFunctionCheck = typeof source !== 'function',
names = oK(source),
i = 0; i < names.length; i++
) {
key = names[i];
if (
(noFunctionCheck || indexOf.call(nativeF... | javascript | {
"resource": ""
} |
q31643 | copyValueIfObject | train | function copyValueIfObject(where, how) {
var what = where[VALUE];
if (isObject(what)) {
where[VALUE] = how(what);
}
} | javascript | {
"resource": ""
} |
q31644 | createConstructor | train | function createConstructor(hasParentPrototype, parent) {
var Class = function Class() {};
return hasParentPrototype && ('' + parent) !== ('' + Class) ?
function Class() {
return parent.apply(this, arguments);
} :
Class
;
} | javascript | {
"resource": ""
} |
q31645 | define | train | function define(target, key, value, publicStatic) {
var configurable = isConfigurable(key, publicStatic);
defineProperty(target, key, {
enumerable: false, // was: publicStatic,
configurable: configurable,
writable: configurable,
value: value
});
} | javascript | {
"resource": ""
} |
q31646 | isNotASpecialKey | train | function isNotASpecialKey(key, allowInit) {
return key !== CONSTRUCTOR &&
key !== EXTENDS &&
key !== IMPLEMENTS &&
// Blackberry 7 and old WebKit bug only:
// user defined functions have
// enumerable prototype and constructor
key !== PROTOT... | javascript | {
"resource": ""
} |
q31647 | isPublicStatic | train | function isPublicStatic(key) {
for(var c, i = 0; i < key.length; i++) {
c = key.charCodeAt(i);
if ((c < 65 || 90 < c) && c !== 95) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} |
q31648 | transformMixin | train | function transformMixin(trait) {
if (isObject(trait)) return trait;
else {
var i, key, keys, object, proto;
if (trait.isClass) {
if (trait.length) {
warn((trait.name || 'Class') + ' should not expect arguments');
}
for (
object = {init: trait},
p... | javascript | {
"resource": ""
} |
q31649 | setProperty | train | function setProperty(inherits, target, key, descriptor, publicStatic, isNOTExtendingNative) {
var
hasValue = hOP.call(descriptor, VALUE),
configurable,
value
;
if (publicStatic) {
if (hOP.call(target, key)) {
// in case the value is not a static one
if (
inh... | javascript | {
"resource": ""
} |
q31650 | verifyImplementations | train | function verifyImplementations(interfaces, target) {
for (var
current,
key,
i = 0; i < interfaces.length; i++
) {
current = interfaces[i];
for (key in current) {
if (hOP.call(current, key) && !hOP.call(target, key)) {
warn(key.toString() + ' is not implemented');
... | javascript | {
"resource": ""
} |
q31651 | vel | train | function vel (rend) {
assert.equal(typeof rend, 'function')
var update = null
render.toString = toString
render.render = render
render.vtree = vtree
return render
// render the element's vdom tree to DOM nodes
// which can be mounted on the DOM
// any? -> DOMNode
function render (state) {
if (... | javascript | {
"resource": ""
} |
q31652 | render | train | function render (state) {
if (update) return update(state)
const loop = mainLoop(state, renderFn(rend), vdom)
update = loop.update
return loop.target
} | javascript | {
"resource": ""
} |
q31653 | disconnect | train | function disconnect(socket) {
if (socket.namespace.name === '') return socket.disconnect();
socket.packet({type:'disconnect'});
socket.manager.onLeave(socket, socket.namespace.name);
socket.$emit('disconnect', 'booted');
} | javascript | {
"resource": ""
} |
q31654 | back | train | function back (self, cb, cancel) {
if (!cb) cb = noop
if (self._back.length === 0 || self._pending) return cb(null)
var previous = self._back.pop()
var current = self.current()
load(self, previous, done)
function done (err) {
if (err) return cb(err)
if (!cancel) self._forward.push(current)
sel... | javascript | {
"resource": ""
} |
q31655 | addProperty | train | function addProperty(col, func) {
// Exposed on top of the namespace
colour[col] = function(str) {
return func.apply(str);
};
// And on top of all strings
try {
String.prototype.__defineGetter__(col, func);
definedGetters[col] = func;
}... | javascript | {
"resource": ""
} |
q31656 | stylize | train | function stylize(str, style) {
if (colour.mode == 'console') {
return consoleStyles[style][0] + str + consoleStyles[style][1];
} else if (colour.mode == 'browser') {
return browserStyles[style][0] + str + browserStyles[style][1];
} else if (colour.mode == 'browser-css') {... | javascript | {
"resource": ""
} |
q31657 | applyTheme | train | function applyTheme(theme) {
Object.keys(theme).forEach(function(prop) {
if (prototypeBlacklist.indexOf(prop) >= 0) {
return;
}
if (typeof theme[prop] == 'string') {
// Multiple colours white-space seperated #45, e.g. "red bold", #18
... | javascript | {
"resource": ""
} |
q31658 | sequencer | train | function sequencer(map) {
return function () {
if (this == undefined) return "";
var i=0;
return String.prototype.split.apply(this, [""]).map(map).join("");
};
} | javascript | {
"resource": ""
} |
q31659 | choiceListener | train | function choiceListener(index) {
return function (event) {
event.preventDefault();
if (choicesAnimating) return;
clearChoiceListeners();
story.ChooseChoiceIndex(index);
saveGame(index);
clearOldChoices().then(() => progressGame());
}
} | javascript | {
"resource": ""
} |
q31660 | createChoiceListener | train | function createChoiceListener(li, index) {
li.clickListener = choiceListener(index);
li.addEventListener('click', li.clickListener);
li.clearListener = (function () {
this.removeEventListener('click', this.clickListener);
}).bind(li);
} | javascript | {
"resource": ""
} |
q31661 | clearChoiceListeners | train | function clearChoiceListeners() {
const lis = document.querySelectorAll('li');
Array.from(lis).forEach(li => {
if (li.clearListener) li.clearListener();
})
} | javascript | {
"resource": ""
} |
q31662 | createChoiceUl | train | function createChoiceUl () {
const lis = story.currentChoices
.map(choice => {
const li = document.createElement('li');
li.innerHTML = choice.text;
createChoiceListener(li, choice.index);
return li;
});
const ul = document.createElement('ul');
Array.from(lis).forEach(li => ul.appen... | javascript | {
"resource": ""
} |
q31663 | placeChoices | train | function placeChoices () {
const ul = createChoiceUl();
ul.addEventListener('animationend', () => choicesAnimating = false);
choicesAnimating = true;
choiceDiv.appendChild(ul);
} | javascript | {
"resource": ""
} |
q31664 | clearOldChoices | train | function clearOldChoices () {
const oldChoices = choiceDiv.querySelector('.choices.current');
return new Promise(resolve => {
oldChoices.addEventListener('transitionend', () => {
oldChoices.remove();
resolve();
});
oldChoices.className = "choices old";
})
} | javascript | {
"resource": ""
} |
q31665 | deltaDebugFiles | train | function deltaDebugFiles(file) {
try {
logging.increaseIndentation();
state.fileUnderTest = file;
logging.logTargetChange(file, state.tmpDir);
// try removing fileUnderTest completely
var backup = makeBackupFileName();
fs.renameSync(file, ... | javascript | {
"resource": ""
} |
q31666 | train | function () {
var http = false;
// Use IE's ActiveX items to load the file.
if (typeof ActiveXObject != 'undefined') {
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http = new ActiveXObject("Micro... | javascript | {
"resource": ""
} | |
q31667 | ifft2DArray | train | function ifft2DArray(ft, ftRows, ftCols) {
var tempTransform = new Array(ftRows * ftCols);
var nRows = ftRows / 2;
var nCols = (ftCols - 1) * 2;
// reverse transform columns
FFT.init(nRows);
var tmpCols = {re: new Array(nRows), im: new Array(nRows)};
var iRow, iCol;
for (iCol = 0; iCol <... | javascript | {
"resource": ""
} |
q31668 | convolute2DI | train | function convolute2DI(ftSignal, ftFilter, ftRows, ftCols) {
var re, im;
for (var iRow = 0; iRow < ftRows / 2; iRow++) {
for (var iCol = 0; iCol < ftCols; iCol++) {
//
re = ftSignal[(iRow * 2) * ftCols + iCol]
* ftFilter[(iRow * 2) * ftCols + iCol]
... | javascript | {
"resource": ""
} |
q31669 | crop | train | function crop(data, rows, cols, nRows, nCols) {
if (rows === nRows && cols === nCols) {
//Do nothing. Returns the same input!!! Be careful
return data;
}
var output = new Array(nCols * nRows);
var shiftR = Math.floor((rows - nRows) / 2);
var shiftC = Math.floor((cols - nCols) / 2)... | javascript | {
"resource": ""
} |
q31670 | train | function (Cptfn) {
if (!Cptfn || Cptfn.constructor !== Function) {
log.error("[CptWrapper] Invalid Component constructor!");
} else {
this.cpt = new Cptfn();
this.nodeInstance = null; // reference to set the node instance adirty when an attribute changes
t... | javascript | {
"resource": ""
} | |
q31671 | train | function (change) {
var chg = change, cpt = this.cpt;
if (change.constructor === Array) {
if (change.length > 0) {
chg = change[0];
} else {
log.error('[CptNode] Invalid change - nbr of changes: '+change.length);
return;
... | javascript | {
"resource": ""
} | |
q31672 | createCptWrapper | train | function createCptWrapper(Ctl, cptArgs) {
var cw = new CptWrapper(Ctl), att, t, v; // will also create a new controller instance
if (cptArgs) {
var cpt=cw.cpt, ni=cptArgs.nodeInstance;
if (ni.isCptComponent || ni.isCptAttElement) {
// set the nodeInstance reference on the component
... | javascript | {
"resource": ""
} |
q31673 | XKCDPassword | train | function XKCDPassword() {
if (!(this instanceof XKCDPassword)) return new XKCDPassword()
var self = this
events.EventEmitter.call(self)
self.wordlist = null
self.wordfile = null
// if we've got a wordlist at the ready
self.ready = false
self.initialized = false
return this
} | javascript | {
"resource": ""
} |
q31674 | fft2d | train | function fft2d(re, im) {
var tre = [],
tim = [],
i = 0;
// x-axis
for (var y = 0; y < _n; y++) {
i = y * _n;
for (var x1 = 0; x1 < _n; x1++) {
tre[x1] = re[x1 + i];
tim[x1] = im[x1 + i];
}
fft1d(tre, tim);
for (var x2 = 0; x2 < ... | javascript | {
"resource": ""
} |
q31675 | ifft2d | train | function ifft2d(re, im) {
var tre = [],
tim = [],
i = 0;
// x-axis
for (var y = 0; y < _n; y++) {
i = y * _n;
for (var x1 = 0; x1 < _n; x1++) {
tre[x1] = re[x1 + i];
tim[x1] = im[x1 + i];
}
ifft1d(tre, tim);
for (var x2 = 0; x2 ... | javascript | {
"resource": ""
} |
q31676 | formatExpression | train | function formatExpression (expression, firstIndex, walker) {
var category = expression.category, codeStmts, code = '', nextIndex = firstIndex;
var exprIndex = firstIndex;
var expAst;
if (category === 'jsexptext') {
//compile the expression to detect errors and parse-out identifiers
try ... | javascript | {
"resource": ""
} |
q31677 | formatTextBlock | train | function formatTextBlock (node, nextExprIndex, walker) {
var content = node.content, item, exprArray = [], args = [], index = 0; // idx is the index in the $text array
// (=args)
for (var i = 0; i < content.length; i++) {
it... | javascript | {
"resource": ""
} |
q31678 | formatValue | train | function formatValue(v,depth) {
if (depth===undefined || depth===null) {
depth=1;
}
var tp=typeof(v), val;
if (v===null) {
return "null";
} else if (v===undefined) {
return "undefined";
} else if (tp==='object') {
if (depth>0) {
var properties=[];
... | javascript | {
"resource": ""
} |
q31679 | train | function(scope, defaultValue) {
var val = evaluator(tree, scope);
if( typeof defaultValue === 'undefined') {
return val;
} else {
return (val === undefined || val === null || val != val) ? defaultValue : val;
}
} | javascript | {
"resource": ""
} | |
q31680 | train | function(scope, newValue) {
if (!isAssignable) {
throw new Error('Expression "' + input + '" is not assignable');
}
if (tree.a === 'idn') {
json.set(scope, tree.v, newValue);
} else if (tree.a === 'bnr') {
json.set(evaluator... | javascript | {
"resource": ""
} | |
q31681 | setURLParameter | train | function setURLParameter(url, key, value) {
if(typeof url !== 'string') {
throw new Error('URLs must be a string');
}
if(urlUtils) {
//node.js
url = urlUtils.parse(url);
url.search = ((url.search) ? url.search + '&' : '?') + key + '=' + value;
url = urlUtils.format(url);
}
else {
//... | javascript | {
"resource": ""
} |
q31682 | hashcons | train | function hashcons(node) {
const keys = t.VISITOR_KEYS[node.type];
if (!keys) return;
let hash = hashcode(node);
for (const key of keys) {
const subNode = node[key];
if (Array.isArray(subNode)) {
for (const child of subNode) {
if (child) {
hash += hashcons(child);
}
... | javascript | {
"resource": ""
} |
q31683 | formatError | train | function formatError (error, input) {
var message = error.toString().replace(/\s*\(\d*\:\d*\)\s*$/i, ''); // remove line number / col number
var beforeMatch = ('' + input.slice(0, error.pos)).match(/.*$/i);
var afterMatch = ('' + input.slice(error.pos)).match(/.*/i);
var before = beforeMatch ? beforeMa... | javascript | {
"resource": ""
} |
q31684 | raspi_i2c_devname | train | function raspi_i2c_devname()
{
try {
var revisionBuffer = fs.readFileSync('/sys/module/bcm2708/parameters/boardrev');
var revisionInt = parseInt(revisionBuffer.toString(), 10);
//console.log('Raspberry Pi board revision: ', revisionInt);
// Older boards use i2c-0, newer boards use i2... | javascript | {
"resource": ""
} |
q31685 | train | function() {
// determine if cpt supports template arguments
if (this.template) {
// as template can be changed dynamically we have to sync the constructor
this.ctlConstuctor=this.template.controllerConstructor;
}
var ctlProto=this.ctlConstuctor.prototype;
this.ctlAttributes=ctlProto.$at... | javascript | {
"resource": ""
} | |
q31686 | train | function(localPropOnly) {
if (this.ctlWrapper) {
this.ctlWrapper.$dispose();
this.ctlWrapper=null;
this.controller=null;
}
this.ctlAttributes=null;
this.cleanObjectProperties(localPropOnly);
this.ctlConstuctor=null;
var tpa=this.tplAttributes;
if (tpa) {
for (var k in... | javascript | {
"resource": ""
} | |
q31687 | train | function () {
this.attEltNodes=null;
this._attGenerators=null;
// determine the possible template attribute names
var tpAttNames={}, ca=this.ctlAttributes, defaultTplAtt=null, lastTplAtt=null, count=0;
for (var k in ca) {
if (ca.hasOwnProperty(k) && ca[k].type==="template") {
// k is ... | javascript | {
"resource": ""
} | |
q31688 | train | function (defaultTplAtt) {
if (!this.children) {
return;
}
// TODO memoize result at prototype level to avoid processing this multiple times
var ct=this.getCptContentType(), loadCpts=true;
if (ct==="ERROR") {
loadCpts=false;
log.error(this.info+" Component content cannot mix attr... | javascript | {
"resource": ""
} | |
q31689 | train | function() {
var aen=this.attEltNodes;
if (!aen) {
return null;
}
var attElts=[], cta=this.ctlAttributes;
for (var i=0,sz=aen.length; sz>i;i++) {
aen[i].registerAttElements(attElts);
}
// check that all elements are valid (i.e. have valid names)
var nm, elt, ok, elts=[], cte=... | javascript | {
"resource": ""
} | |
q31690 | train | function() {
var ce=this.childElements;
if (!ce || !ce.length) {
return;
}
var cw;
for (var i=0,sz=ce.length;sz>i;i++) {
cw=ce[i].ctlWrapper;
if (cw && !cw.initialized) {
cw.init(null,this.controller);
}
}
} | javascript | {
"resource": ""
} | |
q31691 | train | function (evt) {
var evh = this.evtHandlers, et = evt.type;
if (evh) {
for (var i = 0, sz = evh.length; sz > i; i++) {
if (evh[i].evtType === et) {
evh[i].executeCb(evt, this.eh, this.parent.vscope);
break;
}
}
}
} | javascript | {
"resource": ""
} | |
q31692 | train | function (prevNode, newNode) {
if (prevNode === newNode) {
return;
}
TNode.replaceNodeBy.call(this,prevNode, newNode);
var aen=this.attEltNodes;
if (aen) {
for (var i=0,sz=aen.length; sz>i;i++) {
aen[i].replaceNodeBy(prevNode, newNode);
}
}... | javascript | {
"resource": ""
} | |
q31693 | train | function() {
var c=[], ce=this.childElements, celts=this.ctlElements, eltType;
if (ce && ce.length) {
for (var i=0, sz=ce.length;sz>i;i++) {
eltType=celts[ce[i].name].type;
if (eltType==="component") {
c.push(ce[i].controller);
} else if (eltType==="template") {
... | javascript | {
"resource": ""
} | |
q31694 | train | function () {
if (this.edirty) {
var en=this.attEltNodes;
if (en) {
for (var i=0,sz=en.length; sz>i; i++) {
en[i].refresh();
}
// if content changed we have to rebuild childElements
this.retrieveAttElements();
... | javascript | {
"resource": ""
} | |
q31695 | getAction | train | function getAction(controllerName, actionName) {
controllerName = controllerName.camelize();
var controller = app.controllers[controllerName];
if (controller === undefined && app.models[controllerName])
controller = defaultController;
if (controller)
return controller[actionName || 'index'];
else
re... | javascript | {
"resource": ""
} |
q31696 | addSingleRoute | train | function addSingleRoute(verb, routePath, controllerName, actionName) {
// add controller and action fields to the request
var reqExtender = function(req, res, next) {
req.controller = controllerName;
req.action = actionName || 'index';
next();
};
var params = [routePath, reqExtender];
params = param... | javascript | {
"resource": ""
} |
q31697 | train | function(req, res, next) {
req.controller = controllerName;
req.action = actionName || 'index';
next();
} | javascript | {
"resource": ""
} | |
q31698 | getPolicies | train | function getPolicies(controller, action) {
var policies = config.policies;
var currentPolicies = [];
if (policies[controller] && policies[controller][action]) {
currentPolicies = policies[controller][action];
} else if (Object.isString(policies[controller])) {
currentPolicies = policies[controller];
} e... | javascript | {
"resource": ""
} |
q31699 | addResourceRoute | train | function addResourceRoute(routePath, controllerName) {
resourceRouting.forEach(function(route) {
var actionPath = route.path.replace(':controller', controllerName);
route.verbs.forEach(function (verb) {
addSingleRoute(verb, actionPath, controllerName, route.target.action);
});
});
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.