_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q63200 | Connection | test | function Connection(socket, parent) {
logger('new Connection to %s', parent.type);
this.id = uuid();
this.socket = socket;
this.parent = parent;
this.responseHandlers = {};
if (this.parent.browser) {
this.socket.onmessage = this.message.bind(this);
this.socket.onclose = socketClosed.bind(this);
... | javascript | {
"resource": ""
} |
q63201 | mark | test | function mark(type, attrs) {
return function(...args) {
let mark = type.create(takeAttrs(attrs, args))
let {nodes, tag} = flatten(type.schema, args, n => mark.type.isInSet(n.marks) ? n : n.mark(mark.addToSet(n.marks)))
return {flat: nodes, tag}
}
} | javascript | {
"resource": ""
} |
q63202 | serverRequest | test | function serverRequest(config) {
var defer = $q.defer();
if (provider.debug) $log.info('$sails ' + config.method + ' ' + config.url, config.data || '');
if (config.timeout > 0) {
$timeout(timeoutRequest, config.timeout);
} else if (isP... | javascript | {
"resource": ""
} |
q63203 | processBootStrap | test | function processBootStrap(file) {
var data = fs.readFileSync(file).toString();
var idx = data.indexOf('bootstrap(');
if (idx === -1) { return null; }
else { idx+=10; }
var odx1 = data.indexOf(',', idx);
var odx2 = data.indexOf(')', idx);
if (odx2 < odx1 && odx2 !== -1 || odx1 === -1) { odx1... | javascript | {
"resource": ""
} |
q63204 | fixTsConfig | test | function fixTsConfig() {
var tsConfig={}, tsFile = '../../tsconfig.json';
if (fs.existsSync(tsFile)) {
tsConfig = require(tsFile);
}
if (!tsConfig.compilerOptions || !tsConfig.compilerOptions.typeRoots) {
tsConfig.compilerOptions = {
target: "es5",
module: "commonjs",... | javascript | {
"resource": ""
} |
q63205 | fixRefFile | test | function fixRefFile() {
var existingRef='', refFile = '../../references.d.ts';
if (fs.existsSync(refFile)) {
existingRef = fs.readFileSync(refFile).toString();
}
if (existingRef.indexOf('typescript/lib/lib.d.ts') === -1) {
// has not been previously modified
var fix = '/// <reference path... | javascript | {
"resource": ""
} |
q63206 | fixNativeScriptPackage | test | function fixNativeScriptPackage() {
var packageJSON = {}, packageFile = '../../package.json';
packageJSON.name = "NativeScriptApp";
packageJSON.version = "0.0.0";
// var AngularJSON = {};
if (fs.existsSync(packageFile)) {
packageJSON = require(packageFile);
} else {
console.lo... | javascript | {
"resource": ""
} |
q63207 | fixAngularPackage | test | function fixAngularPackage() {
var packageJSON = {}, packageFile = '../../../package.json';
if (fs.existsSync(packageFile)) {
packageJSON = require(packageFile);
} else {
console.log("This should not happen, your are missing your main package.json file!");
return;
}
if (!pac... | javascript | {
"resource": ""
} |
q63208 | fixMainFile | test | function fixMainFile(component) {
var mainTS = '', mainFile = '../../app/main.ts';
if (fs.existsSync(mainFile)) {
mainTS = fs.readFileSync(mainFile).toString();
}
if (mainTS.indexOf('MagicService') === -1) {
// has not been previously modified
var fix = '// this import should be first in order to ... | javascript | {
"resource": ""
} |
q63209 | fixGitIgnore | test | function fixGitIgnore(ignorePattern) {
var fileString = '', ignoreFile = '../../../.gitignore';
if (fs.existsSync(ignoreFile)) {
fileString = fs.readFileSync(ignoreFile).toString();
}
if (fileString.indexOf(ignorePattern) === -1) {
// has not been previously modified
var fix = fileString +
'... | javascript | {
"resource": ""
} |
q63210 | displayFinalHelp | test | function displayFinalHelp()
{
console.log("-------------- Welcome to the Magical World of NativeScript -----------------------------");
console.log("To finish, follow this guide https://github.com/NathanWalker/nativescript-ng2-magic#usage");
console.log("After you have completed the steps in the usage guide... | javascript | {
"resource": ""
} |
q63211 | bind | test | function bind(func, thisObject, var_args)
{
var args = slice(arguments, 2);
/**
* @param {...} var_args
*/
function bound(var_args)
{
return InjectedScriptHost.callFunction(func, thisObject, concat(args, slice(arguments)));
}
bound.toString = function()
{
return "b... | javascript | {
"resource": ""
} |
q63212 | test | function(object, objectGroupName, forceValueType, generatePreview, columnNames, isTable, doNotBind, customObjectConfig)
{
try {
return new InjectedScript.RemoteObject(object, objectGroupName, doNotBind, forceValueType, generatePreview, columnNames, isTable, undefined, customObjectConfig);
... | javascript | {
"resource": ""
} | |
q63213 | test | function(callArgumentJson)
{
callArgumentJson = nullifyObjectProto(callArgumentJson);
var objectId = callArgumentJson.objectId;
if (objectId) {
var parsedArgId = this._parseObjectId(objectId);
if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScriptId)
... | javascript | {
"resource": ""
} | |
q63214 | test | function(topCallFrame, callFrameId, functionObjectId, scopeNumber, variableName, newValueJsonString)
{
try {
var newValueJson = /** @type {!RuntimeAgent.CallArgument} */ (InjectedScriptHost.eval("(" + newValueJsonString + ")"));
var resolvedValue = this._resolveCallArgument(newValueJ... | javascript | {
"resource": ""
} | |
q63215 | validate | test | function validate(str) {
let tj;
if (typeof str === 'object') {
tj = str;
} else if (typeof str === 'string') {
try {
tj = jsonlint.parse(str);
} catch (err) {
return false;
}
} else {
return false;
}
return tilejsonValidateObject... | javascript | {
"resource": ""
} |
q63216 | _loop2 | test | function _loop2(_name) {
var klass = resolve(associations[_name].klass);
var data = associated[_name];
// clear association
if (!data) {
model[_name] = null;
return "continue";
}
if (associations[_name].type === 'hasOne') {
var other = (typeof data === "unde... | javascript | {
"resource": ""
} |
q63217 | handleErrors | test | function handleErrors(errors, data) {
const message = errors[0].message;
const error = new Error(`GraphQL Error: ${message}`);
error.rawError = errors;
error.rawData = data;
throw error;
} | javascript | {
"resource": ""
} |
q63218 | zip | test | function zip(zipFile, srcList, dstPath) {
if (!dstPath) {
dstPath = false;
}
const output = fs.createWriteStream(zipFile);
const archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
});
return new Promise((resolve, reject) => {
output.on('close', function() {
retu... | javascript | {
"resource": ""
} |
q63219 | exec | test | function exec(cmd, verbose) {
verbose = verbose === false ? verbose : true;
const stdout = execSync(cmd);
if (verbose) {
console.log(stdout.toString());
}
return stdout;
} | javascript | {
"resource": ""
} |
q63220 | fileToString | test | function fileToString(file) {
try {
const stat = fs.lstatSync(file);
if (stat.isFile()) {
const content = fs.readFileSync(file, 'utf8');
return content.toString();
}
}
catch (e) {
if (!e.message.includes('ENOENT') && !e.message.includes('name too long, lstat')) {
throw e;
}
... | javascript | {
"resource": ""
} |
q63221 | mergeYamls | test | function mergeYamls(file1, file2) {
const obj1 = yaml.safeLoad(fileToString(file1), { schema: yamlfiles.YAML_FILES_SCHEMA });
const obj2 = yaml.safeLoad(fileToString(file2), { schema: yamlfiles.YAML_FILES_SCHEMA });
return yaml.safeDump(merge({}, obj1, obj2));
} | javascript | {
"resource": ""
} |
q63222 | loadKesOverride | test | function loadKesOverride(kesFolder, kesClass = 'kes.js') {
let kesOverridePath = path.resolve(kesFolder, kesClass);
let KesOverride;
try {
KesOverride = require(kesOverridePath);
}
catch (e) {
// If the Kes override file exists, then the error occured when
// trying to parse the file, so re-throw... | javascript | {
"resource": ""
} |
q63223 | determineKesClass | test | function determineKesClass(options, Kes) {
let KesOverride;
// If there is a kes class specified, use that
const kesClass = get(options, 'kesClass');
if (kesClass) {
KesOverride = loadKesOverride(process.cwd(), kesClass);
}
else {
let kesFolder;
// Check if there is kes.js in the kes folder
... | javascript | {
"resource": ""
} |
q63224 | failure | test | function failure(e) {
if (e.message) {
console.log(e.message);
}
else {
console.log(e);
}
process.exit(1);
} | javascript | {
"resource": ""
} |
q63225 | getSystemBucket | test | function getSystemBucket(config) {
let bucket = get(config, 'buckets.internal');
if (bucket && typeof bucket === 'string') {
return bucket;
}
bucket = get(config, 'system_bucket');
if (bucket && typeof bucket === 'string') {
return bucket;
}
return undefined;
} | javascript | {
"resource": ""
} |
q63226 | buildNestedCfs | test | function buildNestedCfs(config, KesClass, options) {
const limit = pLimit(1);
if (config.nested_templates) {
const nested = config.nested_templates;
console.log('Nested templates are found!');
const ps = Object.keys(nested).map((name) => limit(() => {
console.log(`Compiling nested template for ${n... | javascript | {
"resource": ""
} |
q63227 | buildCf | test | function buildCf(options, cmd) {
const KesClass = utils.determineKesClass(options, Kes);
let parentConfig;
try {
parentConfig = new Config(options);
}
catch (e) {
return Promise.reject(e);
}
return buildNestedCfs(parentConfig, KesClass, options).then((config) => {
const kes = new KesClass(con... | javascript | {
"resource": ""
} |
q63228 | buildLambda | test | function buildLambda(options, cmd) {
if (cmd) {
const KesClass = utils.determineKesClass(options, Kes);
const config = new Config(options);
const kes = new KesClass(config);
kes.updateSingleLambda(cmd).then(r => utils.success(r)).catch(e => utils.failure(e));
}
else {
utils.failure(new Error('... | javascript | {
"resource": ""
} |
q63229 | sendResponse | test | function sendResponse(event, context, responseStatus, responseData) {
const responseBody = JSON.stringify({
Status: responseStatus,
Reason: 'See the details in CloudWatch Log Stream: ' + context.logStreamName,
PhysicalResourceId: context.logStreamName,
StackId: event.StackId,
RequestId: event.Requ... | javascript | {
"resource": ""
} |
q63230 | optionsToString | test | function optionsToString(options) {
return Object.keys(options)
.map(function processOption(key) {
return key + "=" + options[key];
})
.join(",");
} | javascript | {
"resource": ""
} |
q63231 | assign | test | function assign(target) {
var sources = Array.prototype.slice.call(arguments, 1);
function assignArgument(previous, source) {
Object.keys(source).forEach(function assignItem(key) {
previous[key] = source[key]; // eslint-disable-line no-param-reassign
});
return previous;
... | javascript | {
"resource": ""
} |
q63232 | openPopupWithPost | test | function openPopupWithPost(url, postData, name, options) {
var form = document.createElement("form");
var win;
form.setAttribute("method", "post");
form.setAttribute("action", url);
form.setAttribute("target", name);
Object.keys(postData).forEach(function addFormItem(key) {
var input =... | javascript | {
"resource": ""
} |
q63233 | popupExecute | test | function popupExecute(execute, url, name, options, callback) {
var popupName = name || defaultPopupName();
var popupOptions = optionsResolveCentered(assign({}, defaultOptions, options));
var popupCallback = callback || function noop() {};
var optionsString = optionsToString(popupOptions);
var win = ... | javascript | {
"resource": ""
} |
q63234 | popup | test | function popup(url, name, options, callback) {
return popupExecute(window.open, url, name, options, callback);
} | javascript | {
"resource": ""
} |
q63235 | popupWithPost | test | function popupWithPost(url, postData, name, options, callback) {
function openWithPostData(popupUrl, popupName, optionsString) {
return openPopupWithPost(popupUrl, postData, popupName, optionsString);
}
return popupExecute(openWithPostData, url, name, options, callback);
} | javascript | {
"resource": ""
} |
q63236 | getWrappingContentRange | test | function getWrappingContentRange(editor) {
if (editor.somethingSelected()) {
const sel = editor.listSelections().filter(sel => sel.anchor !== sel.head)[0];
if (sel) {
return comparePos(sel.anchor, sel.head) < 0
? { from: sel.anchor, to: sel.head }
: { from: sel.head, to: sel.anchor };
}
}
// Nothi... | javascript | {
"resource": ""
} |
q63237 | betweenTags | test | function betweenTags(editor, range) {
if (equalCursorPos(range.anchor, range.head)) {
const cursor = range.anchor;
const mode = editor.getModeAt(cursor);
if (mode.name === 'xml') {
const left = editor.getTokenAt(cursor);
const right = editor.getTokenAt(Object.assign({}, cursor, { ch: cursor.ch + 1 }));
... | javascript | {
"resource": ""
} |
q63238 | canExtract | test | function canExtract(editor, pos, config) {
const tokenType = editor.getTokenTypeAt(pos);
if (config.type === 'stylesheet') {
return tokenType !== 'comment' && tokenType !== 'string';
}
if (config.syntax === 'html') {
return tokenType === null;
}
if (config.syntax === 'slim' || config.syntax === 'pug') {
... | javascript | {
"resource": ""
} |
q63239 | getStylesheetCompletions | test | function getStylesheetCompletions(editor, pos, config) {
const line = editor.getLine(pos.line).slice(0, pos.ch);
const prefix = extractPrefix(line, /[\w-@$]/);
if (prefix) {
// Make sure that current position precedes element name (e.g. not attribute,
// class, id etc.)
const prefixRange = {
from: { line: ... | javascript | {
"resource": ""
} |
q63240 | getSnippetCompletions | test | function getSnippetCompletions(editor, pos, config) {
const { type, syntax } = config;
if (!editor.state.emmetCompletions) {
editor.state.emmetCompletions = {};
}
const cache = editor.state.emmetCompletions;
if (!(syntax in cache)) {
const registry = createSnippetsRegistry(type, syntax, config.snippets);
... | javascript | {
"resource": ""
} |
q63241 | getStylesheetSnippets | test | function getStylesheetSnippets(registry) {
return convertToCSSSnippets(registry).map(snippet => {
let preview = snippet.property;
const keywords = snippet.keywords();
if (keywords.length) {
preview += `: ${removeFields(keywords.join(' | '))}`;
} else if (snippet.value) {
preview += `: ${removeFields(snip... | javascript | {
"resource": ""
} |
q63242 | getMarkupSnippets | test | function getMarkupSnippets(registry, config) {
return registry.all({ type: 'string' }).map(snippet => ({
key: snippet.key,
value: snippet.value,
preview: removeFields(expand(snippet.value, config)),
snippet: snippet.key
}));
} | javascript | {
"resource": ""
} |
q63243 | extractPrefix | test | function extractPrefix(str, match) {
let offset = str.length;
while (offset > 0) {
if (!match.test(str[offset - 1])) {
break;
}
offset--;
}
return str.slice(offset);
} | javascript | {
"resource": ""
} |
q63244 | isValidMarker | test | function isValidMarker(editor, marker) {
const range = marker.find();
// No newlines inside abbreviation
if (range.from.line !== range.to.line) {
return false;
}
// Make sure marker contains valid abbreviation
let text = editor.getRange(range.from, range.to);
if (!text || /^\s|\s$/g.test(text)) {
return fa... | javascript | {
"resource": ""
} |
q63245 | test | function (property) {
var def = this._definition[property];
if (def.type === 'boolean') {
// if it's a bool, just flip it
this[property] = !this[property];
} else if (def && def.values) {
// If it's a property with an array of values
// skip to the... | javascript | {
"resource": ""
} | |
q63246 | test | function (attr) {
if (attr == null) return !!Object.keys(this._changed).length;
if (has(this._derived, attr)) {
return this._derived[attr].depList.some(function (dep) {
return this.hasChanged(dep);
}, this);
}
return has(this._changed, attr);
} | javascript | {
"resource": ""
} | |
q63247 | test | function (propertyName) {
if (!this._eventBubblingHandlerCache[propertyName]) {
this._eventBubblingHandlerCache[propertyName] = function (name, model, newValue) {
if (changeRE.test(name)) {
this.trigger('change:' + propertyName + '.' + name.split(':')[1], model, n... | javascript | {
"resource": ""
} | |
q63248 | createDerivedProperty | test | function createDerivedProperty(modelProto, name, definition) {
var def = modelProto._derived[name] = {
fn: isFunction(definition) ? definition : definition.fn,
cache: (definition.cache !== false),
depList: definition.deps || []
};
// add to our shared dependency list
def.depList... | javascript | {
"resource": ""
} |
q63249 | Image | test | function Image(image, address){
var at = this.attributes = image.attribs;
this.name = path.basename(at.src, path.extname(at.src));
this.saveTo = path.dirname(require.main.filename) + "/";
this.extension = path.extname(at.src);
this.address = url.resolve(address, at.src);
this.fromAddress = address;
} | javascript | {
"resource": ""
} |
q63250 | shipitTask | test | function shipitTask(grunt) {
'use strict';
// Init shipit
grunt.shipit = new Shipit();
grunt.registerTask('shipit', 'Shipit Task', function (env) {
var config = grunt.config.get('shipit');
grunt.shipit.environment = env;
// Support legacy options.
if (!config.default && config.options)
... | javascript | {
"resource": ""
} |
q63251 | injectTemplate | test | function injectTemplate (s, node, offset, id) {
const t = node.src ? readSrc(id, node.src) : node.content
// Compile template
const compiled = compiler.compile(t)
const renderFuncs = '\nrender: ' + toFunction(compiled.render) + ',' +
'\nstaticRenderFns: [' + compiled.staticRenderFns.map(toFunction).join(',... | javascript | {
"resource": ""
} |
q63252 | _defaultCheckSize | test | function _defaultCheckSize(size) {
return function (raw) {
if (raw.length < size) {
return false;
}
this.buffer = raw.substr(size);
return raw.substr(0, size);
};
} | javascript | {
"resource": ""
} |
q63253 | int64add5 | test | function int64add5(dst, a, b, c, d, e)
{
var w0 = (a.l & 0xffff) + (b.l & 0xffff) + (c.l & 0xffff) + (d.l & 0xffff) + (e.l & 0xffff);
var w1 = (a.l >>> 16) + (b.l >>> 16) + (c.l >>> 16) + (d.l >>> 16) + (e.l >>> 16) + (w0 >>> 16);
var w2 = (a.h & 0xffff) + (b.h & 0xffff) + (c.h & 0xffff) + (d.h & 0xffff) + (e.... | javascript | {
"resource": ""
} |
q63254 | test | function (configFile, options) {
DataStream.call(this);
this.options = options || {};
var self = this;
// apply config
this.configFile = configFile;
this.init();
// Bundles streams
this.bundles = {};
// Let return instance before build
this.buildConfig = this.compileConfig(co... | javascript | {
"resource": ""
} | |
q63255 | getSandboxMap | test | function getSandboxMap(ast) {
var map = {};
walker.with_walkers({
// looking for first var with sandbox item;
"var" : function (vars) {
for (var i = 0, c = vars.length, varItem; i < c; i++) {
varItem = vars[i];
if (varItem[... | javascript | {
"resource": ""
} |
q63256 | breakSandbox | test | function breakSandbox(ast, replaceMap) {
var sandboxName = ast[2][0] || 'sb';
var newAst = walker.with_walkers({
// lookup for dot
// looking for this pattern
// ["dot", ["name", "sb"], "require"] -> ["name", map["require"]]
"dot" : function () {
... | javascript | {
"resource": ""
} |
q63257 | test | function () {
if (isSandboxVariableWiped) {
return;
}
for (var i = 0, c = this[1].length, varItem; i < c; i++) {
varItem = this[1][i];
if (varItem[0] === 'sandbox') {
isSandboxVariableWip... | javascript | {
"resource": ""
} | |
q63258 | getEvents | test | function getEvents(ast) {
var usage = {},
eventIndex = 0;
walker.with_walkers({
// looking for first var with sandbox item;
"call" : function () {
if (this[1] && this[2][0]) {
var functionName = this[1][1];
swit... | javascript | {
"resource": ""
} |
q63259 | wipeLmdEvents | test | function wipeLmdEvents(ast) {
var itemsToWipe = ['lmd_on', 'lmd_trigger', 'lmd_events'];
return walker.with_walkers({
// wipe lmdEvents variables
"var": function () {
if (!itemsToWipe.length) {
return;
}
for (v... | javascript | {
"resource": ""
} |
q63260 | test | function () {
if (!itemsToWipe.length) {
return;
}
for (var i = 0, c = this[1].length, varItem; i < c; i++) {
varItem = this[1][i];
if (varItem) {
var itemIndex = itemsToWipe.indexOf(varI... | javascript | {
"resource": ""
} | |
q63261 | test | function (optionName, isApply, isInline) {
// /*if ($P.CSS || $P.JS || $P.ASYNC) {*/
var inlinePreprocessorBlock = isInline ? '/*if (' + optionName + ') {*/' : 'if (' + optionName + ') {',
bracesCounter = 0,
startIndex = lmd_js.indexOf(inlinePreprocessorBlock),
start... | javascript | {
"resource": ""
} | |
q63262 | test | function (e) {
if (isNotLoaded) {
isNotLoaded = 0;
// register or cleanup
link.removeAttribute('id');
if (!e) {
sb.trigger('*:request-error', moduleName, module);
}
... | javascript | {
"resource": ""
} | |
q63263 | d3_layout_hierarchyRebind | test | function d3_layout_hierarchyRebind(object, hierarchy) {
object.sort = d3.rebind(object, hierarchy.sort);
object.children = d3.rebind(object, hierarchy.children);
object.links = d3_layout_hierarchyLinks;
object.value = d3.rebind(object, hierarchy.value);
// If the new API is used, enabling inlining.
object.... | javascript | {
"resource": ""
} |
q63264 | position | test | function position(row, u, rect, flush) {
var i = -1,
n = row.length,
x = rect.x,
y = rect.y,
v = u ? round(row.area / u) : 0,
o;
if (u == rect.dx) { // horizontal subdivision
if (flush || v > rect.dy) v = v ? rect.dy : 0; // over+underflow
while (++i < n) {
... | javascript | {
"resource": ""
} |
q63265 | test | function(classes) {
var map = {};
function find(name, data) {
var node = map[name], i;
if (!node) {
node = map[name] = data || {name: name, children: []};
if (name.length) {
node.parent = find("");
... | javascript | {
"resource": ""
} | |
q63266 | stringify | test | function stringify(object) {
var properties = [];
for (var key in object) {
if (object.hasOwnProperty(key)) {
properties.push(quote(key) + ':' + getValue(object[key]));
}
}
return "{" + properties.join(",") + "}";
} | javascript | {
"resource": ""
} |
q63267 | countIf | test | function countIf() {
var self = this, ret;
if (self[0].start && analyzing.indexOf(self) < 0) {
var decision = self[1];
var lineId = self[0].name + ':' + (self[0].start.line + lineOffset);
self[1] = wrapCondition(decision, lineId);
// We are adding new lines, make sure code blocks are actual blocks
... | javascript | {
"resource": ""
} |
q63268 | wrapCondition | test | function wrapCondition(decision, lineId, parentPos) {
if (options.condition === false) {
// condition coverage is disabled
return decision;
}
if (isSingleCondition(decision)) {
var pos = getPositionStart(decision, parentPos);
var condId = lineId + ":" + pos;
analyzing.push(decision);
allCondit... | javascript | {
"resource": ""
} |
q63269 | isSingleCondition | test | function isSingleCondition(decision) {
if (decision[0].start && decision[0].name != "binary") {
return true;
} else if (decision[1] == "&&" || decision[1] == "||") {
return false;
} else {
return true;
}
} | javascript | {
"resource": ""
} |
q63270 | countLabel | test | function countLabel() {
var ret;
if (this[0].start && analyzing.indexOf(this) < 0) {
var content = this[2];
if (content[0].name == "for" && content[4] && content[4].name != "block") {
content[4] = [ "block", [content[4]]];
}
analyzing.push(content);
var ret = countLine.call(this);
analyzing... | javascript | {
"resource": ""
} |
q63271 | giveNameToAnonymousFunction | test | function giveNameToAnonymousFunction () {
var node = this;
if (node[0].name == "var" || node[0].name == "object") {
node[1].forEach(function (assignemt) {
if (assignemt[1]) {
if (assignemt[1][0].name === "function") {
assignemt[1][0].anonymousName = assignemt[0];
} else if (assignemt[1][0].n... | javascript | {
"resource": ""
} |
q63272 | wrapConditionals | test | function wrapConditionals () {
if (options.condition === false) {
// condition coverage is disabled
return;
}
var self = this, ret;
if (self[0].start && analyzing.indexOf(self) < 0) {
analyzing.push(self);
var lineId = self[0].name + ':' + (self[0].start.line + lineOffset);
self[1] = wrapCondit... | javascript | {
"resource": ""
} |
q63273 | test | function (name, deps, module) {
switch (arguments.length) {
case 1: // define(function () {})
module = name;
deps = name = sb.undefined;
break;
case 2: // define(['a', 'b'], function () {})
module = deps;
deps = name;
name = sb... | javascript | {
"resource": ""
} | |
q63274 | stats_calculate_coverage | test | function stats_calculate_coverage(moduleName) {
var stats = sb.trigger('*:stats-get', moduleName, null)[1],
total,
covered,
lineId,
lineNum,
parts;
var lineReport = {};
if (!stats.lines) {
return;
}
stats.coverage = {};
covered = 0;
total = ... | javascript | {
"resource": ""
} |
q63275 | test | function (config, mixins) {
if (Array.isArray(config.mixins) && Array.isArray(mixins)) {
config.mixins.push.apply(config.mixins, mixins);
return config;
}
return deepDestructableMerge(config, {
mixins: mixins
});
} | javascript | {
"resource": ""
} | |
q63276 | test | function (left, right) {
for (var prop in right) {
if (right.hasOwnProperty(prop)) {
if (typeof left[prop] === "object") {
deepDestructableMerge(left[prop], right[prop]);
} else {
left[prop] = right[prop];
}
}
}
return left... | javascript | {
"resource": ""
} | |
q63277 | test | function (config, configDir) {
config = config || {};
if (typeof config.extends !== "string") {
return config;
}
var parentConfig = tryExtend(readConfig(configDir, config.extends), configDir);
return deepDestructableMerge(parentConfig, config);
} | javascript | {
"resource": ""
} | |
q63278 | test | function (modulePath, dependsFileMask) {
modulePath = [].concat(modulePath);
return modulePath.map(function (modulePath) {
var fileName = modulePath.replace(/^.*\/|\.[a-z0-9]+$/g, '');
return path.join(path.dirname(modulePath), dependsFileMask.replace('*', fileName));
});
} | javascript | {
"resource": ""
} | |
q63279 | test | function (configA, configB, flagsNames, isMasterConfig) {
// Apply Flags
flagsNames.forEach(function (optionsName) {
// if master -> B
if (typeof configB[optionsName] === "undefined") {
return;
}
if (isMasterConfig) {
configA[optionsName] = configB[option... | javascript | {
"resource": ""
} | |
q63280 | addPluginsFromBundles | test | function addPluginsFromBundles(resultConfig) {
if (resultConfig.bundles) {
var bundles = Object.keys(resultConfig.bundles),
lmdPlugins = Object.keys(LMD_PLUGINS);
// Apply flags from bundles
bundles.forEach(function (bundleName) {
mergeFlags(resultConfig, resultConfi... | javascript | {
"resource": ""
} |
q63281 | test | function (code, options) {
var exports = [],
requires = [],
bind = [],
extra_exports = options.extra_exports,
extra_require = options.extra_require,
extra_bind = options.extra_bind,
exportCode,
bindModuleName;
// add exports to the module end
// extra... | javascript | {
"resource": ""
} | |
q63282 | test | function (code, moduleOptions, moduleType) {
switch (moduleType) {
case "3-party":
// create lmd module from non-lmd module
code = wrap3partyModule(code, moduleOptions);
break;
case "plain":
// wrap plain module
code = wrapPlainModule(code... | javascript | {
"resource": ""
} | |
q63283 | getModuleType | test | function getModuleType (code) {
var ast;
if (typeof code === "object") {
ast = code;
} else {
try {
JSON.parse(code);
return "json";
} catch (e) {}
try {
ast = parser.parse(code);
} catch (e) {
return "string";
... | javascript | {
"resource": ""
} |
q63284 | d3_transform | test | function d3_transform(m) {
var r0 = [m.a, m.b],
r1 = [m.c, m.d],
kx = d3_transformNormalize(r0),
kz = d3_transformDot(r0, r1),
ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz));
this.translate = [m.e, m.f];
this.rotate = Math.atan2(m.b, m.a) * d3_transformDegrees;
this.scale =... | javascript | {
"resource": ""
} |
q63285 | mousewheel | test | function mousewheel() {
start.apply(this, arguments);
if (!d3_behavior_zoomZooming) d3_behavior_zoomZooming = d3_behavior_zoomLocation(d3.svg.mouse(d3_behavior_zoomTarget));
d3_behavior_zoomTo(d3_behavior_zoomDelta() + xyz[2], d3.svg.mouse(d3_behavior_zoomTarget), d3_behavior_zoomZooming);
} | javascript | {
"resource": ""
} |
q63286 | d3_behavior_zoomDelta | test | function d3_behavior_zoomDelta() {
// mousewheel events are totally broken!
// https://bugs.webkit.org/show_bug.cgi?id=40441
// not only that, but Chrome and Safari differ in re. to acceleration!
if (!d3_behavior_zoomDiv) {
d3_behavior_zoomDiv = d3.select("body").append("div")
.style("visibility", ... | javascript | {
"resource": ""
} |
q63287 | test | function (data) {
var config;
// case data is argv string
if (typeof data === "string") {
// try to parse new version
config = parseArgv(data);
// its new config argv string
if (Object.keys(config).length) {
// translate short params to long one
conf... | javascript | {
"resource": ""
} | |
q63288 | parse | test | function parse (options, document, callback) {
xml2js.parseString(document, {
trim: true,
normalizeTags: true,
normalize: true
}, function (err, result) {
var source = options.source;
if (!err) {
// Process the url input, but break if base.input returns false.
// In other words, ... | javascript | {
"resource": ""
} |
q63289 | convert | test | function convert(options, buffer, next, callback) {
var gunzip = path.extname(options.source) === ".gz";
if (gunzip) {
zlib.gunzip(buffer, function (err, result) {
if (err) {
callback(common.prependMsgToErr(err, options.source, true));
} else {
next(options, result && result.toStrin... | javascript | {
"resource": ""
} |
q63290 | getUrl | test | function getUrl (options, parseFn, callback) {
request({
url: options.source,
encoding: null,
timeout: options.timeout() // get the default timeout
}, function (err, res, body) {
var error = err || common.checkResponse(res, ["text/xml", "application/xml"]);
if (error) {
callback(common.pr... | javascript | {
"resource": ""
} |
q63291 | getFile | test | function getFile (options, parseFn, callback) {
fs.readFile(options.source, function (err, data) {
if (err) {
callback(common.prependMsgToErr(err, options.source, true));
} else {
convert(options, data, parseFn, callback);
}
});
} | javascript | {
"resource": ""
} |
q63292 | test | function (error, message, quoteInput) {
var result, prepend, empty = "", quote = "'";
if (error) {
if (message) {
prepend = quoteInput ? empty.concat(quote, message, quote) : message;
}
// Force Error instance, coerce given error to a string
error = error instanceof Error ? err... | javascript | {
"resource": ""
} | |
q63293 | test | function (res, mediaTypes) {
var contentTypeOk,
result = "status: '" + res.statusCode + "', GET failed.";
mediaTypes = !Array.isArray(mediaTypes) ? [mediaTypes] : mediaTypes;
if (res.statusCode === 200) {
// if content-type exists, and media type found then contentTypeOk
contentTypeOk ... | javascript | {
"resource": ""
} | |
q63294 | nodeCall | test | function nodeCall (nodeFunc /* args... */) {
var nodeArgs = Array.prototype.slice.call(arguments, 1);
return new Promise(function (resolve, reject) {
/**
* Resolve a node callback
*/
function nodeResolver (err, value) {
if (err) {
reject(err);
} else {
resolve(value);
... | javascript | {
"resource": ""
} |
q63295 | prepareWrite | test | function prepareWrite (outputPath, callback) {
var path = pathLib.parse(outputPath);
var dir = pathLib.join(path.root, path.dir);
mkdirp(dir, callback);
} | javascript | {
"resource": ""
} |
q63296 | parse | test | function parse (options, document, callback) {
xml2js.parseString(document, {
trim: true,
normalizeTags: true,
normalize: true
}, function (err, result) {
var sitemapUrls = [];
var sitemapIndexOptions = Object.assign({}, options, {
outputPath: undefined
});
if (!err) {
// Ch... | javascript | {
"resource": ""
} |
q63297 | test | function (options, listener) {
var opts = Object.assign({}, base.defaults(defaults), options);
return base.run(opts, generateInput, listener);
} | javascript | {
"resource": ""
} | |
q63298 | generateInput | test | function generateInput (options) {
return nodeCall(
fs.readFile,
options.source
)
.catch(function (err) {
options._abort(err);
})
.then(function (data) {
var error;
if (data) {
data.toString().split('\n').every(function (line) {
var page = line.replace(/^\s+|... | javascript | {
"resource": ""
} |
q63299 | generateInput | test | function generateInput (options) {
var result = new Promise(function (resolve, reject) {
var all;
if (Array.isArray(options.source)) {
all = options.source.every(function (sourceUrl) {
var url = urlm.parse(sourceUrl);
var opts = Object.assign({}, options, {
protocol: url.proto... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.