_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q40900 | refreshProxyAccessToken | train | function refreshProxyAccessToken() {
settings.AZTokenProvider().then(function(token) {
proxyAccessToken = token;
logger.log('Refreshed proxy access token: ' + proxyAccessToken);
}, function(err) {
logger.log(err);
emitter.emit('error', 'Unable to refresh a... | javascript | {
"resource": ""
} |
q40901 | train | function (path, pathname, hash, uuid) {
this.actionQueue.push(this.webdriverClient.screenshot.bind(this.webdriverClient));
this.actionQueue.push(this._screenshotCb.bind(this, path, pathname, hash, uuid));
return this;
} | javascript | {
"resource": ""
} | |
q40902 | train | function (path, pathname, hash, uuid, result) {
var deferred = Q.defer();
// replace base64 metadata
var base64Data = JSON.parse(result).value.replace(/^data:image\/png;base64,/,'');
// replace placeholders
var realpath = this._replacePathPlaceholder(path + pathname);
// check if we need to add ... | javascript | {
"resource": ""
} | |
q40903 | train | function (pathname) {
pathname = pathname.replace(':browser', this.browserName);
pathname = pathname.replace(':version', this._parseBrowserVersion(this.sessionStatus.version));
pathname = pathname.replace(':timestamp', Math.round(new Date().getTime() / 1000));
pathname = pathname.replace(':osVersion', t... | javascript | {
"resource": ""
} | |
q40904 | train | function (version) {
var vs = version.replace(/[^0-9\\.]/g, '');
vs = vs.replace(/\./g, '_');
return vs;
} | javascript | {
"resource": ""
} | |
q40905 | train | function () {
var date = new Date();
var dateStr = '';
var day = date.getDate();
var month = date.getMonth();
month = (month+'').length === 1 ? '0' + month : month;
day = (day+'').length === 1 ? '0' + day : day;
dateStr += month + '_';
dateStr += day + '_';
dateStr += date.getFullY... | javascript | {
"resource": ""
} | |
q40906 | train | function () {
var date = new Date();
var dateStr = this._parseDate();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
hours = (hours+'').length === 1 ? '0' + hours : hours;
minutes = (minutes+'').length === 1 ? '0' + minutes : minutes;
seco... | javascript | {
"resource": ""
} | |
q40907 | setDataRegistry | train | function setDataRegistry(data) {
assertType(data, 'object', false, 'Invalid data specified');
if (!window.__private__) window.__private__ = {};
window.__private__.dataRegistry = data;
} | javascript | {
"resource": ""
} |
q40908 | writeFile | train | function writeFile(config, isJson, callback) {
try {
fs.writeFile('./.nplintrc', isJson ? JSON.stringify(config, null, 4) : yaml.safeDump(config), callback);
} catch (e) {
return callback(e);
}
} | javascript | {
"resource": ""
} |
q40909 | train | function(moduleIds) {
for (var i = moduleIds.length; i--;) {
var moduleId = moduleIds[i],
module = getModule(moduleId);
if (module == null) {
module = _modules[moduleId] = {};
_fetchFunc(moduleId);
}
}
} | javascript | {
"resource": ""
} | |
q40910 | train | function() {
var i = 0;
while (i<_callbacks.length) {
var deps = _callbacks[i][0],
func = _callbacks[i][1],
n = 0;
while (n<deps.length) {
if (areDeepDepsDefined(deps[n])) {
deps.splice(n, 1);
}
else {
n++;
}
}
if (!deps.length) {
_callbacks.splice(i, 1);
if (fu... | javascript | {
"resource": ""
} | |
q40911 | train | function(moduleId) {
var scriptEl = document.createElement('script');
scriptEl.type = 'text/javascript';
scriptEl.src = resolveModuleUri(moduleId);
var useStandard = !!scriptEl.addEventListener,
timeoutHandle;
var errorFunc = function() {
postLoadFunc(false);
};
var loadFunc = function() {
if ... | javascript | {
"resource": ""
} | |
q40912 | copyAndOffsetMapping | train | function copyAndOffsetMapping(existingMapping) {
var column = getColumnAfter(existingMapping.generatedLine - 1, existingMapping.generatedColumn);
var newMapping = {
generated: {
line : existingMapping.generatedLine,
column: column
}
};
if (existingMapping.source) {
... | javascript | {
"resource": ""
} |
q40913 | mentionsPredicate | train | function mentionsPredicate(str) {
// null/empty check
if (!str) {
return false;
// has @ symbol
} else if (str.indexOf('@') < 0) {
return false;
// has @ symbol as first char
} else if (str[0] !== '@') {
return false;
// contains non-word chars
} else if ((/[^\w\s]/).test(str.slice(1))) {
... | javascript | {
"resource": ""
} |
q40914 | execute | train | function execute(req, res) {
// must coerce channel to string
var len = this.state.pubsub.publish(
req.conn, '' + req.args[0], req.args[1]);
res.send(null, len);
} | javascript | {
"resource": ""
} |
q40915 | _reverseAndPrecompute | train | function _reverseAndPrecompute () {
STATE_NAME_STRICT = Object.keys(US_STATE_NAME_TO_CODE);
var territoryKeys = Object.keys(US_INHABITED_TERRITORIES_NAME_TO_CODE);
(STATE_NAME_STRICT || []).forEach(function(stateName) {
US_STATE_CODE_TO_NAME[US_STATE_NAME_TO_CODE[stateName]] = stateName;
U... | javascript | {
"resource": ""
} |
q40916 | isUSAState | train | function isUSAState (state, strict) {
state = state && NODE_RATIFY.isString(state) ? _toTitleCase(state) : null;
var topLevel = (US_STATE_CODE_TO_NAME[state] || US_STATE_NAME_TO_CODE[state]);
if(strict) {
return topLevel ? true : false;
} else {
return (US_INHABITED_TERRITORIES_CODE_TO_... | javascript | {
"resource": ""
} |
q40917 | getStateName | train | function getStateName(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_CODE_TO_NAME[searchKey] || US_CAPITAL_TO_STATE_NAME[searchKey]);
if(strict) {
return topLevel;
} else {
return (US_INHABITED_TER... | javascript | {
"resource": ""
} |
q40918 | getUSPSCode | train | function getUSPSCode(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_NAME_TO_CODE[searchKey] || US_STATE_NAME_TO_CODE[US_CAPITAL_TO_STATE_NAME[searchKey]]);
if(strict) {
return topLevel;
} else {
se... | javascript | {
"resource": ""
} |
q40919 | getStateCapital | train | function getStateCapital(searchKey, strict) {
searchKey = searchKey && NODE_RATIFY.isString(searchKey) ? _toTitleCase(searchKey) : null;
var topLevel = (US_STATE_NAME_TO_CAPITAL[searchKey] || US_STATE_NAME_TO_CAPITAL[US_STATE_CODE_TO_NAME[searchKey]]);
if(strict) {
return topLevel;
} else {
... | javascript | {
"resource": ""
} |
q40920 | log | train | function log() {
var args = NS ? [chalk.bold.gray(NS)] : []
for(var i=0; i<arguments.length; i++) {
var arg = arguments[i];
args.push(chalk.cyan( typeof arg === "object" ? JSON.stringify(arg) : arg ))
// adds a separator
if(i < arguments.length-1) args.push(chalk.gray("|"));
}
if(testLog) tes... | javascript | {
"resource": ""
} |
q40921 | logArr | train | function logArr(arr) {
if(arguments.length > 1) {
if(!suppressWarnings) console.warn("'logArr' only supports 1 parameter. Converting to regular 'log'.");
log(Array.prototype.slice.call(arguments));
return;
}
if(! _.isArray(arr)) {
if(!suppressWarnings) console.warn("'logArr' used, but first argu... | javascript | {
"resource": ""
} |
q40922 | warn | train | function warn() {
if(suppressWarnings) return
var args = NS ? [chalk.bold.gray(NS)] : []
for(var i=0; i<arguments.length; i++) {
var arg = arguments[i];
args.push(chalk.bold.yellow.bgRed( typeof arg === "object" ? JSON.stringify(arg) : arg ))
// adds a separator
if(i < arguments.length-1) a... | javascript | {
"resource": ""
} |
q40923 | configure | train | function configure(alg, pswd, sto) {
algorithm = alg;
password = pswd;
sessionTimeout = sto;
} | javascript | {
"resource": ""
} |
q40924 | pluginFactory | train | function pluginFactory(cache) {
// ensure cache
var internalCache = cache || {};
// create an instance of cache populater
var getCache = cacheFactory(internalCache);
// return a closure with a pluginFactory() sidecar
browserifyIncremental.pluginFactory = pluginFactory;
return browserifyIncremental;
... | javascript | {
"resource": ""
} |
q40925 | setupPipeline | train | function setupPipeline() {
var deps = bundler.pipeline.get('deps');
deps.push(getCache(deps._streams[0].cache));
} | javascript | {
"resource": ""
} |
q40926 | cacheFactory | train | function cacheFactory(internalCache) {
// comparison cache will be use by getters
// since getters are persistent on the internal cache then the comparison cache also needs to be persistent
var isTestedCache = {};
/**
* Get a pipeline 'deps' stage that populates cache for incremental compile.
* Called ... | javascript | {
"resource": ""
} |
q40927 | defineGetterFor | train | function defineGetterFor(depsCache, filename) {
// instead of making the property re-definable we instead make assignment idempotent
if (!depsCache.hasOwnProperty(filename)) {
Object.defineProperty(depsCache, filename, {get: getter});
}
// create a getter
// we need to use a getter as it is... | javascript | {
"resource": ""
} |
q40928 | getter | train | function getter() {
// not found
var cached = internalCache[filename];
if (!cached) {
return undefined;
}
// we have already tested whether the cached value is valid and deleted it if not
else if (isTestedCache[filename]) {
return cached.output;
}
// test... | javascript | {
"resource": ""
} |
q40929 | getModuleConfig | train | function getModuleConfig(nameOrPath,modules) {
for (var i = 0; i < modules.length; i++) {
var config = modules[i];
if (config.options && (config.options.directory === nameOrPath || config.name === nameOrPath)) {
return config;
}
}
return null;
} | javascript | {
"resource": ""
} |
q40930 | getModules | train | function getModules(argv,modules){
if(argv.module){
var which = getModuleConfig(argv.module,modules);
if(which){
return [which];
}else{
return [];
}
}
return modules;
} | javascript | {
"resource": ""
} |
q40931 | removeNotNeededNodes | train | function removeNotNeededNodes(parentElements, newChildren, oldChildren) {
let remaining = parentElements.childNodes.length;
if (oldChildren.length !== remaining) {
console.warn(
"ZLIQ: Something other then ZLIQ has manipulated the children of the element",
parentElements,
". This can lead to s... | javascript | {
"resource": ""
} |
q40932 | shouldRecycleElement | train | function shouldRecycleElement(oldElement, props, tag) {
return (
!isTextNode(oldElement) &&
oldElement.id === "" &&
!nodeTypeDiffers(oldElement, tag)
);
} | javascript | {
"resource": ""
} |
q40933 | getProvider | train | function getProvider(providerName, providerConfig) {
return _.extend({}, providerConfig.opts, {
profile: function profile(credentials, params, get, callback) {
var proof = null;
/* eslint camelcase:0 */
if (providerConfig.useProof) {
... | javascript | {
"resource": ""
} |
q40934 | init | train | function init(ctx) {
var server = ctx.server;
var deferred = Q.defer();
server.register({register: require('bell')}, function (err) {
if (err) {
deferred.reject(err);
return;
}
_.each(config.security.social, function (provide... | javascript | {
"resource": ""
} |
q40935 | findLanguageNameFromCode | train | function findLanguageNameFromCode( languageCode ) {
var a = 0;
var b = LANGUAGES.length;
var m = b;
var item, code, name;
languageCode = languageCode.toLowerCase();
while( b - a > 1 ) {
m = Math.floor( (a + b) / 2 );
item = LANGUAGES[m];
code = item[0];
name = item[1];
if( code == lang... | javascript | {
"resource": ""
} |
q40936 | train | function (db, query, callback) {
// query parameter is optional
if (!callback) {
callback = query
query = {}
}
// create a new request object
var req = {
// db name
db: db,
// authenticated url to db
db_url: url.resolve(couch_url, encodeURIComponent(db)),
/... | javascript | {
"resource": ""
} | |
q40937 | registerHandler | train | function registerHandler(routeItem, headler) {
let method = routeItem.method.toLowerCase();
debug(
'Binding "%s" to path "%s" with method "%s"',
routeItem.handler, routeItem.path, method.toUpperCase()
);
headler.actionHandler = true;
components.app[method](routeItem.path, headler);
} | javascript | {
"resource": ""
} |
q40938 | routeSolver | train | function routeSolver(routeItem, handler, resolver) {
switch (typeof handler) {
case 'function':
// solve as function handler
registerHandler(routeItem, null, routeItem.handler);
break;
case 'string':
// solve as controller - action handler
resolver(routeItem, handler)... | javascript | {
"resource": ""
} |
q40939 | transpile | train | function transpile( sourceCode, sourceName, minify ) {
try {
const
sourceFileName = Path.basename( sourceName ),
ast = parseToAST( sourceCode ),
transfo = Babel.transformSync( sourceCode, buildOptions( sourceFileName, minify ) ),
// transfo = Babel.transformFr... | javascript | {
"resource": ""
} |
q40940 | UnorderedList | train | function UnorderedList(items) {
if (typeof items == 'string') {
items = items.split(' ');
}
this._items = items || [];
this.__defineGetter__('length', this._length);
} | javascript | {
"resource": ""
} |
q40941 | fold | train | function fold(count, buf)
{
if(!count || buf.length % 2) return buf;
var ret = buf.slice(0,buf.length/2);
for(i = 0; i < ret.length; i++) ret[i] = ret[i] ^ buf[i+ret.length];
return fold(count-1,ret);
} | javascript | {
"resource": ""
} |
q40942 | pickReverseEach | train | function pickReverseEach( reverse, node, callback ) {
var test = type.call( node, 'Undefined' ) ||
node==='false' ||
node===false ||
(
type.call( node, 'Boolean' ) &&
!node.valueOf()
);
if ( test ) {
pickRevers... | javascript | {
"resource": ""
} |
q40943 | processTokens | train | function processTokens(tokens, callback) {
"use strict";
var processFunctions = underscore.map(tokens, function (word) {
return function (cb) {
tokenizeWord(word, cb);
};
});
async.parallel(
processFunctions,
function (error, results) {
if (error) ... | javascript | {
"resource": ""
} |
q40944 | getRelevantStackFrom | train | function getRelevantStackFrom (stack) {
var filteredStack = [];
var relevantStack = [];
stack = stack.split('\n');
for (var i = 0; i < stack.length; i += 1) {
if (isExternalStackEntry(stack[i])) {
filteredStack.push(stack[i])
}
}
// If the filtered stack is empty, i.e. the error originated ... | javascript | {
"resource": ""
} |
q40945 | formatFailedStep | train | function formatFailedStep (step) {
// Safari seems to have no stack trace,
// so we just return the error message:
if (!step.stack) { return step.message }
var relevantMessage = [];
var relevantStack = [];
// Remove the message prior to processing the stack to prevent issues like
// https://github.com/k... | javascript | {
"resource": ""
} |
q40946 | train | function (clientArguments) {
var grepRegex = /^--grep=(.*)$/;
if (Object.prototype.toString.call(clientArguments) === '[object Array]') {
var indexOfGrep = indexOf(clientArguments, '--grep');
if (indexOfGrep !== -1) {
return clientArguments[indexOfGrep + 1]
}
return map(filter(clientArgumen... | javascript | {
"resource": ""
} | |
q40947 | createStartFn | train | function createStartFn (karma, jasmineEnv) {
function setOption (option, set) {
if (option != null) {
set(option)
}
}
// This function will be assigned to `window.__karma__.start`:
return function () {
console.log('suman started.');
window.__suman.tsrq.resume();
// var clientConfig... | javascript | {
"resource": ""
} |
q40948 | _copy_property | train | function _copy_property(opts, key, a, b) {
debug.assert(opts).is('object');
debug.assert(key).is('string');
debug.assert(a).is('object');
debug.assert(b).is('object');
a[key] = b[key];
if(opts.cache && opts.cache._has_cursors && is.obj(b[key]) && b[key].hasOwnProperty('$id')) {
var f = opts.cache.findCursor(b... | javascript | {
"resource": ""
} |
q40949 | merge_objects_ | train | function merge_objects_(b) {
if(is.func(b)) {
b = b();
}
debug.assert(b).is('object');
_merge_object(opts, a, b);
} | javascript | {
"resource": ""
} |
q40950 | train | function (init) {
if (!init) {
this.startAngleRad = this.yAxis.startAngleRad;
H.seriesTypes.pie.prototype.animate.call(this, init);
}
} | javascript | {
"resource": ""
} | |
q40951 | execute | train | function execute(req, res) {
this.log.notice('background saving started by pid %s', process.pid);
function onSave(err) {
/* istanbul ignore next: not prepared to mock this right now */
if(err) return this.log.warning('background save failed: %s', err.message);
this.log.notice('background saving terminat... | javascript | {
"resource": ""
} |
q40952 | validate | train | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(Persistence.saving) throw SaveInProgress;
} | javascript | {
"resource": ""
} |
q40953 | SlowLogRecord | train | function SlowLogRecord(cmd, args) {
this._now = Date.now();
this._cmd = [cmd].concat(args);
// start timer value when command execution started
this._start = process.hrtime();
} | javascript | {
"resource": ""
} |
q40954 | isSlowerThan | train | function isSlowerThan(amount) {
// always logging
var diff = process.hrtime(this._start)
, micro = Math.round(((diff[0] * 1e9) + diff[1]) / 1e3);
if(amount === 0) return micro;
if(micro > amount) {
return micro;
}
return -1;
} | javascript | {
"resource": ""
} |
q40955 | toArray | train | function toArray(id, time) {
var o = [
id,
Math.round(this._now / 1000),
time,
this._cmd];
return o;
} | javascript | {
"resource": ""
} |
q40956 | SlowLog | train | function SlowLog(conf) {
this._conf = conf;
// log commands slower than this number of microseconds
// disabled by default
this._slowerThan = -1;
// maximum length of the slow log
this._maxLen = 128;
// set up log records array
this.reset();
// log record for the current executing command
this._... | javascript | {
"resource": ""
} |
q40957 | start | train | function start(cmd, args) {
if(!this.enabled) return false;
this._record = new SlowLogRecord(cmd, args);
return this._record;
} | javascript | {
"resource": ""
} |
q40958 | stop | train | function stop() {
var time;
if(!this.enabled) return false;
time = this._record.isSlowerThan(this._slowerThan);
if(this._record && time > -1) {
this._records.unshift(this._record.toArray(id++, time));
if(this._records.length >= this._maxLen) {
this._records.pop();
}
}
} | javascript | {
"resource": ""
} |
q40959 | get | train | function get(amount) {
amount = amount !== undefined && amount >= 0 ? amount : 10;
amount = Math.min(amount, this._records.length);
return this._records.slice(0, amount);
} | javascript | {
"resource": ""
} |
q40960 | TypeDef | train | function TypeDef(arity, type, repeats) {
// arity for the parameter
this.arity = arity;
// type declarations as an array
this.type = type;
// does this value accumulate repeating declarations
this.repeats = repeats;
} | javascript | {
"resource": ""
} |
q40961 | validate | train | function validate(key, values) {
if(this.arity > 0 && values.length !== this.arity) {
throw new TypeDefError(
util.format('bad arity for \'%s\', expected %s got %s',
key, this.arity, values.length));
}
var types = Array.isArray(this.type) ? this.type : [this.type]
, i
, type
, val
... | javascript | {
"resource": ""
} |
q40962 | encode | train | function encode(key, value, stringify) {
var space = ' ', val = [], i, type = this.type;
function coerce(type, val) {
var out
, enumerable = Array.isArray(type);
if(enumerable) {
if(!~type.indexOf(val)) {
throw new TypeDefError(
util.format('enum error on key \'%s\', got \'%s\... | javascript | {
"resource": ""
} |
q40963 | qualityCmp | train | function qualityCmp(a, b) {
if (a.quality === b.quality) {
return 0;
} else if (a.quality < b.quality) {
return 1;
} else {
return -1;
}
} | javascript | {
"resource": ""
} |
q40964 | parseEncoding | train | function parseEncoding(s, i) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);
if (!match) return null;
var encoding = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';');
for (var i = 0; i < params.length; i ++) {
var p = params[i].trim().split('=');
if (p[0] === 'q') {
q = pars... | javascript | {
"resource": ""
} |
q40965 | getMagic | train | function getMagic() {
var mmmagic;
if (magic || magic === false) {
return magic;
}
// Get mmmagic module
mmmagic = alchemy.use('mmmagic')
if (mmmagic) {
magic = new mmmagic.Magic(mmmagic.MAGIC_MIME_TYPE);
} else {
log.error('Could not load mmmagic module');
magic = false;
}
return magic;
} | javascript | {
"resource": ""
} |
q40966 | indent | train | function indent(node) {
var next = node;
var i = 0;
while (next) {
++i;
next = next.suite || next.parent;
}
return Array(i).join(' ');
} | javascript | {
"resource": ""
} |
q40967 | route | train | function route() {
configure()
middlewares()
for (let route of config.routes) {
if (route.type === 'view')
server[route.method](route.src, (req, res) => {
res.render(`${app.root}/views/${route.dest}.twig`, {})
})
if (... | javascript | {
"resource": ""
} |
q40968 | errors | train | function errors() {
// handling 404 errors from config.express['404_redirect'] property
if (config['404_redirect']) {
server.use(function (req, res, next) {
res.status(302)
res.writeHead(302, { 'Location': config['404_redirect'] })
res.end()
... | javascript | {
"resource": ""
} |
q40969 | sadd | train | function sadd(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) {
val = new Set();
this.setKey(key, val, undefined, undefined, undefined, req);
}
return... | javascript | {
"resource": ""
} |
q40970 | smembers | train | function smembers(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return [];
return val.data;
} | javascript | {
"resource": ""
} |
q40971 | sismember | train | function sismember(key, member, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.sismember(member);
} | javascript | {
"resource": ""
} |
q40972 | spop | train | function spop(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
var element = val.spop();
if(val.scard() === 0) {
this.delKey(key, req);
}
return element;
} | javascript | {
"resource": ""
} |
q40973 | srem | train | function srem(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) return 0;
var deleted = val.srem(args);
if(val.scard() === 0) {
this.delKey(key, req);
}
... | javascript | {
"resource": ""
} |
q40974 | smove | train | function smove(source, destination, member, req) {
var src = this.getKey(source, req)
, dest = this.getKey(destination, req);
if(src === undefined || !src.sismember(member)) return 0;
if(dest === undefined) {
dest = new Set();
this.setKey(destination, dest, undefined, undefined, undefined, req);
}
... | javascript | {
"resource": ""
} |
q40975 | sunion | train | function sunion(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set
, src
, i;
set = new Set();
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) continue;
set.sadd... | javascript | {
"resource": ""
} |
q40976 | sunionstore | train | function sunionstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object'
? args[args.length - 1] : null;
var list = this.sunion.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefin... | javascript | {
"resource": ""
} |
q40977 | sinter | train | function sinter(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set = new Set()
, list
, src
, i;
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) return [];
se... | javascript | {
"resource": ""
} |
q40978 | sinterstore | train | function sinterstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sinter.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undef... | javascript | {
"resource": ""
} |
q40979 | sdiff | train | function sdiff(key /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object' ? args.pop() : null
, set = this.getKey(key, req)
, list
, src
, j
, i;
if(!set) return [];
list = set.data.slice(0);
for(j = 0;j < list.length;j++) {
... | javascript | {
"resource": ""
} |
q40980 | sdiffstore | train | function sdiffstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sdiff.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefin... | javascript | {
"resource": ""
} |
q40981 | existence | train | function existence ( filepath ) {
var does = grunt.file.exists ( filepath );
if ( !does ) {
grunt.log.warn ( filepath + " not found." );
}
return does;
} | javascript | {
"resource": ""
} |
q40982 | clone | train | function clone(url, dir) {
_child_process2['default'].execSync('git clone ' + url, { cwd: _path2['default'].resolve(dir) });
} | javascript | {
"resource": ""
} |
q40983 | listTags | train | function listTags(localRepoDir) {
var stdout = _child_process2['default'].execSync('git tag -l', { cwd: _path2['default'].resolve(localRepoDir) });
return stdout.toString().match(/[^\r\n]+/g).filter(function (v) {
return v.length !== 0;
}).map(function (v) {
return v.trim();
});
} | javascript | {
"resource": ""
} |
q40984 | buildIndexFile | train | function buildIndexFile(isProd) {
return new Promise((resolve) => {
files.readFile(path.resolve(__dirname, ".includes/index.html"), (err, html) => {
if (err) throw err;
html = html.replace("$appDesc$", wapitisConfig.appDesc);
html = html.replace("$themeColor$", wapitisConfig.themeColor);
html... | javascript | {
"resource": ""
} |
q40985 | getChildRegistry | train | function getChildRegistry(element, findClosest) {
assert((element === window) || (element instanceof Node) || !element, 'Invalid element specified');
assertType(findClosest, 'boolean', true, `The parameter 'findClosest', if specified, must be a boolean value`);
if (!element || element === document || element ===... | javascript | {
"resource": ""
} |
q40986 | translate | train | function translate(cldr, locale, opts) {
if (typeof cldr === 'string') return augment(interpolate(cldr, opts));
opts = opts || {};
var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);
validate(cldr, pluralize);
va... | javascript | {
"resource": ""
} |
q40987 | validate | train | function validate(cldr, pluralize) {
pluralize.formats.forEach(function(key) {
if (!cldr[key]) throw new Error('translation object missing required key "' + key + '"');
});
} | javascript | {
"resource": ""
} |
q40988 | toFunctions | train | function toFunctions(cldr, pluralize, opts, paramsObj) {
return Object.keys(cldr).reduce(function(acc, key) {
if (key.indexOf('_') === 0) return acc;
var value = cldr[key];
if (typeof value !== 'string') return acc;
var t = acc[key] = interpolate(value, opts);
merge(paramsObj, t.params);
retur... | javascript | {
"resource": ""
} |
q40989 | discoverKey | train | function discoverKey(arr, discoverableKeys, defaultKey) {
if (arr.length === 0) return defaultKey;
if (arr.length === 1) return arr[0];
for (var i = 0; i < arr.length; i++) {
if (discoverableKeys[arr[i]]) return arr[i];
}
return defaultKey;
} | javascript | {
"resource": ""
} |
q40990 | augment | train | function augment(fn, keys) {
keys = keys || fn.params || [];
if (!Array.isArray(keys)) keys = Object.keys(keys);
fn.params = keys;
return fn;
} | javascript | {
"resource": ""
} |
q40991 | lookup | train | function lookup(locale, format, obj) {
if (!locale) throw new Error('missing required "locale" parameter');
locale = locale.toLowerCase().replace('-', '_');
format = format || 'cardinal';
var p = obj[format];
if (!p) throw new Error('unsupported format "' + format + '"');
var fn = p[locale] || p[locale.spli... | javascript | {
"resource": ""
} |
q40992 | convertArray | train | function convertArray(arr, pluralize, opts) {
if (arr.length !== pluralize.count) throw new Error('missing required length of plural formats: expected ' + pluralize.count + '; got ' + arr.length);
return pluralize.formats.reduce(function(acc, key, i) {
acc[key] = arr[i];
return acc;
}, {});
} | javascript | {
"resource": ""
} |
q40993 | formatNumbers | train | function formatNumbers(prevParams, decimal) {
var params = {}, value;
for (var k in prevParams) {
value = prevParams[k];
params[k] = typeof value === 'number' ? decimal(value) : value;
}
return params;
} | javascript | {
"resource": ""
} |
q40994 | Controller | train | function Controller (message) {
if (!(message instanceof Message)) throw new Error('message must be an instanceof Message');
if (!(this instanceof Controller)) return new Controller(message);
debug('new controller');
events.EventEmitter.call(this);
this.message = message;
this.data = this.message.data... | javascript | {
"resource": ""
} |
q40995 | toRgba | train | function toRgba(color, opacity = false) {
color = tinycolor(color);
if (opacity) {
color.setAlpha(calcOpacity(opacity));
}
return color.toRgbString();
} | javascript | {
"resource": ""
} |
q40996 | isEmpty | train | function isEmpty(value) {
if (Array.isArray(value)) {
// If first item in array is undefined, we assume there are no parameters
// This happens as a result of using the rest operator in a mixin
return value.length === 0 || value[0] === undefined;
}
return value === undefined;
} | javascript | {
"resource": ""
} |
q40997 | isFraction | train | function isFraction(value) {
if (typeof value !== 'string') {
return false;
}
value = value.split('/');
return value.length === 2 && value[0] % 1 === 0 && value[1] % 1 === 0;
} | javascript | {
"resource": ""
} |
q40998 | prefix | train | function prefix(value, prefix, ignored = []) {
if (prefix === false) {
return value;
}
if (ignored.includes(prefix)) {
return toDashCase(value);
}
return prefix + '-' + toDashCase(value);
} | javascript | {
"resource": ""
} |
q40999 | unit | train | function unit(value, property) {
let ignored = ['font-weight', 'opacity', 'content', 'columns', 'column-count'];
if (ignored.includes(property) || property === false || value === 0 || /\s/.test(value)) {
return value.toString();
}
if (! isUnit(value) && isNumber(value)) {
if (property === 'line-height') {
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.