_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q36800
validateReQL
train
function validateReQL (reql, reqlOpts, whitelist) { var args = assertArgs(arguments, { 'reql': '*', '[reqlOpts]': 'object', 'whitelist': 'array' }) reql = args.reql reqlOpts = args.reqlOpts whitelist = args.whitelist var firstErr var errCount = 0 var promises = whitelist.map(function (reqlVa...
javascript
{ "resource": "" }
q36801
do_plain
train
function do_plain(url, opts) { opts = do_args(url, opts); if(opts.redirect_loop_counter === undefined) { opts.redirect_loop_counter = 10; } var buffer; var d = Q.defer(); var req = require(opts.protocol).request(opts.url, function(res) { var buffer = ""; res.setEncoding('utf8'); function collect_chunks(ch...
javascript
{ "resource": "" }
q36802
do_js
train
function do_js(url, opts) { opts = opts || {}; if(is.object(opts) && is['function'](opts.body)) { opts.body = FUNCTION(opts.body).stringify(); } else if(is.object(opts) && is.string(opts.body)) { } else { throw new TypeError('opts.body is not function nor string'); } opts.headers = opts.headers || {}; if(opt...
javascript
{ "resource": "" }
q36803
entrify
train
function entrify(dir, options = {}) { if (!dir) { throw new Error('the path is required') } if (typeof dir !== 'string') { throw new Error('the path must be a string') } options = Object.assign({}, defaults, options) return entrifyFromPkg(dir, options) }
javascript
{ "resource": "" }
q36804
entrifyFromPkg
train
function entrifyFromPkg(dir, options) { // Find package.json files. const pkgPaths = glob.sync('**/package.json', { cwd: dir, nodir: true, absolute: true }) pkgPaths.forEach((pkgPath) => { console.log('[entrify]', 'Found:', pkgPath) const pkg = require(pkgPath) // A package.json file should have a ...
javascript
{ "resource": "" }
q36805
indexTemplate
train
function indexTemplate(format, data) { if (format === 'cjs') { return `module.exports = require('${data.main}')` } if (format === 'esm') { return `import ${data.name} from '${data.main}' export default ${data.name}` } }
javascript
{ "resource": "" }
q36806
camelize
train
function camelize(str) { return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (letter, index) => { return index === 0 ? letter.toLowerCase() : letter.toUpperCase() }).replace(/[\s\-_]+/g, '') }
javascript
{ "resource": "" }
q36807
getOperationResponseHeaders
train
function getOperationResponseHeaders(operation) { var headers = []; if (operation) { _.each(operation.responses, function(response, responseCode) { // Convert responseCode to a numeric value for sorting ("default" comes last) responseCode = parseInt(responseCode) || 999; ...
javascript
{ "resource": "" }
q36808
cast
train
function cast(string) { var result = String(string); switch (result) { case 'null': result = null; break; case 'true': case 'false': result = result === 'true'; break; default: if (String(parseInt(result, 10)) === result) { result = parseInt(result, 10); } else if (String(parseFloat(resu...
javascript
{ "resource": "" }
q36809
train
function (srcpath) { return fs.readdirSync(srcpath).filter(function(file) { return fs.statSync(path.join(srcpath, file)).isDirectory(); }); }
javascript
{ "resource": "" }
q36810
train
function (csprojFilePath, success, error) { var parser = new xml2js.Parser(), projectGuid; fs.readFile(csprojFilePath, function(err, data) { if (typeof(data) !== 'undefined') { parser.parseString(data, function (err, result) { ...
javascript
{ "resource": "" }
q36811
train
function () { fs.writeFile(solutionFile, solutionFileContents, function(err) { if (err) { grunt.fail.warning('Failed to update solution file.'); } done(); }); }
javascript
{ "resource": "" }
q36812
storeActors
train
function storeActors() { test.actorsStored = 0; for (var i = 0; i < test.actorsInfo.length; i++) { test.actor.set('ID', null); test.actor.set('name', test.actorsInfo[i][0]); test.actor.set('born', test.actorsInfo[i][1]); test.actor.set('isMale', test.actorsInfo[i][2]); ...
javascript
{ "resource": "" }
q36813
actorStored
train
function actorStored(model, error) { if (typeof error != 'undefined') { callback(error); return; } if (++test.actorsStored >= test.actorsInfo.length) { getAllActors(); } }
javascript
{ "resource": "" }
q36814
getAllActors
train
function getAllActors() { try { storeBeingTested.getList(test.list, {}, function (list, error) { if (typeof error != 'undefined') { callback(error); return; } test.shouldBeTrue(list._items.length == 20, '20'); getTomHanks(); }); ...
javascript
{ "resource": "" }
q36815
getTomHanks
train
function getTomHanks() { try { storeBeingTested.getList(test.list, {name: "Tom Hanks"}, function (list, error) { if (typeof error != 'undefined') { callback(error); return; } test.shouldBeTrue(list._items.length == 1, ('1 not ' + list._items.length)); ...
javascript
{ "resource": "" }
q36816
getAlphabetical
train
function getAlphabetical() { try { storeBeingTested.getList(test.list, {}, {name: 1}, function (list, error) { if (typeof error != 'undefined') { callback(error); return; } // Verify each move returns true when move succeeds test.shouldBeTrue...
javascript
{ "resource": "" }
q36817
storeStooges
train
function storeStooges() { self.log(self.oldStoogesFound); self.log(self.oldStoogesKilled); spec.integrationStore.putModel(self.moe, stoogeStored); spec.integrationStore.putModel(self.larry, stoogeStored); spec.integrationStore.putModel(self.shemp, stoogeStored); ...
javascript
{ "resource": "" }
q36818
stoogeRetrieved
train
function stoogeRetrieved(model, error) { if (typeof error != 'undefined') { callback(error); return; } self.stoogesRetrieved.push(model); if (self.stoogesRetrieved.length == 3) { self.shouldBeTrue(true,'here'); // Now we have stored...
javascript
{ "resource": "" }
q36819
stoogeChanged
train
function stoogeChanged(model, error) { if (typeof error != 'undefined') { callback(error); return; } self.shouldBeTrue(model.get('name') == 'Curly','Curly'); var curly = new self.Stooge(); curly.set('id', model.get('id')); try { ...
javascript
{ "resource": "" }
q36820
storeChangedShempToCurly
train
function storeChangedShempToCurly(model, error) { if (typeof error != 'undefined') { callback(error); return; } self.shouldBeTrue(model.get('name') == 'Curly','Curly'); // Now test delete self.deletedModelId = model.get('id'); // Remember this ...
javascript
{ "resource": "" }
q36821
stoogeDeleted
train
function stoogeDeleted(model, error) { if (typeof error != 'undefined') { callback(error); return; } // model parameter is what was deleted self.shouldBeTrue(undefined === model.get('id')); // ID removed self.shouldBeTrue(model.get('name') == 'Cu...
javascript
{ "resource": "" }
q36822
hesDeadJim
train
function hesDeadJim(model, error) { if (typeof error != 'undefined') { if ((error != 'Error: id not found in store') && (error != 'Error: model not found in store')) { callback(error); return; } } else { callback(Error('no error deletin...
javascript
{ "resource": "" }
q36823
generateDocs
train
function generateDocs(specjs) { var docs = GENERATE_MODULE(specjs.MODULE, ''); GENERATE_TYPE = (function(enums) { return function(type) { return (_.contains(enums, type) ? ('Enum ' + type) : type); } })(_.keys(specjs.ENUMS_BY_GROUP)); docs = _.reduce(specjs.METHODS, function(memo, methodSpec, m...
javascript
{ "resource": "" }
q36824
GENERATE_CLASSES
train
function GENERATE_CLASSES(classes, parent) { return _.reduce(classes, function(memo, classSpec, className) { return memo + GENERATE_CLASS(className, classSpec.description, parent, classSpec.parent) + _.reduce(classSpec.methods, function(memo, methodSpec, methodName) { return memo += GENERATE_M...
javascript
{ "resource": "" }
q36825
GENERATE_CLASS
train
function GENERATE_CLASS(name, description, namespace, parent) { return GENERATE_DOC(description + '\n' + '@class ' + name + '\n' + (namespace ? ('@module ' + namespace + '\n') : '') /* TODO: leave out until figure out what swig does with inheritance + (parent ? ('@extends ' + parent + '\n') : '')...
javascript
{ "resource": "" }
q36826
GENERATE_ENUM
train
function GENERATE_ENUM(name, spec, parent) { return GENERATE_DOC(spec.description + '\n' + '@property ' + name + '\n' + '@type Enum ' + spec.type + '\n' + '@for ' + (parent ? parent : 'common') + '\n'); }
javascript
{ "resource": "" }
q36827
GENERATE_VAR
train
function GENERATE_VAR(name, spec, parent) { return GENERATE_DOC(spec.description + '\n' + '@property ' + name + '\n' + '@type ' + spec.type + '\n' + '@for ' + parent + '\n'); }
javascript
{ "resource": "" }
q36828
train
function(lDigits, rDigits) { var difference = []; // assert: lDigits.length >= rDigits.length var carry = 0, i; for (i = 0; i < rDigits.length; i += 1) { difference[i] = lDigits[i] - rDigits[i] + carry; if (difference[i] < 0) { difference[i] += 2; carry = ...
javascript
{ "resource": "" }
q36829
train
function(normalizedLeft, normalizedRight) { if (normalizedLeft.length !== normalizedRight.length) { return normalizedLeft.length - normalizedRight.length; } for (var i = normalizedLeft.length - 1; i >= 0; i -= 1) { if (normalizedLeft[i] !== normalizedRight[i]) { return normalize...
javascript
{ "resource": "" }
q36830
SocketProxy
train
function SocketProxy() { // the socket we are paired with this.pair = null; // internal sockets have fd -1 this._handle = {fd: -1}; // mimic a remote address / remote port this.remoteAddress = '0.0.0.0'; this.remotePort = '0'; // give the client some time to listen // for the connect event functi...
javascript
{ "resource": "" }
q36831
gatherPopulateParams
train
function gatherPopulateParams (populate, pointers, model, deepPath) { var modelName = model.modelName; var paths = model.schema.paths; var path = ''; var options; var params; var ref; var deep = false; while (deepPath.length) { path += (path ? '.' : '')+deepPath.shift(); options = paths[path]...
javascript
{ "resource": "" }
q36832
selectPointers
train
function selectPointers (params) { if (params.pointers) { delete params.pointers['-_id']; params.select = Object.keys(params.pointers).join(' '); } else { delete params.select; } return params.select; }
javascript
{ "resource": "" }
q36833
firstBite
train
function firstBite(dir) { targetDir = dir || path.join(__dirname, '../../..'); if (targetDir.substring(targetDir.length - 1) === '/') { targetDir = targetDir.substring(0, targetDir.length - 1); } }
javascript
{ "resource": "" }
q36834
eventuallyEqual
train
function eventuallyEqual(promise, expected, done) { all([ promise.should.be.fulfilled, promise.should.eventually.deep.equal(expected) ], done); }
javascript
{ "resource": "" }
q36835
eventuallyRejectedWith
train
function eventuallyRejectedWith(promise, expected, done) { all([ promise.should.be.rejectedWith(expected) ], done); }
javascript
{ "resource": "" }
q36836
train
function (updated) { // When the stream passes a new values, save a reference to it and call // the compute's internal `updated` method (which ultimately calls `get`) streamHandler = function (val) { lastValue = val; updated(); }; ...
javascript
{ "resource": "" }
q36837
setRoot
train
function setRoot(mountpath) { // mount to root if not mountpath let root=mountpath?mountpath:""; // add leading slash if needed root=root.match(/^\/.*/)?root:`/${root}`; // chop off trailing slash root=root.match(/^.*\/$/)?root.substring(0,root.length-1):root; // if root is just slash then...
javascript
{ "resource": "" }
q36838
popupClick
train
function popupClick(e) { var editor = this, popup = e.data.popup, target = e.target; // Check for message and prompt popups if (popup === popups.msg || $(popup).hasClass(PROMPT_CLASS)) return; // Get the button info var buttonDiv = $.data(popup, BUTTON), ...
javascript
{ "resource": "" }
q36839
createPopup
train
function createPopup(popupName, options, popupTypeClass, popupContent, popupHover) { // Check if popup already exists if (popups[popupName]) return popups[popupName]; // Create the popup var $popup = $(DIV_TAG) .hide() .addClass(POPUP_CLASS) .appendTo("body"); ...
javascript
{ "resource": "" }
q36840
disable
train
function disable(editor, disabled) { // Update the textarea and save the state if (disabled) { editor.$area.attr(DISABLED, DISABLED); editor.disabled = true; } else { editor.$area.removeAttr(DISABLED); delete editor.disabled; } // Switch the iframe into desi...
javascript
{ "resource": "" }
q36841
execCommand
train
function execCommand(editor, command, value, useCSS, button) { // Restore the current ie selection restoreRange(editor); // Set the styling method if (!ie) { if (useCSS === undefined || useCSS === null) useCSS = editor.options.useCSS; editor.doc.execCommand("styleWithCSS",...
javascript
{ "resource": "" }
q36842
focus
train
function focus(editor) { setTimeout(function() { if (sourceMode(editor)) editor.$area.focus(); else editor.$frame[0].contentWindow.focus(); refreshButtons(editor); }, 0); }
javascript
{ "resource": "" }
q36843
hidePopups
train
function hidePopups() { $.each(popups, function(idx, popup) { $(popup) .hide() .unbind(CLICK) .removeData(BUTTON); }); }
javascript
{ "resource": "" }
q36844
imagesPath
train
function imagesPath() { var cssFile = "jquery.cleditor.css", href = $("link[href$='" + cssFile +"']").attr("href"); return href.substr(0, href.length - cssFile.length) + "images/"; }
javascript
{ "resource": "" }
q36845
refreshButtons
train
function refreshButtons(editor) { // Webkit requires focus before queryCommandEnabled will return anything but false if (!iOS && $.browser.webkit && !editor.focused) { editor.$frame[0].contentWindow.focus(); window.focus(); editor.focused = true; } // Get the object used for...
javascript
{ "resource": "" }
q36846
selectedHTML
train
function selectedHTML(editor) { restoreRange(editor); var range = getRange(editor); if (ie) return range.htmlText; var layer = $("<layer>")[0]; layer.appendChild(range.cloneContents()); var html = layer.innerHTML; layer = null; return html; }
javascript
{ "resource": "" }
q36847
selectedText
train
function selectedText(editor) { restoreRange(editor); if (ie) return getRange(editor).text; return getSelection(editor).toString(); }
javascript
{ "resource": "" }
q36848
showMessage
train
function showMessage(editor, message, button) { var popup = createPopup("msg", editor.options, MSG_CLASS); popup.innerHTML = message; showPopup(editor, popup, button); }
javascript
{ "resource": "" }
q36849
showPopup
train
function showPopup(editor, popup, button) { var offset, left, top, $popup = $(popup); // Determine the popup location if (button) { var $button = $(button); offset = $button.offset(); left = --offset.left; top = offset.top + $button.height(); } else { var ...
javascript
{ "resource": "" }
q36850
updateFrame
train
function updateFrame(editor, checkForChange) { var code = editor.$area.val(), options = editor.options, updateFrameCallback = options.updateFrame, $body = $(editor.doc.body); // Check for textarea change to avoid unnecessary firing // of potentially heavy updateFrame callback...
javascript
{ "resource": "" }
q36851
updateTextArea
train
function updateTextArea(editor, checkForChange) { var html = $(editor.doc.body).html(), options = editor.options, updateTextAreaCallback = options.updateTextArea, $area = editor.$area; // Check for iframe change to avoid unnecessary firing // of potentially heavy updateTextArea c...
javascript
{ "resource": "" }
q36852
send
train
function send(err, reply, cb) { // invoke before function, used to end a slowlog // timer before sending output if(this.before) this.before(); if(this.cb) { return this.cb(err, reply); } this.conn.write(err || reply, cb); }
javascript
{ "resource": "" }
q36853
genCap
train
function genCap(point, ux, uy, v1i, v2i, pushVert, pushIndices) { if (!point.cap) { genRoundedCap(point, ux, uy, v1i, v2i, pushVert, pushIndices); } else { switch (point.cap.type) { case LineCaps.LINECAP_TYPE_ARROW: genArrowCap(point, ux, uy, v1i, v2i, pushVert, pushI...
javascript
{ "resource": "" }
q36854
train
function(db) { var views_uuid = uuid(); debug.assert(views_uuid).is('uuid'); return db.query('CREATE SEQUENCE views_seq') .query(['CREATE TABLE IF NOT EXISTS views (', " id uuid PRIMARY KEY NOT NULL default uuid_generate_v5('"+views_uuid+"', nextval('views_seq'::regclass)::text),", ' types_id uuid R...
javascript
{ "resource": "" }
q36855
train
function (target, eventName, listener, useCapture) { var ver = System.utils.UserAgent.IE.getVersion(); if (is(target, System.EventEmitter)) { target.on(eventName, listener, useCapture); } else if ((ver != -1 && ver <= 8) || is(target, Element)) { if (ver != -1 && ver < 11...
javascript
{ "resource": "" }
q36856
combineRules
train
async function combineRules(rulesList) { return Object.keys(rulesList) .reduce(async (collection, definitions) => { const isEnabled = rulesList[definitions]; let { default: rules } = await import(`../rules/${definitions}`); if (!isEnabled) rules = await disableRules(rules); const previou...
javascript
{ "resource": "" }
q36857
reqToJSON
train
function reqToJSON (req, additional) { additional = additional || [] if (additional === true) { additional = [ 'rawHeaders', 'rawTrailers', // express/koa 'fresh', 'cookies', 'ip', 'ips', 'stale', 'subdomains' ] } var keys = [ 'body', 'header...
javascript
{ "resource": "" }
q36858
Join
train
function Join(name) { this.name = name; this.criteria = null; this.table = null; this.map = null; this.type = this.ONE_TO_ONE; this.default = false; }
javascript
{ "resource": "" }
q36859
compileDEP
train
function compileDEP( project, src, watch ) { const moduleName = src.name(), depFilename = Util.replaceExtension( moduleName, '.dep' ); if ( !project.srcOrLibPath( depFilename ) ) return ''; const depFile = new Source( project, depFilename ); let code = ''; try { const depJSON = Tol...
javascript
{ "resource": "" }
q36860
processAttributeVar
train
function processAttributeVar( project, depJSON, watch, depAbsPath ) { if ( typeof depJSON.var === 'undefined' ) return ''; let head = 'const GLOBAL = {', firstItem = true; Object.keys( depJSON.var ).forEach( function forEachVarName( varName ) { const varFilename = depJSON.var[ varN...
javascript
{ "resource": "" }
q36861
filtered
train
function filtered(js) { return js.substr(1).split('|').reduce(function(js, filter){ var parts = filter.split(':') , name = parts.shift() , args = parts.shift() || ''; if (args) args = ', ' + args; return 'filters.' + name + '(' + js + args + ')'; }); }
javascript
{ "resource": "" }
q36862
resolveInclude
train
function resolveInclude(name, filename) { var path = join(dirname(filename), name); var ext = extname(name); if (!ext) path += '.ejs'; return path; }
javascript
{ "resource": "" }
q36863
suiteFinished
train
function suiteFinished(suite, status, results) { suite.finished = true; suite.status = status; suite.duration = new Date() - suite.startTime; suite.results = results; delete suite.startTime; if (suite.index == finishedIndex) { for (var i = finishedIndex; i < suites.length; i++) { ...
javascript
{ "resource": "" }
q36864
train
function ( config, actual ) { // In this way, if any topic declare the compilerOptions this will not // include in the tsconfig.json if ( actual.compilerOptions !== undefined ) { if ( config.compilerOptions === undefined ) { // Attach an empty object config.compilerOptions = {}; } // In the ...
javascript
{ "resource": "" }
q36865
proxy
train
function proxy(req, res) { var method = req.db[req.cmd] , args; // append the request object to the args // required so that database events can pass // request and thereby connection information // when emitting events by key, this allows // transactional semantics args = req.args.slice(0).concat(re...
javascript
{ "resource": "" }
q36866
execute
train
function execute(req, res) { var proxy = req.exec ? req.exec.proxy : this.proxy; res.send(null, proxy(req, res)); }
javascript
{ "resource": "" }
q36867
train
function (model, values, functionPrefix) { // for a string, see if it has parameter matches, and if so, try to make the substitutions. var getValue = function (fromString) { var matches = fromString.match(/(\${.*?})/g); if (matches != null) { ...
javascript
{ "resource": "" }
q36868
barbe
train
function barbe(text, arr, data) { if (!Array.isArray(arr)) { data = arr; arr = ["{", "}"]; } if (!data || data.constructor !== Object) { return text; } arr = arr.map(regexEscape); let deep = (obj, path) => { iterateObject(obj, (value, c) => { path.p...
javascript
{ "resource": "" }
q36869
pad
train
function pad(n, s) { var before = Array(n + 1).join(' ') return s.split(/\r\n|\r|\n/) .map(function(a){ return before + a }) .join('\n') }
javascript
{ "resource": "" }
q36870
maybeRenderSuite
train
function maybeRenderSuite(signal) { return function(a) { return a.cata({ Suite: function(){ return Just([signal.path.length, a.name]) } , Case: Nothing }) }}
javascript
{ "resource": "" }
q36871
logs
train
function logs(a) { return a.isIgnored? '' : a.log.length === 0? '' : /* otherwise */ '\n' + pad( 2 , '=== Captured logs:\n' + a.log.map(function(x){ return faded('- '...
javascript
{ "resource": "" }
q36872
_filesToFile
train
function _filesToFile (files, target, separator, callback) { if ("undefined" === typeof files) { throw new ReferenceError("missing \"files\" argument"); } else if ("object" !== typeof files || !(files instanceof Array)) { throw new TypeError("\"files\" argument is not an Array"); } else if ("...
javascript
{ "resource": "" }
q36873
_removeDirectoryContentProm
train
function _removeDirectoryContentProm (contents) { const content = contents.shift(); return isDirectoryProm(content).then((exists) => { return exists ? new Promise((resolve, reject) => { _rmdirp(content, (err) => { return err ? reject(err) : resolve(); }); }) : new Promise((resolve, re...
javascript
{ "resource": "" }
q36874
_emptyDirectoryProm
train
function _emptyDirectoryProm (directory) { return new Promise((resolve, reject) => { readdir(directory, (err, files) => { return err ? reject(err) : resolve(files); }); }).then((files) => { const result = []; for (let i = 0; i < files.length; ++i) { result.push(join(directory, fil...
javascript
{ "resource": "" }
q36875
parseEndTag
train
function parseEndTag(tag, tagName) { // If no tag name is provided, clean shop if (!tagName) var pos = 0; // Find the closest opened tag of the same type else { tagName = tagName.toLowerCase(); for (var pos = stack.length - 1; pos >= 0; pos--) if (st...
javascript
{ "resource": "" }
q36876
Profile
train
function Profile(options) { this.path = node_path.resolve(profile.resolveHomePath(options.path)); this.schema = options.schema; this.context = options.context || null; this.raw_data = {}; this.codec = this._get_codec(options.codec); this.options = options; }
javascript
{ "resource": "" }
q36877
train
function(name, force, callback) { var err = null; var profiles = this.all(); if (~profiles.indexOf(name)) { err = 'Profile "' + name + '" already exists.'; } else if (!force && ~RESERVED_PROFILE_NAME.indexOf(name)) { err = 'Profile name "' + name + '" is reserved by `multi-profile`'; ...
javascript
{ "resource": "" }
q36878
train
function(name) { this.profile = trait(Object.create(this.schema), { context: this.context }); var profile_dir = this.profile_dir = node_path.join(this.path, name); if (!fs.isDir(profile_dir)) { fs.mkdir(profile_dir); } var profile_file = this.profile_file = node_path.join(profile_...
javascript
{ "resource": "" }
q36879
discover
train
function discover(pattern, callback) { glob(pattern, function (err, filepaths) { if (err) callback(err); callback(null, filepaths); }); }
javascript
{ "resource": "" }
q36880
registerPartials
train
function registerPartials(filepaths, callback) { async.map(filepaths, registerPartial, function (err) { if (err) callback(err); callback(null); }); }
javascript
{ "resource": "" }
q36881
registerPartial
train
function registerPartial(filepath, callback) { fs.readFile(filepath, 'utf8', function (err, data) { if (err) callback(err); hbs.registerPartial(path.parse(filepath).name, data); callback(null); }); }
javascript
{ "resource": "" }
q36882
registerTemplates
train
function registerTemplates(filepaths, callback) { async.map(filepaths, registerTemplate, function (err, templates) { if (err) callback(err); callback(null, templates); }); }
javascript
{ "resource": "" }
q36883
registerTemplate
train
function registerTemplate(filepath, callback) { fs.readFile(filepath, 'utf8', function (err, data) { if (err) callback(err); callback(null, { name: path.parse(filepath).name, template: hbs.compile(data) }); }); }
javascript
{ "resource": "" }
q36884
satisfies
train
function satisfies(version, range) { range = range.trim(); // Range '<=99.999.99999' means "all versions", but fails on "2014.10.20-1" if (range === '<=99.999.99999') return true; // If semver satisfies, we return true if (semver.satisfies(version, range)) return true; // If range is a specific version, ...
javascript
{ "resource": "" }
q36885
explode
train
function explode( target, mappings ){ if (!mappings ){ mappings = target; target = {}; } bmoor.iterate( mappings, function( val, mapping ){ bmoor.set( target, mapping, val ); }); return target; }
javascript
{ "resource": "" }
q36886
mask
train
function mask( obj ){ if ( Object.create ){ var T = function Masked(){}; T.prototype = obj; return new T(); }else{ return Object.create( obj ); } }
javascript
{ "resource": "" }
q36887
merge
train
function merge( to ){ var from, i, c, m = function( val, key ){ to[ key ] = merge( to[key], val ); }; for( i = 1, c = arguments.length; i < c; i++ ){ from = arguments[i]; if ( to === from ){ continue; }else if ( to && to.merge ){ to.merge( from ); }else if ( !bmoor.isObject(from...
javascript
{ "resource": "" }
q36888
equals
train
function equals( obj1, obj2 ){ var t1 = typeof obj1, t2 = typeof obj2, c, i, keyCheck; if ( obj1 === obj2 ){ return true; }else if ( obj1 !== obj1 && obj2 !== obj2 ){ return true; // silly NaN }else if ( obj1 === null || obj1 === undefined || obj2 === null || obj2 === undefined ){ return ...
javascript
{ "resource": "" }
q36889
exec
train
function exec (func, context, args) { switch (args.length) { case 0: func.call(context); break; case 1: func.call(context, args[0]); break; case 2: func.call(context, args[0], args[1]); break; case 3: func.call(context, args[0], args[1], args[2]); break; case 4: func.call(context, args[0], args[1], args[2], ...
javascript
{ "resource": "" }
q36890
propagate
train
function propagate (parent, prefix) { var self = this; if (!parent || typeof parent.emit !== 'function') { throw new TypeError('"parent" argument must implement an "emit" method'); } self.parent = parent; self.parentPrefix = prefix; return this; }
javascript
{ "resource": "" }
q36891
hasCompleteEventParams
train
function hasCompleteEventParams(eventType, listener) { var hasParams = eventType && listener, isTypeString = typeof eventType === 'string', isTypeFunction = typeof listener === 'function'; if (!isTypeFunction) { throw new TypeError(EventDispatcher.TYPE_ERROR); ...
javascript
{ "resource": "" }
q36892
Description
train
function Description(def) { if(typeof def === 'string') { this.parse(def); }else if(def && typeof def === 'object' && typeof def.txt === 'string' && typeof def.md === 'string') { this.md = def.md; this.txt = def.txt; }else{ throw new Error('invalid value for description'); } }
javascript
{ "resource": "" }
q36893
useYarn
train
function useYarn(setYarn) { if (typeof setYarn !== "undefined") { allowYarn = setYarn; } if (typeof allowYarn !== "undefined") { return allowYarn; } return getYarnVersionIfAvailable() ? true : false; }
javascript
{ "resource": "" }
q36894
_load
train
function _load(file, defaultConfig, dump) { const f = normalize(file); const b = f.base; const p = f.profile; const ext = f.ext; if (ext) { const p = b + ext; let r = loadSpecific(b, '.js', p, defaultConfig, dump); if (r) return r; if (defaultConfig) return default...
javascript
{ "resource": "" }
q36895
HttpApplication
train
function HttpApplication() { this.app = express(); this._registerConfigurations(); this._registerMiddlewares(); this._registerControllers(); this._registerAreas(); this.initialize.apply(this, arguments); }
javascript
{ "resource": "" }
q36896
train
function(parent, field, options) { options = options || {}; // Unique id for this node's generated method this.id = utils.generateId(); // Link to parent node this.parent = parent; // The field related to this node this.field = field; // Any options this.options = options; // Just some metadata ...
javascript
{ "resource": "" }
q36897
statFile
train
function statFile(path, sizes_data, sizes_file_path){ writeFileData(path, fs.statSync(path).mtime.getTime(), fs.statSync(path).size, sizes_data, sizes_file_path); }
javascript
{ "resource": "" }
q36898
writeFileData
train
function writeFileData(file_path, time, size, sizes_data, sizes_file_path){ var file_ext = path.extname(file_path).replace('.',''); var file_name = path.basename(file_path); // create file type object if it doesnt exist if(sizes_data[file_ext] === undefined){ sizes_data[file_ext] = {}; } // create fi...
javascript
{ "resource": "" }
q36899
ScriptRunner
train
function ScriptRunner() { this.flush(); function onMessage(msg, handle) { var script, digest; switch(msg.event) { case 'loglevel': log.level(msg.level); break; case 'eval': try { script = this.load(msg.source).script; this.run(script, msg.args); ...
javascript
{ "resource": "" }