_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q4600
_transform
train
function _transform( xslStr, xmlDoc, xsltParams ) { const params = xsltParams || {}; return new Promise( ( resolve, reject ) => { libxslt.parse( xslStr, ( error, stylesheet ) => { if ( error ) { reject( error ); } else { stylesheet.apply( xmlDoc, p...
javascript
{ "resource": "" }
q4601
_parseXml
train
function _parseXml( xmlStr ) { let doc; return new Promise( ( resolve, reject ) => { try { doc = libxmljs.parseXml( xmlStr ); resolve( doc ); } catch ( e ) { reject( e ); } } ); }
javascript
{ "resource": "" }
q4602
_replaceTheme
train
function _replaceTheme( doc, theme ) { const HAS_THEME = /(theme-)[^"'\s]+/; if ( !theme ) { return doc; } const formClassAttr = doc.root().get( '/root/form' ).attr( 'class' ); const formClassValue = formClassAttr.value(); if ( HAS_THEME.test( formClassValue ) ) { formClassAtt...
javascript
{ "resource": "" }
q4603
_replaceMediaSources
train
function _replaceMediaSources( xmlDoc, mediaMap ) { if ( !mediaMap ) { return xmlDoc; } // iterate through each element with a src attribute xmlDoc.find( '//*[@src] | //a[@href]' ).forEach( mediaEl => { const attribute = ( mediaEl.name().toLowerCase() === 'a' ) ? 'href' : 'src'; ...
javascript
{ "resource": "" }
q4604
_replaceLanguageTags
train
function _replaceLanguageTags( doc, survey ) { const map = {}; const languageElements = doc.find( '/root/form/select[@id="form-languages"]/option' ); // List of parsed language objects const languages = languageElements.map( el => { const lang = el.text(); return language.parse( lang, ...
javascript
{ "resource": "" }
q4605
_getLanguageSampleText
train
function _getLanguageSampleText( doc, lang ) { // First find non-empty text content of a hint with that lang attribute. // If not found, find any span with that lang attribute. const langSampleEl = doc.get( `/root/form//span[contains(@class, "or-hint") and @lang="${lang}" and normalize-space() and not(./tex...
javascript
{ "resource": "" }
q4606
_renderMarkdown
train
function _renderMarkdown( htmlDoc ) { const replacements = {}; // First turn all outputs into text so *<span class="or-output></span>* can be detected htmlDoc.find( '/root/form//span[contains(@class, "or-output")]' ).forEach( ( el, index ) => { const key = `---output-${index}`; const textNo...
javascript
{ "resource": "" }
q4607
_md5
train
function _md5( message ) { const hash = crypto.createHash( 'md5' ); hash.update( message ); return hash.digest( 'hex' ); }
javascript
{ "resource": "" }
q4608
markdownToHtml
train
function markdownToHtml( text ) { // note: in JS $ matches end of line as well as end of string, and ^ both beginning of line and string const html = text // html encoding of < because libXMLJs Element.text() converts html entities .replace( /</gm, '&lt;' ) // html encoding of < because ...
javascript
{ "resource": "" }
q4609
getLiveStream
train
function getLiveStream(options) { return raspivid(Object.assign({ width: 960, height: 540, framerate: 20, profile: 'baseline', timeout: 0 }, options)) .pipe(new Splitter(NALseparator)) .pipe(new stream.Transform({ transform: function (chunk, encoding, callback) { ...
javascript
{ "resource": "" }
q4610
_request
train
function _request( options ) { options.headers = options.headers || {}; options.headers[ 'X-OpenRosa-Version' ] = '1.0'; const method = options.method || 'get'; return new Promise( ( resolve, reject ) => { request[ method ]( options, ( error, response, body ) => { if ( error ) { ...
javascript
{ "resource": "" }
q4611
percentage
train
function percentage(num) { const MAX_CHARACTERS = 4; const relativePercentage = Math.ceil(num * 100 / (100 / MAX_CHARACTERS)); return `[${'▒'.repeat(relativePercentage)}${' '.repeat(MAX_CHARACTERS - relativePercentage)}]`; }
javascript
{ "resource": "" }
q4612
extend
train
function extend(obj, dft) { if (obj == null) { obj = {}; } for (var k in dft) { var v = dft[k]; if (obj[k] != null) { continue; } obj[k] = v; } return obj; }
javascript
{ "resource": "" }
q4613
isBlank
train
function isBlank(char) { return (char === ' ' || char === '\f' || char === '\n' || char === '\r' || char === '\t' || char === '\v' || char === '\u00A0' || char === '\u2028' || char === '\u2029'); }
javascript
{ "resource": "" }
q4614
substr
train
function substr(astralSafeCharacterArray, len) { // var boundary, cutted, result var cutted = astralSafeCharacterArray.slice(0, len).join(''); if (!this.reserveLastWord) { return cutted; } var boundary = astralSafeCharacterArray.slice(len - 1, len + 1).join('');...
javascript
{ "resource": "" }
q4615
isCheerioInstance
train
function isCheerioInstance(elem) { return elem && elem.contains && elem.html && elem.parseHTML && true; }
javascript
{ "resource": "" }
q4616
getScratch
train
function getScratch (eleOrCy, name) { if (eleOrCy.scratch("_autopanOnDrag") === undefined) { eleOrCy.scratch("_autopanOnDrag", {}); } var scratchPad = eleOrCy.scratch("_autopanOnDrag"); return ( name === undefined ) ? scratchPad : scratchPad[name]; }
javascript
{ "resource": "" }
q4617
filter
train
function filter(name, options) { return utils.through.obj(function(file, enc, next) { if (file.isNull()) { next(); return; } var basename = path.basename(file.history[0]); var stem = basename.slice(0, -3); if (basename === name || stem === name) { next(null, file); } else {...
javascript
{ "resource": "" }
q4618
write
train
function write(path, str) { fs.writeFile(path, str); console.log(chalk.cyan(' create:'), path); }
javascript
{ "resource": "" }
q4619
readTemplate
train
function readTemplate(path) { var template = fs.readFileSync(__dirname + '/templates/' + path, 'utf8'); for (var index in data) { template = template.split('__' + index + '__').join(data[index]); } return template; }
javascript
{ "resource": "" }
q4620
mkdir
train
function mkdir(path, fn) { shell.mkdir('-p', path); shell.chmod(755, path); console.log(chalk.cyan(' create:'), path); if (fn) fn(); }
javascript
{ "resource": "" }
q4621
train
function (store, evtName, handler) { var args = [], len = arguments.length - 3; while ( len-- > 0 ) args[ len ] = arguments[ len + 3 ]; this._riotx_change_handlers.push({ store: store, evtName: evtName, handler: handler }); args.unshift(handler); args.unshift(evtName); sto...
javascript
{ "resource": "" }
q4622
train
function () { var this$1 = this; // the context of `this` will be equal to riot tag instant. this.on('unmount', function () { this$1.off('*'); forEach_1(this$1._riotx_change_handlers, function (obj) { obj.store.off(obj.evtName, obj.handler); }); delete this$1...
javascript
{ "resource": "" }
q4623
readFromStream
train
function readFromStream(stream, callback) { var buf = []; stream.on("data", onData); stream.on("end", onEnd); stream.on("error", onError); function onData(data) { buf.push(data); } function onEnd() { if (callback) callback(null, buf.join("")); callback = null; } function onError(err) { ...
javascript
{ "resource": "" }
q4624
train
function($scope) { this.$scope = $scope; this.$markdownInput = $scope.find(SELECTORS.MARKDOWN_INPUT); this.$form = $scope.find(SELECTORS.FORM); this.$titleInput = $scope.find(SELECTORS.TITLE_INPUT); this.$deleteButton = $scope.find(SELECTORS.DELETE); this.dropzone = new Dropzone(SELECTORS.DROP...
javascript
{ "resource": "" }
q4625
train
function (file, responseText) { console.log(responseText); // console should show the ID you pointed to // read the upload path from the elements data-upload attribute. var uploadPath = $(this.dropzone.element).data("upload") + responseText; var linkToUploadedFile = "(" + uploadPath + ")...
javascript
{ "resource": "" }
q4626
add
train
function add(css, name) { if (name) { byName[name] = css; } else { remainder.push(css); } needsInject = true; }
javascript
{ "resource": "" }
q4627
styleObjectToString
train
function styleObjectToString(style) { return Object.keys(style).reduce(function (acc, prop) { return (acc + " " + prop + ": " + (style[prop]) + ";") }, '') }
javascript
{ "resource": "" }
q4628
arrayishAdd
train
function arrayishAdd(obj, key, value, ensureArray, index) { var dest = obj[key]; var isArr = isArray(dest); var hasIndex = !isUndefined(index); if (dest && dest === value) { return } // if the key was never set, set it once if (!dest && ensureArray) { obj[key] = [value]; } el...
javascript
{ "resource": "" }
q4629
arrayishRemove
train
function arrayishRemove(obj, key, value, ensureArray) { if (isArray(obj[key])) { var index = obj[key].indexOf(value); if (index !== -1) { obj[key].splice(index, 1); } if (!obj[key].length) { delete obj[key]; } else if (obj[key].length === 1 && !ensureArray) { obj[key] = obj[key][0]...
javascript
{ "resource": "" }
q4630
makeReplaceVirtual
train
function makeReplaceVirtual(tag, ref) { var frag = createFragment(); makeVirtual.call(tag, frag); ref.parentNode.replaceChild(frag, ref); }
javascript
{ "resource": "" }
q4631
normalizeAttrName
train
function normalizeAttrName(attrName) { if (!attrName) { return null } attrName = attrName.replace(ATTRS_PREFIX, ''); if (CASE_SENSITIVE_ATTRIBUTES[attrName]) { attrName = CASE_SENSITIVE_ATTRIBUTES[attrName]; } return attrName }
javascript
{ "resource": "" }
q4632
updateOpts
train
function updateOpts(isLoop, parent, isAnonymous, opts, instAttrs) { // isAnonymous `each` tags treat `dom` and `root` differently. In this case // (and only this case) we don't need to do updateOpts, because the regular parse // will update those attrs. Plus, isAnonymous tags don't need opts anyway ...
javascript
{ "resource": "" }
q4633
componentUpdate
train
function componentUpdate(tag, data, expressions) { var __ = tag.__; var nextOpts = {}; var canTrigger = tag.isMounted && !__.skipAnonymous; // inherit properties from the parent tag if (__.isAnonymous && __.parent) { extend(tag, __.parent); } extend(tag, data); updateOpts.app...
javascript
{ "resource": "" }
q4634
componentMixin
train
function componentMixin(tag$$1) { var mixins = [], len = arguments.length - 1; while ( len-- > 0 ) mixins[ len ] = arguments[ len + 1 ]; each(mixins, function (mix) { var instance; var obj; var props = []; // properties blacklisted and will not be bound to the tag ins...
javascript
{ "resource": "" }
q4635
remove
train
function remove(tags, i) { tags.splice(i, 1); this.unmount(); arrayishRemove(this.parent, this, this.__.tagName, true); }
javascript
{ "resource": "" }
q4636
move
train
function move(root, nextTag, isVirtual) { if (isVirtual) { moveVirtual.apply(this, [root, nextTag]); } else { safeInsert(root, this.root, nextTag.root); } }
javascript
{ "resource": "" }
q4637
insert
train
function insert(root, nextTag, isVirtual) { if (isVirtual) { makeVirtual.apply(this, [root, nextTag]); } else { safeInsert(root, this.root, nextTag.root); } }
javascript
{ "resource": "" }
q4638
append
train
function append(root, isVirtual) { if (isVirtual) { makeVirtual.call(this, root); } else { root.appendChild(this.root); } }
javascript
{ "resource": "" }
q4639
getItemId
train
function getItemId(keyAttr, originalItem, keyedItem, hasKeyAttrExpr) { if (keyAttr) { return hasKeyAttrExpr ? tmpl(keyAttr, keyedItem) : originalItem[keyAttr] } return originalItem }
javascript
{ "resource": "" }
q4640
createRefDirective
train
function createRefDirective(dom, tag, attrName, attrValue) { return create(RefExpr).init(dom, tag, attrName, attrValue) }
javascript
{ "resource": "" }
q4641
createIfDirective
train
function createIfDirective(dom, tag, attr) { return create(IfExpr).init(dom, tag, attr) }
javascript
{ "resource": "" }
q4642
parseExpressions
train
function parseExpressions(root, mustIncludeRoot) { var this$1 = this; var expressions = []; walkNodes(root, function (dom) { var type = dom.nodeType; var attr; var tagImpl; if (!mustIncludeRoot && dom === root) { return } // text node if (type === 3 ...
javascript
{ "resource": "" }
q4643
setMountState
train
function setMountState(value) { var ref = this.__; var isAnonymous = ref.isAnonymous; define(this, 'isMounted', value); if (!isAnonymous) { if (value) { this.trigger('mount'); } else { this.trigger('unmount'); this.off('*'); this.__.wasCreated = fa...
javascript
{ "resource": "" }
q4644
componentMount
train
function componentMount(tag$$1, dom, expressions, opts) { var __ = tag$$1.__; var root = __.root; root._tag = tag$$1; // keep a reference to the tag just created // Read all the attrs on this instance. This give us the info we need for updateOpts parseAttributes.apply(__.parent, [root, ro...
javascript
{ "resource": "" }
q4645
tagUnmount
train
function tagUnmount(tag, mustKeepRoot, expressions) { var __ = tag.__; var root = __.root; var tagIndex = __TAGS_CACHE.indexOf(tag); var p = root.parentNode; if (!__.skipAnonymous) { tag.trigger('before-unmount'); } // clear all attributes coming from the mounted tag walkAttr...
javascript
{ "resource": "" }
q4646
train
function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; if (!settings$2.debug) { return; } args.unshift('DEBUG'); settings$2.logger.output.apply(null, args); }
javascript
{ "resource": "" }
q4647
injectKineticProperties
train
function injectKineticProperties (kineticConfig, kineticHierarchy, kineticEvents) { for (var type in kineticHierarchy) { var parents = kineticHierarchy[type]; KineticProperty.getParents[type] = [type].concat(parents); for (var pi in paren...
javascript
{ "resource": "" }
q4648
train
function() { var d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]); var m0 = this.m[3] * d; var m1 = -this.m[1] * d; var m2 = -this.m[2] * d; var m3 = this.m[0] * d; var m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]); va...
javascript
{ "resource": "" }
q4649
train
function(x, y) { var m0 = this.m[0], m1 = this.m[1], m2 = this.m[2], m3 = this.m[3], m4 = this.m[4], m5 = this.m[5], yt = ((m0 * (y - m5)) - (m1 * (x - m4))) / ((m0 * m3) - (m1 * m2)), xt = (x - m...
javascript
{ "resource": "" }
q4650
train
function() { var randColor = (Math.random() * 0xFFFFFF << 0).toString(16); while (randColor.length < 6) { randColor = ZERO + randColor; } return HASH + randColor; }
javascript
{ "resource": "" }
q4651
train
function(color) { var rgb; // color string if (color in COLORS) { rgb = COLORS[color]; return { r: rgb[0], g: rgb[1], b: rgb[2] }; } // hex ...
javascript
{ "resource": "" }
q4652
train
function(o1, o2) { var retObj = this._clone(o2); for(var key in o1) { if(this._isObject(o1[key])) { retObj[key] = this._merge(o1[key], retObj[key]); } else { retObj[key] = o1[key]; } ...
javascript
{ "resource": "" }
q4653
train
function(constructor, methods) { var key; for (key in methods) { constructor.prototype[key] = methods[key]; } }
javascript
{ "resource": "" }
q4654
train
function(mimeType, quality) { try { // If this call fails (due to browser bug, like in Firefox 3.6), // then revert to previous no-parameter image/png behavior return this._canvas.toDataURL(mimeType, quality); } catch(e) { ...
javascript
{ "resource": "" }
q4655
train
function(shape) { var fillEnabled = shape.getFillEnabled(); if(fillEnabled) { this._fill(shape); } if(shape.getStrokeEnabled()) { this._stroke(shape); } }
javascript
{ "resource": "" }
q4656
train
function(relaxed) { var traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args; for (n=0; n<len; n++) { trace = traceArr[n]; method = trace.method; // methods ...
javascript
{ "resource": "" }
q4657
train
function() { var a = arguments; this._context.arc(a[0], a[1], a[2], a[3], a[4], a[5]); }
javascript
{ "resource": "" }
q4658
train
function(methodName) { var origMethod = that[methodName], ret; that[methodName] = function() { args = _simplifyArray(Array.prototype.slice.call(arguments, 0)); ret = origMethod.apply(that, arguments); ...
javascript
{ "resource": "" }
q4659
train
function(evt) { var e = { target: this, type: evt.type, evt: evt }; this.fire(evt.type, e); }
javascript
{ "resource": "" }
q4660
train
function() { var parent = this.getParent(); if(parent && parent.children) { parent.children.splice(this.index, 1); parent._setChildrenIndices(); delete this.parent; } // every cached attr that is calculated via node tree ...
javascript
{ "resource": "" }
q4661
train
function(config) { var key, method; if(config) { for(key in config) { if (key === CHILDREN) { } else { method = SET + Kinetic.Util._capitalize(key); // use setter if avai...
javascript
{ "resource": "" }
q4662
train
function() { var depth = this.getDepth(), that = this, index = 0, nodes, len, n, child; function addChildren(children) { nodes = []; len = children.length; for(n = 0; n < len; n++) { ...
javascript
{ "resource": "" }
q4663
train
function() { var absoluteMatrix = this.getAbsoluteTransform().getMatrix(), absoluteTransform = new Kinetic.Transform(), offset = this.offset(); // clone the matrix array absoluteTransform.m = absoluteMatrix.slice(); absoluteTransform.trans...
javascript
{ "resource": "" }
q4664
train
function(pos) { var origTrans = this._clearTransform(), it; // don't clear translation this.attrs.x = origTrans.x; this.attrs.y = origTrans.y; delete origTrans.x; delete origTrans.y; // unravel transform it...
javascript
{ "resource": "" }
q4665
train
function(change) { var changeX = change.x, changeY = change.y, x = this.getX(), y = this.getY(); if(changeX !== undefined) { x += changeX; } if(changeY !== undefined) { y += changeY; ...
javascript
{ "resource": "" }
q4666
train
function() { if (!this.parent) { Kinetic.Util.warn('Node has no parent. moveToTop function is ignored.'); return; } var index = this.index; this.parent.children.splice(index, 1); this.parent.children.push(this); this...
javascript
{ "resource": "" }
q4667
train
function() { if (!this.parent) { Kinetic.Util.warn('Node has no parent. moveUp function is ignored.'); return; } var index = this.index, len = this.parent.getChildren().length; if(index < len - 1) { this.pare...
javascript
{ "resource": "" }
q4668
train
function(zIndex) { if (!this.parent) { Kinetic.Util.warn('Node has no parent. zIndex parameter is ignored.'); return; } var index = this.index; this.parent.children.splice(index, 1); this.parent.children.splice(zIndex, 0, this);...
javascript
{ "resource": "" }
q4669
train
function() { var type = Kinetic.Util, obj = {}, attrs = this.getAttrs(), key, val, getter, defaultValue; obj.attrs = {}; // serialize only attributes that are not function, image, DOM, or objects with methods for(key in at...
javascript
{ "resource": "" }
q4670
train
function(config) { Kinetic.Util._getImage(this.toDataURL(config), function(img) { config.callback(img); }); }
javascript
{ "resource": "" }
q4671
train
function(layers) { var lays = []; // if passing in no layers if (!layers) { lays = []; } // if passing in an array of Layers // NOTE: layers could be an array or Kinetic.Collection. for simplicity, I'm just inspecting /...
javascript
{ "resource": "" }
q4672
train
function(layer) { var layers = this.layers, len, n; if (layers) { len = layers.length; // don't add the layer if it already exists for (n = 0; n < len; n++) { if (layers[n]._id === layer._id) { ...
javascript
{ "resource": "" }
q4673
train
function() { var a = Kinetic.Animation, animations = a.animations, len = animations.length, n; for(n = 0; n < len; n++) { if(animations[n].id === this.id) { return true; } } ...
javascript
{ "resource": "" }
q4674
train
function(t, b, c, d) { return c - Kinetic.Easings.BounceEaseOut(d - t, 0, c, d) + b; }
javascript
{ "resource": "" }
q4675
train
function(t, b, c, d) { if(t < d / 2) { return Kinetic.Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b; } else { return Kinetic.Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b; } }
javascript
{ "resource": "" }
q4676
train
function() { var children = Kinetic.Collection.toCollection(this.children); var child; for (var i = 0; i < children.length; i++) { child = children[i]; // reset parent to prevent many _setChildrenIndices calls delete child.parent; ...
javascript
{ "resource": "" }
q4677
train
function() { var children = Kinetic.Collection.toCollection(this.children); var child; for (var i = 0; i < children.length; i++) { child = children[i]; // reset parent to prevent many _setChildrenIndices calls delete child.parent; ...
javascript
{ "resource": "" }
q4678
train
function(child) { if (arguments.length > 1) { for (var i = 0; i < arguments.length; i++) { this.add(arguments[i]); } return; } if (child.getParent()) { child.moveTo(this); return; ...
javascript
{ "resource": "" }
q4679
train
function(node) { var parent = node.getParent(); while(parent) { if(parent._id === this._id) { return true; } parent = parent.getParent(); } return false; }
javascript
{ "resource": "" }
q4680
train
function(alphaThreshold) { var threshold = alphaThreshold || 0, cachedCanvas = this._cache.canvas, sceneCanvas = this._getCachedSceneCanvas(), sceneContext = sceneCanvas.getContext(), hitCanvas = cachedCanvas.hit, hitContext = h...
javascript
{ "resource": "" }
q4681
train
function(container) { if( typeof container === STRING) { var id = container; container = Kinetic.document.getElementById(container); if (!container) { throw 'Can not find container in document with id ' + id; } }...
javascript
{ "resource": "" }
q4682
train
function() { var layers = this.children, len = layers.length, n; for(n = 0; n < len; n++) { layers[n].clear(); } return this; }
javascript
{ "resource": "" }
q4683
train
function(config) { config = config || {}; var mimeType = config.mimeType || null, quality = config.quality || null, x = config.x || 0, y = config.y || 0, canvas = new Kinetic.SceneCanvas({ width: config.width ||...
javascript
{ "resource": "" }
q4684
train
function(config) { var cb = config.callback; config.callback = function(dataUrl) { Kinetic.Util._getImage(dataUrl, function(img) { cb(img); }); }; this.toDataURL(config); }
javascript
{ "resource": "" }
q4685
train
function(layer) { if (arguments.length > 1) { for (var i = 0; i < arguments.length; i++) { this.add(arguments[i]); } return; } Kinetic.Container.prototype.add.call(this, layer); layer._setCanvasSize(this....
javascript
{ "resource": "" }
q4686
train
function(index) { Kinetic.Node.prototype.setZIndex.call(this, index); var stage = this.getStage(); if(stage) { stage.content.removeChild(this.getCanvas()._canvas); if(index < stage.getChildren().length - 1) { stage.content.insertBe...
javascript
{ "resource": "" }
q4687
train
function() { Kinetic.Node.prototype.moveToTop.call(this); var stage = this.getStage(); if(stage) { stage.content.removeChild(this.getCanvas()._canvas); stage.content.appendChild(this.getCanvas()._canvas); } }
javascript
{ "resource": "" }
q4688
train
function() { if(Kinetic.Node.prototype.moveDown.call(this)) { var stage = this.getStage(); if(stage) { var children = stage.getChildren(); stage.content.removeChild(this.getCanvas()._canvas); stage.content.insertBefo...
javascript
{ "resource": "" }
q4689
train
function() { return this.attrs.height === AUTO ? (this.getTextHeight() * this.textArr.length * this.getLineHeight()) + this.getPadding() * 2 : this.attrs.height; }
javascript
{ "resource": "" }
q4690
loadSample
train
function loadSample(url, doAfterLoading) { var fetchSound = new XMLHttpRequest(); // Load the Sound with XMLHttpRequest fetchSound.open("GET", url, true); // Path to Audio File fetchSound.responseType = "arraybuffer"; // Read as Binary Data fetchSound.onload = function() { context.decodeAudioDat...
javascript
{ "resource": "" }
q4691
execute
train
function execute (configs, fn, ...args) { if ('verbose' in configs && configs.verbose) { const isoDate = (new Date()).toISOString() console.error(COLOR_FG_YELLOW + '[' + isoDate + '] Start mongo.execute: ' + JSON.stringify([configs, fn, args]) + COLOR_RESET) } const dbConfigs = util.getDeepCopiedObject(co...
javascript
{ "resource": "" }
q4692
train
function (op, other) { return new(tree.Dimension) (tree.operate(op, this.value, other.value), this.unit || other.unit); }
javascript
{ "resource": "" }
q4693
getPatchedObject
train
function getPatchedObject (obj, patcher, clone = true) { if (!patcher) { return obj } let newObj, newPatcher if (clone) { newObj = getDeepCopiedObject(obj) newPatcher = getDeepCopiedObject(patcher) } else { newObj = obj newPatcher = patcher } // patch const keys = Object.keys(newPatc...
javascript
{ "resource": "" }
q4694
visit
train
function visit(collection, pattern, address) { collection = collection || []; var foundSoFar = false; collection.forEach(function (collectionItem) { foundSoFar = foundSoFar || testForField(collectionItem, pattern, address); }); ...
javascript
{ "resource": "" }
q4695
resolveAddress
train
function resolveAddress(object, path) { var parts = path.split('.'); if (object === undefined) { return; } return parts.length < 2 ? object[parts[0]] : resolveAddress(object[parts[0]], parts.slice(1).join('.')); }
javascript
{ "resource": "" }
q4696
api
train
async function api(endpoint, token) { token = token ? `&access_token=${token}` : ''; const response = await fetch(`https://api.github.com/repos/${endpoint}${token}`); return response.json(); }
javascript
{ "resource": "" }
q4697
bcadd
train
function bcadd(left_operand, right_operand, scale) { var first, second, result; if (typeof(scale) == 'undefined') { scale = libbcmath.scale; } scale = ((scale < 0) ? 0 : scale); // create objects first = libbcmath.bc_init_num(); second = libbcmath.bc_init_num(); result = ...
javascript
{ "resource": "" }
q4698
bcsub
train
function bcsub(left_operand, right_operand, scale) { var first, second, result; if (typeof(scale) == 'undefined') { scale = libbcmath.scale; } scale = ((scale < 0) ? 0 : scale); // create objects first = libbcmath.bc_init_num(); second = libbcmath.bc_init_num(); result = ...
javascript
{ "resource": "" }
q4699
bccomp
train
function bccomp(left_operand, right_operand, scale) { var first, second; //bc_num if (typeof(scale) == 'undefined') { scale = libbcmath.scale; } scale = ((scale < 0) ? 0 : scale); first = libbcmath.bc_init_num(); second = libbcmath.bc_init_num(); first = libbcmath.bc_str2nu...
javascript
{ "resource": "" }