_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q62700 | getPrevMap | test | function getPrevMap(from) {
if (typeof options.map.prev === 'string') {
var mapPath = options.map.prev + path.basename(from) + '.map';
if (grunt.file.exists(mapPath)) {
return grunt.file.read(mapPath);
}
}
} | javascript | {
"resource": ""
} |
q62701 | test | function (req, res, next) {
if(req.url.indexOf('.') === -1 && req.url.indexOf(startDir) > -1){
req.url = startPath;
}
return next();
} | javascript | {
"resource": ""
} | |
q62702 | parseIPv4 | test | function parseIPv4(addr) {
if (typeof(addr) !== 'string')
throw new TypeError('addr (string) is required');
var octets = addr.split(/\./).map(function (octet) {
return (parseInt(octet, 10));
});
if (octets.length !== 4)
throw new TypeError... | javascript | {
"resource": ""
} |
q62703 | getNested | test | function getNested(obj, prop) {
var service = obj[prop];
if (service === undefined && Bottle.config.strict) {
throw new Error('Bottle was unable to resolve a service. `' + prop + '` is undefined.');
}
return service;
} | javascript | {
"resource": ""
} |
q62704 | getNestedBottle | test | function getNestedBottle(name) {
var bottle;
if (!this.nested[name]) {
bottle = Bottle.pop();
this.nested[name] = bottle;
this.factory(name, function SubProviderFactory() {
return bottle.container;
});
}
return this.nested[n... | javascript | {
"resource": ""
} |
q62705 | applyMiddleware | test | function applyMiddleware(middleware, name, instance, container) {
var descriptor = {
configurable : true,
enumerable : true
};
if (middleware.length) {
descriptor.get = function getWithMiddlewear() {
var index = 0;
var next = fu... | javascript | {
"resource": ""
} |
q62706 | middleware | test | function middleware(fullname, func) {
var parts, name;
if (typeof fullname === FUNCTION_TYPE) {
func = fullname;
fullname = GLOBAL_NAME;
}
parts = fullname.split(DELIMITER);
name = parts.shift();
if (parts.length) {
getNestedBottle... | javascript | {
"resource": ""
} |
q62707 | createProvider | test | function createProvider(name, Provider) {
var providerName, properties, container, id, decorators, middlewares;
id = this.id;
container = this.container;
decorators = this.decorators;
middlewares = this.middlewares;
providerName = name + PROVIDER_SUFFIX;
... | javascript | {
"resource": ""
} |
q62708 | provider | test | function provider(fullname, Provider) {
var parts, name;
parts = fullname.split(DELIMITER);
if (this.providerMap[fullname] && parts.length === 1 && !this.container[fullname + PROVIDER_SUFFIX]) {
return console.error(fullname + ' provider already instantiated.');
}
thi... | javascript | {
"resource": ""
} |
q62709 | createService | test | function createService(name, Service, isClass) {
var deps = arguments.length > 3 ? slice.call(arguments, 3) : [];
var bottle = this;
return factory.call(this, name, function GenericFactory() {
var serviceFactory = Service; // alias for jshint
var args = deps.map(getNested... | javascript | {
"resource": ""
} |
q62710 | service | test | function service(name, Service) {
return createService.apply(this, [name, Service, true].concat(slice.call(arguments, 2)));
} | javascript | {
"resource": ""
} |
q62711 | serviceFactory | test | function serviceFactory(name, factoryService) {
return createService.apply(this, [name, factoryService, false].concat(slice.call(arguments, 2)));
} | javascript | {
"resource": ""
} |
q62712 | defineValue | test | function defineValue(name, val) {
Object.defineProperty(this, name, {
configurable : true,
enumerable : true,
value : val,
writable : true
});
} | javascript | {
"resource": ""
} |
q62713 | setValueObject | test | function setValueObject(container, name) {
var nestedContainer = container[name];
if (!nestedContainer) {
nestedContainer = {};
defineValue.call(container, name, nestedContainer);
}
return nestedContainer;
} | javascript | {
"resource": ""
} |
q62714 | value | test | function value(name, val) {
var parts;
parts = name.split(DELIMITER);
name = parts.pop();
defineValue.call(parts.reduce(setValueObject, this.container), name, val);
return this;
} | javascript | {
"resource": ""
} |
q62715 | constant | test | function constant(name, value) {
var parts = name.split(DELIMITER);
name = parts.pop();
defineConstant.call(parts.reduce(setValueObject, this.container), name, value);
return this;
} | javascript | {
"resource": ""
} |
q62716 | decorator | test | function decorator(fullname, func) {
var parts, name;
if (typeof fullname === FUNCTION_TYPE) {
func = fullname;
fullname = GLOBAL_NAME;
}
parts = fullname.split(DELIMITER);
name = parts.shift();
if (parts.length) {
getNestedBottle.... | javascript | {
"resource": ""
} |
q62717 | instanceFactory | test | function instanceFactory(name, Factory) {
return factory.call(this, name, function GenericInstanceFactory(container) {
return {
instance : Factory.bind(Factory, container)
};
});
} | javascript | {
"resource": ""
} |
q62718 | pop | test | function pop(name) {
var instance;
if (typeof name === STRING_TYPE) {
instance = bottles[name];
if (!instance) {
bottles[name] = instance = new Bottle();
instance.constant('BOTTLE_NAME', name);
}
return instance;
}
... | javascript | {
"resource": ""
} |
q62719 | register | test | function register(Obj) {
var value = Obj.$value === undefined ? Obj : Obj.$value;
return this[Obj.$type || 'service'].apply(this, [Obj.$name, value].concat(Obj.$inject || []));
} | javascript | {
"resource": ""
} |
q62720 | resetProviders | test | function resetProviders(names) {
var tempProviders = this.originalProviders;
var shouldFilter = Array.isArray(names);
Object.keys(this.originalProviders).forEach(function resetProvider(originalProviderName) {
if (shouldFilter && names.indexOf(originalProviderName) === -1) {
... | javascript | {
"resource": ""
} |
q62721 | throwIfInvalidNode | test | function throwIfInvalidNode(node, functionName) {
if (!exports.isASTNode(node)) {
throw new Error(functionName + "(): " + util.inspect(node) + " is not a valid AST node.");
}
} | javascript | {
"resource": ""
} |
q62722 | isEvent | test | function isEvent(expr, eventDeclarations) {
for (let { node, enclosingContract } of eventDeclarations) {
if (expr.callee.name === node.name && sourceCode.isAChildOf(expr, enclosingContract)) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q62723 | registerEventName | test | function registerEventName(emitted) {
const { node } = emitted;
(!emitted.exit) && events.push({ node, enclosingContract: sourceCode.getParent(node) });
} | javascript | {
"resource": ""
} |
q62724 | inspectVariableDeclarator | test | function inspectVariableDeclarator(emitted) {
let node = emitted.node;
if (!emitted.exit) {
allVariableDeclarations [node.id.name] = node;
}
} | javascript | {
"resource": ""
} |
q62725 | inspectProgram | test | function inspectProgram(emitted) {
if (emitted.exit) {
Object.keys(allVariableDeclarations).forEach(function(name) {
context.report({
node: allVariableDeclarations [name],
message: "Variable '" + name + "' is declared but n... | javascript | {
"resource": ""
} |
q62726 | inspectIdentifier | test | function inspectIdentifier(emitted) {
if (!emitted.exit) {
let node = emitted.node,
sourceCode = context.getSourceCode();
if (
allVariableDeclarations [node.name] &&
sourceCode.getParent(node).type !== "VariableDeclarator"
... | javascript | {
"resource": ""
} |
q62727 | inspectFunctionsOfContract | test | function inspectFunctionsOfContract(emitted) {
if (emitted.exit) {
return;
}
const { node } = emitted, { body } = node;
let cursor = 0;
// Filter out non-function nodes
body.filter(child => {
return ["FunctionDecla... | javascript | {
"resource": ""
} |
q62728 | inspectCallExpression | test | function inspectCallExpression(emitted) {
let node = emitted.node,
callArgs = node.arguments;
if (emitted.exit) {
return;
}
let nodeCode = sourceCode.getText(node);
//for a 0-argument call, ensure that name is followed by '()... | javascript | {
"resource": ""
} |
q62729 | inspectExperimentalPragmaStatement | test | function inspectExperimentalPragmaStatement(emitted) {
if (emitted.exit) {
return;
}
const { node } = emitted,
nodesAllowedAbove = ["ExperimentalPragmaStatement", "PragmaStatement"],
programNode = context.getSourceCode().getParent(node... | javascript | {
"resource": ""
} |
q62730 | test | function(sourceCode, errorMessages) {
let fixedSourceCode = "", fixes = [], fixesApplied = [], remainingMessages = [];
let cursor = Number.NEGATIVE_INFINITY;
function attemptFix(fix) {
let start = fix.range [0], end = fix.range [1];
// If this fix overlaps with the prev... | javascript | {
"resource": ""
} | |
q62731 | inspectTopLevelDeclaration | test | function inspectTopLevelDeclaration(emitted) {
let body = emitted.node.body || [],
levelOneIndentRegExp = new RegExp("^\\n" + BASE_INDENTATION_STYLE + "$"),
endingLineRegExp = new RegExp("^" + BASE_INDENTATION_STYLE + "(\\S| \\*)$"), //either a non-whitespace character or 1 e... | javascript | {
"resource": ""
} |
q62732 | inspectBlockStatement | test | function inspectBlockStatement(emitted) {
let node = emitted.node;
//if the complete block resides on the same line, no need to check for indentation
if (emitted.exit || (sourceCode.getLine(node) === sourceCode.getEndingLine(node))) {
return;
}
... | javascript | {
"resource": ""
} |
q62733 | test | function(node, beforeCount, afterCount) {
let sourceCodeText = this.text;
if (node) {
if (astUtils.isASTNode(node)) {
return this.text.slice(
Math.max(0, node.start - (Math.abs(beforeCount) || 0)),
node.end + (Math.abs(afterCount) || ... | javascript | {
"resource": ""
} | |
q62734 | inspectVariableDeclaration | test | function inspectVariableDeclaration(emitted) {
let node = emitted.node, code = sourceCode.getText(node);
if (emitted.exit) {
return;
}
//if a particular character is '=', check its left and right for single space
for (let i = 2; i < code.leng... | javascript | {
"resource": ""
} |
q62735 | RuleContext | test | function RuleContext(ruleName, ruleDesc, ruleMeta, Solium) {
let contextObject = this;
// Set contect attribute 'options' iff options were provided.
ruleDesc.options && Object.assign(contextObject, { options: ruleDesc.options });
//set read-only properties of the context object
Object.defineProper... | javascript | {
"resource": ""
} |
q62736 | resolveUpstream | test | function resolveUpstream(upstream) {
let coreRulesetRegExp = /^solium:[a-z_]+$/;
// Determine whether upstream is a solium core ruleset or a sharable config.
if (coreRulesetRegExp.test(upstream)) {
try {
return require("../../config/rulesets/solium-" + upstream.split(":") [1]).rules;
... | javascript | {
"resource": ""
} |
q62737 | resolvePluginConfig | test | function resolvePluginConfig(name, plugin) {
let config = {};
Object.keys(plugin.rules).forEach(function(ruleName) {
config [name + "/" + ruleName] = plugin.rules [ruleName].meta.docs.type;
});
return config;
} | javascript | {
"resource": ""
} |
q62738 | writeConfigFile | test | function writeConfigFile(config) {
try {
fs.writeFileSync(
SOLIUMRC_FILENAME_ABSOLUTE,
JSON.stringify(config, null, 2)
);
} catch (e) {
errorReporter.reportFatal(
`An error occurred while writing to ${SOLIUMRC_FILENAME_ABSOLUTE}:${EOL}${e.message}`);
... | javascript | {
"resource": ""
} |
q62739 | lintString | test | function lintString(sourceCode, userConfig, errorReporter, fileName) {
let lintErrors, fixesApplied;
try {
if (userConfig.options.autofix || userConfig.options.autofixDryrun) {
let result = solium.lintAndFix(sourceCode, userConfig);
lintErrors = result.errorMessages;
... | javascript | {
"resource": ""
} |
q62740 | lintFile | test | function lintFile(fileName, userConfig, errorReporter) {
let sourceCode;
try {
sourceCode = fs.readFileSync(fileName, "utf8");
} catch (e) {
errorReporter.reportFatal("Unable to read " + fileName + ": " + e.message);
process.exit(errorCodes.FILE_NOT_FOUND);
}
return lintStr... | javascript | {
"resource": ""
} |
q62741 | createCliOptions | test | function createCliOptions(cliObject) {
function collect(val, memo) {
memo.push(val);
return memo;
}
cliObject
.version(`Solium version ${version}`)
.description("Linter to find & fix style and security issues in Solidity smart contracts.")
.usage("[options] <keyword>... | javascript | {
"resource": ""
} |
q62742 | test | function(options, listItemsSchema) {
let validateOptionsList = SchemaValidator.compile({
type: "array",
minItems: listItemsSchema.length,
additionalItems: false,
items: listItemsSchema
});
return validateOptionsList(options);
} | javascript | {
"resource": ""
} | |
q62743 | inspectFD | test | function inspectFD(emitted) {
const { node } = emitted,
visibilityModifiers = ["public", "external", "internal", "private"];
const modifiers = (node.modifiers || []),
firstVisibilityModifierIndex = modifiers.findIndex(m => visibilityModifiers.includes(m.name));
... | javascript | {
"resource": ""
} |
q62744 | isHex | test | function isHex(literal) {
let reg = /^[0-9a-f]+$/i;
//test for '0x' separately because hex notation should not be a part of the standard RegExp
if (literal.slice(0, 2) !== "0x") {
return false;
}
return reg.test(literal.slice(2));
} | javascript | {
"resource": ""
} |
q62745 | Soundfont | test | function Soundfont (ctx, nameToUrl) {
console.warn('new Soundfont() is deprected')
console.log('Please use Soundfont.instrument() instead of new Soundfont().instrument()')
if (!(this instanceof Soundfont)) return new Soundfont(ctx)
this.nameToUrl = nameToUrl || Soundfont.nameToUrl
this.ctx = ctx
this.instr... | javascript | {
"resource": ""
} |
q62746 | oscillatorPlayer | test | function oscillatorPlayer (ctx, defaultOptions) {
defaultOptions = defaultOptions || {}
return function (note, time, duration, options) {
console.warn('The oscillator player is deprecated.')
console.log('Starting with version 0.9.0 you will have to wait until the soundfont is loaded to play sounds.')
va... | javascript | {
"resource": ""
} |
q62747 | instrument | test | function instrument (ac, name, options) {
if (arguments.length === 1) return function (n, o) { return instrument(ac, n, o) }
var opts = options || {}
var isUrl = opts.isSoundfontURL || isSoundfontURL
var toUrl = opts.nameToUrl || nameToUrl
var url = isUrl(name) ? name : toUrl(name, opts.soundfont, opts.format... | javascript | {
"resource": ""
} |
q62748 | hasSystemLib | test | function hasSystemLib (lib) {
var libName = 'lib' + lib + '.+(so|dylib)'
var libNameRegex = new RegExp(libName)
// Try using ldconfig on linux systems
if (hasLdconfig()) {
try {
if (childProcess.execSync('ldconfig -p 2>/dev/null | grep -E "' + libName + '"').length) {
return true
}
... | javascript | {
"resource": ""
} |
q62749 | thenify | test | async function thenify(fn) {
return await new Promise(function(resolve, reject) {
function callback(err, res) {
if (err) return reject(err);
return resolve(res);
}
fn(callback);
});
} | javascript | {
"resource": ""
} |
q62750 | startWatching | test | function startWatching(opts) {
var chokidarOpts = createChokidarOpts(opts);
var watcher = chokidar.watch(opts.patterns, chokidarOpts);
var throttledRun = _.throttle(run, opts.throttle);
var debouncedRun = _.debounce(throttledRun, opts.debounce);
watcher.on('all', function(event, path) {
var... | javascript | {
"resource": ""
} |
q62751 | _resolveIgnoreOpt | test | function _resolveIgnoreOpt(ignoreOpt) {
if (!ignoreOpt) {
return ignoreOpt;
}
var ignores = !_.isArray(ignoreOpt) ? [ignoreOpt] : ignoreOpt;
return _.map(ignores, function(ignore) {
var isRegex = ignore[0] === '/' && ignore[ignore.length - 1] === '/';
if (isRegex) {
... | javascript | {
"resource": ""
} |
q62752 | requireProp | test | function requireProp(props, propName, componentName) {
return isEmpty(props[propName])
? new Error(
`The prop \`${propName}\` is required for \`${componentName}\`.`
)
: null
} | javascript | {
"resource": ""
} |
q62753 | _0to1 | test | function _0to1(props, propName, componentName) {
if (isEmpty(props[propName])) {
return null
}
if (
typeof props[propName] === 'number' &&
props[propName] >= 0 &&
props[propName] <= 1
) {
return null
}
return new Error(
`Invalid prop \`${propName}\` supplied to \`${componentName}\`. ... | javascript | {
"resource": ""
} |
q62754 | babel | test | function babel(options = {}) {
return (context, { addLoader }) =>
addLoader({
// setting `test` defaults here, in case there is no `context.match` data
test: /\.(js|jsx)$/,
use: [
{
loader: 'thread-loader',
options: {
// Keep workers alive for more effecti... | javascript | {
"resource": ""
} |
q62755 | imageLoader | test | function imageLoader() {
return (context, { addLoader }) =>
addLoader({
test: /\.(gif|ico|jpg|jpeg|png|webp)$/,
loader: 'url-loader',
options: {
limit: 10000,
name: fileNameTemplate,
},
})
} | javascript | {
"resource": ""
} |
q62756 | csvLoader | test | function csvLoader() {
return (context, { addLoader }) =>
addLoader({
test: /\.csv$/,
loader: 'csv-loader',
options: {
dynamicTyping: true,
header: true,
skipEmptyLines: true,
},
})
} | javascript | {
"resource": ""
} |
q62757 | cssSvgLoader | test | function cssSvgLoader() {
return (context, { addLoader }) =>
addLoader({
// This needs to be different form the reactSvgLoader, otherwise it will merge
test: /(.*)\.svg$/,
issuer: {
test: /\.css$/,
},
loader: 'url-loader',
options: {
limit: 10000,
name: ... | javascript | {
"resource": ""
} |
q62758 | prependEntry | test | function prependEntry(entry) {
const blockFunction = (context, util) => {
if (!context.entriesToPrepend) context.entriesToPrepend = []
context.entriesToPrepend.unshift(entry)
return config => config
}
return Object.assign(blockFunction, {
post: prependEntryPostHook,
})
} | javascript | {
"resource": ""
} |
q62759 | build | test | function build() {
log.info(`Creating an optimized production build...`)
const compiler = createWebpackCompiler(
() => {
log.ok(`The ${chalk.cyan(relativeAppBuildPath)} folder is ready to be deployed.`)
},
() => {
log.err(`Aborting`)
process.exit(2)
}
)
return new Promise((res... | javascript | {
"resource": ""
} |
q62760 | mergeData | test | function mergeData (to, from) {
if (!from) { return to }
var key, toVal, fromVal;
var keys = Object.keys(from);
for (var i = 0; i < keys.length; i++) {
key = keys[i];
toVal = to[key];
fromVal = from[key];
if (!hasOwn(to, key)) {
set(to, key, fromVal);
} el... | javascript | {
"resource": ""
} |
q62761 | withDefault | test | function withDefault(type) {
return Object.defineProperty(type, 'def', {
value: function value(def) {
if (def === undefined && !this.default) {
return this;
}
if (!isFunction(def) && !validateType(this, def)) {
warn(this._vueTypes_name + " - invalid default value: \"" + d... | javascript | {
"resource": ""
} |
q62762 | withValidate | test | function withValidate(type) {
return Object.defineProperty(type, 'validate', {
value: function value(fn) {
this.validator = fn.bind(this);
return this;
},
enumerable: false
});
} | javascript | {
"resource": ""
} |
q62763 | toType | test | function toType(name, obj, validateFn) {
if (validateFn === void 0) {
validateFn = false;
}
Object.defineProperty(obj, '_vueTypes_name', {
enumerable: false,
writable: false,
value: name
});
withDefault(withRequired(obj));
if (validateFn) {
withValidate(obj);
}
if (is... | javascript | {
"resource": ""
} |
q62764 | validateType | test | function validateType(type, value, silent) {
if (silent === void 0) {
silent = false;
}
var typeToCheck = type;
var valid = true;
var expectedType;
if (!isPlainObject_1(type)) {
typeToCheck = {
type: type
};
}
var namePrefix = typeToCheck._vueTypes_name ? typeToCheck._vu... | javascript | {
"resource": ""
} |
q62765 | CustomEvent | test | function CustomEvent(type, eventInitDict) {
/*jshint eqnull:true */
var event = document.createEvent(eventName);
if (typeof type != 'string') {
throw new Error('An event name must be provided');
}
if (eventName == 'Event') {
event.initCustomEvent = initCustomE... | javascript | {
"resource": ""
} |
q62766 | initCustomEvent | test | function initCustomEvent(
type, bubbles, cancelable, detail
) {
/*jshint validthis:true*/
this.initEvent(type, bubbles, cancelable);
this.detail = detail;
} | javascript | {
"resource": ""
} |
q62767 | cleanUpRuntimeEvents | test | function cleanUpRuntimeEvents() {
// Remove all touch events added during 'onDown' as well.
document.removeEventListener('touchmove', onMove, getPassiveSupported() ? { passive: false } : false);
document.removeEventListener('touchend', onUp);
document.removeEventListener(... | javascript | {
"resource": ""
} |
q62768 | addRuntimeEvents | test | function addRuntimeEvents() {
cleanUpRuntimeEvents();
// @see https://developers.google.com/web/updates/2017/01/scrolling-intervention
document.addEventListener('touchmove', onMove, getPassiveSupported() ? { passive: false } : false);
document.addEventListener('touchend'... | javascript | {
"resource": ""
} |
q62769 | normalizeEvent | test | function normalizeEvent(ev) {
if (ev.type === 'touchmove' || ev.type === 'touchstart' || ev.type === 'touchend') {
var touch = ev.targetTouches[0] || ev.changedTouches[0];
return {
x: touch.clientX,
y: touch.clientY,
... | javascript | {
"resource": ""
} |
q62770 | onDown | test | function onDown(ev) {
var event = normalizeEvent(ev);
if (!pointerActive && !paused) {
pointerActive = true;
decelerating = false;
pointerId = event.id;
pointerLastX = pointerCurrentX = event.x;
pointerLastY = point... | javascript | {
"resource": ""
} |
q62771 | onMove | test | function onMove(ev) {
ev.preventDefault();
var event = normalizeEvent(ev);
if (pointerActive && event.id === pointerId) {
pointerCurrentX = event.x;
pointerCurrentY = event.y;
addTrackingPoint(pointerLastX, pointerLastY);
... | javascript | {
"resource": ""
} |
q62772 | addTrackingPoint | test | function addTrackingPoint(x, y) {
var time = Date.now();
while (trackingPoints.length > 0) {
if (time - trackingPoints[0].time <= 100) {
break;
}
trackingPoints.shift();
}
trackingPoints.push({ x: x, y: ... | javascript | {
"resource": ""
} |
q62773 | updateAndRender | test | function updateAndRender() {
var pointerChangeX = pointerCurrentX - pointerLastX;
var pointerChangeY = pointerCurrentY - pointerLastY;
targetX += pointerChangeX * multiplier;
targetY += pointerChangeY * multiplier;
if (bounce) {
var diff = ch... | javascript | {
"resource": ""
} |
q62774 | startDecelAnim | test | function startDecelAnim() {
var firstPoint = trackingPoints[0];
var lastPoint = trackingPoints[trackingPoints.length - 1];
var xOffset = lastPoint.x - firstPoint.x;
var yOffset = lastPoint.y - firstPoint.y;
var timeOffset = lastPoint.time - firstPoint.time;
... | javascript | {
"resource": ""
} |
q62775 | stepDecelAnim | test | function stepDecelAnim() {
if (!decelerating) {
return;
}
decVelX *= friction;
decVelY *= friction;
targetX += decVelX;
targetY += decVelY;
var diff = checkBounds();
if (Math.abs(decVelX) > stopThreshold ... | javascript | {
"resource": ""
} |
q62776 | checkBounds | test | function checkBounds(restrict) {
var xDiff = 0;
var yDiff = 0;
if (boundXmin !== undefined && targetX < boundXmin) {
xDiff = boundXmin - targetX;
} else if (boundXmax !== undefined && targetX > boundXmax) {
xDiff = boundXmax - targetX;
... | javascript | {
"resource": ""
} |
q62777 | initCompDirs | test | function initCompDirs(){
var compRoot = path.resolve(process.cwd(),'src/components'),
compReg = /^[A-Z]\w+$/;
//['Button', 'Select']
compDirs = fs.readdirSync(compRoot).filter(function(filename){
return compReg.test(filename)
})
return compDirs
} | javascript | {
"resource": ""
} |
q62778 | appendLogToFileStream | test | function appendLogToFileStream(fileName, newLog, headerLineCount) {
const filePath = path.join(__dirname, '../../', fileName)
const oldChangelog = grunt.file.read(filePath)
.toString()
.split('\n');
let wStr = fs.createWriteStream(filePath)
/** lines used by the default header */
let lo... | javascript | {
"resource": ""
} |
q62779 | doSeek | test | function doSeek(length, eocdrNotFoundCallback) {
reader.readUint8Array(reader.size - length, length, function(bytes) {
for (var i = bytes.length - EOCDR_MIN; i >= 0; i--) {
if (bytes[i] === 0x50 && bytes[i + 1] === 0x4b && bytes[i + 2] === 0x05 && bytes[i + 3] === 0x06) {
eocdrCallback(new DataVie... | javascript | {
"resource": ""
} |
q62780 | CronJob | test | function CronJob (sandbox, job) {
/**
* @property name - The name of the cron job
* @property schedule - The cron schedule of the job
* @property next_scheduled_at - The next time this job is scheduled
*/
assign(this, job);
/**
* @property claims - The claims embedded in the Webtas... | javascript | {
"resource": ""
} |
q62781 | Sandbox | test | function Sandbox (options) {
var securityVersion = 'v1';
this.url = options.url;
this.container = options.container;
this.token = options.token;
this.onBeforeRequest = []
.concat(options.onBeforeRequest)
.filter(hook => typeof hook === 'function');
try {
var typ = Decod... | javascript | {
"resource": ""
} |
q62782 | Webtask | test | function Webtask (sandbox, token, options) {
if (!options) options = {};
if (sandbox.securityVersion === 'v1') {
try {
/**
* @property claims - The claims embedded in the Webtask's token
*/
this.claims = Decode(token);
/**
* @... | javascript | {
"resource": ""
} |
q62783 | wrappedPromise | test | function wrappedPromise(executor) {
if (!(this instanceof wrappedPromise)) {
return Promise(executor);
}
if (typeof executor !== 'function') {
return new Promise(executor);
}
var context, args;
var promise = new Promise(wrappedExecutor);
promise.__proto__ = wrappedPromise.proto... | javascript | {
"resource": ""
} |
q62784 | union | test | function union(dest, added) {
var destLength = dest.length;
var addedLength = added.length;
var returned = [];
if (destLength === 0 && addedLength === 0) return returned;
for (var j = 0; j < destLength; j++) returned[j] = dest[j];
if (addedLength === 0) return returned;
for (var i = 0; i < addedLengt... | javascript | {
"resource": ""
} |
q62785 | simpleWrap | test | function simpleWrap(original, list, length) {
inAsyncTick = true;
for (var i = 0; i < length; ++i) {
var listener = list[i];
if (listener.create) listener.create(listener.data);
}
inAsyncTick = false;
// still need to make sure nested async calls are made in the context
// of the listeners active a... | javascript | {
"resource": ""
} |
q62786 | wrapCallback | test | function wrapCallback(original) {
var length = listeners.length;
// no context to capture, so avoid closure creation
if (length === 0) return original;
// capture the active listeners as of when the wrapped function was called
var list = listeners.slice();
for (var i = 0; i < length; ++i) {
if (list[... | javascript | {
"resource": ""
} |
q62787 | test | function (dir, options, internal) {
// Parse arguments.
options = options || largest.options;
// Get all file stats in parallel.
return fs.readdirAsync(dir)
.then (function (files) {
var paths = _.map(files, function (file) { return path.join(dir, file); });
return Promise.all(_.ma... | javascript | {
"resource": ""
} | |
q62788 | makeAsyncFunc | test | function makeAsyncFunc(config) {
// Validate the specified configuration
config.validate();
// Create an async function tailored to the given options.
var result = function async(bodyFunc) {
// Create a semaphore for limiting top-level concurrency, if specified in options.
var semaphore ... | javascript | {
"resource": ""
} |
q62789 | makeAsyncIterator | test | function makeAsyncIterator(bodyFunc, config, semaphore) {
// Return a function that returns an iterator.
return function iterable() {
// Capture the initial arguments used to start the iterator, as an array.
var startupArgs = new Array(arguments.length + 1); // Reserve 0th arg for the yield func... | javascript | {
"resource": ""
} |
q62790 | makeAsyncNonIterator | test | function makeAsyncNonIterator(bodyFunc, config, semaphore) {
// Return a function that executes fn in a fiber and returns a promise of fn's result.
return function nonIterable() {
// Get all the arguments passed in, as an array.
var argsAsArray = new Array(arguments.length);
for (var i =... | javascript | {
"resource": ""
} |
q62791 | traverseClone | test | function traverseClone(o, visitor) {
var result;
if (_.isArray(o)) {
var len = o.length;
result = new Array(len);
for (var i = 0; i < len; ++i) {
result[i] = traverseClone(o[i], visitor);
visitor(result, i);
}
}
else if (_.isPlainObject(o)) {
... | javascript | {
"resource": ""
} |
q62792 | thunkToPromise | test | function thunkToPromise(thunk) {
return new Promise(function (resolve, reject) {
var callback = function (err, val) { return (err ? reject(err) : resolve(val)); };
thunk(callback);
});
} | javascript | {
"resource": ""
} |
q62793 | test | function (dir) {
var files = fs.readdirSync(dir);
// Get all file stats in parallel.
var paths = _.map(files, function (file) { return path.join(dir, file); });
var stats = _.map(paths, function (path) { return fs.statSync(path); });
// Count the files.
return _.filter(stats, function (stat) {... | javascript | {
"resource": ""
} | |
q62794 | scopedCopyIndex | test | async function scopedCopyIndex(client, sourceIndex, targetIndex) {
const { taskID } = await client.copyIndex(
sourceIndex.indexName,
targetIndex.indexName,
['settings', 'synonyms', 'rules']
);
return targetIndex.waitTask(taskID);
} | javascript | {
"resource": ""
} |
q62795 | moveIndex | test | async function moveIndex(client, sourceIndex, targetIndex) {
const { taskID } = await client.moveIndex(
sourceIndex.indexName,
targetIndex.indexName
);
return targetIndex.waitTask(taskID);
} | javascript | {
"resource": ""
} |
q62796 | indexExists | test | async function indexExists(index) {
try {
const { nbHits } = await index.search();
return nbHits > 0;
} catch (e) {
return false;
}
} | javascript | {
"resource": ""
} |
q62797 | loadModule | test | function loadModule(moduleName) {
var module = modules[moduleName];
if (module !== undefined) {
return module;
}
// This uses a switch for static require analysis
switch (moduleName) {
case 'charset':
module = require('./lib/charset');
break;
case 'encoding':
module = require('... | javascript | {
"resource": ""
} |
q62798 | parseAcceptLanguage | test | function parseAcceptLanguage(accept) {
var accepts = accept.split(',');
for (var i = 0, j = 0; i < accepts.length; i++) {
var language = parseLanguage(accepts[i].trim(), i);
if (language) {
accepts[j++] = language;
}
}
// trim accepts
accepts.length = j;
return accepts;
} | javascript | {
"resource": ""
} |
q62799 | parseLanguage | test | function parseLanguage(str, i) {
var match = simpleLanguageRegExp.exec(str);
if (!match) return null;
var prefix = match[1],
suffix = match[2],
full = prefix;
if (suffix) full += "-" + suffix;
var q = 1;
if (match[3]) {
var params = match[3].split(';')
for (var j = 0; j < params.length; j... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.