_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q11800 | compareNames | train | function compareNames(a, b) {
if (!isArray(a)) a = splitAuthorString(a);
if (!isArray(b)) b = splitAuthorString(b);
var aPos = 0, bPos = 0;
var authorLimit = Math.min(a.length, b.length);
var failed = false;
while (aPos < authorLimit && bPos < authorLimit) {
if (fuzzyStringCompare(a[aPos], b[bPos])) { // Dire... | javascript | {
"resource": ""
} |
q11801 | train | function(call, error, response, body, codes, reject) {
if (error) {
if (typeof error == 'string') {
var message = util.format("Unexpected error on %s %s, reason : %s",
call.method, call.uri, error);
util.log(message);
var exception = new Error(message);
exception.call = call;
rej... | javascript | {
"resource": ""
} | |
q11802 | Element | train | function Element (driver, parent, selector, id) {
this._driver = driver;
this._parent = parent;
| javascript | {
"resource": ""
} |
q11803 | train | function (benchmark, simultaneousRequests, done) {
var pageName,
engineName;
this.benchmark = benchmark;
this.simultaneousRequests = simultaneousRequests;
this.done = done;
if (typeof simultaneousRequests !== "number") {
throw new Error("simultaneousRequests must be an integer; " + | javascript | {
"resource": ""
} | |
q11804 | visit | train | function visit() {
if (this.isBlacklisted()) return false;
if (this.opts.shouldSkip && this.opts.shouldSkip(this)) return false;
this.call("enter");
if (this.shouldSkip) {
return this.shouldStop;
}
var node = this.node;
var opts = this.opts;
if (node) {
if (Array.isArray(node)) {
// tr... | javascript | {
"resource": ""
} |
q11805 | JSONPath | train | function JSONPath(expression, options) {
if (!options || typeof options != 'object') {
options = {};
}
if (!options.resultType) {
options.resultType = 'value';
}
if (typeof options.flatten == 'undefined') | javascript | {
"resource": ""
} |
q11806 | getParentPath | train | function getParentPath(path, sep) {
if (!is.nonEmptyStr(path)) return false;
if (!is.nonEmptyStr(sep)) sep = defaultSepChar;
// create new path and remove leading and trailing sep chars
var properties = filter(path.split(sep), function(elem) {
return is.str(elem) && elem.length;
});
... | javascript | {
"resource": ""
} |
q11807 | createUnionTypeAnnotation | train | function createUnionTypeAnnotation(types) {
var flattened = removeTypeDuplicates(types);
if (flattened.length === 1) {
| javascript | {
"resource": ""
} |
q11808 | removeTypeDuplicates | train | function removeTypeDuplicates(nodes) {
var generics = {};
var bases = {};
// store union type groups to circular references
var typeGroups = [];
var types = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (!node) continue;
// detect duplicates
if (types.indexOf(node)... | javascript | {
"resource": ""
} |
q11809 | createTypeAnnotationBasedOnTypeof | train | function createTypeAnnotationBasedOnTypeof(type) {
if (type === "string") {
return t.stringTypeAnnotation();
} else if (type === "number") {
return t.numberTypeAnnotation();
} else if (type === "undefined") {
return t.voidTypeAnnotation();
} else if (type === "boolean") {
return t.booleanTypeAnn... | javascript | {
"resource": ""
} |
q11810 | deepEquals | train | function deepEquals(a, b) {
var i, key;
if (isScalar(a) && isScalar(b)) {
return scalarEquals(a, b);
}
if (a === null || b === null || a === undefined || b === undefined) return a === b;
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return false;
for (i = 0; i < a.length; i++) {
i... | javascript | {
"resource": ""
} |
q11811 | deepCopy | train | function deepCopy(obj) {
var res;
var i;
var key;
if (isTerminal(obj)) {
res = obj;
} else if (Array.isArray(obj)) {
res = Array(obj.length);
for (i = 0; i < obj.length; i++) {
res[i] = | javascript | {
"resource": ""
} |
q11812 | setPath | train | function setPath(obj, path, value) {
var cur = obj;
var parts = path.split('.');
var i;
for (i = 0; i < parts.length; i++) {
if (i === parts.length - 1) {
cur[parts[i]] = value;
| javascript | {
"resource": ""
} |
q11813 | deletePath | train | function deletePath(obj, path) {
var cur = obj;
var parts = path.split('.');
var i;
for (i = 0; i < parts.length; i++) {
if (i === parts.length - 1) {
delete cur[parts[i]];
| javascript | {
"resource": ""
} |
q11814 | getPath | train | function getPath(obj, path, allowSkipArrays) {
if (path === null || path === undefined) return obj;
var cur = obj;
var parts = path.split('.');
var i;
for (i = 0; i < parts.length; i++) {
if (isScalar(cur)) return undefined;
if (Array.isArray(cur) && allowSkipArrays | javascript | {
"resource": ""
} |
q11815 | merge | train | function merge(/* object, sources */) {
var lastSource = arguments[arguments.length - 1];
if (
typeof lastSource === 'function' ||
(
arguments.length > 2 &&
Array.isArray(lastSource) &&
lastSource.indexOf(arguments[1]) >= 0
| javascript | {
"resource": ""
} |
q11816 | dottedDiff | train | function dottedDiff(val1, val2) {
if (isScalar(val1) && isScalar(val2)) {
return | javascript | {
"resource": ""
} |
q11817 | objectHash | train | function objectHash(obj) {
var hash = crypto.createHash('md5'); | javascript | {
"resource": ""
} |
q11818 | sanitizeDate | train | function sanitizeDate(val) {
if (!val) return null;
if (_.isDate(val)) return val;
if (_.isString(val)) return new Date(Date.parse(val));
if (_.isNumber(val)) return new Date(val); | javascript | {
"resource": ""
} |
q11819 | render | train | async function render(view, options) {
view += settings.viewExt;
const viewPath = path.join(settings.root, view);
debug(`render: ${viewPath}`);
// get from cache
if (settings.cache && cache[viewPath]) {
return cache[viewPath].call(options.scope, options);
}
const tpl = await fs.readFi... | javascript | {
"resource": ""
} |
q11820 | parse | train | function parse(code) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
opts.allowHashBang = true;
opts.sourceType = "module";
opts.ecmaVersion = Infinity;
opts.plugins = {
jsx: true,
flow: true
};
opts.features = {};
for (var key in _transformation2["default... | javascript | {
"resource": ""
} |
q11821 | renderToString | train | function renderToString(meta) {
if (meta.html) return meta.html.source
var output = [
'<!DOCTYPE html>', '<html>', '<head>', '<meta charset="utf8" />'
]
var { head, body } = meta
head.metas.forEach(e => output.push(renderMeta(e.name, e.http, e.content)))
head.styles.forEach(e => output.push(renderStyle(... | javascript | {
"resource": ""
} |
q11822 | getRoute | train | function getRoute(route) {
for (var key in settings.routes) {
if (key === route) {
| javascript | {
"resource": ""
} |
q11823 | compareUrlRoute | train | function compareUrlRoute(currentURL, currentRoute) {
var regex = /\{(.*)\}/i;
var arraySize = currentRoute.length,
testValue = false;
for (var i = 0; i < arraySize; i++) {
var dynamic = regex.exec(currentRoute[i]);
... | javascript | {
"resource": ""
} |
q11824 | train | function (commit, until) {
var checker = this;
until = !isNaN(until) ? until : (new Date()).getTime() + (this.getOption('timeout'));
if ((new Date()).getTime() > until) {
return this.handleError('Timeout');
}
return this.getBuilds()
... | javascript | {
"resource": ""
} | |
q11825 | clientsGenerator | train | function clientsGenerator()
{
var i = 0,
len = clientsList.length;
for( ; i < len; i++ )
{
var client = { name : clientsList[ i ].name };
var time = _.timeNow();
setTimeout(( function( client, time )
{
/* sending clients to shop */
| javascript | {
"resource": ""
} |
q11826 | loadEntities | train | function loadEntities() {
// Uncompress the base charmap
charMap = require('./string_entities_map.js');
HTMLEntities = {};
for (key in charMap) {
for | javascript | {
"resource": ""
} |
q11827 | isCharVowel | train | function isCharVowel(char = '', includeY = true) {
if (isEmpty(char)) return false;
const regexp = includeY ? /[aeiouy]/ : | javascript | {
"resource": ""
} |
q11828 | convertFullwidthCharsToASCII | train | function convertFullwidthCharsToASCII(text = '') {
const asciiChars = [...text].map((char, index) => {
const code = char.charCodeAt(0);
const lower = isCharInRange(char, LOWERCASE_FULLWIDTH_START, LOWERCASE_FULLWIDTH_END);
const upper = isCharInRange(char, UPPERCASE_FULLWIDTH_START, UPPERCASE_FULLWIDTH_EN... | javascript | {
"resource": ""
} |
q11829 | train | function(){
var view = "_design/searchJob/_view/jobstatus?key=" + JSON.stringify('UPLOADING');
return server.methods.clusterprovider.getView(view)
.then(function(docs){
| javascript | {
"resource": ""
} | |
q11830 | train | function (options) {
if (!options) // fast path
return _defaults;
var ret = _.extend({}, _defaults);
_.each(['N', 'g', 'k'], function (p) {
if (options[p]) {
if (typeof options[p] === "string")
ret[p] = new BigInteger(options[p], 16);
| javascript | {
"resource": ""
} | |
q11831 | doMultipleInheritance | train | function doMultipleInheritance(new_constructor, parent_constructor, proto) {
var more;
if (proto == null) {
proto = Object.create(new_constructor.prototype);
}
// See if this goes even deeper FIRST
// (older properties could get overwritten)
more = Object.getPrototypeOf(parent_constructor.prototype);
... | javascript | {
"resource": ""
} |
q11832 | getNamespace | train | function getNamespace(namespace) {
var result,
name,
data;
// Try getting the namespace
if (!namespace) {
result = Blast.Classes;
} else {
result = Obj.path(Blast.Classes, namespace);
}
if (result == null) {
name = namespace.split('.');
name = name[name.length - 1];
result = C... | javascript | {
"resource": ""
} |
q11833 | getClass | train | function getClass(path) {
var pieces = path.split('.'),
result;
result = Obj.path(Blast.Classes, path);
if (typeof result == 'function') {
if (result.is_namespace) {
| javascript | {
"resource": ""
} |
q11834 | getClassPathInfo | train | function getClassPathInfo(path) {
var result = {},
namespace,
name,
temp;
// See what's there
temp = Obj.path(Blast.Classes, path);
// Is there nothing at the current path?
if (!temp) {
if (path.indexOf('.') > -1) {
// Split the path
temp = path.split('.');
// The last pa... | javascript | {
"resource": ""
} |
q11835 | doConstitutors | train | function doConstitutors(constructor) {
var waiting,
tasks,
i;
if (has_constituted.get(constructor)) {
return;
}
has_constituted.set(constructor, true);
tasks = constructor.constitutors;
if (tasks) {
for (i = 0; i < tasks.length; i++) {
doConstructorTask(constructor, tasks[i]);
... | javascript | {
"resource": ""
} |
q11836 | doConstructorTask | train | function doConstructorTask(constructor, task) {
var finished;
finished = finished_constitutors.get(constructor);
if (!finished) {
finished = [];
finished_constitutors.set(constructor, finished);
}
| javascript | {
"resource": ""
} |
q11837 | applyDecoration | train | function applyDecoration(constructor, key, options) {
if (options.kind == 'method') {
return Fn.setMethod(constructor, key, options.descriptor);
}
| javascript | {
"resource": ""
} |
q11838 | setStaticProperty | train | function setStaticProperty(key, getter, setter, inherit) {
return | javascript | {
"resource": ""
} |
q11839 | compose | train | function compose(key, compositor, traits) { | javascript | {
"resource": ""
} |
q11840 | ensureConstructorStaticMethods | train | function ensureConstructorStaticMethods(newConstructor) {
if (typeof newConstructor.setMethod !== 'function') {
Blast.defineValue(newConstructor, protoPrepareStaticProperty);
Blast.defineValue(newConstructor, protoSetStaticProperty);
Blast.defineValue(newConstructor, protoPrepareProperty);
Blast.defineVa... | javascript | {
"resource": ""
} |
q11841 | map | train | function map(transform) {
var cb = makeAsync(transform, 2);
| javascript | {
"resource": ""
} |
q11842 | reduce | train | function reduce(reducer, initialValue) {
var accumulator = initialValue;
var cb = makeAsync(reducer, 3);
return through.obj(
function transform(chunk, enc, next) | javascript | {
"resource": ""
} |
q11843 | copy | train | function copy(acc, k) {
const val = x[k]
let cpy
if (Array.isArray(val)) {
cpy = val.slice(0)
} else {
| javascript | {
"resource": ""
} |
q11844 | RCS | train | function RCS (input, opts) {
opts = opts || {}
this.log = require('./logger')('rcs-lib', {debug: opts.verbose || false})
var config
// If feeding in a direct config object
if (opts.config !== null && typeof opts.config === 'object') {
config = opts.config
} else {
config = this.readConfig(opts.co... | javascript | {
"resource": ""
} |
q11845 | train | function (obj, eventType, eventHandler) {
if (!obj.eventHandlers) { obj.eventHandlers = {}; }
if (!obj.eventHandlers[eventType]) {
obj.eventHandlers[eventType] = [];
}
if (eventHandler) { | javascript | {
"resource": ""
} | |
q11846 | train | function(parentClass, isWhat, tag, features) { // v0 spec implementation using https://github.com/WebReflection/document-register-element
var elementClass = Object.create(parentClass.prototype);
// Clone event handlers
if (elementClass.eventHandlers) {
var clonedHandlers = {};
for (var i in elem... | javascript | {
"resource": ""
} | |
q11847 | train | function (obj, properties) {
var events, propertyDescriptors, i;
if (!properties) { return; }
// Clone events
if (properties.on) {
events = Object.assign({}, properties.on);
}
Object.assign(obj, properties); // IE11 need a polyfill
// Handle events
if (events) {
for (i in events) {
... | javascript | {
"resource": ""
} | |
q11848 | train | function() {
'use strict';
var features = arguments;
if (!features.length) {
return;
}
// Detect isWhat, tag and parent class
var props = feature.apply(null, arguments);
var isWhat = props.is;
var tag = props.tag;
var parentClass = props.extends; | javascript | {
"resource": ""
} | |
q11849 | train | function() {
'use strict';
var self = this || {};
if (arguments.length) {
for (var i = 0; i<arguments.length; i++) {
if (typeof arguments[i] | javascript | {
"resource": ""
} | |
q11850 | Property | train | function Property(node, print) {
print.list(node.decorators, { separator: "" });
if (node.method || node.kind === "get" || node.kind === "set") {
this._method(node, print);
} else {
if (node.computed) {
this.push("[");
print.plain(node.key);
this.push("]");
} else {
// print `... | javascript | {
"resource": ""
} |
q11851 | ArrayExpression | train | function ArrayExpression(node, print) {
var elems = node.elements;
var len = elems.length;
this.push("[");
print.printInnerComments();
for (var i = 0; i < elems.length; i++) {
var elem = elems[i];
if (elem) {
if (i > 0) this.space();
print.plain(elem);
if (i < len - 1) this.push(",... | javascript | {
"resource": ""
} |
q11852 | getSourceTrees | train | function getSourceTrees(pathsToSearch) {
return {
read: function(readTree) {
var promises = _.map(pathsToSearch, function(path) {
return new Promise(function(resolve) {
fs.exists(path, function(exists) {
resolve((exists) ? path : null);
});
});
});
return Promise.all(promises)
.... | javascript | {
"resource": ""
} |
q11853 | checkTorrentIntegrity | train | async function checkTorrentIntegrity(torrentFile, dataFile) {
const _ntRead = promisify(nt.read);
return _ntRead(torrentFile)
.then((torrent) => {
return new Promise((resolve, reject) => {
torrent.metadata.info.name = path.basename(dataFile);
const hasher = torrent.hashCheck(path.dirname(dat... | javascript | {
"resource": ""
} |
q11854 | canCompile | train | function canCompile(filename, altExts) {
var exts = altExts || canCompile.EXTENSIONS; | javascript | {
"resource": ""
} |
q11855 | list | train | function list(val) {
if (!val) {
return [];
} else if (Array.isArray(val)) {
return val;
} else if (typeof val === "string") {
| javascript | {
"resource": ""
} |
q11856 | regexify | train | function regexify(val) {
if (!val) return new RegExp(/.^/);
if (Array.isArray(val)) val = new RegExp(val.map(_lodashStringEscapeRegExp2["default"]).join("|"), "i");
if (_lodashLangIsString2["default"](val)) {
// normalise path separators
val = _slash2["default"](val);
// remove starting wildcards o... | javascript | {
"resource": ""
} |
q11857 | shouldIgnore | train | function shouldIgnore(filename, ignore, only) {
filename = _slash2["default"](filename);
if (only) {
var _arr = only;
for (var _i = 0; _i < _arr.length; _i++) {
var pattern = _arr[_i];
if (_shouldIgnore(pattern, filename)) return false;
}
return true;
} else if (ignore.length) {
... | javascript | {
"resource": ""
} |
q11858 | parseTemplate | train | function parseTemplate(loc, code) {
var ast = _helpersParse2["default"](code, { filename: loc, looseModules: true }).program;
ast | javascript | {
"resource": ""
} |
q11859 | activatePostCSSPlugins | train | function activatePostCSSPlugins(config) {
const plugins = [];
if (config.lintRules || config.lintRules !== "") {
// TODO: Throw easy-to-understand error message
// incorrect path? (ex. "lintRules": "aaa")
// typo? (ex. "lintRules": "stylelint-config-suitcs")
const lintRules = require(config.lintRul... | javascript | {
"resource": ""
} |
q11860 | ImportSpecifier | train | function ImportSpecifier(node, print) {
print.plain(node.imported);
if (node.local && node.local.name !== node.imported.name) | javascript | {
"resource": ""
} |
q11861 | es5Plugins | train | function es5Plugins(){
return [
require('babel-plugin-check-es2015-constants'),
require('babel-plugin-transform-es2015-arrow-functions'),
require('babel-plugin-transform-es2015-block-scoped-functions'),
require('babel-plugin-transform-es2015-block-scoping'),
require('babel-plugin-trans... | javascript | {
"resource": ""
} |
q11862 | train | function(obj, key, value) {
if(typeof obj[key] === "undefined") {
obj[key] = value;
}
else {
//Check if the current option is not an array
| javascript | {
"resource": ""
} | |
q11863 | PriorityQueue | train | function PriorityQueue(initialItems) {
var self = this;
MinHeap.call(this, function (a, b) {
return self.priority(a) < self.priority(b) ? -1 : 1;
});
this._priority = {};
initialItems = | javascript | {
"resource": ""
} |
q11864 | clean | train | function clean(type, options) {
options = assign({}, defaults, options);
if (type === 'dblclick') {
options.detail = 2;
| javascript | {
"resource": ""
} |
q11865 | createMouseEvent | train | function createMouseEvent(type, options) {
options = clean(type, options);
var e = document.createEvent('MouseEvent');
e.initMouseEvent(
type,
options.bubbles,
options.cancelable,
options.view,
options.detail,
options.screenX,
| javascript | {
"resource": ""
} |
q11866 | createKeyboardEvent | train | function createKeyboardEvent(type, options) {
options = clean(type, options);
var e = document.createEvent('KeyboardEvent');
(e.initKeyEvent || e.initKeyboardEvent).call(
e,
type,
options.bubbles,
options.cancelable,
options.view,
options.ctrl,
options.alt,
options.shift,
optio... | javascript | {
"resource": ""
} |
q11867 | createEvent | train | function createEvent(type, options) {
switch (type) {
case 'dblclick':
case 'click':
return createMouseEvent(type, options);
case 'keydown':
| javascript | {
"resource": ""
} |
q11868 | createIeEvent | train | function createIeEvent(type, options) {
options = clean(type, options);
var e = document.createEventObject();
e.altKey = options.alt;
e.bubbles = options.bubbles;
e.button = options.button;
e.cancelable = options.cancelable;
e.clientX = options.clientX;
e.clientY = options.clientY;
e.ctrlKey = options... | javascript | {
"resource": ""
} |
q11869 | _check_and_save | train | function _check_and_save(path){
//console.log('l@: ' + path);
if( afs.exists_p(path) ){
if( afs.file_p(path) ){
//console.log('found file: ' + path);
// Break into parts for saving if it is a full file.
var filename = path;
var slash_loc = path.lastIndexOf('/') + 1;
if( slash_loc != 0 ){
filen... | javascript | {
"resource": ""
} |
q11870 | _add_permanently_to | train | function _add_permanently_to(stack, item_or_list){
if( item_or_list && tcache[stack] ){
if( ! us.isArray(item_or_list) ){ | javascript | {
"resource": ""
} |
q11871 | _set_common | train | function _set_common(stack_name, thing){
var ret = null;
if( stack_name == 'css_libs' ||
stack_name == 'js_libs' ||
stack_name == 'js_vars' ){
_add_permanently_to(stack_name, thing);
| javascript | {
"resource": ""
} |
q11872 | _use_zcache_p | train | function _use_zcache_p(yes_no){
if( yes_no == true ){
use_zcache_p = true;
}else if( yes_no == false ){ | javascript | {
"resource": ""
} |
q11873 | _get | train | function _get(key){
var ret = null;
// Pull from cache or re-read from fs.
//console.log('key: ' + key)
//console.log('use_zcache_p: ' + use_zcache_p)
if( use_zcache_p ){
| javascript | {
"resource": ""
} |
q11874 | _apply | train | function _apply (tmpl_name, tmpl_args){
var ret = null;
var tmpl = _get(tmpl_name);
if( tmpl ){ | javascript | {
"resource": ""
} |
q11875 | replaceSensitive | train | function replaceSensitive(chr, dbl) {
var result,
dbl_result;
if (typeof baseDiacriticsMap[chr] === 'undefined') {
return chr;
}
result = '[' + chr
result += baseDiacriticsMap[chr];
result += ']';
if (dbl && baseDiacriticsMap[dbl]) {
dbl_result = | javascript | {
"resource": ""
} |
q11876 | replaceInsensitive | train | function replaceInsensitive(chr, dbl) {
var lower = chr.toLowerCase(),
upper = chr.toUpperCase(),
result,
dbl_result;
if (lower == upper) {
return chr;
}
result = '[' + lower + upper;
result += (baseDiacriticsMap[lower]||'');
result += (baseDiacriticsMap[upper]||'');
result += ']... | javascript | {
"resource": ""
} |
q11877 | resolveConfig | train | function resolveConfig (fileName, options) {
options = options || {}
var schema = options.schema
var resolvePackageJson = options.resolvePackageJson || false
var fileNames = [fileName, resolvePackageJson ? 'package.json' : null].filter(
item => !!item
)
| javascript | {
"resource": ""
} |
q11878 | list | train | async function list(torrentHandler, config) {
try {
const list = await clientTorrent.list(config.pid);
for(const i in list) {
torrentHandler.handle(list[i], config.pid); | javascript | {
"resource": ""
} |
q11879 | load | train | function load() {
if (process.env.BABEL_DISABLE_CACHE) return;
process.on("exit", save);
process.nextTick(save);
| javascript | {
"resource": ""
} |
q11880 | makeReactive | train | function makeReactive(componentDefinition, renderFn, ...stateStreamNames) {
class ReactiveComponent extends PureComponent {
constructor(props, context) {
super(props, context);
this.state = { childProps: {} }
this.omnistream = this.context.omnistream;
// Make the dispatch function accessi... | javascript | {
"resource": ""
} |
q11881 | getStatementParent | train | function getStatementParent() {
var path = this;
do {
if (Array.isArray(path.container)) {
return | javascript | {
"resource": ""
} |
q11882 | getDeepestCommonAncestorFrom | train | function getDeepestCommonAncestorFrom(paths, filter) {
// istanbul ignore next
var _this = this;
if (!paths.length) {
return this;
}
if (paths.length === 1) {
return paths[0];
}
// minimum depth of the tree so we know the highest node
var minDepth = Infinity;
// last common ancestor
var... | javascript | {
"resource": ""
} |
q11883 | getAncestry | train | function getAncestry() {
var path = this;
var paths = [];
do {
| javascript | {
"resource": ""
} |
q11884 | inShadow | train | function inShadow(key) {
var path = this;
do {
if (path.isFunction()) {
var shadow = path.node.shadow;
if (shadow) {
// this is because sometimes we may have a `shadow` value of:
//
// { this: false }
//
| javascript | {
"resource": ""
} |
q11885 | getRealHeaderCheck | train | function getRealHeaderCheck(expectedHeader, caseSensitive, fieldNames) {
return function (content) {
let actualHeader;
if (caseSensitive) {
actualHeader = content;
} else {
actualHeader = arrayToUpperCase(content);
expectedHeader = arrayToUpperCase(expectedHeader);
| javascript | {
"resource": ""
} |
q11886 | getStrictCheck | train | function getStrictCheck(expectedHeader, caseSensitive, severity) {
return function (content) {
let actualHeader;
if (caseSensitive) {
actualHeader = content;
} else {
actualHeader = arrayToUpperCase(content);
expectedHeader = arrayToUpperCase(expectedHeader);
}
if (expectedHeader.length !== actual... | javascript | {
"resource": ""
} |
q11887 | getMissingColumnCheck | train | function getMissingColumnCheck(expectedHeader, caseSensitive, severity) {
return function (content) {
let actualHeader;
if (caseSensitive) {
actualHeader = content;
} else {
actualHeader = arrayToUpperCase(content);
expectedHeader = arrayToUpperCase(expectedHeader); | javascript | {
"resource": ""
} |
q11888 | getMandatoryColumnCheck | train | function getMandatoryColumnCheck(mandatoryColumns, severity) {
/**
* @param the coluns found and matched.
*/
return function (foundColumns) {
// the header must have all the expected columns but may have more
let err = _missingColumns(mandatoryColumns, foundColumns);
if (err) {
| javascript | {
"resource": ""
} |
q11889 | ReaddirPlusFile | train | function ReaddirPlusFile(source) {
/**
* File name. Eg. "file.txt"
* @type {string}
*/
this.name = null;
/**
* Full path. Eg. "/home/myname/path/to/directory/subdir/file.txt"
* @type {string}
*/
this.path = null;
/**
* Relative path, based on the directory you submitted to readdir. Eg. "subdir/file... | javascript | {
"resource": ""
} |
q11890 | toExports | train | function toExports(dir, patterns, recurse, options, fn) {
if (arguments.length === 1 && !isGlob(dir)) {
var key = 'toExports:' + dir;
if (cache.hasOwnProperty(key)) {
return cache[key];
}
var result = lookup(dir, false, {}).reduce(function (res, fp) {
if (filter(fp, fn)) {
| javascript | {
"resource": ""
} |
q11891 | lookup | train | function lookup(dir, recurse) {
if (typeof dir !== 'string') {
throw new Error('export-files expects a string as the first argument.');
}
var key = 'lookup:' + dir + ('' + recurse);
if (cache.hasOwnProperty(key)) {
return cache[key];
}
var files = fs.readdirSync(dir);
var len = files.length;
v... | javascript | {
"resource": ""
} |
q11892 | renameKey | train | function renameKey(fp, opts) {
if (opts && opts.renameKey) {
| javascript | {
"resource": ""
} |
q11893 | read | train | function read(fp, opts, fn) {
opts = opts || {};
opts.encoding = opts.encoding || 'utf8';
if (opts.read) {
return opts.read(fp, opts);
} else if (fn) {
| javascript | {
"resource": ""
} |
q11894 | isBinding | train | function isBinding(node, parent) {
var keys = _retrievers.getBindingIdentifiers.keys[parent.type];
if (keys) {
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var val = parent[key];
if (Array.isArray(val)) {
| javascript | {
"resource": ""
} |
q11895 | isSpecifierDefault | train | function isSpecifierDefault(specifier) {
return t.isImportDefaultSpecifier(specifier) | javascript | {
"resource": ""
} |
q11896 | isScope | train | function isScope(node, parent) {
if (t.isBlockStatement(node) && t.isFunction(parent, { body: node })) {
| javascript | {
"resource": ""
} |
q11897 | isImmutable | train | function isImmutable(node) {
if (t.isType(node.type, "Immutable")) return true;
if (t.isLiteral(node)) {
if (node.regex) {
// regexs are mutable
return false;
} else {
// immutable!
return true;
}
} else if (t.isIdentifier(node)) { | javascript | {
"resource": ""
} |
q11898 | train | function (data, ctxModel, ctxVars) {
const options = xtend(this.options, { ctxVars, logger: this.logger });
const parser = new kevs.Parser();
const ast = parser.parse(data);
if (ast.type !== 'kevScript') {
const err = new Error('Unable to parse script');
err.parser = ast;
err.warnings... | javascript | {
"resource": ""
} | |
q11899 | setPropertyVal | train | function setPropertyVal (pObj, pProp, pNewVal) {
if (typeof pProp === 'string') {
pProp = pProp || '';
pProp = pProp.split('.');
}
if (pProp.length > 1) {
var prop = pProp.shift();
pObj[prop] = (typeof pObj[prop] !== 'undefined'
| javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.