_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q36600 | train | function(symbol, ctx, partials, indent) {
var partial = this.ep(symbol, partials);
if (!partial) {
return '';
}
return partial.ri(ctx, partials, indent);
} | javascript | {
"resource": ""
} | |
q36601 | train | function(func, ctx, partials) {
var cx = ctx[ctx.length - 1];
return func.call(cx);
} | javascript | {
"resource": ""
} | |
q36602 | findInScope | train | function findInScope(key, scope, doModelGet) {
var val, checkVal;
if (scope && typeof scope == 'object') {
if (scope[key] != null) {
val = scope[key];
// try lookup with get for backbone or similar model data
} else if (doModelGet && scope.get && typeof scope.get == 'function') {
... | javascript | {
"resource": ""
} |
q36603 | _mergeOptions | train | function _mergeOptions () {
var options = {}
for (var i = 0; i < arguments.length; ++i) {
let obj = arguments[i]
for (var attr in obj) { options[attr] = obj[attr] }
}
return options
} | javascript | {
"resource": ""
} |
q36604 | Base | train | function Base(runner) {
var self = this
, stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }
, failures = this.failures = [];
if (!runner) return;
this.runner = runner;
runner.stats = stats;
runner.on('start', function(){
stats.start = new Date;
});
runner.on(... | javascript | {
"resource": ""
} |
q36605 | inlineDiff | train | function inlineDiff(err, escape) {
var msg = errorDiff(err, 'WordsWithSpace', escape);
// linenos
var lines = msg.split('\n');
if (lines.length > 4) {
var width = String(lines.length).length;
msg = lines.map(function(str, i){
return pad(++i, width) + ' |' + ' ' + str;
}).join('\n');
}
//... | javascript | {
"resource": ""
} |
q36606 | unifiedDiff | train | function unifiedDiff(err, escape) {
var indent = ' ';
function cleanUp(line) {
if (escape) {
line = escapeInvisibles(line);
}
if (line[0] === '+') return indent + colorLines('diff added', line);
if (line[0] === '-') return indent + colorLines('diff removed', line);
if (line.match(/\@\... | javascript | {
"resource": ""
} |
q36607 | stringify | train | function stringify(obj) {
if (obj instanceof RegExp) return obj.toString();
return JSON.stringify(obj, null, 2);
} | javascript | {
"resource": ""
} |
q36608 | canonicalize | train | function canonicalize(obj, stack) {
stack = stack || [];
if (utils.indexOf(stack, obj) !== -1) return obj;
var canonicalizedObj;
if ('[object Array]' == {}.toString.call(obj)) {
stack.push(obj);
canonicalizedObj = utils.map(obj, function(item) {
return canonicalize(item, stack);
});... | javascript | {
"resource": ""
} |
q36609 | RejectedPromise | train | function RejectedPromise(reason, unused, onRejected, deferred) {
if (!onRejected) {
deferredAdopt(deferred, RejectedPromise, reason);
return this;
}
if (!deferred) {
deferred = new Deferred(this.constructor);
}
defer(tryCatchDeferred(deferred, onRejected, reason));
return deferred.promise;
} | javascript | {
"resource": ""
} |
q36610 | PendingPromise | train | function PendingPromise(queue, onFulfilled, onRejected, deferred) {
if (!deferred) {
if (!onFulfilled && !onRejected) { return this; }
deferred = new Deferred(this.constructor);
}
queue.push({
deferred: deferred,
onFulfilled: onFulfilled || deferred.resolve,
onRejected: onRejected || deferred.... | javascript | {
"resource": ""
} |
q36611 | adopt | train | function adopt(promise, state, value, adoptee) {
var queue = promise._value;
promise._state = state;
promise._value = value;
if (adoptee && state === PendingPromise) {
adoptee._state(value, void 0, void 0, {
promise: promise,
resolve: void 0,
reject: void 0
});
}
for (var i = 0; ... | javascript | {
"resource": ""
} |
q36612 | deferredAdopt | train | function deferredAdopt(deferred, state, value) {
if (deferred) {
var promise = deferred.promise;
promise._state = state;
promise._value = value;
}
} | javascript | {
"resource": ""
} |
q36613 | each | train | function each(collection, iterator) {
for (var i = 0; i < collection.length; i++) {
iterator(collection[i], i);
}
} | javascript | {
"resource": ""
} |
q36614 | tryCatchDeferred | train | function tryCatchDeferred(deferred, fn, arg) {
var promise = deferred.promise;
var resolve = deferred.resolve;
var reject = deferred.reject;
return function() {
try {
var result = fn(arg);
doResolve(promise, resolve, reject, result, result);
} catch (e) {
reject(e);
}
};
} | javascript | {
"resource": ""
} |
q36615 | password | train | function password (n, special) {
n = n || 3;
special = special === true;
var result = "",
i = -1,
used = {},
hasSub = false,
hasExtra = false,
flip, lth, pos, rnd, word;
function sub (x, idx) {
if (!hasSub && word.indexOf(x) > -1) {
word = word.replace(x, subs[idx]);
hasSub = true;
flip = fals... | javascript | {
"resource": ""
} |
q36616 | CountStream | train | function CountStream (opts) {
if (!(this instanceof CountStream)) return new CountStream(opts)
stream.PassThrough.call(this, opts)
this.destroyed = false
this.size = 0
} | javascript | {
"resource": ""
} |
q36617 | train | function(stack) {
if (exports.async_trace_limit <= 0) {
return;
}
var count = exports.async_trace_limit - 1;
var previous = stack;
while (previous && count > 1) {
previous = previous.__previous__;
--count;
}
if (previous) {
delete previous.__previous__;
... | javascript | {
"resource": ""
} | |
q36618 | train | function(callback) {
// capture current error location
var trace_error = new Error();
trace_error.id = ERROR_ID++;
trace_error.__previous__ = current_trace_error;
trace_error.__trace_count__ = current_trace_error ? current_trace_error.__trace_count__ + 1 : 1;
limit_frames(trace_error);
var n... | javascript | {
"resource": ""
} | |
q36619 | addTime | train | function addTime(options, client) {
return function(next, project) {
var dates = options.dates;
delete options.dates;
var join = futures.join();
join.add(dates.map(function(date) {
var promise = futures.future();
// we must clone to prevent options.date overri... | javascript | {
"resource": ""
} |
q36620 | askForSave | train | function askForSave(conf) {
return function(next, project) {
process.stdout.write('Do you yant to save this project combinaison: (y/N)');
utils.readInput(function(input) {
if (input == 'y') {
process.stdout.write('Name of this combinaison: ');
utils.readIn... | javascript | {
"resource": ""
} |
q36621 | optionsFrom | train | function optionsFrom(argv) {
var date = argv.date,
dates = utils.parseDate(date),
options = { time: argv.hours,
dates: dates,
billable: argv.billable || argv.b,
description: argv.description };
return options;
} | javascript | {
"resource": ""
} |
q36622 | reqURL | train | function reqURL(req, newPath) {
return url.format({
protocol: 'https', //req.protocol, // by default this returns http which gets redirected
host: req.get('host'),
pathname: newPath
})
} | javascript | {
"resource": ""
} |
q36623 | ToolTip | train | function ToolTip({ className, children, label, position, type }) {
const classes = cx(
tooltipClassName,
`${tooltipClassName}--${position}`,
`${tooltipClassName}--${type}`,
className
)
return (
<button role="tooltip" type="button" className={classes} aria-label={label}>
{children}
</... | javascript | {
"resource": ""
} |
q36624 | format | train | function format(node, context, recur) {
var blockComments = context.blockComments(node);
for (var i = 0; i < node.body.length; i++) {
var previous = node.body[i - 1];
var current = node.body[i];
var next = node.body[i + 1];
if (current.type === 'EmptyStatement') {
c... | javascript | {
"resource": ""
} |
q36625 | showFields | train | function showFields (data, version, fields) {
var o = {}
;[data,version].forEach(function (s) {
Object.keys(s).forEach(function (k) {
o[k] = s[k]
})
})
return search(o, fields.split("."), version._id, fields)
} | javascript | {
"resource": ""
} |
q36626 | findPartials | train | function findPartials(fragment) {
var found = [];
walkRecursive(fragment.t, function(item) {
if (item.t === 8) {
found.push(item.r);
}
});
return _.uniq(found);
} | javascript | {
"resource": ""
} |
q36627 | train | function (location, opts, callback) {
resolve(location, function (err, fileUri) {
if (err) {
return callback(err)
}
bundle(fileUri, opts, callback)
})
} | javascript | {
"resource": ""
} | |
q36628 | sendError | train | function sendError(req, res, err) {
return res.end("(" + function (err) {
throw new Error(err)
} + "(" + JSON.stringify(err.message) + "))")
} | javascript | {
"resource": ""
} |
q36629 | ByteCharateristic | train | function ByteCharateristic(opts) {
ByteCharateristic.super_.call(this, opts);
this.on('beforeWrite', function(data, res) {
res(data.length == opts.sizeof ? Results.Success : Results.InvalidAttributeLength);
});
this.toBuffer = byte2buf(opts.sizeof);
this.fromBuffer = buf2byte(opts.sizeof);
} | javascript | {
"resource": ""
} |
q36630 | LockStateCharateristic | train | function LockStateCharateristic(opts) {
LockStateCharateristic.super_.call(this, objectAssign({
uuid: 'ee0c2081-8786-40ba-ab96-99b91ac981d8',
properties: ['read'],
sizeof: 1
}, opts));
} | javascript | {
"resource": ""
} |
q36631 | TxPowerLevelCharateristic | train | function TxPowerLevelCharateristic(opts) {
TxPowerLevelCharateristic.super_.call(this, objectAssign({
uuid: 'ee0c2084-8786-40ba-ab96-99b91ac981d8',
properties: ['read', 'write'],
}, opts));
this.on('beforeWrite', function(data, res) {
res(data.length == 4 ? Results.Success : Results.InvalidAttributeLength);
... | javascript | {
"resource": ""
} |
q36632 | TxPowerModeCharateristic | train | function TxPowerModeCharateristic(opts) {
TxPowerModeCharateristic.super_.call(this, objectAssign({
uuid: 'ee0c2087-8786-40ba-ab96-99b91ac981d8',
properties: ['read', 'write'],
sizeof: 1
}, opts));
this.removeAllListeners('beforeWrite');
this.on('beforeWrite', function(data, res) {
var err = Results.Succe... | javascript | {
"resource": ""
} |
q36633 | BeaconPeriodCharateristic | train | function BeaconPeriodCharateristic(opts) {
BeaconPeriodCharateristic.super_.call(this, objectAssign({
uuid: 'ee0c2088-8786-40ba-ab96-99b91ac981d8',
properties: ['read', 'write'],
sizeof: 2
}, opts));
} | javascript | {
"resource": ""
} |
q36634 | getBrowserLanguage | train | function getBrowserLanguage() {
var first = window.navigator.languages
? window.navigator.languages[0]
: null
var lang = first
|| window.navigator.language
|| window.navigator.browserLanguage
|| window.navigator.userLanguage
return lang
} | javascript | {
"resource": ""
} |
q36635 | isPositiveIntegerArray | train | function isPositiveIntegerArray(value) {
var success = true;
for(var i = 0; i < value.length; i++) {
if(!config.checkIntegerValue.test(value[i]) || parseInt(value[i]) <= 0) {
success = false;
break;
}
}
return success;
} | javascript | {
"resource": ""
} |
q36636 | isValidDate | train | function isValidDate(dateString, dateFormat, returnDateFormat) {
if(moment(dateString, dateFormat).format(dateFormat) !== dateString) {
return false;
}
if(!moment(dateString, dateFormat).isValid()) {
return false;
}
if(returnDateFormat) {
return moment(dateString, dateFormat)... | javascript | {
"resource": ""
} |
q36637 | objValByStr | train | function objValByStr(name, separator, context) {
var func, i, n, ns, _i, _len;
if (!name || !separator || !context) {
return null;
}
ns = name.split(separator);
func = context;
try {
for (i = _i = 0, _len = ns.length; _i < _len; i = ++_i) {
n = ns[i];
func... | javascript | {
"resource": ""
} |
q36638 | train | function (arrArg) {
return arrArg.filter(function (elem, pos, arr) {
return arr.indexOf(elem) === pos;
});
} | javascript | {
"resource": ""
} | |
q36639 | CSP | train | function CSP(class1, class2) {
var cov1 = stat.cov(class1);
var cov2 = stat.cov(class2);
this.V = numeric.eig(math.multiply(math.inv(math.add(cov1, cov2)), cov1)).E.x;
} | javascript | {
"resource": ""
} |
q36640 | FieldLabel | train | function FieldLabel(props) {
var label = props.label, indicator = props.indicator, tooltipProps = props.tooltipProps, infoIconProps = props.infoIconProps;
var indicatorEl = null;
if (indicator === 'optional') {
indicatorEl = React.createElement("span", { className: 'indicator' }, "(optional)");
... | javascript | {
"resource": ""
} |
q36641 | FieldError | train | function FieldError(props) {
var touched = props.touched, error = props.error;
if (touched && error) {
return React.createElement("div", { className: 'c-form-field--error-message' }, error);
}
return null;
} | javascript | {
"resource": ""
} |
q36642 | buffered | train | function buffered(fn) {
var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
var id = void 0;
var bn = function bn() {
var _this = this;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_k... | javascript | {
"resource": ""
} |
q36643 | imgGlitch | train | function imgGlitch(img, options) {
var imgElement = 'string' === typeof img ? document.querySelector(img) : img;
if (!(imgElement instanceof HTMLImageElement && imgElement.constructor === HTMLImageElement)) {
throw new TypeError('renderImgCorruption expects input img to be a valid image element');
}
var co... | javascript | {
"resource": ""
} |
q36644 | add | train | function add(name, methods) {
// Create a container class that extends Document for our methods.
class ConcreteDocument extends Document {
constructor(document, root) {
super(name, document, root);
}
}
// Assign the methods to the new classes prototype.
assignIn(ConcreteDocument.prototype, met... | javascript | {
"resource": ""
} |
q36645 | train | function(subpath, regs){
for(var i = 0, len = regs.length; i < len; i++){
var reg = regs[i];
if(reg && fis.util.filter(subpath, reg)){
return i;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q36646 | confBool | train | function confBool(obj, field) {
if (field in obj)
obj[field] = bool(obj[field]);
} | javascript | {
"resource": ""
} |
q36647 | train | function (consumer_key, consumer_secret) {
this.oauth = new OAuth.OAuth(
'https://query.yahooapis.com/v1/yql/',
'https://query.yahooapis.com/v1/yql/',
consumer_key, //consumer key
consumer_secret, //consumer secret
'1.0',
null,
'HMAC-SHA1'
... | javascript | {
"resource": ""
} | |
q36648 | clone | train | function clone (obj) {
if(!isObject(obj, true)) return obj
var _obj
_obj = Array.isArray(obj) ? [] : {}
for(var k in obj) _obj[k] = clone(obj[k])
return _obj
} | javascript | {
"resource": ""
} |
q36649 | iteratePipeFile | train | function iteratePipeFile () {
if (!isIterating()) { return undefined; }
let data = iterateData;
let file = data.collection[data.i];
data.i++;
if (data.i >= data.collection.length) {
resetIterateData();
pipeLastFile(file);
} else {
pipeFile(file, iteratePipeFile);
}... | javascript | {
"resource": ""
} |
q36650 | iterateWriteArray | train | function iterateWriteArray () {
if (!isIterating()) { return undefined; }
let data = iterateData;
let content = data.collection[data.i];
data.i++;
if (data.i >= data.collection.length) {
resetIterateData();
writable.write(content, 'utf8', onWriteFinish);
} else {
writ... | javascript | {
"resource": ""
} |
q36651 | iterateWriteLinkedList | train | function iterateWriteLinkedList () {
if (!isIterating()) { return undefined; }
let data = iterateData;
let content = iterateData.item.content;
data.item = data.item.next;
if (data.item === null) {
resetIterateData();
writable.write(content, 'utf8', onWriteFinish);
} else {
... | javascript | {
"resource": ""
} |
q36652 | pipeFile | train | function pipeFile (file, endCallback) {
testPipeFile();
testFunction(endCallback, 'endCallback');
let readable = fs.createReadStream(file);
readableEndCallback = endCallback;
readable.once('error', throwAsyncError);
readable.once('close', onReadableClose);
readable.pipe(writable, { end: ... | javascript | {
"resource": ""
} |
q36653 | pipeFileArray | train | function pipeFileArray (arr) {
testPipeFile();
// Just end WriteStream if no files need to be read to keep default pipe behavior.
if (arr.length === 0) {
writable.end();
} else {
iterateData.collection = arr;
iteratePipeFile();
}
} | javascript | {
"resource": ""
} |
q36654 | pipeLastFile | train | function pipeLastFile (file) {
testPipeFile();
let readable = fs.createReadStream(file);
readable.once('error', throwAsyncError);
readable.pipe(writable);
} | javascript | {
"resource": ""
} |
q36655 | Leverage | train | function Leverage(client, sub, options) {
if (!this) return new Leverage(client, sub, options);
//
// Flakey detection if we got a options argument or an actual Redis client. We
// could do an instanceOf RedisClient check but I don't want to have Redis as
// a dependency of this module.
//
if ('object' =... | javascript | {
"resource": ""
} |
q36656 | failed | train | function failed(err) {
leverage.emit(channel +'::error', err);
if (!bailout) return debug('received an error without bailout mode, gnoring it', err.message);
leverage.emit(channel +'::bailout', err);
leverage.unsubscribe(channel);
} | javascript | {
"resource": ""
} |
q36657 | parse | train | function parse(packet) {
if ('object' === typeof packet) return packet;
try { return JSON.parse(packet); }
catch (e) { return failed(e); }
} | javascript | {
"resource": ""
} |
q36658 | flush | train | function flush() {
if (queue.length) {
//
// We might want to indicate that these are already queued, so we don't
// fetch data again.
//
queue.splice(0).sort(function sort(a, b) {
return a.id - b.id;
}).forEach(onmessage);
}
} | javascript | {
"resource": ""
} |
q36659 | allowed | train | function allowed(packet) {
if (!packet) return false;
if (uv.position === 'inactive' || (!uv.received(packet.id) && ordered)) {
queue.push(packet);
return false;
}
return true;
} | javascript | {
"resource": ""
} |
q36660 | onmessage | train | function onmessage(packet) {
if (arguments.length === 2) packet = arguments[1];
packet = parse(packet);
if (allowed(packet)) emit(packet);
} | javascript | {
"resource": ""
} |
q36661 | initialize | train | function initialize(config, callback, config_helper) {
config_helper = config_helper || require('../config/index');
if(!checkConfSanity(config)) {
callback(new Error('conf.dbopt is not sane, can\'t initialize composite adapter'));
return;
}
populateDatabasesArray(config, config_helper, function(err, d... | javascript | {
"resource": ""
} |
q36662 | deepSync | train | function deepSync(target, source, overwrite) {
if (!(((target) && (typeof target === 'object')) &&
((source) && (typeof source === 'object'))) ||
(source instanceof Array) || (target instanceof Array)) {
throw new TypeError('Source and Target must be objects.');
}
let sourceKeys =... | javascript | {
"resource": ""
} |
q36663 | equalSimpleArrays | train | function equalSimpleArrays(arr1, arr2) {
if (arr1 && (arr1.length > 0))
return (
arr2 &&
(arr2.length === arr1.length) &&
arr2.every((v, i) => (v === arr1[i]))
);
return (!arr2 || (arr2.length === 0));
} | javascript | {
"resource": ""
} |
q36664 | equalSimpleMaps | train | function equalSimpleMaps(map1, map2) {
const keys1 = (map1 && Object.keys(map1));
if (map1 && (keys1.length > 0)) {
const keys2 = (map2 && Object.keys(map2));
return (
keys2 &&
(keys2.length === keys1.length) &&
keys2.every(k => (map2[k] === map1[k]))
);
}
return (!map2 || (Object.keys(map2).leng... | javascript | {
"resource": ""
} |
q36665 | needsAdd | train | function needsAdd(ptr, record, value) {
const propDesc = ptr.propDesc;
if (propDesc.isArray()) {
if (ptr.collectionElement)
return true;
if (propDesc.scalarValueType === 'object')
return !equalObjectArrays(/*ptr.getValue(record), value*/);
return !equalSimpleArrays(ptr.getValue(record), value);
}
if ... | javascript | {
"resource": ""
} |
q36666 | build | train | function build(recordTypes, recordTypeName, patch) {
// get the record type descriptor
if (!recordTypes.hasRecordType(recordTypeName))
throw new common.X2UsageError(
`Unknown record type ${recordTypeName}.`);
const recordTypeDesc = recordTypes.getRecordTypeDesc(recordTypeName);
// make sure the patch spec is... | javascript | {
"resource": ""
} |
q36667 | buildMerge | train | function buildMerge(recordTypes, recordTypeName, mergePatch) {
// only object merge patches are supported
if (((typeof mergePatch) !== 'object') || (mergePatch === null))
throw new common.X2SyntaxError('Merge patch must be an object.');
// build JSON patch
const jsonPatch = new Array();
buildMergeLevel('', mer... | javascript | {
"resource": ""
} |
q36668 | buildMergeLevel | train | function buildMergeLevel(basePtr, levelMergePatch, jsonPatch) {
for (let propName in levelMergePatch) {
const mergeVal = levelMergePatch[propName];
const path = basePtr + '/' + propName;
if (mergeVal === null) {
jsonPatch.push({
op: 'remove',
path: path
});
} else if (Array.isArray(mergeVal)) {
... | javascript | {
"resource": ""
} |
q36669 | resolvePropPointer | train | function resolvePropPointer(recordTypeDesc, propPointer, noDash, ptrUse) {
// parse the pointer
const ptr = pointers.parse(recordTypeDesc, propPointer, noDash);
// check if top pointer
if (ptr.isRoot())
throw new common.X2SyntaxError(
'Patch operations involving top records as a whole are not' +
' allowe... | javascript | {
"resource": ""
} |
q36670 | validatePatchOperationValue | train | function validatePatchOperationValue(
recordTypes, opType, opInd, pathPtr, val, forUpdate) {
// error function
const validate = errMsg => {
if (errMsg)
throw new common.X2SyntaxError(
`Invalid value in patch operation #${opInd + 1} (${opType}):` +
` ${errMsg}`);
};
// check if we have the value
if... | javascript | {
"resource": ""
} |
q36671 | isValidRefValue | train | function isValidRefValue(recordTypes, val, propDesc) {
if ((typeof val) !== 'string')
return false;
const hashInd = val.indexOf('#');
if ((hashInd <= 0) || (hashInd === val.length - 1))
return false;
const refTarget = val.substring(0, hashInd);
if (refTarget !== propDesc.refTarget)
return false;
const r... | javascript | {
"resource": ""
} |
q36672 | isValidObjectValue | train | function isValidObjectValue(recordTypes, val, objectPropDesc, forUpdate) {
const container = objectPropDesc.nestedProperties;
for (let propName of container.allPropertyNames) {
const propDesc = container.getPropertyDesc(propName);
if (propDesc.isView() || propDesc.isCalculated())
continue;
const propVal = v... | javascript | {
"resource": ""
} |
q36673 | validatePatchOperationFrom | train | function validatePatchOperationFrom(opType, opInd, pathPtr, fromPtr, forMove) {
const invalidFrom = msg => new common.X2SyntaxError(
`Invalid "from" pointer in patch operation #${opInd + 1} (${opType}):` +
` ${msg}`);
if (forMove && pathPtr.isChildOf(fromPtr))
throw invalidFrom('may not move location into on... | javascript | {
"resource": ""
} |
q36674 | isCompatibleObjects | train | function isCompatibleObjects(objectPropDesc1, objectPropDesc2) {
const propNames2 = new Set(objectPropDesc2.allPropertyNames);
const container1 = objectPropDesc1.nestedProperties;
const container2 = objectPropDesc2.nestedProperties;
for (let propName of objectPropDesc1.allPropertyNames) {
const propDesc1 = conta... | javascript | {
"resource": ""
} |
q36675 | addInvolvedProperty | train | function addInvolvedProperty(pathPtr, involvedPropPaths, updatedPropPaths) {
if (updatedPropPaths) {
const propPathParts = pathPtr.propPath.split('.');
let propPath = '';
for (let i = 0, len = propPathParts.length - 1; i < len; i++) {
if (propPath.length > 0)
propPath += '.';
propPath += propPathParts... | javascript | {
"resource": ""
} |
q36676 | addInvolvedObjectProperty | train | function addInvolvedObjectProperty(
objectPropDesc, involvedPropPaths, updatedPropPaths) {
if (updatedPropPaths)
updatedPropPaths.add(
objectPropDesc.container.nestedPath + objectPropDesc.name);
const container = objectPropDesc.nestedProperties;
for (let propName of container.allPropertyNames) {
const prop... | javascript | {
"resource": ""
} |
q36677 | convertArabicBack | train | function convertArabicBack(apfb) {
var toReturn = "",
selectedChar;
theLoop:
for( var i = 0 ; i < apfb.length ; ++i ) {
selectedChar = apfb.charCodeAt(i);
for( var j = 0 ; j < charsMap.length ; ++j ) {
if( charsMap[j][4] == selectedChar || charsMap[j][2] == selectedChar ||
charsMap[j][1] == selected... | javascript | {
"resource": ""
} |
q36678 | createFilesProvider | train | function createFilesProvider({
regex = null
, single = HANDLE
, multi = PROMPT_AND_HANDLE
, choiceAll = true
, handler = null
, promptHeader = defaultPromptHeader
, promptFooter = defaultPromptFooter
} = {}) {
return new FilesProvider({
regex
, single
, multi
, choice... | javascript | {
"resource": ""
} |
q36679 | prepareStackTrace | train | function prepareStackTrace( error, structuredStackTrace ) {
// If error already have a cached trace inside, just return that
// happens on true errors most
if ( error.__cachedTrace ) { return error.__cachedTrace; }
const stackTrace = utils.createStackTrace( error, structuredStackTrace );
error.__cachedTrace ... | javascript | {
"resource": ""
} |
q36680 | wrapCallback | train | function wrapCallback( fn, frameLocation ) {
const traceError = new Error();
traceError.__location = frameLocation;
traceError.__previous = currentTraceError;
return function $wrappedCallback( ...args ) {
currentTraceError = traceError;
try {
return fn.call( this, ...args );
} catch ( e ) {
... | javascript | {
"resource": ""
} |
q36681 | $wrapped | train | function $wrapped( ...args ) {
const wrappedArgs = args.slice();
args.forEach( ( arg, i ) => {
if ( typeof arg === 'function' ) {
wrappedArgs[i] = wrapCallback( args[i], origin );
}
} );
return method.call( this, ...wrappedArgs );
} | javascript | {
"resource": ""
} |
q36682 | ls_ | train | function ls_ (req, depth, cb) {
if (typeof cb !== "function") cb = depth, depth = 1
mkdir(npm.cache, function (er) {
if (er) return log.er(cb, "no cache dir")(er)
function dirFilter (f, type) {
return type !== "dir" ||
( f && f !== npm.cache + "/" + req
&& f !== npm.cache + "/" + req ... | javascript | {
"resource": ""
} |
q36683 | parse | train | function parse(cmd, params)
{
return Object.keys(params).reduce(iterator.bind(this, params), cmd);
} | javascript | {
"resource": ""
} |
q36684 | iterator | train | function iterator(params, cmd, p)
{
var value = params[p];
// shortcut
if (!cmd) return cmd;
// fold booleans into strings accepted by shell
if (typeof value == 'boolean')
{
value = value ? '1' : '';
}
if (value !== null && ['undefined', 'string', 'number'].indexOf(typeof value) == -1)
{
//... | javascript | {
"resource": ""
} |
q36685 | buildPropsTreeBranches | train | function buildPropsTreeBranches(
recordTypes, topPropDesc, clause, baseValueExprCtx, scopePropPath,
propPatterns, options) {
// create the branching tree top node
const topNode = PropertyTreeNode.createTopNode(
recordTypes, topPropDesc, baseValueExprCtx, clause);
// add direct patterns
const valuePropsTrees =... | javascript | {
"resource": ""
} |
q36686 | buildSuperPropsTreeBranches | train | function buildSuperPropsTreeBranches(
recordTypes, recordTypeDesc, superPropNames) {
// create the branching tree top node
const topNode = PropertyTreeNode.createTopNode(
recordTypes, {
isScalar() { return true; },
isCalculated() { return false; },
refTarget: recordTypeDesc.superRecordTypeName
},
new... | javascript | {
"resource": ""
} |
q36687 | buildSimplePropsTree | train | function buildSimplePropsTree(
recordTypes, topPropDesc, clause, baseValueExprCtx, propPaths) {
// create the branching tree top node
const topNode = PropertyTreeNode.createTopNode(
recordTypes, topPropDesc, baseValueExprCtx, clause);
// add properties
const valuePropsTrees = new Map();
const options = {
ig... | javascript | {
"resource": ""
} |
q36688 | addProperty | train | function addProperty(
topNode, scopePropPath, propPattern, clause, options, valuePropsTrees,
wcPatterns) {
// process the pattern parts
let expandChildren = false;
const propPatternParts = propPattern.split('.');
const numParts = propPatternParts.length;
let parentNode = topNode;
let patternPrefix = topNode.pa... | javascript | {
"resource": ""
} |
q36689 | train | function(model, options, finish) {
var asyncCreator = async() // Task runner that actually creates all the Mongo records
// Deal with timeout errors (usually unsolvable circular references) {{{
.timeout(settings.timeout || 2000, function() {
var taskIDs = {};
var remaining = this._struct
// Prepare a loo... | javascript | {
"resource": ""
} | |
q36690 | extractFKs | train | function extractFKs(schema) {
var FKs = {};
_.forEach(schema.paths, function(path, id) {
if (id == 'id' || id == '_id') {
// Pass
} else if (path.instance && path.instance == 'ObjectID') {
FKs[id] = {type: FK_OBJECTID};
} else if (path.caster && path.caster.instance == 'ObjectID') { // Array of ObjectIDs... | javascript | {
"resource": ""
} |
q36691 | injectFKs | train | function injectFKs(row, fks) {
_.forEach(fks, function(fk, id) {
if (!_.has(row, id)) return; // Skip omitted FK refs
var lookupKey = _.get(row, id);
switch (fk.type) {
case FK_OBJECTID: // 1:1 relationship
if (!settings.refs[lookupKey])
throw new Error('Attempting to inject non-existant reference "... | javascript | {
"resource": ""
} |
q36692 | determineFKs | train | function determineFKs(row, fks) {
var refs = [];
_.forEach(fks, function(fk, id) {
if (row[id] === undefined) return; // Skip omitted FK refs
switch (fk.type) {
case FK_OBJECTID: // 1:1 relationship
refs.push(row[id]);
break;
case FK_OBJECTID_ARRAY: // 1:M array based relationship
_.forEach(ro... | javascript | {
"resource": ""
} |
q36693 | unflatten | train | function unflatten(obj) {
var out = {};
_.forEach(obj, function(v, k) {
_.set(out, k, v);
});
return out;
} | javascript | {
"resource": ""
} |
q36694 | createRow | train | function createRow(collection, id, row, callback) {
injectFKs(row, settings.knownFK[collection]);
// build up list of all sub-document _ref's that we need to find in the newly saved document
// this is to ensure we capture _id from inside nested array documents that do not exist at root level
var refsMeta = [];
t... | javascript | {
"resource": ""
} |
q36695 | train | function(arr, iterator) {
if (typeof iterator !== 'function') return apiRejection('iterator must be a function');
var self = this;
var i = 0;
return Promise.resolve().then(function iterate() {
if (i == arr.length) return;
return Promise.resolve(iterator.call(self, arr[i]))
.then(function(resul... | javascript | {
"resource": ""
} | |
q36696 | train | function(value, ifFn, elseFn) {
if ((ifFn && typeof ifFn !== 'function') || (elseFn && typeof elseFn !== 'function')) return apiRejection('ifFn and elseFn must be functions');
var fn = value ? ifFn : elseFn;
if (!fn) return Promise.resolve(value);
return Promise.resolve(fn.call(this, value));
} | javascript | {
"resource": ""
} | |
q36697 | fill | train | function fill(buffer, value) {
$.checkArgumentType(buffer, 'Buffer', 'buffer');
$.checkArgumentType(value, 'number', 'value');
var length = buffer.length;
for (var i = 0; i < length; i++) {
buffer[i] = value;
}
return buffer;
} | javascript | {
"resource": ""
} |
q36698 | emptyBuffer | train | function emptyBuffer(bytes) {
$.checkArgumentType(bytes, 'number', 'bytes');
var result = new buffer.Buffer(bytes);
for (var i = 0; i < bytes; i++) {
result.write('\0', i);
}
return result;
} | javascript | {
"resource": ""
} |
q36699 | integerAsBuffer | train | function integerAsBuffer(integer) {
$.checkArgumentType(integer, 'number', 'integer');
var bytes = [];
bytes.push((integer >> 24) & 0xff);
bytes.push((integer >> 16) & 0xff);
bytes.push((integer >> 8) & 0xff);
bytes.push(integer & 0xff);
return new Buffer(bytes);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.