_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q63400
prepare
test
function prepare(repoState, opts) { const workingState = repoState.getCurrentState(); const changes = workingState.getChanges(); // Is this an empty commit ? opts.empty = workingState.isClean(); // Parent SHA opts.parents = new Immutable.List([ workingState.getHead() ]); // Ge...
javascript
{ "resource": "" }
q63401
flush
test
function flush(repoState, driver, commitBuilder, options = {}) { options = Object.assign({ branch: repoState.getCurrentBranch(), ignoreEmpty: true }, options); if (options.ignoreEmpty && commitBuilder.isEmpty() && commitBuilder.getParents().count() < 2) { return Q(re...
javascript
{ "resource": "" }
q63402
format
test
function format(color, messages) { var length = messages.length; if (length === 0 || typeof(color) !== 'string') { return; } return (util.format.apply(null, messages)[color]); }
javascript
{ "resource": "" }
q63403
push
test
function push(repoState, driver, opts = {}) { opts = Object.assign({ branch: repoState.getCurrentBranch(), force: false, remote: { name: 'origin' } }, opts); return driver.push(opts) // Can fail with NOT_FAST_FORWARD // TODO update remote branch in repoState ...
javascript
{ "resource": "" }
q63404
pull
test
function pull(repoState, driver, opts = {}) { opts = Object.assign({ branch: repoState.getCurrentBranch(), force: false, remote: { name: 'origin' } }, opts); return driver.pull(opts) // Update branch SHA .then(() => { return driver.fetchBranches()...
javascript
{ "resource": "" }
q63405
compareRefs
test
function compareRefs(driver, base, head) { const baseRef = base instanceof Branch ? base.getFullName() : base; const headRef = head instanceof Branch ? head.getFullName() : head; return driver.findParentCommit(baseRef, headRef) .then((parentCommit) => { // There can be no parent commit ...
javascript
{ "resource": "" }
q63406
solveTree
test
function solveTree(treeConflict, solved) { solved = treeConflict.getConflicts() .merge(solved) // Solve unresolved conflicts .map(function defaultSolve(conflict) { if (!conflict.isSolved()) { return conflict.keepBase(); } else { return conflict; } }); ...
javascript
{ "resource": "" }
q63407
mergeCommit
test
function mergeCommit(treeConflict, parents, options) { options = options || {}; const opts = {}; // Assume the commit is not empty opts.empty = false; // Parent SHAs opts.parents = new Immutable.List(parents); opts.author = options.author; opts.message = options.message || 'Merged co...
javascript
{ "resource": "" }
q63408
_getSolvedEntries
test
function _getSolvedEntries(treeConflict) { const parentEntries = treeConflict.getParent().getTreeEntries(); const baseEntries = treeConflict.getBase().getTreeEntries(); const headEntries = treeConflict.getHead().getTreeEntries(); const baseDiff = _diffEntries(parentEntries, baseEntries); const head...
javascript
{ "resource": "" }
q63409
addBlob
test
function addBlob(cache, sha, blob) { const blobs = cache.getBlobs(); const newBlobs = blobs.set(sha, blob); const newCache = cache.set('blobs', newBlobs); return newCache; }
javascript
{ "resource": "" }
q63410
get
test
function get(repoState, dirPath) { // Remove trailing '/' etc. const normDirPath = Path.join(dirPath, '.'); const filepaths = DirUtils.readFilenamesRecursive(repoState, normDirPath); const tree = { value: File.createDir(normDirPath), children: {} }; for (let i = 0; i < filepath...
javascript
{ "resource": "" }
q63411
normCreatedCommit
test
function normCreatedCommit(ghCommit) { const commit = Commit.create({ sha: ghCommit.sha, message: ghCommit.message, author: getSimpleAuthor(ghCommit.author), date: ghCommit.author.date, parents: ghCommit.parents.map(function getSha(o) { return o.sha; }) }); return co...
javascript
{ "resource": "" }
q63412
normListedCommit
test
function normListedCommit(ghCommit) { const commit = Commit.create({ sha: ghCommit.sha, message: ghCommit.commit.message, author: getCompleteAuthor(ghCommit), date: ghCommit.commit.author.date, files: ghCommit.files, parents: ghCommit.parents.map(c => c.sha) }); ...
javascript
{ "resource": "" }
q63413
stat
test
function stat(repoState, filepath) { const workingState = repoState.getCurrentState(); // Lookup potential changes const change = workingState.getChanges().get(filepath); // Lookup file entry const treeEntry = workingState.getTreeEntries().get(filepath); // Determine SHA of the blob let bl...
javascript
{ "resource": "" }
q63414
readAsString
test
function readAsString(repoState, filepath, encoding) { const blob = read(repoState, filepath); return blob.getAsString(encoding); }
javascript
{ "resource": "" }
q63415
exists
test
function exists(repoState, filepath) { const workingState = repoState.getCurrentState(); const mergedFileSet = WorkingUtils.getMergedTreeEntries(workingState); return mergedFileSet.has(filepath); }
javascript
{ "resource": "" }
q63416
remove
test
function remove(repoState, filepath) { if (!exists(repoState, filepath)) { throw error.fileNotFound(filepath); } const change = Change.createRemove(); return ChangeUtils.setChange(repoState, filepath, change); }
javascript
{ "resource": "" }
q63417
move
test
function move(repoState, filepath, newFilepath) { if (filepath === newFilepath) { return repoState; } const initialWorkingState = repoState.getCurrentState(); // Create new file, with Sha if possible const sha = WorkingUtils.findSha(initialWorkingState, filepath); let changeNewFile; ...
javascript
{ "resource": "" }
q63418
hasChanged
test
function hasChanged(previousState, newState, filepath) { const previouslyExists = exists(previousState, filepath); const newExists = exists(newState, filepath); if (!previouslyExists && !newExists) { // Still non existing return false; } else if (exists(previousState, filepath) !== exist...
javascript
{ "resource": "" }
q63419
setup
test
function setup(connection, done) { var config = createDefaultConfig(), options = { proxy: false, headers: {} }; // reset the global variable with handles to port numbers handles = {}; if (connection !== 'direct') { options.proxy = true; config.proxy.gateway = { prot...
javascript
{ "resource": "" }
q63420
configureNock
test
function configureNock(options, config) { var result = {}; // deny all real net connections except for localhost nock.disableNetConnect(); nock.enableNetConnect('localhost'); function createNock(url) { var instance = nock(url), expectedViaHeader = options.headers['Via'] || ...
javascript
{ "resource": "" }
q63421
configureExpress
test
function configureExpress(config, done) { var portfinder = require('portfinder'); tmp.dir(function(err, filepath){ handles.filepath = filepath; portfinder.getPort(function (err, port) { if (err) throw(err); handles.port = port; fs.writeFileSync(path.join(handles.filepath, 'index.txt'),...
javascript
{ "resource": "" }
q63422
configureLanProxy
test
function configureLanProxy(options, config, done) { var portfinder = require('portfinder'), request = require('request'), credentials = config.proxy.gateway.auth, gatewayPort, expectedAuthorizationHeader, requestViaHeader, responseViaHeader; handles = handles || {}; handles.g...
javascript
{ "resource": "" }
q63423
cleanup
test
function cleanup(done) { config = null; rules.forEach(function(rule){ rule.done(); }); nock.cleanAll(); handles.server.close(); if (handles.gatewayServer !== undefined && handles.gatewayServer !== null) { handles.gatewayServer.close(); } fs.unlinkSync(path.join(handles.filepath, '/index.txt')...
javascript
{ "resource": "" }
q63424
setChange
test
function setChange(repoState, filepath, change) { let workingState = repoState.getCurrentState(); let changes = workingState.getChanges(); const type = change.getType(); // Simplify change when possible if (type === CHANGE_TYPE.REMOVE && !workingState.getTreeEntries().has(filepath)) { ...
javascript
{ "resource": "" }
q63425
revertAll
test
function revertAll(repoState) { let workingState = repoState.getCurrentState(); // Create empty list of changes const changes = new Immutable.OrderedMap(); // Update workingState and repoState workingState = workingState.set('changes', changes); return RepoUtils.updateCurrentWorkingState(repoS...
javascript
{ "resource": "" }
q63426
revertForFile
test
function revertForFile(repoState, filePath) { let workingState = repoState.getCurrentState(); // Remove file from changes map const changes = workingState.getChanges().delete(filePath); // Update workingState and repoState workingState = workingState.set('changes', changes); return RepoUtils.u...
javascript
{ "resource": "" }
q63427
revertForDir
test
function revertForDir(repoState, dirPath) { let workingState = repoState.getCurrentState(); let changes = workingState.getChanges(); // Remove all changes that are in the directory changes = changes.filter((change, filePath) => { return !PathUtils.contains(dirPath, filePath); }); // Up...
javascript
{ "resource": "" }
q63428
revertAllRemoved
test
function revertAllRemoved(repoState) { let workingState = repoState.getCurrentState(); const changes = workingState.getChanges().filter( // Remove all changes that are in the directory (change) => { return change.getType() === CHANGE_TYPE.REMOVE; } ); // Update worki...
javascript
{ "resource": "" }
q63429
normPath
test
function normPath(p) { p = path.normalize(p); if (p[0] == '/') p = p.slice(1); if (p[p.length - 1] == '/') p = p.slice(0, -1); if (p == '.') p = ''; return p; }
javascript
{ "resource": "" }
q63430
pathContains
test
function pathContains(dir, path) { dir = dir ? normPath(dir) + '/' : dir; path = normPath(path); return path.indexOf(dir) === 0; }
javascript
{ "resource": "" }
q63431
readFilenamesRecursive
test
function readFilenamesRecursive(repoState, dirName) { dirName = PathUtils.norm(dirName); const workingState = repoState.getCurrentState(); const fileSet = WorkingUtils.getMergedFileSet(workingState); return fileSet.filter((path) => { return PathUtils.contains(dirName, path); }).toArray(); ...
javascript
{ "resource": "" }
q63432
move
test
function move(repoState, dirName, newDirName) { // List entries to move const filesToMove = readFilenamesRecursive(repoState, dirName); // Push change to remove all entries return filesToMove.reduce((repoState, oldPath) => { const newPath = Path.join( newDirName, Path.re...
javascript
{ "resource": "" }
q63433
create
test
function create(repositoryState, driver, name, opts = {}) { const { // Base branch for the new branch base = repositoryState.getCurrentBranch(), // Fetch the working state and switch to it ? checkout = true, // Drop changes from base branch the new working state ? cle...
javascript
{ "resource": "" }
q63434
update
test
function update(repoState, driver, branchName) { branchName = Normalize.branchName(branchName || repoState.getCurrentBranch()); return driver.fetchBranches() .then((branches) => { const newBranch = branches.find((branch) => { return branch.getFullName() === branchName; }); ...
javascript
{ "resource": "" }
q63435
remove
test
function remove(repoState, driver, branch) { return driver.deleteBranch(branch) .then(() => { return repoState.updateBranch(branch, null); }); }
javascript
{ "resource": "" }
q63436
fetch
test
function fetch(repoState, driver, sha) { if (isFetched(repoState, sha)) { // No op if already fetched return Q(repoState); } const cache = repoState.getCache(); // Fetch the blob return driver.fetchBlob(sha) // Then store it in the cache .then((blob) => { const newCa...
javascript
{ "resource": "" }
q63437
test
function (context, options, callback) { // add the current request to the queue context.retryQueue.push([options, callback]); // bail if the token is currently being refreshed if (context.refreshActive) { return false; } // ready to refresh context.refreshActive = true; return re...
javascript
{ "resource": "" }
q63438
PokitDok
test
function PokitDok(clientId, clientSecret, version) { this.clientId = clientId; this.clientSecret = clientSecret; this.version = version || 'v4'; this.refreshActive = false; this.retryQueue = []; this.accessToken = null; }
javascript
{ "resource": "" }
q63439
featureArrayToFeatureString
test
function featureArrayToFeatureString(features, bias, firstFeatureNumber) { if (!Array.isArray(features)) throw new Error("Expected an array, but got "+JSON.stringify(features)) var line = (bias? " "+firstFeatureNumber+":"+bias: ""); for (var feature=0; feature<features.length; ++feature) { var value = features[f...
javascript
{ "resource": "" }
q63440
test
function(feature) { if (!(feature in this.featureNameToFeatureIndex)) { var newIndex = this.featureIndexToFeatureName.length; this.featureIndexToFeatureName.push(feature); this.featureNameToFeatureIndex[feature] = newIndex; } }
javascript
{ "resource": "" }
q63441
test
function(hash) { if (hash instanceof Array) { for (var index in hash) this.addFeature(hash[index]); } else if (hash instanceof Object) { for (var feature in hash) this.addFeature(feature); } else throw new Error("FeatureLookupTable.addFeatures expects a hash or an array, but got: "+JSON.stringify...
javascript
{ "resource": "" }
q63442
test
function(hash) { this.addFeatures(hash); var array = []; for (var featureIndex=0; featureIndex<this.featureIndexToFeatureName.length; ++featureIndex) array[featureIndex]=0; if (hash instanceof Array) { for (var i in hash) array[this.featureNameToFeatureIndex[hash[i]]] = true; } else if (hash instanc...
javascript
{ "resource": "" }
q63443
test
function(hashes) { this.addFeaturess(hashes); var arrays = []; for (var i=0; i<hashes.length; ++i) { arrays[i] = []; for (var feature in this.featureNameToFeatureIndex) arrays[i][this.featureNameToFeatureIndex[feature]] = hashes[i][feature] || 0; } return arrays; }
javascript
{ "resource": "" }
q63444
test
function(array) { var hash = {}; for (var feature in this.featureNameToFeatureIndex) { if (array[this.featureNameToFeatureIndex[feature]]) hash[feature] = array[this.featureNameToFeatureIndex[feature]]; } return hash; }
javascript
{ "resource": "" }
q63445
test
function(arrays) { var hashes = []; for (var i=0; i<arrays.length; ++i) hashes[i] = this.arrayToHash(arrays[i]); return hashes; }
javascript
{ "resource": "" }
q63446
test
function(sample, splitLabels, treeNode) { var superlabels = {}; // the first parts of each of the splitLabels var mapSuperlabelToRest = {}; // each value is a list of continuations of the key. for (var i in splitLabels) { var splitLabel = splitLabels[i]; var superlabel = splitLabel[0]; superlabels[sup...
javascript
{ "resource": "" }
q63447
test
function(dataset, treeNode) { var superlabelsDataset = []; var mapSuperlabelToRestDataset = {}; dataset.forEach(function(datum) { var splitLabels = datum.output; // [ [ 'Offer', 'Leased Car', 'Without leased car' ], [ 'Offer', 'Working Hours', '9 hours' ] ] var superlabels = {}; // the first part...
javascript
{ "resource": "" }
q63448
test
function(sample, explain, treeNode, depth) { if (!depth) depth = 1; // classify the superlabel var superlabelsWithExplain = treeNode.superlabelClassifier.classify(sample, explain); var superlabels = (explain>0? superlabelsWithExplain.classes: superlabelsWithExplain); var splitLabels = []; if (explain>0)...
javascript
{ "resource": "" }
q63449
test
function(opts) { if (!('binaryClassifierType' in opts)) { console.dir(opts); throw new Error("opts must contain binaryClassifierType"); } if (!opts.binaryClassifierType) { console.dir(opts); throw new Error("opts.binaryClassifierType is null"); } this.binaryClassifierType = opts.binaryClassifierType; thi...
javascript
{ "resource": "" }
q63450
test
function(opts) { this.retrain_count = opts.retrain_count || 10; this.Constant = opts.Constant || 5.0; this.weights = { //DUMMY_CLASS:{} }; this.weights_sum = { //DUMMY_CLASS:{} }; this.seenFeatures = {}; this.num_iterations = 0 }
javascript
{ "resource": "" }
q63451
test
function(classes) { classes = hash.normalized(classes); for (var aClass in classes) { if (!(aClass in this.weights)) { this.weights[aClass]={}; this.weights_sum[aClass]={}; } } }
javascript
{ "resource": "" }
q63452
test
function(opts) { opts = opts || {}; if (!opts.multilabelClassifierType) { console.dir(opts); throw new Error("opts.multilabelClassifierType is null"); } if (!opts.numberofclassifiers) { console.dir(opts); throw new Error("opts.numberofclassifiers is null"); } // this.splitLabel = opts.splitLabel || fu...
javascript
{ "resource": "" }
q63453
test
function(expected, actual) { this.count++; if (expected && actual) this.TP++; if (!expected && actual) this.FP++; if (expected && !actual) this.FN++; if (!expected && !actual) this.TN++; if (expected==actual) this.TRUE++; }
javascript
{ "resource": "" }
q63454
test
function (expectedClasses, actualClasses ) { var explanations = []; actualClasses = hash.normalized(actualClasses); expectedClasses = hash.normalized(expectedClasses); var allTrue = true; if (!(Object.keys(expectedClasses)[0] in this.confusion)) this.confusion[Object.keys(expectedClasses)[0]] = {} i...
javascript
{ "resource": "" }
q63455
test
function (expectedClasses, actualClasses, logTruePositives) { var explanations = []; actualClasses = hash.normalized(actualClasses); expectedClasses = hash.normalized(expectedClasses); var allTrue = true; for (var actualClass in actualClasses) { if (actualClass in expectedClasses) { if (logTruePositi...
javascript
{ "resource": "" }
q63456
test
function (expectedClasses, actualClasses, logTruePositives ) { var explanations = {}; explanations['TP'] = []; explanations['FP'] = []; explanations['FN'] = []; actualClasses = hash.normalized(actualClasses); expectedClasses = hash.normalized(expectedClasses); var allTrue = true; for (var actualClass in a...
javascript
{ "resource": "" }
q63457
test
function(dataset) { if (this.debug) console.log("trainBatch start"); var timestamp = new Date().getTime()+"_"+process.pid var learnFile = svmcommon.writeDatasetToFile(dataset, this.bias, /*binarize=*/true, this.model_file_prefix+"_"+timestamp, "SvmPerf", FIRST_FEATURE_NUMBER); var modelFile = learnFile.rep...
javascript
{ "resource": "" }
q63458
modelStringToModelMap
test
function modelStringToModelMap(modelString) { var matches = SVM_PERF_MODEL_PATTERN.exec(modelString); if (!matches) { console.log(modelString); throw new Error("Model does not match SVM-perf format"); }; //var threshold = parseFloat(matches[1]); // not needed - we use our own bias var featuresAndWeights = mat...
javascript
{ "resource": "" }
q63459
test
function(dataset, relationName, featureLookupTable) { var arff = "% Automatically generated by Node.js\n"; arff += "@relation "+relationName+"\n"; featureLookupTable.featureIndexToFeatureName.forEach(function(featureName) { if (_.isUndefined(featureName)) arff += "@attribute undefined {0,1}"+"\n"; else if (...
javascript
{ "resource": "" }
q63460
SvmLinear
test
function SvmLinear(opts) { this.learn_args = opts.learn_args || ""; this.model_file_prefix = opts.model_file_prefix || null; this.bias = opts.bias || 1.0; this.multiclass = opts.multiclass || false; this.debug = opts.debug||false; this.train_command = opts.train_command || 'liblinear_train'; this.test_command = ...
javascript
{ "resource": "" }
q63461
test
function(dataset) { this.timestamp = new Date().getTime()+"_"+process.pid // check for multilabel _.each(dataset, function(datum, key, list){ if (_.isArray(datum.output)) if (datum.output.length > 1) { console.log("Multi-label is not allowed") console.log(JSON.stringify(darum.output,...
javascript
{ "resource": "" }
q63462
modelStringToModelMap
test
function modelStringToModelMap(modelString) { var matches = LIB_LINEAR_MODEL_PATTERN.exec(modelString); if (!matches) { console.log(modelString); throw new Error("Model does not match SVM-Linear format"); }; var labels = matches[1].split(/\s+/); var mapLabelToMapFeatureToWeight = {}; for (var iLabel in labels...
javascript
{ "resource": "" }
q63463
test
function(sample, labels) { labels = multilabelutils.normalizeOutputLabels(labels); for (var l in labels) { var positiveLabel = labels[l]; this.makeSureClassifierExists(positiveLabel); this.mapClassnameToClassifier[positiveLabel].trainOnline(sample, 1); } for (var negativeLabel in this.mapClassnameToCla...
javascript
{ "resource": "" }
q63464
test
function(opts) { if (!opts.multiclassClassifierType) { console.dir(opts); throw new Error("opts.multiclassClassifierType not found"); } this.multiclassClassifierType = opts.multiclassClassifierType; this.featureExtractor = FeaturesUnit.normalize(opts.featureExtractor); this.multiclassClassifier = new this.mu...
javascript
{ "resource": "" }
q63465
concatOptionDataArrays
test
function concatOptionDataArrays(options, data, prop) { if (!_.has(options, prop) && !_.has(data, prop)) { return; } var combined = []; if (_.isArray(options[prop])) { combined = combined.concat(options[prop]); } if (_.isArray(data[prop])) { combined = combined.concat(dat...
javascript
{ "resource": "" }
q63466
preorder
test
function preorder(node, nodeIndex, parent) { var children var length var index var position var child if (is(test, node, nodeIndex, parent)) { return null } children = node.children if (!children || children.length === 0) { return node } // Move all living chi...
javascript
{ "resource": "" }
q63467
filterRelations
test
function filterRelations(relation) { var mappedData = includedData.find(function (inc) { return inc.id === relation.id; }); var RelationModel = getModel(relation.type); var modeledData = new RelationModel(mappedData); return checkForRelations(modeledData, modeledData.data); }
javascript
{ "resource": "" }
q63468
test
function (bundleName, filter) { var bundle, files = []; bundle = this._bundles[bundleName]; if (!bundle) { throw new Error('Unknown bundle "' + bundleName + '"'); } Object.keys(bundle.files).forEach(function (fullpath) { var res = { ...
javascript
{ "resource": "" }
q63469
test
function (bundleName, filter) { var bundle = this._bundles[bundleName]; if (!bundle) { throw new Error('Unknown bundle "' + bundleName + '"'); } return this._walkBundleResources(bundle, filter); }
javascript
{ "resource": "" }
q63470
test
function (filter) { var self = this, ress = []; Object.keys(this._bundles).forEach(function (bundleName) { var bundle = self._bundles[bundleName]; self._walkBundleResources(bundle, filter).forEach(function (res) { ress.push(res); }); ...
javascript
{ "resource": "" }
q63471
test
function (filter) { var bundleName, bundles = this._bundles, bundleNames = []; if ('function' !== typeof filter) { return Object.keys(this._bundles); } for (bundleName in bundles) { if (bundles.hasOwnProperty(bundleName)) { ...
javascript
{ "resource": "" }
q63472
test
function (findPath) { // FUTURE OPTIMIZATION: use a more complicated datastructure for faster lookups var found = {}, // length: path longest; // expands path in case of symlinks findPath = libfs.realpathSync(findPath); // searchs based on expanded path Objec...
javascript
{ "resource": "" }
q63473
test
function (baseDirectory, name, version, pkg, options) { var seed; seed = { baseDirectory: baseDirectory, name: name, version: version }; if (pkg) { seed.name = (pkg.locator && pkg.locator.name ? pkg.locator.name : pkg.name); see...
javascript
{ "resource": "" }
q63474
test
function (seed, parent) { var bundle, ruleset = this._loadRuleset(seed), msg; if (seed.options.location) { // This is fairly legacy, and we might be able to remove it. seed.baseDirectory = libpath.resolve(seed.baseDirectory, seed.options.location); ...
javascript
{ "resource": "" }
q63475
test
function (fullPath) { var bundleName, bundle, ruleset, relativePath, pathParts, subBundleSeed, res; bundleName = this._getBundleNameByPath(fullPath); bundle = this._bundles[bundleName]; if (bundle.baseDirectory === ...
javascript
{ "resource": "" }
q63476
test
function (fullPath, relativePath, rule) { var r, regex; relativePath = BundleLocator._toUnixPath(relativePath); for (r = 0; r < rule.length; r += 1) { regex = rule[r]; if (regex.test(relativePath)) { return true; } } return fa...
javascript
{ "resource": "" }
q63477
test
function (res, ruleset) { var bundle = this._bundles[res.bundleName], ruleName, rule, relativePath = BundleLocator._toUnixPath(res.relativePath), match; bundle.files[res.fullPath] = true; for (ruleName in ruleset) { if (ruleset.hasOwn...
javascript
{ "resource": "" }
q63478
test
function (res) { var bundle = this._bundles[res.bundleName], type = res.type, subtype, selector = res.selector, name = res.name; if (!bundle.resources[selector]) { bundle.resources[selector] = {}; } if (!bundle.resources[select...
javascript
{ "resource": "" }
q63479
test
function (res, filter) { if (!filter || Object.keys(filter).length === 0) { return true; } var prop; for (prop in filter) { if ('extensions' === prop) { // sugar for users if ('string' === typeof filter.extensions) { ...
javascript
{ "resource": "" }
q63480
test
function (pkgDepths) { // pkgDepths -> depth: [metas] var depths, minDepth, maxDepth, seeds; depths = Object.keys(pkgDepths); minDepth = Math.min.apply(Math, depths); maxDepth = Math.max.apply(Math, depths); seeds = pkgDepths[minDepth];...
javascript
{ "resource": "" }
q63481
test
function (all) { var byDepth = {}; // name: depth: [metas] all.forEach(function (seed) { if (!byDepth[seed.name]) { byDepth[seed.name] = {}; } if (!byDepth[seed.name][seed.npmDepth]) { byDepth[seed.name][seed.npmDepth] = []; ...
javascript
{ "resource": "" }
q63482
test
function (bundleSeed) { var self = this, parentName, parent, bundle, filters; // TODO -- merge options (second arg) over bundleSeed.options parentName = this._getBundleNameByPath(libpath.dirname(bundleSeed.baseDirectory)); parent = this._b...
javascript
{ "resource": "" }
q63483
test
function (srcObject, excludeKeys) { var destObject = {}, key; for (key in srcObject) { if (srcObject.hasOwnProperty(key)) { if (-1 === excludeKeys.indexOf(key)) { destObject[key] = srcObject[key]; } } } ...
javascript
{ "resource": "" }
q63484
Bundle
test
function Bundle(baseDirectory, options) { this.options = options || {}; this.name = libpath.basename(baseDirectory); this.baseDirectory = baseDirectory; this.type = undefined; this.files = {}; this.resources = {}; }
javascript
{ "resource": "" }
q63485
getBaseScales
test
function getBaseScales(type, domain, range, nice, tickCount) { const factory = (type === 'time' && scaleUtc) || (type === 'log' && scaleLog) || scaleLinear const scale = createScale(factory, domain, range) if (nice) scale.nice(tickCount) return scale }
javascript
{ "resource": "" }
q63486
BufferingTracer
test
function BufferingTracer(tracer, options) { options = options || {}; var self = this; this._tracer = tracer; this._maxTraces = options.maxTraces || 50; this._sendInterval = options.sendInterval ? (options.sendInterval * 1000) : 10 * 1000; this._lastSentTs = Date.now(); this._buffer = []; this._stopped...
javascript
{ "resource": "" }
q63487
build
test
function build(gulp) { // make sure we don't lose anything from required files // @see https://github.com/Mikhus/gulp-help-doc/issues/2 // currently this is not supported for typescript var source = OPTIONS.isTypescript ? fs.readFileSync('gulpfile.ts').toString() : OPTIONS.gulpfile ? ...
javascript
{ "resource": "" }
q63488
chunk
test
function chunk(str, maxLen) { var len = maxLen || OPTIONS.lineWidth; var curr = len; var prev = 0; var out = []; while (str[curr]) { if (str[curr++] == ' ') { out.push(str.substring(prev, curr)); prev = curr; curr += len; } } out.push(s...
javascript
{ "resource": "" }
q63489
usage
test
function usage(gulp, options) { // re-define options if needed if (options) { Object.assign(OPTIONS, options); } return new Promise(function(resolve) { build(gulp); print(); resolve(); }); }
javascript
{ "resource": "" }
q63490
filterArray
test
function filterArray (arr, toKeep) { var i = 0 while (i < arr.length) { if (toKeep(arr[i])) { i++ } else { arr.splice(i, 1) } } }
javascript
{ "resource": "" }
q63491
cssExtract
test
function cssExtract (bundle, opts) { opts = opts || {} var outFile = opts.out || opts.o || 'bundle.css' var sourceMap = d(opts.sourceMap, bundle && bundle._options && bundle._options.debug, false) assert.equal(typeof bundle, 'object', 'bundle should be an object') assert.equal(typeof opts, 'object', 'opts s...
javascript
{ "resource": "" }
q63492
validatePlaceholders
test
function validatePlaceholders( { id, idPlural, translations }, validationErrors ) { // search for {{placeholderName}} // Also search for e.g. Chinese symbols in the placeholderName let pattern = /{{\s*(\S+?)\s*?}}/g; let placeholders = id.match(pattern) || []; // We also want to add placeholders from the...
javascript
{ "resource": "" }
q63493
groupGettextItems
test
function groupGettextItems(gettextItems) { return gettextItems .filter((item) => item.messageId) // filter out items without message id .sort((item1, item2) => { return ( item1.loc.fileName.localeCompare(item2.loc.fileName) || item1.loc.line - item2.loc.line ); }) .reduce((...
javascript
{ "resource": "" }
q63494
traverseJson
test
function traverseJson(json, callback) { let { translations } = json; Object.keys(translations).forEach((namespace) => { Object.keys(translations[namespace]).forEach((k) => { callback(translations[namespace][k], translations[namespace], k); }); }); }
javascript
{ "resource": "" }
q63495
findAllDependencies
test
function findAllDependencies(file, knownDependencies, sourceDirectories, knownFiles) { if (!knownDependencies) { knownDependencies = []; } if (typeof knownFiles === "undefined"){ knownFiles = []; } else if (knownFiles.indexOf(file) > -1){ return knownDependencies; } if (sourceDirectories) { ...
javascript
{ "resource": "" }
q63496
parse
test
function parse(query) { if (query[0] == "?") query = query.slice(1); var pairs = query.split("&"), obj = {}; for (var i in pairs) { var pair = pairs[i].split("="), key = decodeURIComponent(pair[0]), value = pair[1] ? decodeURIComponent(pai...
javascript
{ "resource": "" }
q63497
stringify
test
function stringify(obj) { var arr = []; for (var x in obj) { arr.push(encodeURIComponent(x) + "=" + encodeURIComponent(obj[x])); } return arr.join("&"); }
javascript
{ "resource": "" }
q63498
_compileAny
test
function _compileAny(any, options){ // Array if (oj.isArray(any)) _compileTag(any, options) // String else if (oj.isString(any)){ if (options.html != null) options.html.push(any) if (any.length > 0 && any[0] === '<'){ var root = document.createElement('div') r...
javascript
{ "resource": "" }
q63499
_attributesBindEventsToDOM
test
function _attributesBindEventsToDOM(events, el, inserts){ var ek, ev, _results = [] for (ek in events){ ev = events[ek] _a(oj.$ != null, "jquery is missing when binding a '" + ek + "' event") // accumulate insert events manually since DOMNodeInserted is slow and depreciated if (ek == 'in...
javascript
{ "resource": "" }