_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q64200 | parsePropertyChains | test | function parsePropertyChains(expr) {
var parsedExpr = '', chain;
// allow recursion (e.g. into function args) by resetting propertyRegex
// This is more efficient than creating a new regex for each chain, I assume
var prevCurrentIndex = currentIndex;
var prevLastIndex = propertyRegex.lastIndex;
currentInd... | javascript | {
"resource": ""
} |
q64201 | parseFunction | test | function parseFunction(link, index, expr) {
var call = getFunctionCall(expr);
// Always call functions in the scope of the object they're a member of
if (index === 0) {
link = addThisOrGlobal(link);
} else {
link = '_ref' + currentReference + link;
}
var calledLink = link + '(~~insideParens~~)';
... | javascript | {
"resource": ""
} |
q64202 | parseBrackets | test | function parseBrackets(link, index, expr) {
var call = getFunctionCall(expr);
var insideBrackets = call.slice(1, -1);
var evaledLink = parsePart(link, index);
index += 1;
link = '[~~insideBrackets~~]';
if (expr.charAt(propertyRegex.lastIndex) === '.') {
link = parsePart(link, index);
} else {
lin... | javascript | {
"resource": ""
} |
q64203 | addReferences | test | function addReferences(expr) {
if (referenceCount) {
var refs = [];
for (var i = 1; i <= referenceCount; i++) {
refs.push('_ref' + i);
}
expr = 'var ' + refs.join(', ') + ';\n' + expr;
}
return expr;
} | javascript | {
"resource": ""
} |
q64204 | test | function(fn) {
var pending
var hasNext
function next() {
setTimeout(function() {
if (pending === false) return
pending = false
if (hasNext) {
hasNext = false
fn(next)
}
}, 50) // call after gulp ending handler done
}
return function()... | javascript | {
"resource": ""
} | |
q64205 | assert | test | function assert (t, m) {
if (!t) {
var err = new AssertionError(m)
if (Error.captureStackTrace) Error.captureStackTrace(err, assert)
throw err
}
} | javascript | {
"resource": ""
} |
q64206 | bindArguments | test | function bindArguments(func) {
function binder() {
return func.apply(this, args.concat(slice.call(arguments)));
}
var args = slice.call(arguments, 1);
return binder;
} | javascript | {
"resource": ""
} |
q64207 | getExceptions | test | function getExceptions() {
const openers = [];
const closers = [];
if ( options.braceException ) {
openers.push('{');
closers.push('}');
}
if ( options.bracketException ) {
openers.push('[');
closers.push(']');
}
if ( options.parenException ) ... | javascript | {
"resource": ""
} |
q64208 | shouldOpenerHaveSpace | test | function shouldOpenerHaveSpace( left, right ) {
if ( sourceCode.isSpaceBetweenTokens( left, right ) ) {
return false;
}
if ( ALWAYS ) {
if ( astUtils.isClosingParenToken( right ) ) {
return false;
}
return !isOpenerException( right );
}
return isO... | javascript | {
"resource": ""
} |
q64209 | shouldCloserHaveSpace | test | function shouldCloserHaveSpace( left, right ) {
if ( astUtils.isOpeningParenToken( left ) ) {
return false;
}
if ( sourceCode.isSpaceBetweenTokens( left, right ) ) {
return false;
}
if ( ALWAYS ) {
return !isCloserException( left );
}
return isCloserEx... | javascript | {
"resource": ""
} |
q64210 | shouldOpenerRejectSpace | test | function shouldOpenerRejectSpace( left, right ) {
if ( right.type === 'Line' ) {
return false;
}
if ( !astUtils.isTokenOnSameLine( left, right ) ) {
return false;
}
if ( !sourceCode.isSpaceBetweenTokens( left, right ) ) {
return false;
}
if ( ALWAYS )... | javascript | {
"resource": ""
} |
q64211 | shouldCloserRejectSpace | test | function shouldCloserRejectSpace( left, right ) {
if ( astUtils.isOpeningParenToken( left ) ) {
return false;
}
if ( !astUtils.isTokenOnSameLine( left, right ) ) {
return false;
}
if ( !sourceCode.isSpaceBetweenTokens( left, right ) ) {
return false;
}
... | javascript | {
"resource": ""
} |
q64212 | defineConfigurable | test | function defineConfigurable ( obj, key, val ) {
Object.defineProperty(obj, key, {
configurable: true,
enumerable: false,
writable: true,
value: val
});
} | javascript | {
"resource": ""
} |
q64213 | ToInteger | test | function ToInteger ( argument ) {
var number = +argument;
if ( number !== number ) {
return 0;
}
if ( number === 0 || number === Infinity || number === -Infinity ) {
return number;
}
return ( number >= 0 ? 1 : -1 ) * Math.floor(Math.abs(number));
} | javascript | {
"resource": ""
} |
q64214 | ToLength | test | function ToLength ( argument ) {
var len = ToInteger(argument);
return len <= 0 ? 0 : Math.min(len, Math.pow(2, 53) - 1);
} | javascript | {
"resource": ""
} |
q64215 | CreateArrayIterator | test | function CreateArrayIterator ( array, kind ) {
var O = ToObject(array),
iterator = Object.create(ArrayIteratorPrototype);
defineInternal(iterator, '[[IteratedObject]]', O);
defineInternal(iterator, '[[ArrayIteratorNextIndex]]', 0);
defineInternal(iterator, '[[ArrayIteratorKind]]', kind);
retur... | javascript | {
"resource": ""
} |
q64216 | PromiseResolve | test | function PromiseResolve () {
return function F ( resolution ) {
var promise = F['[[Promise]]'], reactions;
if ( Type(promise) !== 'object' ) {
throw TypeError();
}
if ( promise['[[PromiseStatus]]'] !== 'unresolved' ) {
return undefined;
}
reactions = promise['[[Pr... | javascript | {
"resource": ""
} |
q64217 | GetCapabilitiesExecutor | test | function GetCapabilitiesExecutor () {
return function F ( resolve, reject ) {
var promiseCapability = F['[[Capability]]'];
if ( Type(promiseCapability['[[Resolve]]']) !== 'undefined' ) {
throw TypeError();
}
if ( Type(promiseCapability['[[Reject]]']) !== 'undefined' ) {
throw... | javascript | {
"resource": ""
} |
q64218 | PromiseResolutionHandlerFunction | test | function PromiseResolutionHandlerFunction () {
return function F ( x ) {
var promise = F['[[Promise]]'],
fulfillmentHandler = F['[[FulfillmentHandler]]'],
rejectionHandler = F['[[RejectionHandler]]'],
selfResolutionError, C, promiseCapability, updateResult;
if ( SameValue(x, prom... | javascript | {
"resource": ""
} |
q64219 | test | function(target, sequence, t) {//t==trigger (usually a 'click'ish event)
sequence = sequence.split(_.splitRE);
for (var i=0, e, props; i<sequence.length && (!e||!e.isSequenceStopped()); i++) {
props = _.parse(sequence[i]);
if (props) {
props.se... | javascript | {
"resource": ""
} | |
q64220 | test | function(e) {
var el = e.target, attr,
type = e.type,
key = type.indexOf('key') === 0 ? e.which || e.keyCode || '' : '',
special = _.special[type+key];
if (el && special) {
type = special(e, el, el.nodeName.toLowerCase());
... | javascript | {
"resource": ""
} | |
q64221 | reportNoEndingSpace | test | function reportNoEndingSpace( node, token, tokenBefore ) {
context.report({
node: node,
loc: token.loc.start,
message: 'There should be no space before \'' + token.value + '\'',
fix: function( fixer ) {
return fixer.removeRange([ tokenBefore.range[ 1 ], token.range[ 0 ] ]);
}
... | javascript | {
"resource": ""
} |
q64222 | reportRequiredBeginningSpace | test | function reportRequiredBeginningSpace( node, token ) {
context.report({
node: node,
loc: token.loc.start,
message: 'A space is required after \'' + token.value + '\'',
fix: function( fixer ) {
return fixer.insertTextAfter( token, ' ' );
}
});
} | javascript | {
"resource": ""
} |
q64223 | reportRequiredEndingSpace | test | function reportRequiredEndingSpace( node, token ) {
context.report({
node: node,
loc: token.loc.start,
message: 'A space is required before \'' + token.value + '\'',
fix: function( fixer ) {
return fixer.insertTextBefore( token, ' ' );
}
});
} | javascript | {
"resource": ""
} |
q64224 | generateDestinationLonLat | test | function generateDestinationLonLat ({
lat,
lon
}) {
const latOffset = (getDistance() / LAT_DEGREE) * getSign()
const lonOffset = (getDistance() / (LAT_DEGREE * Math.cos(lat))) * getSign()
return {
lat: lat + latOffset,
lon: lon + lonOffset
}
} | javascript | {
"resource": ""
} |
q64225 | test | function (keyParts, hash) {
for (var i = 0; i < keyParts.length-1; ++i) {
hash = getValue(keyParts[i], hash);
if (typeof(hash) === 'undefined') {
return undefined;
}
}
var lastKeyPartIndex = keyParts.length-1;
return getValue(keyParts[lastKeyPartIndex], hash)
} | javascript | {
"resource": ""
} | |
q64226 | gitAuthors | test | function gitAuthors (cb) {
return exec('git log --pretty="%an <%ae>"', function (er, stdout, stderr) {
if (er || stderr) throw new Error(er || stderr)
return cb(null, stdout.split('\n').reverse())
})
} | javascript | {
"resource": ""
} |
q64227 | lookupGithubLogin | test | function lookupGithubLogin (p, print, callback) {
var apiURI = 'https://api.github.com/search/users?q='
var options = { json: true, headers: { 'user-agent': pkg.name + '/' + pkg.version } }
if (process.env.OAUTH_TOKEN) {
options.headers['Authorization'] = 'token ' + process.env.OAUTH_TOKEN.trim()
}
functi... | javascript | {
"resource": ""
} |
q64228 | _unpackOutput | test | function _unpackOutput(message) {
if (message.charAt(0) != keyczar_util.VERSION_BYTE) {
throw new Error('Unsupported version byte: ' + message.charCodeAt(0));
}
var keyhash = message.substr(1, keyczar_util.KEYHASH_LENGTH);
message = message.substr(1 + keyczar_util.KEYHASH_LENGTH);
return {k... | javascript | {
"resource": ""
} |
q64229 | _rsaHash | test | function _rsaHash(publicKey) {
var md = forge.md.sha1.create();
// hash:
// 4-byte big endian length
// "magnitude" of the public modulus (trim all leading zero bytes)
// same for the exponent
_hashBigNumber(md, publicKey.n);
_hashBigNumber(md, publicKey.e);
var digest = md.digest();
... | javascript | {
"resource": ""
} |
q64230 | _makeRsaKey | test | function _makeRsaKey(rsaKey) {
var key = {
keyhash: _rsaHash(rsaKey),
size: rsaKey.n.bitLength()
};
key.encrypt = function(plaintext) {
// needed to make this work with private keys
var tempKey = forge.pki.setRsaPublicKey(rsaKey.n, rsaKey.e);
var ciphertext = tempKey... | javascript | {
"resource": ""
} |
q64231 | test | function() {
if (!result) {
var exec = grunt.config.get('exec');
for (var key in exec) {
exec[key].cmd = nvmUse + ' && ' + exec[key].cmd;
}
grunt.config.set('exec', exec);
}
} | javascript | {
"resource": ""
} | |
q64232 | test | function(callback) {
var command = '. ' + nvmPath;
childProcess.exec(command, cmdOpts, function(err, stdout, stderr) {
if (stderr.indexOf('No such file or directory') !== -1) {
if (nvmPath === home + '/.nvm/nvm.sh') {
nvmPath = home + '/nvm/nvm.sh';
nvmInit = '. ' ... | javascript | {
"resource": ""
} | |
q64233 | test | function(thisPackage, callback) {
var command = nvmUse + ' && npm install -g ' + thisPackage;
childProcess.exec(command, cmdOpts,function(err, stdout, stderr) {
if (err) { throw err ;}
grunt.verbose.writeln(stdout);
grunt.log.oklns('Installed ' + thisPackage);
callback();
... | javascript | {
"resource": ""
} | |
q64234 | test | function() {
prompt.start();
var prop = {
name: 'yesno',
message: 'You do not have any node versions installed that satisfy this project\'s requirements ('.white + expected.yellow + '). Would you like to install the latest compatible version? (y/n)'.white,
validator: /y[es]*|n[o]?/,... | javascript | {
"resource": ""
} | |
q64235 | test | function() {
nvmLs('remote', function() {
bestMatch = semver.maxSatisfying(remotes, expected);
nvmUse = nvmInit + 'nvm use ' + bestMatch;
var command = nvmInit + 'nvm install ' + bestMatch;
childProcess.exec(command, cmdOpts,function(err, stdout, stderr) {
if (err) { t... | javascript | {
"resource": ""
} | |
q64236 | test | function(loc, callback) {
var command = nvmInit + 'nvm ls';
if (loc === 'remote') {
command += '-remote';
}
childProcess.exec(command, cmdOpts, function(err, stdout, stderr) {
var data = stripColorCodes(stdout.toString()).replace(/\s+/g, '|'),
available = data.split... | javascript | {
"resource": ""
} | |
q64237 | test | function() {
// Make sure a node version is intalled that satisfies
// the projects required engine. If not, prompt to install.
nvmLs('local', function() {
var matches = semver.maxSatisfying(locals, expected);
if (matches) {
bestMatch = matches;
nvmUse = nvmInit + ... | javascript | {
"resource": ""
} | |
q64238 | EachSubject | test | function EachSubject(subject, elements, elementName, opt_noIndex) {
ProxyBase.call(this);
this.elementSubjects = [];
for (var i = 0; i < elements.length; ++i) {
var es = subjectFactory.newSubject(subject.failureStrategy, elements[i]);
es.named(elementName + (opt_noIndex ? '' : (' ' + i)) + ' of ' + subjec... | javascript | {
"resource": ""
} |
q64239 | EventualSubject | test | function EventualSubject(subject, promise) {
DeferredSubject.call(this);
this.subject = subject;
var self = this;
this.promise = promise.then(
function(value) {
// Play back the recorded calls on a new subject which is created based on the resolved
// value of the promise.
var valueSubject... | javascript | {
"resource": ""
} |
q64240 | PromiseSubject | test | function PromiseSubject(failureStrategy, value) {
Subject.call(this, failureStrategy, value);
// Make this object a thenable
this.then = this.value.then.bind(this.value);
this.catch = this.value.catch.bind(this.value);
} | javascript | {
"resource": ""
} |
q64241 | doGet | test | function doGet(store, key, options = {}) {
// Resolve back to original key if referenced
key = store._resolveRefKey(key);
const { referenceDepth = 1 } = options;
const cacheKey = `${key}:${referenceDepth}`;
const shouldCache = !store._isWritable;
if (shouldCache) {
if (store._getCache[cacheKey]) {
... | javascript | {
"resource": ""
} |
q64242 | resolveReferences | test | function resolveReferences(store, value, depth) {
if (--depth < 0) {
return value;
}
if (Array.isArray(value)) {
const n = value.length;
const v = new Array(n);
let item;
for (let i = n - 1; i >= 0; i--) {
item = value[i];
v[i] = resolveReferences(
store,
store._i... | javascript | {
"resource": ""
} |
q64243 | formatString | test | function formatString(value, options) {
var opts = options || {};
var result = value.replace(/[\0-\37]/g, function (ch) {
switch (ch) {
case '\n': return '\\n';
case '\r': return '\\r';
case '\t': return '\\t';
case '\b': return '\\b';
case '\v': return '\\v';
case '\f': retu... | javascript | {
"resource": ""
} |
q64244 | formatObject | test | function formatObject(value, options) {
if (value === undefined) {
return 'undefined';
}
if (value === null) {
return 'null';
}
if (typeof(value) == 'object') {
if (value instanceof RegExp || value instanceof Date) {
return value + '';
}
var opts = options || {};
var innerOpts ... | javascript | {
"resource": ""
} |
q64245 | _exportPublicKey | test | function _exportPublicKey(key) {
var t = key.metadata.type;
var p = key.metadata.purpose;
if (!(t == keyczar.TYPE_RSA_PRIVATE && (p == keyczar.PURPOSE_DECRYPT_ENCRYPT || p == keyczar.PURPOSE_SIGN_VERIFY))) {
throw new Error('Unsupported key type/purpose:' + t + '/' + p);
}
var publicPurpose... | javascript | {
"resource": ""
} |
q64246 | _getPrimaryVersion | test | function _getPrimaryVersion(metadata) {
var primaryVersion = null;
for (var i = 0; i < metadata.versions.length; i++) {
if (metadata.versions[i].status == STATUS_PRIMARY) {
if (primaryVersion !== null) {
throw new Error('Invalid key: multiple primary keys');
}
... | javascript | {
"resource": ""
} |
q64247 | formatMap | test | function formatMap(value, options) {
return 'Map(' + registry.format(Array.from(value.entries()), options) + ')';
} | javascript | {
"resource": ""
} |
q64248 | load | test | function load(store, key, url, options) {
const { cacheControl, rejectOnError, retry, timeout } = options;
options.id = key;
store.debug('load %s from %s', key, url);
return agent
.get(url, options)
.timeout(timeout)
.retry(retry)
.then(res => {
// Abort if already destroyed
if (s... | javascript | {
"resource": ""
} |
q64249 | mergeCacheControl | test | function mergeCacheControl(cacheControl, defaultCacheControl) {
if (cacheControl == null) {
return Object.assign({}, defaultCacheControl);
}
return {
maxAge: 'maxAge' in cacheControl ? cacheControl.maxAge : defaultCacheControl.maxAge,
staleIfError: 'staleIfError' in cacheControl ? cacheControl.staleI... | javascript | {
"resource": ""
} |
q64250 | generateExpiry | test | function generateExpiry(headers = {}, defaultCacheControl) {
const cacheControl = mergeCacheControl(parseCacheControl(headers['cache-control']), defaultCacheControl);
const now = Date.now();
let expires = now;
if (headers.expires) {
expires = typeof headers.expires === 'string' ? Number(new Date(headers.e... | javascript | {
"resource": ""
} |
q64251 | generateResponseHeaders | test | function generateResponseHeaders(expiry = {}, defaultCacheControl, isError) {
const now = Date.now();
let maxAge;
if (isError) {
maxAge =
expiry && expiry.expiresIfError > now && expiry.expiresIfError - now < defaultCacheControl.maxAge
? Math.ceil((expiry.expiresIfError - now) / 1000)
:... | javascript | {
"resource": ""
} |
q64252 | hasExpired | test | function hasExpired(expiry, isError) {
if (!expiry) {
return true;
}
// Round up to nearest second
return Math.ceil(Date.now() / 1000) * 1000 > (isError ? expiry.expiresIfError : expiry.expires);
} | javascript | {
"resource": ""
} |
q64253 | formatSet | test | function formatSet(value, options) {
return 'Set(' + registry.format(Array.from(value.values()), options) + ')';
} | javascript | {
"resource": ""
} |
q64254 | formatArray | test | function formatArray(value, options) {
var opts = options || {};
var innerOpts = Object.assign({}, opts, { clip: false });
var parts = ['['];
var length = 2; // Include both open and close bracket.
for (var i = 0; i < value.length; ++i) {
var sep = i > 0 ? ', ' : '';
var s = registry.format(value[i], ... | javascript | {
"resource": ""
} |
q64255 | reset | test | function reset(store, data) {
store.debug('reset');
store._data = data;
store.changed = true;
} | javascript | {
"resource": ""
} |
q64256 | serialise | test | function serialise(key, data, config) {
if (isPlainObject(data)) {
const obj = {};
for (const prop in data) {
const keyChain = key ? `${key}/${prop}` : prop;
const value = data[prop];
if (config[keyChain] !== false) {
if (isPlainObject(value)) {
obj[prop] = serialise(keyC... | javascript | {
"resource": ""
} |
q64257 | explode | test | function explode(store, data) {
if (isPlainObject(data)) {
const obj = {};
for (const prop in data) {
obj[prop] = explode(store, data[prop]);
}
return obj;
} else if (Array.isArray(data)) {
return data.map(value => explode(store, value));
} else if (store._isRefValue(data)) {
return... | javascript | {
"resource": ""
} |
q64258 | Subject | test | function Subject(failureStrategy, value) {
this.failureStrategy = failureStrategy;
this.value = value;
this.name = null;
this.format = format;
this.failureMessage = null;
} | javascript | {
"resource": ""
} |
q64259 | test | function(json){
// Protect against forgetting the new keyword when calling the constructor
if(!(this instanceof User)){
return new User(json);
}
// If the given object is already an instance then just return it. DON'T copy it.
if(User.isInstance(json)){
return json;
}
... | javascript | {
"resource": ""
} | |
q64260 | test | function () {
for (var fls in configs) {
dirName = utils.folderName(configs[fls]['input'], configs[fls]['folderName']);
dirType = configs[fls]['type'];
destFolderDir = path.join(configs[fls]['destinationSourcePath'], dirName);
destDir = configs[fls]['destinationSo... | javascript | {
"resource": ""
} | |
q64261 | test | function (fls) {
if (fs.existsSync(destFolderDir)) {
console.log(':::~~' + dirName + ' exists, please pick another name or delete previous to create new~~:::')
deferred.reject(fls.type + ' exists, please pick another name.');
} else {
console.log(':::~~' + dirName + '... | javascript | {
"resource": ""
} | |
q64262 | test | function () {
fse.emptyDirSync(tmpDir);
fse.copySync(refSrcDir, tmpDir, { overwrite: true }, err => {
if (err) {
console.log(':::~~error in copying to temp directory:' + err + '~~:::');
fse.removeSync(destFolderDir);
fse.emptyDirSync(tmpDir);
... | javascript | {
"resource": ""
} | |
q64263 | test | function (oldPath, fls) {
console.log(":::~~processing your temp folder and file~~:::"+oldPath);
var parsedPath = updateFileNamePath(path.parse(oldPath), fls);
var newPath = path.format(parsedPath);
var firstFolderName = utils.getFirstFolderName(oldPath, tempFolderName);
fs.renam... | javascript | {
"resource": ""
} | |
q64264 | test | function (parsedPath, fls) {
// parsedPath.dir, parsedPath.base, parsedPath.ext, parsedPath.name
var newName = "";
var fileConfigs = "";
var folderDirArray = getNestedFolderName(parsedPath);
parsedPath['folderName'] = utils.getBaseFolderName(parsedPath.dir) != tempFolderName ? ut... | javascript | {
"resource": ""
} | |
q64265 | test | function (parsedPath) {
var tempPathArray = tmpDir.split("\\");
var parsedPathArray = parsedPath.dir.split("\\");
if (parseInt(tempPathArray.length) === parseInt(parsedPathArray.length)) {
return "base";
} else if (parseInt(tempPathArray.length) < parseInt(parsedPathArray.len... | javascript | {
"resource": ""
} | |
q64266 | test | function (oldContent, replaceConfig, fls) {
var newContent = oldContent.replace(contentReplaceRegx, function (e) {
for (var cont in replaceConfig) {
var contRegex = new RegExp(cont, 'g');
if (e.match(contRegex)) {
var replaceValue = utils.getReplac... | javascript | {
"resource": ""
} | |
q64267 | test | function () {
fse.emptyDirSync(destFolderDir);
fse.copySync(tmpDir, destFolderDir, { overwrite: true }, err => {
if (err) {
console.log(':::~~error in copying to destination directory:' + err + '~~:::');
fse.removeSync(destFolderDir);
fse.empty... | javascript | {
"resource": ""
} | |
q64268 | scan | test | function scan(text) {
let sr = SReader.create(text);
let tokens = [];
while (!sr.isDone()) {
tokens.push(readNext(sr));
}
return tokens;
} | javascript | {
"resource": ""
} |
q64269 | KeystoneClient | test | function KeystoneClient(url, options) {
options = options || {};
if (options.username) {
if (!options.password && !options.apiKey) {
throw new Error('If username is provided you also need to provide password or apiKey');
}
}
this._url = url;
this._username = options.username;
this._apiKey = ... | javascript | {
"resource": ""
} |
q64270 | findAllParents | test | function findAllParents( p ) {
var lastParent = p[ 0 ];
var lastParentsParent = parents[ lastParent ];
if ( lastParentsParent === undefined ) {
return p;
} else {
p.unshift( lastParentsParent );
return findAllParents( p );
}
} | javascript | {
"resource": ""
} |
q64271 | findDirectChildren | test | function findDirectChildren( className ) {
var children = [];
for ( var longname in parents ) {
if ( parents[ longname ] === className ) {
children.push( longname );
}
}
return children;
} | javascript | {
"resource": ""
} |
q64272 | makeHierarchyList | test | function makeHierarchyList( classes ) {
if ( classes.length === 0 ) {
return '';
} else {
var className = classes.shift();
return '<ul><li>' + linkTo( className ) + ' ' + makeHierarchyList( classes ) + '</li></ul>'
}
} | javascript | {
"resource": ""
} |
q64273 | makeChildrenList | test | function makeChildrenList( classes ) {
var list = '<ul>';
classes.forEach( function ( className ) {
list += '<li>' + linkTo( className ) + '</li>';
})
list += '</ul>';
return list;
} | javascript | {
"resource": ""
} |
q64274 | test | function ( e ) {
var doclet = e.doclet;
if (
doclet.kind === 'class' &&
doclet.augments !== undefined &&
doclet.augments.length > 0
) {
parents[ doclet.longname ] = doclet.augments[ 0 ];
}
} | javascript | {
"resource": ""
} | |
q64275 | test | function(json){
// Protect against forgetting the new keyword when calling the constructor
if(!(this instanceof Tag)){
return new Tag(json);
}
// If the given object is already an instance then just return it. DON'T copy it.
if(Tag.isInstance(json)){
return json;
}
... | javascript | {
"resource": ""
} | |
q64276 | gotOption | test | function gotOption (option) {
if (map[option]) {
option = map[option]
var name = option[0]
// Assume a boolean, and set to true because the argument is present.
var value = true
// If it takes arguments, override with a value.
var count = option[2]
while (count--) {
... | javascript | {
"resource": ""
} |
q64277 | test | function(json){
// Protect against forgetting the new keyword when calling the constructor
if(!(this instanceof Error)){
return new Error(json);
}
// If the given object is already an instance then just return it. DON'T copy it.
if(Error.isInstance(json)){
return json;
}
... | javascript | {
"resource": ""
} | |
q64278 | test | function(json){
// Protect against forgetting the new keyword when calling the constructor
if(!(this instanceof ChildAndParentsRelationship)){
return new ChildAndParentsRelationship(json);
}
// If the given object is already an instance then just return it. DON'T copy it.
if(ChildAnd... | javascript | {
"resource": ""
} | |
q64279 | test | function(json){
// Protect against forgetting the new keyword when calling the constructor
if(!(this instanceof ArtifactMetadata)){
return new ArtifactMetadata(json);
}
// If the given object is already an instance then just return it. DON'T copy it.
if(ArtifactMetadata.isInstance(js... | javascript | {
"resource": ""
} | |
q64280 | test | function(json){
// Protect against forgetting the new keyword when calling the constructor
if(!(this instanceof FeatureSet)){
return new FeatureSet(json);
}
// If the given object is already an instance then just return it. DON'T copy it.
if(FeatureSet.isInstance(json)){
return... | javascript | {
"resource": ""
} | |
q64281 | test | function (key) {
var tmp = window.document.cookie.match((new RegExp(key + '=[^;]+($|;)', 'gi')));
if (!tmp || !tmp[0]) {
return null;
} else {
return window.unescape(tmp[0].substring(key.length + 1, tmp[0].length).replace(';', '')) || null;
}
} | javascript | {
"resource": ""
} | |
q64282 | test | function(name, func, pluginName) {
if(pluginName !== undefined) {
currentPluginName = pluginName;
}
var eventCurrentPluginName = currentPluginName,
// Create an event we can bind and register
myEventFunc = function() {
var pubsubCore = pubsub.getCore();
currentPluginName =... | javascript | {
"resource": ""
} | |
q64283 | test | function(json){
// Protect against forgetting the new keyword when calling the constructor
if(!(this instanceof ChangeInfo)){
return new ChangeInfo(json);
}
// If the given object is already an instance then just return it. DON'T copy it.
if(ChangeInfo.isInstance(json)){
return... | javascript | {
"resource": ""
} | |
q64284 | test | function(repo) {
return p.spawn('git', ['remote', 'show', program.remote], CHILD_IGNORE).then(function() {
/* OK, github already exists. */
}, function(e) {
/* Doesn't exist, create it! */
return p.spawn('git', ['remote','add',program.remote,'git@github.com:' + repo]);
});
} | javascript | {
"resource": ""
} | |
q64285 | test | function(repo, branchname) {
return ensureRemote(repo).then(function() {
return p.spawn('git', ['push', program.remote, 'HEAD:refs/heads/' + branchname], CHILD_IGNORE);
});
} | javascript | {
"resource": ""
} | |
q64286 | runSync | test | function runSync () {
for (runIndex = 0; runIndex < sampleSize; runIndex++) {
fn.call(child)
}
setTimeout(finishChild, 0)
} | javascript | {
"resource": ""
} |
q64287 | runAsync | test | function runAsync () {
if (runIndex++ < sampleSize) {
fn.call(child, function () {
setTimeout(runAsync, 0)
})
} else {
setTimeout(finishChild, 0)
}
} | javascript | {
"resource": ""
} |
q64288 | test | function(json){
// Protect against forgetting the new keyword when calling the constructor
if(!(this instanceof Comment)){
return new Comment(json);
}
// If the given object is already an instance then just return it. DON'T copy it.
if(Comment.isInstance(json)){
return json;
... | javascript | {
"resource": ""
} | |
q64289 | watch | test | function watch (dir) {
if (!ignoreDir.test(dir) && !map[dir]) {
fs.lstat(dir, function (e, stat) {
if (!e) {
if (stat.isSymbolicLink()) {
var source = dir
fs.readlink(source, function (e, link) {
if (!e) {
var dest = link
if (dest[0] !== '/... | javascript | {
"resource": ""
} |
q64290 | addDir | test | function addDir (dir, stat) {
var mtime = stat.mtime.getTime()
if (!map[dir] && list.length <= maxListSize) {
map[dir] = mtime
list.push(dir)
clearTimeout(sortList.timer)
sortList.timer = setTimeout(sortList, checkInterval)
fs.readdir(dir, function (e, files) {
if (!e) {
files.forE... | javascript | {
"resource": ""
} |
q64291 | startWatches | test | function startWatches () {
list.forEach(function (dir, i) {
if (i < maxFsWatches) {
try {
fs.watch(dir, function (op, file) {
notify(dir + '/' + file)
})
} catch (e) {
// fs.watch is known to be unstable.
}
}
})
} | javascript | {
"resource": ""
} |
q64292 | checkDir | test | function checkDir () {
var n = indexes[i]
if (i > 44) {
indexes[i] = (indexes[i] + 5) % list.length
}
i = (i + 1) % indexes.length
var dir = list[n]
if (dir) {
fs.stat(dir, function (e, stat) {
if (!e && (stat.mtime > okToNotifyAfter)) {
fs.readdir(dir, function (e, files) {
... | javascript | {
"resource": ""
} |
q64293 | notify | test | function notify (path) {
var now = Date.now()
if ((now > okToNotifyAfter) && !ignoreFile.test(path)) {
process.send(path)
okToNotifyAfter = now + notifyInterval
sortList()
}
} | javascript | {
"resource": ""
} |
q64294 | decorateFn | test | function decorateFn (fn) {
fn.returns = function (value) {
fn._returns = value
return fn
}
return fn
} | javascript | {
"resource": ""
} |
q64295 | MockDate | test | function MockDate (value) {
// A MockDate constructs an inner date and exposes its methods.
var innerDate
// If a value is specified, use it to construct a real date.
if (arguments.length) {
innerDate = new timers.Date(value)
// If time isn't currently mocked, construct a real date for the real time.
}... | javascript | {
"resource": ""
} |
q64296 | moveTime | test | function moveTime () {
if (mock.time._SPEED) {
// Remember what the real time was before updating.
mock.time._PREVIOUS_TIME = realNow()
// Set time to be incremented.
setTimeout(function () {
var now = realNow()
var elapsed = now - mock.time._PREVIOUS_TIME
if (elapsed) {
var ... | javascript | {
"resource": ""
} |
q64297 | getScheduler | test | function getScheduler (isInterval) {
return function (fn, time) {
schedules.push({
id: ++schedules.id,
fn: fn,
time: Date.now() + time,
interval: isInterval ? time : false
})
}
} | javascript | {
"resource": ""
} |
q64298 | getUnscheduler | test | function getUnscheduler () {
// TODO: Create a map of IDs if the schedules array gets large.
return function (id) {
for (var i = 0, l = schedules.length; i < l; i++) {
var schedule = schedules[i]
if (schedule.id === id) {
schedules.splice(i, 1)
break
}
}
}
} | javascript | {
"resource": ""
} |
q64299 | runSchedules | test | function runSchedules () {
// Sort by descending time order.
schedules.sort(function (a, b) {
return b.time - a.time
})
// Track the soonest interval run time, in case we're already there.
var minNewTime = Number.MAX_VALUE
// Iterate, from the end until we reach the current mock time.
var i = schedule... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.