_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q58800 | $version | validation | function $version(byte) {
version = (version << 8) | byte;
if (++offset < 4) return $version;
if (version >= 2 && version <= 3) {
offset = 0;
return $num;
}
throw new Error("Invalid version number " + num);
} | javascript | {
"resource": ""
} |
q58801 | $num | validation | function $num(byte) {
num = (num << 8) | byte;
if (++offset < 4) return $num;
offset = 0;
emit({version: version, num: num});
return $header;
} | javascript | {
"resource": ""
} |
q58802 | emitObject | validation | function emitObject() {
var body = bodec.join(parts);
if (body.length !== length) {
throw new Error("Body length mismatch");
}
var item = {
type: numToType[type],
size: length,
body: body,
offset: start
};
if (ref) item.ref = ref;
parts.length = 0;
start = 0... | javascript | {
"resource": ""
} |
q58803 | $body | validation | function $body(byte, i, chunk) {
if (inf.write(byte)) return $body;
var buf = inf.flush();
if (buf.length !== length) throw new Error("Length mismatch, expected " + length + " got " + buf.length);
inf.recycle();
if (buf.length) {
parts.push(buf);
}
emitObject();
// If this was all ... | javascript | {
"resource": ""
} |
q58804 | $checksum | validation | function $checksum(byte) {
checksum += toHex(byte);
if (++offset < 20) return $checksum;
var actual = sha1sum.digest();
if (checksum !== actual) throw new Error("Checksum mismatch: " + actual + " != " + checksum);
} | javascript | {
"resource": ""
} |
q58805 | validation | function(elem) {
var pattern = new RegExp(_filterValue, 'i');
var element = elem;
if (pattern.test(element.textContent)) {
element.style.display = '';
} else {
element.style.display = 'none';
}
} | javascript | {
"resource": ""
} | |
q58806 | validation | function() {
var collection = _logContainer.childNodes;
var i = collection.length;
if (i === 0) {
return;
}
while (i) {
_filterElement(collection[i - 1]);
i -= 1;
}
window.scrollTo(0, document.body.scrollHeight);
} | javascript | {
"resource": ""
} | |
q58807 | validation | function(filterInput, uri) {
var _url = new URL(uri);
var _filterValueFromURL = _url.searchParams.get('filter');
if (typeof _filterValueFromURL !== 'undefined' && _filterValueFromURL !== null) {
_filterValue = _filterValueFromURL;
filterInput.value = _filterValue; // eslint-disable-line
}
... | javascript | {
"resource": ""
} | |
q58808 | validation | function(value, uri) {
var _url = new URL(uri);
var _params = new URLSearchParams(_url.search.slice(1));
if (value === '') {
_params.delete('filter');
} else {
_params.set('filter', value);
}
_url.search = _params.toString();
window.history.replaceState(null, document.title, _url... | javascript | {
"resource": ""
} | |
q58809 | init | validation | function init(opts) {
var self = this;
// Elements
_logContainer = opts.container;
_filterInput = opts.filterInput;
_filterInput.focus();
_topbar = opts.topbar;
_body = opts.body;
_setFilterValueFromURL(_filterInput, window.location.toString());
// Filter input b... | javascript | {
"resource": ""
} |
q58810 | validation | function (bBox) {
var size = Math.max(bBox[3], bBox[4], bBox[5]);
var ratio = Math.max(viewer._width, viewer._height) / Math.min(viewer._width, viewer._height);
viewer._distance = size / Math.tan(viewer.perspectiveCamera.fov * Math.PI / 180.0) * ratio * 1.0;
} | javascript | {
"resource": ""
} | |
q58811 | handleMouseDown | validation | function handleMouseDown(event) {
mouseDown = true;
lastMouseX = event.clientX;
lastMouseY = event.clientY;
startX = event.clientX;
startY = event.clientY;
//get coordinates within canvas (with the right orientation)
var r = viewer._canvas.getBoundingClientRect()... | javascript | {
"resource": ""
} |
q58812 | clone | validation | function clone(obj) {
var key, copy = {};
if (!obj) {
return;
}
for (key in obj) {
copy[key] = obj[key];
}
return copy;
} | javascript | {
"resource": ""
} |
q58813 | navigate | validation | function navigate(n) {
var position = currentPosition();
var numSlides = document.getElementsByClassName('slide').length;
/* Positions are 1-indexed, so we need to add and subtract 1 */
var nextPosition = (position - 1 + n) % numSlides + 1;
/* Normalize nextPosition in-case of a negative modulo result */
... | javascript | {
"resource": ""
} |
q58814 | updateURL | validation | function updateURL() {
try {
window.history.replaceState({} , null, '#' + currentPosition());
} catch (e) {
window.location.hash = currentPosition();
}
} | javascript | {
"resource": ""
} |
q58815 | updateProgress | validation | function updateProgress() {
var progressBar = document.querySelector('.progress-bar');
if (progressBar !== null) {
var numSlides = document.getElementsByClassName('slide').length;
var position = currentPosition() - 1;
var percent = (numSlides === 1) ? 100 : 100 * position / (numSlides - 1);
progres... | javascript | {
"resource": ""
} |
q58816 | updateTabIndex | validation | function updateTabIndex() {
var allLinks = document.querySelectorAll('.slide a');
var position = currentPosition();
var currentPageLinks = document.getElementById('slide-' + position).querySelectorAll('a');
var i;
for (i = 0; i < allLinks.length; i++) {
allLinks[i].setAttribute('tabindex', -1);
}
fo... | javascript | {
"resource": ""
} |
q58817 | pluck | validation | function pluck(obj, fields) {
var plucked = {};
if (!obj) {
return;
}
fields.forEach(function (field) {
plucked[field] = obj[field];
});
return plucked;
} | javascript | {
"resource": ""
} |
q58818 | loadSingle | validation | function loadSingle(source) {
var promise;
if (source.match(/^https?:\/\//)) {
promise = httpGetPromise(source);
} else {
promise = readFilePromise(normalizePath(source));
}
return promise;
} | javascript | {
"resource": ""
} |
q58819 | populateSingle | validation | function populateSingle(filename, destination, key) {
return loadSingle(filename)
.then(function (data) {
if (data) {
/**
* If the key points to an array in the destination map, then
* we should also append to an array in the `loaded` section
* of the map.
*
... | javascript | {
"resource": ""
} |
q58820 | load | validation | function load(map, options) {
var promises = [];
var loaded = {};
var filename;
options = options || {};
for (var key in map) {
if (map.hasOwnProperty(key)) {
if (!map[key] || map[key].length === 0) {
continue;
}
filename = map[key];
if (!options.external) {
file... | javascript | {
"resource": ""
} |
q58821 | loadSettings | validation | function loadSettings(source, ctx) {
return loadSingle(source).then(function (data) {
if (data) {
data = JSON.parse(data);
ctx.override = data.override;
}
});
} | javascript | {
"resource": ""
} |
q58822 | readFilePromise | validation | function readFilePromise(filename) {
var deferred;
deferred = Q.defer();
fs.readFile(filename, 'utf-8', function (err, contents) {
if (err) {
if (err.code === 'ENOENT') {
debug(err.code + ': ' + filename);
return deferred.resolve();
}
debug(err + ' ' + filename);
// T... | javascript | {
"resource": ""
} |
q58823 | httpGetPromise | validation | function httpGetPromise(url) {
var deferred = Q.defer(), get;
var cb = function (res) {
var data = '';
res.on('data', function (chunk) {
data += chunk;
});
res.on('err', function (err) {
debug(err + ' ' + url);
deferred.reject(err);
});
res.on('end', function () {
... | javascript | {
"resource": ""
} |
q58824 | getUserHome | validation | function getUserHome() {
return process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
} | javascript | {
"resource": ""
} |
q58825 | Request | validation | function Request(method, urlPath, cache) {
this._method = method;
this._urlPath = urlPath;
this._cache = cache;
this._queryParams = [];
// _postParams should initially be null instead of {} because we want to allow people to send POST requests with
// empty data sets (if they need to). This way, we can differen... | javascript | {
"resource": ""
} |
q58826 | logRequestError | validation | function logRequestError(err) {
var {response} = err;
if (!response) {
logger.warning(`ReactServerAgent raised exception for URL ${this._urlPath}`, err);
} else if (response.notFound) {
// 404? don't care about response
logger.warning(`Resource not found on server: ${this._urlPath}`);
} else if (response.ser... | javascript | {
"resource": ""
} |
q58827 | validation | function(fn, opts, trim, basePath, prefix){
var slashPattern = isWindows
?/\\/g
:/\//g
var name = fn.substring(basePath.length+trim.length, fn.length)
.replace(/\.jsx?$/, '')
.replace(slashPattern,'.')
if (opts.label) {
name += '.'+opts.label
}
if (prefix) {
name = prefix + name
}
return name;
} | javascript | {
"resource": ""
} | |
q58828 | writeBody | validation | function writeBody(req, res, context, start, page) {
// standardize to an array of EarlyPromises of ReactElements
var elementPromises = PageUtil.standardizeElements(page.getElements());
// This is where we'll store our rendered HTML strings. A value of
// `undefined` means we haven't rendered that element yet.
... | javascript | {
"resource": ""
} |
q58829 | writeElements | validation | function writeElements(res, elements) {
// Pick up where we left off.
var start = RLS().nextElement||(RLS().nextElement=0);
for (var i = start; i < elements.length; RLS().nextElement = ++i){
// If we haven't rendered the next element yet, we're done.
if (elements[i] === ELEMENT_PENDING) break;
// Got one!
... | javascript | {
"resource": ""
} |
q58830 | makeStandard | validation | function makeStandard(standardize, fn){
return function(){
return standardize(fn.apply(null, [].slice.call(arguments)));
}
} | javascript | {
"resource": ""
} |
q58831 | validation | function (state, title, url) {
var win = this.win;
if (this.canClientNavigate()) {
win.history.pushState(state, title, url);
} else {
this.navigationWindow().location.href = url;
}
} | javascript | {
"resource": ""
} | |
q58832 | validation | function (state, title, url) {
var win = this.win;
if (this.canClientNavigate()) {
win.history.replaceState(state, title, url);
} else if (url !== this.currentUrl()) {
// On browsers that don't support history navigation, only want to
// replace state if the URL is actually changing. Otherwise we're
... | javascript | {
"resource": ""
} | |
q58833 | writeClientBootstrapFile | validation | function writeClientBootstrapFile(outputDir, opts) {
const outputFile = outputDir + "/entry.js";
fs.writeFileSync(outputFile, `
import reactServer from "react-server";
import routes from "./routes_client";
if (typeof window !== "undefined") {
window.__setReactServerBase = (path) => {
__webpack_p... | javascript | {
"resource": ""
} |
q58834 | errorInterceptor | validation | function errorInterceptor (level, msg, meta) {
if (meta instanceof Error) {
meta = {error: meta};
} else if (meta && meta.status && meta.response) {
meta = {error: meta};
}
if (_.isPlainObject(meta)) {
// allow {error: <someError>} as a valid `meta`
meta = _.mapValues(meta, normalizeError);
}
return met... | javascript | {
"resource": ""
} |
q58835 | normalizeError | validation | function normalizeError (err) {
if (err instanceof Error) {
return _.pickBy({
message: err.message,
stack: err.stack,
}, val => !_.isEmpty(val));
}
if (err && err.status && err.response) {
// this is probably a superagent error response. we definitely don't
// want to log the whole thing
return {
... | javascript | {
"resource": ""
} |
q58836 | wrapLogger | validation | function wrapLogger(getLoggerForConfig, opts) {
var mainLogger = getLoggerForConfig('main', opts)
, timeLogger = getLoggerForConfig('time', opts)
, gaugeLogger = getLoggerForConfig('gauge', opts)
, classifyTime = makeTimeClassifier(opts)
, classifyGauge = makeGaugeClassifier(opts)
// Thes... | javascript | {
"resource": ""
} |
q58837 | makeThresholdsSieve | validation | function makeThresholdsSieve(options, defaults) {
if (!options) options = {};
// Pre-apply defaults.
Object.keys(defaults).forEach(key => options[key] || (options[key] = defaults[key]));
return (key, overrides) => {
if (overrides && overrides[key] !== void 0) return overrides[key];
return options[key];
}
} | javascript | {
"resource": ""
} |
q58838 | merge_objs | validation | function merge_objs(source,target) {
for (var k in source) { if (source.hasOwnProperty(k)) {
target[k] = source[k]; // TODO: does this need to be recursive for our purposes?
}}
return target;
} | javascript | {
"resource": ""
} |
q58839 | check_chain_group_scripts_ready | validation | function check_chain_group_scripts_ready(chain_group) {
var any_scripts_ready = false;
for (var i=0; i<chain_group.scripts.length; i++) {
if (chain_group.scripts[i].ready && chain_group.scripts[i].exec_trigger) {
any_scripts_ready = true;
chain_group.scripts[i].exec_trigger();
chain_group.scripts[i].... | javascript | {
"resource": ""
} |
q58840 | create_script_load_listener | validation | function create_script_load_listener(elem,registry_item,flag,onload) {
elem.onload = elem.onreadystatechange = function() {
if ((elem.readyState && elem.readyState != "complete" && elem.readyState != "loaded") || registry_item[flag]) return;
elem.onload = elem.onreadystatechange = null;
onload();
};
} | javascript | {
"resource": ""
} |
q58841 | script_executed | validation | function script_executed(registry_item) {
registry_item.ready = registry_item.finished = true;
for (var i=0; i<registry_item.finished_listeners.length; i++) {
registry_item.finished_listeners[i]();
}
registry_item.ready_listeners = [];
registry_item.finished_listeners = [];
} | javascript | {
"resource": ""
} |
q58842 | request_script | validation | function request_script(chain_opts,script_obj,registry_item,onload,preload_this_script) {
// setTimeout() "yielding" prevents some weird race/crash conditions in older browsers
setTimeout(function(){
var script, src = script_obj.real_src, xhr;
// don't proceed until `append_to` is ready to append to
if ("... | javascript | {
"resource": ""
} |
q58843 | execute_preloaded_script | validation | function execute_preloaded_script(chain_opts,script_obj,registry_item) {
var script;
function preload_execute_finished() {
if (script != null) { // make sure this only ever fires once
script = null;
script_executed(registry_item);
}
}
if (registry[script_obj.src].finished) return;
if ... | javascript | {
"resource": ""
} |
q58844 | do_script | validation | function do_script(chain_opts,script_obj,chain_group,preload_this_script) {
var registry_item,
registry_items,
ready_cb = function(){ script_obj.ready_cb(script_obj,function(){ execute_preloaded_script(chain_opts,script_obj,registry_item); }); },
finished_cb = function(){ script_obj.finished_cb(script_ob... | javascript | {
"resource": ""
} |
q58845 | validation | function(){
registry_item.ready = true;
for (var i=0; i<registry_item.ready_listeners.length; i++) {
registry_item.ready_listeners[i]();
}
registry_item.ready_listeners = [];
} | javascript | {
"resource": ""
} | |
q58846 | chain_script_ready | validation | function chain_script_ready(script_obj,exec_trigger) {
if (chain_opts[_Debug]) log_msg("script preload finished: "+script_obj.real_src);
script_obj.ready = true;
script_obj.exec_trigger = function() {
if (chain_opts[_Debug]) log_msg("script execute start: "+script_obj.real_src);
exec_trigger();
... | javascript | {
"resource": ""
} |
q58847 | chain_script_executed | validation | function chain_script_executed(script_obj,chain_group) {
if (chain_opts[_Debug]) log_msg("script execution finished: "+script_obj.real_src);
script_obj.ready = script_obj.finished = true;
script_obj.exec_trigger = null;
// check if chain group is all finished
for (var i=0; i<chain_group.scripts.leng... | javascript | {
"resource": ""
} |
q58848 | advance_exec_cursor | validation | function advance_exec_cursor() {
if (chain_is_corked) return;
while (exec_cursor < chain.length) {
if (is_func(chain[exec_cursor])) {
if (chain_opts[_Debug]) log_msg("$LAB.wait() executing: "+chain[exec_cursor]);
try { chain[exec_cursor++](); } catch (err) {
if (chain_opts[_Debug]) log_e... | javascript | {
"resource": ""
} |
q58849 | init_script_chain_group | validation | function init_script_chain_group() {
if (!group || !group.scripts) {
chain.push(group = {scripts:[],finished:true});
}
} | javascript | {
"resource": ""
} |
q58850 | validation | function(){
if (arguments.length > 0) {
for (var i=0; i<arguments.length; i++) {
chain.push(arguments[i]);
}
group = chain[chain.length-1];
}
else group = false;
advance_exec_cursor();
return chainedAPI;
} | javascript | {
"resource": ""
} | |
q58851 | build | validation | function build() {
console.log('Creating an optimized production build...');
webpack(config).run((err) => {
if (err) {
console.error('Failed to create a production build. Reason:');
console.error(err.message || err);
process.exit(1);
}
console.log(chalk.green('Compiled successfully.')... | javascript | {
"resource": ""
} |
q58852 | findLogPath | validation | function findLogPath(appName, fileName) {
fileName = fileName || 'log.log';
var userData = appName ? null : utils.getUserData();
appName = appName || getAppName();
var homeDir = os.homedir ? os.homedir() : process.env.HOME;
var dir;
switch (process.platform) {
case 'darwin': {
dir = prepareDir(h... | javascript | {
"resource": ""
} |
q58853 | format | validation | function format(msg, formatter, electronLog, removeStyles) {
removeStyles = removeStyles !== undefined ? removeStyles : false;
if (typeof formatter === 'function') {
return formatter(msg, electronLog);
}
var date = new Date(msg.date || Date.now());
var variables = msg.variables;
var result = formatter... | javascript | {
"resource": ""
} |
q58854 | loadPackageName | validation | function loadPackageName() {
var packageFile;
try {
if (require.main.filename) {
packageFile = find(path.dirname(require.main.filename));
}
} catch (e) {
packageFile = null;
}
if (!packageFile && process.resourcesPath) {
packageFile = find(path.join(process.resourcesPath, 'app.asar'));... | javascript | {
"resource": ""
} |
q58855 | generateTypedocDocs | validation | function generateTypedocDocs(typedocDocsDir) {
const publicApiConfigFile = path.resolve(__dirname, '../src/ng5-slider/lib/public_api.json');
const publicApiConfig = JSON.parse(fs.readFileSync(publicApiConfigFile, { encoding: 'utf8' }));
const files = publicApiConfig.exports
.map(exportDef => path.resolve(__d... | javascript | {
"resource": ""
} |
q58856 | generateComponent | validation | function generateComponent(typedocHtmlFile, relativeTypedocHtmlFile, demoAppDocsModuleDir) {
const directory = path.dirname(relativeTypedocHtmlFile);
mkdirp.sync(path.join(demoAppDocsModuleDir, directory));
const fileName = path.basename(relativeTypedocHtmlFile);
const componentHtmlFileName = fileName.replace(... | javascript | {
"resource": ""
} |
q58857 | generateComponentName | validation | function generateComponentName(fileName) {
const bareName = fileName.replace(/\.html$/, '').replace(/[._]/g, '');
return bareName.charAt(0).toUpperCase() + bareName.substr(1) + 'Component';
} | javascript | {
"resource": ""
} |
q58858 | generateModuleFile | validation | function generateModuleFile(componentsMetadata, demoAppDocsModuleDir) {
const imports = componentsMetadata
.map(componentMetadata => `import { ${componentMetadata.name} } from './${componentMetadata.file}';`)
.join('\n');
const components = componentsMetadata
.map(componentMetadata => ` ${componentM... | javascript | {
"resource": ""
} |
q58859 | generatePackageJson | validation | function generatePackageJson() {
const mainFile = path.resolve(__dirname, '../package.json');
const libTemplateFile = path.resolve(__dirname, '../src/ng5-slider/package.json.template');
const libFile = path.resolve(__dirname, '../src/ng5-slider/package.json');
const libTemplateConfig = JSON.parse(fs.readFileSy... | javascript | {
"resource": ""
} |
q58860 | generatePublicApiTs | validation | function generatePublicApiTs() {
const configFile = path.resolve(__dirname, '../src/ng5-slider/lib/public_api.json');
const tsFile = path.resolve(__dirname, '../src/ng5-slider/lib/public_api.ts');
const config = JSON.parse(fs.readFileSync(configFile, { encoding: 'utf8' }));
let tsFileContent = '';
for (let... | javascript | {
"resource": ""
} |
q58861 | readdirRecursivelySync | validation | function readdirRecursivelySync(dir) {
let results = [];
const list = fs.readdirSync(dir);
for (let file of list) {
file = path.resolve(dir, file);
const stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(readdirRecursivelySync(file));
} else {
results... | javascript | {
"resource": ""
} |
q58862 | copyReadmeMd | validation | function copyReadmeMd(sourceReadmeMd) {
const libReadmeFile = path.resolve(__dirname, '../src/ng5-slider/README.md');
const sourceReadme = fs.readFileSync(sourceReadmeMd, { encoding: 'utf8'});
fs.writeFileSync(libReadmeFile, sourceReadme, {encoding: 'utf8'});
} | javascript | {
"resource": ""
} |
q58863 | generateTemplate | validation | function generateTemplate(templateFile, snippetsDir) {
const titleTemplateFile = templateFile.replace('.template.html', '.title-template.html');
const outputTemplateFile = templateFile.replace('.template.html', '.html');
const codeFile = templateFile.replace('.template.html', '.ts');
const styleFile = templateF... | javascript | {
"resource": ""
} |
q58864 | highlight | validation | function highlight(code, lang) {
return prism.highlight(code.trim(), prism.languages[lang]);
} | javascript | {
"resource": ""
} |
q58865 | tabHtml | validation | function tabHtml(tabTitle, codeContent, codeLang) {
return `<ngb-tab title="${escape(tabTitle)}">
<ng-template ngbTabContent>
<pre class="language-${codeLang}"><code class="language-${codeLang}">${escapeBraces(highlight(codeContent, codeLang))}</code></pre>
</ng-template>
</ngb-tab>`;
} | javascript | {
"resource": ""
} |
q58866 | nomalizeScope | validation | function nomalizeScope(initialScope, node) {
let scope = getInnermostScope(initialScope, node)
while (scope && scope.block === node) {
scope = scope.upper
}
return scope
} | javascript | {
"resource": ""
} |
q58867 | merge | validation | function merge(x, y) {
for (const key of Object.keys(y)) {
if (typeof x[key] === "function") {
if (x[key]._handlers == null) {
const fs = [x[key], y[key]]
x[key] = dispatch.bind(null, fs)
x[key]._handlers = fs
} else {
x... | javascript | {
"resource": ""
} |
q58868 | defineVisitor | validation | function defineVisitor(context, options) {
const testInfoPrototype = {
get isStrict() {
return nomalizeScope(context.getScope(), this.node).isStrict
},
}
/**
* Check whether a given case object is full-supported on the configured node version.
* @param {{supported:stri... | javascript | {
"resource": ""
} |
q58869 | isNotSupportingVersion | validation | function isNotSupportingVersion(aCase) {
return (
!aCase.supported ||
options.version.intersects(getSemverRange(`<${aCase.supported}`))
)
} | javascript | {
"resource": ""
} |
q58870 | isNotSupportingOn | validation | function isNotSupportingOn(node) {
return aCase =>
isNotSupportingVersion(aCase) &&
(!aCase.test || aCase.test({ node, __proto__: testInfoPrototype }))
} | javascript | {
"resource": ""
} |
q58871 | readPackageJson | validation | function readPackageJson(dir) {
const filePath = path.join(dir, "package.json")
try {
const text = fs.readFileSync(filePath, "utf8")
const data = JSON.parse(text)
if (typeof data === "object" && data !== null) {
data.filePath = filePath
return data
}
... | javascript | {
"resource": ""
} |
q58872 | get | validation | function get(option) {
if (option && option.allowModules && Array.isArray(option.allowModules)) {
return option.allowModules.map(String)
}
return null
} | javascript | {
"resource": ""
} |
q58873 | getTopAssignment | validation | function getTopAssignment(leafNode) {
let node = leafNode
// Skip MemberExpressions.
while (
node.parent.type === "MemberExpression" &&
node.parent.object === node
) {
node = node.parent
}
// Check assignments.
if (!isAssignee(node)) {
return null
}
... | javascript | {
"resource": ""
} |
q58874 | getModuleExportsNodes | validation | function getModuleExportsNodes(scope) {
const variable = scope.set.get("module")
if (variable == null) {
return []
}
return variable.references
.map(reference => reference.identifier.parent)
.filter(
node =>
node.type === "MemberExpression" &&
... | javascript | {
"resource": ""
} |
q58875 | getExportsNodes | validation | function getExportsNodes(scope) {
const variable = scope.set.get("exports")
if (variable == null) {
return []
}
return variable.references.map(reference => reference.identifier)
} | javascript | {
"resource": ""
} |
q58876 | getLocation | validation | function getLocation(node) {
const token = sourceCode.getTokenAfter(node)
return {
start: node.loc.start,
end: token.loc.end,
}
} | javascript | {
"resource": ""
} |
q58877 | enforceModuleExports | validation | function enforceModuleExports() {
const globalScope = context.getScope()
const exportsNodes = getExportsNodes(globalScope)
const assignList = batchAssignAllowed
? createAssignmentList(getModuleExportsNodes(globalScope))
: []
for (const nod... | javascript | {
"resource": ""
} |
q58878 | enforceExports | validation | function enforceExports() {
const globalScope = context.getScope()
const exportsNodes = getExportsNodes(globalScope)
const moduleExportsNodes = getModuleExportsNodes(globalScope)
const assignList = batchAssignAllowed
? createAssignmentList(exportsNodes)
... | javascript | {
"resource": ""
} |
q58879 | filterNeverIgnoredFiles | validation | function filterNeverIgnoredFiles(p) {
const basedir = path.dirname(p.filePath)
const mainFilePath =
typeof p.main === "string" ? path.join(basedir, p.main) : null
return filePath =>
path.join(basedir, filePath) !== mainFilePath &&
filePath !== "package.json" &&
!NEVER_IGNORE... | javascript | {
"resource": ""
} |
q58880 | normalizeValue | validation | function normalizeValue(x) {
if (Array.isArray(x)) {
return x
}
return Object.keys(x).map(pattern => ({
include: [pattern],
exclude: [],
replace: x[pattern],
}))
} | javascript | {
"resource": ""
} |
q58881 | createMatch | validation | function createMatch(includePatterns, excludePatterns) {
const include = includePatterns.map(pattern => new Minimatch(pattern))
const exclude = excludePatterns.map(pattern => new Minimatch(pattern))
return filePath =>
include.some(m => m.match(filePath)) &&
!exclude.some(m => m.match(filePa... | javascript | {
"resource": ""
} |
q58882 | combine | validation | function combine(converters) {
return filePath => {
for (const converter of converters) {
if (converter.match(filePath)) {
return converter.convert(filePath)
}
}
return filePath
}
} | javascript | {
"resource": ""
} |
q58883 | parse | validation | function parse(option) {
if (
!option ||
!option.convertPath ||
typeof option.convertPath !== "object"
) {
return null
}
const converters = []
for (const pattern of normalizeValue(option.convertPath)) {
const include = toStringArray(pattern.include)
c... | javascript | {
"resource": ""
} |
q58884 | toName | validation | function toName(type, path) {
const baseName = path.join(".")
return type === ReferenceTracker.CALL
? `${baseName}()`
: type === ReferenceTracker.CONSTRUCT
? `new ${baseName}()`
: baseName
} | javascript | {
"resource": ""
} |
q58885 | reportItem | validation | function reportItem(node, name, info) {
context.report({
node,
loc: node.loc,
message:
"{{name}} was deprecated since v{{version}}{{replace}}.",
data: {
name,
version: info.since,
... | javascript | {
"resource": ""
} |
q58886 | get | validation | function get(option) {
if (option && option.tryExtensions && Array.isArray(option.tryExtensions)) {
return option.tryExtensions.map(String)
}
return null
} | javascript | {
"resource": ""
} |
q58887 | getDefaultVersion | validation | function getDefaultVersion(filename) {
const info = getPackageJson(filename)
const nodeVersion = info && info.engines && info.engines.node
return semver.validRange(nodeVersion) || DEFAULT_VERSION
} | javascript | {
"resource": ""
} |
q58888 | getIgnoresEnum | validation | function getIgnoresEnum() {
return Object.keys(
OPTIONS.reduce((retv, key) => {
for (const alias of FEATURES[key].alias) {
retv[alias] = true
}
retv[key] = true
return retv
}, Object.create(null))
)
} | javascript | {
"resource": ""
} |
q58889 | isIgnored | validation | function isIgnored(key, ignores) {
return (
ignores.indexOf(key) !== -1 ||
FEATURES[key].alias.some(alias => ignores.indexOf(alias) !== -1)
)
} | javascript | {
"resource": ""
} |
q58890 | hasPattern | validation | function hasPattern(s, pattern) {
const m = pattern.exec(s)
return m != null && (m[1] || "").length % 2 === 0
} | javascript | {
"resource": ""
} |
q58891 | hasTrailingCommaForFunction | validation | function hasTrailingCommaForFunction(node) {
const length = node.params.length
return (
length >= 1 &&
sourceCode.getTokenAfter(node.params[length - 1]).value === ","
)
} | javascript | {
"resource": ""
} |
q58892 | extendsNull | validation | function extendsNull(node) {
return (
node.superClass != null &&
node.superClass.type === "Literal" &&
node.superClass.value === null
)
} | javascript | {
"resource": ""
} |
q58893 | report | validation | function report(node, key) {
const version = supportInfo.version
const feature = supportInfo.features[key]
if (feature.supported) {
return
}
if (!feature.supportedInStrict) {
context.report({
node,
... | javascript | {
"resource": ""
} |
q58894 | validateRegExp | validation | function validateRegExp(pattern, flags, node) {
if (typeof pattern === "string") {
if (hasPattern(pattern, REGEXP_NAMED_GROUP)) {
report(node, "regexpNamedCaptureGroups")
}
if (hasPattern(pattern, REGEXP_LOOKBEHIND)) {
r... | javascript | {
"resource": ""
} |
q58895 | validateRegExpLiteral | validation | function validateRegExpLiteral(node) {
validateRegExp(node.regex.pattern, node.regex.flags, node)
} | javascript | {
"resource": ""
} |
q58896 | getFilePath | validation | function getFilePath(isModule, id, options) {
try {
return resolve.sync(id, options)
} catch (_err) {
if (isModule) {
return null
}
return path.resolve(options.basedir, id)
}
} | javascript | {
"resource": ""
} |
q58897 | getModuleName | validation | function getModuleName(nameOrPath) {
let end = nameOrPath.indexOf("/")
if (end !== -1 && nameOrPath[0] === "@") {
end = nameOrPath.indexOf("/", 1 + end)
}
return end === -1 ? nameOrPath : nameOrPath.slice(0, end)
} | javascript | {
"resource": ""
} |
q58898 | isBinFile | validation | function isBinFile(filePath, binField, basedir) {
if (!binField) {
return false
}
if (typeof binField === "string") {
return filePath === path.resolve(basedir, binField)
}
return Object.keys(binField).some(
key => filePath === path.resolve(basedir, binField[key])
)
} | javascript | {
"resource": ""
} |
q58899 | getExistingExtensions | validation | function getExistingExtensions(filePath) {
const basename = path.basename(filePath, path.extname(filePath))
try {
return fs
.readdirSync(path.dirname(filePath))
.filter(
filename =>
path.basename(filename, path.extname(filename)) === basename
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.