_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q64300
startGc
test
function startGc(db, options) { this.options = options || {} var freqMs = options.gcFreqMs || 60000 var maxVersions = options.gcMaxVersions var maxAge = options.gcMaxAge var backup = options.gcBackup var callback = options.gcCallback if (maxAge || maxVersions) { maxAge = maxAge || Math.pow(2, 53) ...
javascript
{ "resource": "" }
q64301
test
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof NameFormInfo)){ return new NameFormInfo(json); } // If
javascript
{ "resource": "" }
q64302
test
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof OAuth2)){ return new OAuth2(json); } //
javascript
{ "resource": "" }
q64303
forceInRange
test
function forceInRange (value, min, max) { if (value > max) {return max;} else if (value <
javascript
{ "resource": "" }
q64304
insertIntoList
test
function insertIntoList(item, position, list) { var before = list.slice(0, position); var after
javascript
{ "resource": "" }
q64305
validateProps
test
function validateProps(token) { Object.keys(token.props).forEach(key => { if (!validateProp(key, token.props[key]))
javascript
{ "resource": "" }
q64306
Event
test
function Event(name, attributes) { this._name = name; this._stopped =
javascript
{ "resource": "" }
q64307
create
test
function create(text) { return Tools.instance({ text, pos: 0 }, { isDone, getPos, expect,
javascript
{ "resource": "" }
q64308
test
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof FeedbackInfo)){ return new FeedbackInfo(json); } // If
javascript
{ "resource": "" }
q64309
test
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Reservation)){ return new Reservation(json); } // If
javascript
{ "resource": "" }
q64310
test
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof SearchInfo)){ return new SearchInfo(json); } //
javascript
{ "resource": "" }
q64311
asyncForEach
test
function asyncForEach (array, iterator, done) { if (array.length === 0) { // NOTE: Normally a bad idea to mix sync and async, but it's safe here because // of the way that this method is
javascript
{ "resource": "" }
q64312
safeCall
test
function safeCall (fn, args) { // Get the function arguments as an array args = Array.prototype.slice.call(arguments, 1); // Replace the callback function
javascript
{ "resource": "" }
q64313
callOnce
test
function callOnce (fn) { let fulfilled = false; return function onceWrapper (err) { if (!fulfilled) { fulfilled = true; return fn.apply(this, arguments); } else if (err) { // The callback has already been called, but now an error has occurred
javascript
{ "resource": "" }
q64314
uniqNoSet
test
function uniqNoSet(arr) { var ret = []; for (var i = 0; i < arr.length;
javascript
{ "resource": "" }
q64315
uniqSetWithForEach
test
function uniqSetWithForEach(arr) { var ret = []; (new Set(arr)).forEach(function (el)
javascript
{ "resource": "" }
q64316
Base
test
function Base(config, options) { if (!(this instanceof Base)) { return new Base(config, options); }
javascript
{ "resource": "" }
q64317
memoize
test
function memoize(type, pattern, options, fn) { var key = utils.createKey(type + ':' + pattern, options); var disabled = options && options.cache === false; if (disabled) { braces.clearCache(); return fn(pattern, options);
javascript
{ "resource": "" }
q64318
multiply
test
function multiply(queue, n, options) { return
javascript
{ "resource": "" }
q64319
noInner
test
function noInner(node, type) { if (node.parent.queue.length === 1) { return true; } var nodes = node.parent.nodes; return nodes.length === 3
javascript
{ "resource": "" }
q64320
brackets
test
function brackets(pattern, options) { debug('initializing from
javascript
{ "resource": "" }
q64321
wrap
test
function wrap(arr, sep, opts) { if (sep === '~') { sep = '-'; } var str = arr.join(sep); var pre = opts && opts.regexPrefix; // regex logical `or` if (sep === '|') { str = pre ? pre + str : str; str = '(' + str + ')'; } // regex
javascript
{ "resource": "" }
q64322
formatPadding
test
function formatPadding(ch, pad) { var res = pad ? pad + ch : ch; if (pad && ch.toString().charAt(0) === '-') {
javascript
{ "resource": "" }
q64323
isPadded
test
function isPadded(origA, origB) { if (hasZeros(origA) || hasZeros(origB)) { var alen = length(origA); var blen = length(origB);
javascript
{ "resource": "" }
q64324
Extglob
test
function Extglob(options) { this.options = extend({source: 'extglob'}, options); this.snapdragon = this.options.snapdragon || new Snapdragon(this.options); this.snapdragon.patterns = this.snapdragon.patterns || {}; this.compiler = this.snapdragon.compiler; this.parser = this.snapdragon.parser; compilers(th...
javascript
{ "resource": "" }
q64325
micromatch
test
function micromatch(list, patterns, options) { patterns = utils.arrayify(patterns); list = utils.arrayify(list); var len = patterns.length; if (list.length === 0 || len === 0) { return []; } if (len === 1) { return micromatch.match(list, patterns[0], options); } var omit = []; var keep = []...
javascript
{ "resource": "" }
q64326
sync
test
function sync(source, opts) { var works = getWorks(source, reader_sync_1.default, opts);
javascript
{ "resource": "" }
q64327
stream
test
function stream(source, opts) { var works = getWorks(source,
javascript
{ "resource": "" }
q64328
generateTasks
test
function generateTasks(source, opts) { var patterns = [].concat(source);
javascript
{ "resource": "" }
q64329
getWorks
test
function getWorks(source, _Reader, opts) { var patterns = [].concat(source); var options = optionsManager.prepare(opts); var tasks = taskManager.generate(patterns, options);
javascript
{ "resource": "" }
q64330
generate
test
function generate(patterns, options) { var unixPatterns = patterns.map(patternUtils.unixifyPattern); var unixIgnore = options.ignore.map(patternUtils.unixifyPattern); var positivePatterns = getPositivePatterns(unixPatterns); var negativePatterns = getNegativePatternsAsPositive(unixPatterns, unixIgnore);...
javascript
{ "resource": "" }
q64331
convertPatternsToTasks
test
function convertPatternsToTasks(positive, negative, dynamic) { var positivePatternsGroup = groupPatternsByBaseDirectory(positive); var negativePatternsGroup = groupPatternsByBaseDirectory(negative); // When we have a global group – there is no reason to divide the patterns into independent tasks. // In ...
javascript
{ "resource": "" }
q64332
getNegativePatternsAsPositive
test
function getNegativePatternsAsPositive(patterns, ignore) { var negative = patternUtils.getNegativePatterns(patterns).concat(ignore);
javascript
{ "resource": "" }
q64333
groupPatternsByBaseDirectory
test
function groupPatternsByBaseDirectory(patterns) { return patterns.reduce(function (collection, pattern) { var base = patternUtils.getBaseDirectory(pattern);
javascript
{ "resource": "" }
q64334
convertPatternGroupsToTasks
test
function convertPatternGroupsToTasks(positive, negative, dynamic) { var globalNegative = '.' in negative ? negative['.'] : []; return Object.keys(positive).map(function (base) { var localNegative = findLocalNegativePatterns(base, negative);
javascript
{ "resource": "" }
q64335
findLocalNegativePatterns
test
function findLocalNegativePatterns(positiveBase, negative) { return Object.keys(negative).reduce(function (collection, base) { if (base.startsWith(positiveBase)) {
javascript
{ "resource": "" }
q64336
convertPatternGroupToTask
test
function convertPatternGroupToTask(base, positive, negative, dynamic) { return { base: base, dynamic: dynamic,
javascript
{ "resource": "" }
q64337
matchAny
test
function matchAny(entry, patternsRe) { try { for (var patternsRe_1 = __values(patternsRe), patternsRe_1_1 = patternsRe_1.next(); !patternsRe_1_1.done; patternsRe_1_1 = patternsRe_1.next()) { var regexp = patternsRe_1_1.value; if (regexp.test(entry)) { return true; ...
javascript
{ "resource": "" }
q64338
test
function () { removeNotFoundFiles(); var entries = normalizedEntries; var keys = Object.keys( entries ); if ( keys.length === 0 ) { return; } keys.forEach( function ( entryName ) { var cacheEntry = entries[ entryName ]; try { ...
javascript
{ "resource": "" }
q64339
test
function ( pathToFile ) { var me = this; var dir = path.dirname( pathToFile ); var fName =
javascript
{ "resource": "" }
q64340
test
function ( noPrune ) { var me = this; (!noPrune) && me._prune();
javascript
{ "resource": "" }
q64341
test
function ( docId, cacheDir ) { var obj = Object.create(
javascript
{ "resource": "" }
q64342
test
function ( docId, cacheDir ) { var filePath = cacheDir ? path.resolve( cacheDir,
javascript
{ "resource": "" }
q64343
test
function(cacheName, key, val) { var cache = this.cache(cacheName);
javascript
{ "resource": "" }
q64344
LOOP
test
function LOOP() { // stop if scanned past end of path if (pos >= p.length) { if (cache) cache[original] = p; return cb(null, p); } // find the next part nextPartRe.lastIndex = pos; var result = nextPartRe.exec(p); previous = current; current += result[0]; base = previous...
javascript
{ "resource": "" }
q64345
micromatch
test
function micromatch(files, patterns, opts) { if (!files || !patterns) return []; opts = opts || {}; if (typeof opts.cache === 'undefined') { opts.cache = true; } if (!Array.isArray(patterns)) { return match(files, patterns, opts); } var len = patterns.length, i = 0; var omit = [], keep = []; ...
javascript
{ "resource": "" }
q64346
match
test
function match(files, pattern, opts) { if (utils.typeOf(files) !== 'string' && !Array.isArray(files)) { throw new Error(msg('match', 'files', 'a string or array')); } files = utils.arrayify(files); opts = opts || {}; var negate = opts.negate || false; var orig = pattern; if (typeof pattern === 'str...
javascript
{ "resource": "" }
q64347
isMatch
test
function isMatch(fp, pattern, opts) { if (typeof fp !== 'string') { throw new TypeError(msg('isMatch', 'filepath', 'a
javascript
{ "resource": "" }
q64348
contains
test
function contains(fp, pattern, opts) { if (typeof fp !== 'string') { throw new TypeError(msg('contains', 'pattern', 'a string')); } opts = opts || {}; opts.contains = (pattern !== ''); fp = utils.unixify(fp, opts);
javascript
{ "resource": "" }
q64349
any
test
function any(fp, patterns, opts) { if (!Array.isArray(patterns) && typeof patterns !== 'string') { throw new TypeError(msg('any', 'patterns', 'a string or array')); } patterns = utils.arrayify(patterns); var len = patterns.length;
javascript
{ "resource": "" }
q64350
matchKeys
test
function matchKeys(obj, glob, options) { if (utils.typeOf(obj) !== 'object') { throw new TypeError(msg('matchKeys', 'first argument', 'an object')); } var fn = matcher(glob, options); var res =
javascript
{ "resource": "" }
q64351
matcher
test
function matcher(pattern, opts) { // pattern is a function if (typeof pattern === 'function') { return pattern; } // pattern is a regex if (pattern instanceof RegExp) { return function(fp) { return pattern.test(fp); }; } if (typeof pattern !== 'string') { throw new TypeError(msg('ma...
javascript
{ "resource": "" }
q64352
toRegex
test
function toRegex(glob, options) { // clone options to prevent mutating the original object var opts = Object.create(options || {}); var flags = opts.flags || ''; if (opts.nocase && flags.indexOf('i') === -1) { flags += 'i'; } var parsed = expand(glob, opts); // pass in tokens to avoid parsing more ...
javascript
{ "resource": "" }
q64353
wrapGlob
test
function wrapGlob(glob, opts) { var prefix = (opts && !opts.contains) ? '^' : ''; var after = (opts && !opts.contains) ? '$' : ''; glob = ('(?:' + glob + ')' + after); if
javascript
{ "resource": "" }
q64354
makeRe
test
function makeRe(glob, opts) { if (utils.typeOf(glob) !== 'string') { throw new Error(msg('makeRe', 'glob', 'a
javascript
{ "resource": "" }
q64355
collapse
test
function collapse(str, ch) { var res = str.split(ch); var isFirst = res[0] === ''; var isLast = res[res.length - 1] === ''; res
javascript
{ "resource": "" }
q64356
exponential
test
function exponential(str, options, fn) { if (typeof options === 'function') { fn = options; options = null; } var opts = options || {}; var esc = '__ESC_EXP__'; var exp = 0; var res; var parts = str.split('{,}'); if (opts.nodupes) { return fn(parts.join(''), opts); } exp = parts.lengt...
javascript
{ "resource": "" }
q64357
splitWhitespace
test
function splitWhitespace(str) { var segs = str.split(' '); var len = segs.length; var res = []; var i = 0; while (len--) {
javascript
{ "resource": "" }
q64358
filter
test
function filter(arr, cb) { if (arr == null) return []; if (typeof cb !== 'function') { throw new TypeError('braces: filter expects a callback function.'); } var len = arr.length; var res =
javascript
{ "resource": "" }
q64359
extglob
test
function extglob(str, opts) { opts = opts || {}; var o = {}, i = 0; // fix common character reversals // '*!(.js)' => '*.!(js)' str = str.replace(/!\(([^\w*()])/g, '$1!('); // support file extension negation str = str.replace(/([*\/])\.!\([*]\)/g, function (m, ch) { if (ch === '/') { return es...
javascript
{ "resource": "" }
q64360
wrap
test
function wrap(inner, prefix, esc) { if (esc) inner = escape(inner); switch (prefix) { case '!': return '(?!' + inner + ')[^/]' + (esc ? '%%%~' : '*?'); case '@': return '(?:' + inner + ')'; case '+': return '(?:' + inner + ')+';
javascript
{ "resource": "" }
q64361
toRegex
test
function toRegex(pattern, contains, isNegated) { var prefix = contains ? '^' : ''; var after = contains ? '$' : ''; pattern = ('(?:' + pattern + ')' + after); if
javascript
{ "resource": "" }
q64362
copy
test
function copy(val, key) { if (key === '__proto__') { return; } var obj = this[key]; if (isObject(val) && isObject(obj)) {
javascript
{ "resource": "" }
q64363
advanceTo
test
function advanceTo(input, endChar) { var ch = input.charAt(0); var tok = { len: 1, val: '', esc: '' }; var idx = 0; function advance() { if (ch !== '\\') { tok.esc += '\\' + ch; tok.val += ch; } ch = input.charAt(++idx);
javascript
{ "resource": "" }
q64364
BasicSourceMapConsumer
test
function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) { var sourceMap = aSourceMap; if (typeof aSourceMap === 'string') { sourceMap = util.parseSourceMapInput(aSourceMap); } var version = util.getArg(sourceMap, 'version'); var sources = util.getArg(sourceMap, 'sources'); // Sass 3.3 leaves out the...
javascript
{ "resource": "" }
q64365
compareByOriginalPositions
test
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { var cmp = strcmp(mappingA.source, mappingB.source); if (cmp !== 0) { return cmp; } cmp = mappingA.originalLine - mappingB.originalLine; if (cmp !== 0) { return cmp; } cmp = mappingA.originalColumn - mappingB.originalC...
javascript
{ "resource": "" }
q64366
compareByGeneratedPositionsDeflated
test
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { var cmp = mappingA.generatedLine - mappingB.generatedLine; if (cmp !== 0) { return cmp; } cmp = mappingA.generatedColumn - mappingB.generatedColumn; if (cmp !== 0 || onlyCompareGenerated) { return cmp; } cmp...
javascript
{ "resource": "" }
q64367
computeSourceURL
test
function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { sourceURL = sourceURL || ''; if (sourceRoot) { // This follows what Chrome does. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') { sourceRoot += '/'; } // The spec says: // Line 4: An optional source...
javascript
{ "resource": "" }
q64368
CorkedRequest
test
function CorkedRequest(state) { var _this = this; this.next = null; this.entry = null; this.finish
javascript
{ "resource": "" }
q64369
clearBuffer
test
function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; if (stream._writev && entry && entry.next) { // Fast case, write everything using _writev() var l = state.bufferedRequestCount; var buffer = new Array(l); var holder = state.corkedRequestsFree;...
javascript
{ "resource": "" }
q64370
Node
test
function Node(val, type, parent) { if (typeof type !== 'string') { parent = type; type = null; } define(this, 'parent', parent); define(this, 'isNode', true); define(this, 'expect', null); if (typeof type !== 'string' && isObject(val)) { lazyKeys(); var keys = Object.keys(val); for (va...
javascript
{ "resource": "" }
q64371
append
test
function append(compiler, val, node) { if (typeof compiler.append !== 'function') { return compiler.emit(val,
javascript
{ "resource": "" }
q64372
Snapdragon
test
function Snapdragon(options) { Base.call(this, null, options); this.options = utils.extend({source: 'string'}, this.options); this.compiler = new Compiler(this.options); this.parser = new Parser(this.options); Object.defineProperty(this, 'compilers', { get: function() { return this.compiler.compile...
javascript
{ "resource": "" }
q64373
test
function(msg, node) { var pos = node.position || {start: {column: 0}}; var message = this.options.source + ' column:' + pos.start.column + ': ' + msg;
javascript
{ "resource": "" }
q64374
test
function(node, nodes, i) { var fn = this.compilers[node.type]; this.idx = i; if (typeof fn !==
javascript
{ "resource": "" }
q64375
test
function(ast, options) { var opts = utils.extend({}, this.options, options); this.ast = ast; this.parsingErrors = this.ast.errors; this.output = ''; // source map support if (opts.sourcemap) { var sourcemaps = require('./source-maps'); sourcemaps(this); this.mapVisit(this.ast....
javascript
{ "resource": "" }
q64376
Parser
test
function Parser(options) { debug('initializing', __filename); this.options
javascript
{ "resource": "" }
q64377
test
function(type, fn) { if (this.types.indexOf(type) === -1) {
javascript
{ "resource": "" }
q64378
test
function(type, token) { this.sets[type] = this.sets[type] || []; this.count++;
javascript
{ "resource": "" }
q64379
test
function(type) { this.sets[type] = this.sets[type] || []; this.count--;
javascript
{ "resource": "" }
q64380
test
function(n) { return this.stack.length > 0 ? utils.last(this.stack, n)
javascript
{ "resource": "" }
q64381
test
function(str, len) { var lines = str.match(/\n/g); if (lines) this.line += lines.length; var i = str.lastIndexOf('\n'); this.column = ~i ? len -
javascript
{ "resource": "" }
q64382
test
function(type, openRegex, closeRegex, fn) { this.sets[type] = this.sets[type] || []; /** * Open */ this.set(type + '.open', function() { var parsed = this.parsed; var pos = this.position(); var m = this.match(openRegex); if (!m || !m[0]) return; var val = m[0]; ...
javascript
{ "resource": "" }
q64383
test
function() { var pos = this.position(); if (this.input) return; var prev = this.prev(); while (prev.type !== 'root' && !prev.visited) { if (this.options.strict === true) { throw new SyntaxError('invalid syntax:' + util.inspect(prev, null, 2)); } if (!hasDelims(prev))
javascript
{ "resource": "" }
q64384
test
function() { var parsed = this.parsed; var len = this.types.length; var idx = -1; var tok; while (++idx < len) { if ((tok = this.parsers[this.types[idx]].call(this))) { define(tok,
javascript
{ "resource": "" }
q64385
test
function(input) { if (typeof input !== 'string') { throw new TypeError('expected a string'); } this.init(this.options); this.orig = input; this.input = input; var self = this; function parse() { // check input before calling `.next()` input = self.input; // get the...
javascript
{ "resource": "" }
q64386
mixin
test
function mixin(compiler) { define(compiler, '_comment', compiler.comment); compiler.map = new utils.SourceMap.SourceMapGenerator();
javascript
{ "resource": "" }
q64387
utf8End
test
function utf8End(buf) { var r = buf && buf.length ? this.write(buf) : '';
javascript
{ "resource": "" }
q64388
rangeToPattern
test
function rangeToPattern(start, stop, options) { if (start === stop) { return {pattern: String(start), digits: []}; } var zipped = zip(String(start), String(stop)); var len = zipped.length, i = -1; var pattern = ''; var digits = 0; while (++i < len) { var numbers = zipped[i]; var startDigit ...
javascript
{ "resource": "" }
q64389
use
test
function use(type, fn, options) { var offset = 1; if (typeof type === 'string' || Array.isArray(type)) { fn = wrap(type, fn); offset++; } else { options = fn; fn = type; } if (typeof fn !== 'function') { throw new TypeError('expected a function'); } var self ...
javascript
{ "resource": "" }
q64390
wrap
test
function wrap(type, fn) { return function plugin() { return this.type
javascript
{ "resource": "" }
q64391
memoize
test
function memoize(fun) { // Making cache = {} an optional ES6 parameter breaks coverage. Why? /** @type {({ [key: string]: any })} */ const cache = {}; if (fun.length === 1) { return (/** @type {any} */ arg) => { if (arg in cache) { return cache[arg];
javascript
{ "resource": "" }
q64392
keyblade
test
function keyblade (obj, opts) { opts = Object.assign({ message: _defaultMessage, logBeforeThrow: true, ignore: [] }, opts) opts.ignore = (opts.ignore && Array.isArray(opts.ignore)) ? opts.ignore : [] return new Proxy(obj, { get (target, propKey, receiver) { const useGetter = Reflect.has(t...
javascript
{ "resource": "" }
q64393
subRegister
test
function subRegister(obj, name) { var res; res = isPrimitive(obj[name]) ? {} : obj[name]; return obj[name] =
javascript
{ "resource": "" }
q64394
registerDir
test
function registerDir(leaf, dir, name) { var files; try { files = fs.readdirSync(dir); } catch (_error) {} if (files == null) {
javascript
{ "resource": "" }
q64395
containerStatus
test
function containerStatus(original, status, parent) { var state = { topology: { containers: {} } }; var container = { id: original.id }; if (parent === null) { // nothing to do } else if (parent !== undefined) { container.containedBy = parent; } else { container.containedBy...
javascript
{ "resource": "" }
q64396
lstatFiles
test
async function lstatFiles(dirPath, dirContent) { const readFiles = dirContent.map(async (relativePath) => { const path = join(dirPath, relativePath) const ls = await makePromise(lstat, path) return {
javascript
{ "resource": "" }
q64397
readDirStructure
test
async function readDirStructure(dirPath) { if (!dirPath) { throw new Error('Please specify a path to the directory') } const ls = await makePromise(lstat, dirPath) if (!ls.isDirectory()) { const err = new Error('Path is not a directory') err.code = 'ENOTDIR' throw err } const dir = /** @type...
javascript
{ "resource": "" }
q64398
propertyNameToAttribute
test
function propertyNameToAttribute(name) { var result = name.replace(/([A-Z])/g, function (match, letter) { return
javascript
{ "resource": "" }
q64399
generateCommands
test
function generateCommands(origin, dest) { var destCmds = _.chain(dest.topology.containers) .values() .filter(function(container) { return container.containedBy === container.id || !container.containedBy; }) .map(function(container) { return { cmd: 'configure',
javascript
{ "resource": "" }