_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q60900 | hilbertIndexInverse | validation | function hilbertIndexInverse(dim, index, options) { // :: Int -> Int -> [Int, Int, ..]
options = options || {}
var entry = options.entry || 0,
direction = options.direction || 0,
m = curvePrecision(index, dim),
p = Array.apply(null, new Array(dim)).map(Number.prototype.valueOf, 0)
f... | javascript | {
"resource": ""
} |
q60901 | getConsoleReporterOpts | validation | function getConsoleReporterOpts(opts) {
opts = opts || {};
opts.print = function () {
grunt.log.write.apply(this, arguments);
};
// checking this here for the old name `verbose` (now alias).
opts.verbosity = opts.verbosity === undefined
... | javascript | {
"resource": ""
} |
q60902 | _taskFatalHandler_ | validation | function _taskFatalHandler_(e) {
var err = e ? (e.stack || e.message || e) : 'Unknown Error';
grunt.fatal(err, grunt.fail.code.TASK_FAILURE);
} | javascript | {
"resource": ""
} |
q60903 | validation | function(options, cb) {
// if no sassDir or files are not identify, error.
if (!options.sassDir) {
grunt.log.error('compass-multiple needs sassDir for searching scss files.');
cb(false);
}
// search scss files.(Additional Implementation)
if (options.sassFiles) {
... | javascript | {
"resource": ""
} | |
q60904 | pageRange | validation | function pageRange(selected, numPages, num) {
let selectedPos = Math.ceil(num / 2);
let start = (selected < selectedPos) ? 1
: selected - selectedPos + 1;
let len = (numPages < start + num - 1) ? numPages - start + 1
: num;
return Array
.apply(null, Array(len))
.map((u, i) => start + i);
} | javascript | {
"resource": ""
} |
q60905 | showTasks | validation | function showTasks(tasks) {
const taskList = Object.keys(tasks);
if (taskList.length) {
taskList.forEach((task) => {
process.stdout.write(`Task Name: '${task}'`);
if (tasks[task].description) {
process.stdout.write(` - Description: ${tasks[task].description}`);
}
process.stdout.w... | javascript | {
"resource": ""
} |
q60906 | sh | validation | function sh(cmd, exitOnError, cb) {
const child = exec(cmd, {
encoding: 'utf8',
timeout: 1000 * 60 * 2, // 2 min; just want to make sure nothing gets detached forever.
});
let stdout = '';
child.stdout.on('data', (data) => {
stdout += data;
process.stdout.write(data);
});
child.stderr.on('da... | javascript | {
"resource": ""
} |
q60907 | readYamlFile | validation | function readYamlFile(file, cb) {
fs.readFile(file, 'utf8', (err, data) => {
if (err) throw err;
cb(yaml.safeLoad(data));
});
} | javascript | {
"resource": ""
} |
q60908 | writeYamlFile | validation | function writeYamlFile(file, data, cb) {
fs.writeFile(file, yaml.safeDump(data), () => {
if (cb) cb();
});
} | javascript | {
"resource": ""
} |
q60909 | middleware | validation | function middleware(file, options) {
var matcher = new RegExp("\\.(?:"+ middleware.extensions.join("|")+")$")
if (!matcher.test(file)) return through();
var input = '';
var write = function (buffer) {
input += buffer;
}
var end = function () {
this.queue(createModule(input, options));
this.que... | javascript | {
"resource": ""
} |
q60910 | createModule | validation | function createModule(body, options) {
body = middleware.sanitize(body)
if (String(options.parameterize) !== 'false') {
body = middleware.parameterise(body)
}
if (options.module === "es6" || options.module === "es2015") {
var module = 'export default ' + body + ';\n';
}... | javascript | {
"resource": ""
} |
q60911 | validation | function(schema,definition) {
return _.reduce(schema, function(memo, field) {
// console.log('definition normalize');console.log(definition);
// Marshal mysql DESCRIBE to waterline collection semantics
var attrName = field.COLUMN_NAME.toLowerCase();
/*Comme or... | javascript | {
"resource": ""
} | |
q60912 | validation | function(collectionName, values, key) {
return sql.build(collectionName, values, sql.prepareValue, ', ', key);
} | javascript | {
"resource": ""
} | |
q60913 | validation | function(collectionName, where, key, parentKey) {
return sql.build(collectionName, where, sql.predicate, ' AND ', undefined, parentKey);
} | javascript | {
"resource": ""
} | |
q60914 | validation | function(collectionName, criterion, key, parentKey) {
var queryPart = '';
if (parentKey) {
return sql.prepareCriterion(collectionName, criterion, key, parentKey);
}
// OR
if (key.toLowerCase() === 'or') {
queryPart = sql.build(collectionName, ... | javascript | {
"resource": ""
} | |
q60915 | sqlTypeCast | validation | function sqlTypeCast(type, attrName) {
type = type && type.toLowerCase();
switch (type) {
case 'string':
return 'VARCHAR2(255)';
case 'text':
case 'array':
case 'json':
return 'VARCHAR2(255)';
case 'boolean':
return 'NUM... | javascript | {
"resource": ""
} |
q60916 | validSubAttrCriteria | validation | function validSubAttrCriteria(c) {
return _.isObject(c) && (
!_.isUndefined(c.not) || !_.isUndefined(c.greaterThan) || !_.isUndefined(c.lessThan) ||
!_.isUndefined(c.greaterThanOrEqual) || !_.isUndefined(c.lessThanOrEqual) || !_.isUndefined(c['<']) ||
!_.isUndefined(c['<=']) ... | javascript | {
"resource": ""
} |
q60917 | processIconTemplate | validation | function processIconTemplate(srcFile, destFile, data, cb) {
fs.readFile(srcFile, 'utf8', (err, srcFileContents) => {
if (err) throw err;
const result = template(srcFileContents, {
// Use custom template delimiters of `{{` and `}}`.
interpolate: /{{([\s\S]+?)}}/g,
// Use custom evaluate delim... | javascript | {
"resource": ""
} |
q60918 | icons | validation | function icons(done) {
const stream = gulp.src(config.src)
.pipe(iconfont({
fontName: config.iconName,
appendUniconde: true,
formats: config.formats,
timestamp: config.useTimestamp ? getTimestamp() : 0,
autohint: config.autohint,
normalize: config.normalize,
... | javascript | {
"resource": ""
} |
q60919 | injectData | validation | function injectData(tokenValue, options, key) {
var data;
if (~options.contentType.indexOf('application/json')) {
data = options.data ? JSON.parse(options.data) : {};
data[key] = tokenValue;
options.data = JSON.stringify(data);
} else {
options.data += options.data ? '&' : ''... | javascript | {
"resource": ""
} |
q60920 | injectQuery | validation | function injectQuery(tokenValue, options, param) {
options.url += ~options.url.indexOf('?') ? '&' : '?';
options.url += param + '=' + tokenValue;
} | javascript | {
"resource": ""
} |
q60921 | homedir | validation | function homedir(username) {
return username ? path.resolve(path.dirname(home), username) : home;
} | javascript | {
"resource": ""
} |
q60922 | validation | function (conn, cb) {
if (LOG_DEBUG) {
console.log("BEGIN tearDown");
}
if (typeof conn == 'function') {
cb = conn;
conn = null;
}
if (!conn) {
connections = {};
retur... | javascript | {
"resource": ""
} | |
q60923 | validation | function (connectionName, table, query, data, cb) {
var connectionObject = connections[connectionName];
if (LOG_DEBUG) {
console.log("BEGIN query");
}
if (_.isFunction(data)) {
cb = data;
data = null;
... | javascript | {
"resource": ""
} | |
q60924 | dropTable | validation | function dropTable(item, next) {
// Build Query
var query = 'DROP TABLE ' + utils.escapeName(item) + '';
// Run Query
connectionObject.pool.getConnection(function (err, connection) {
if (LOG_QUERIES) {
... | javascript | {
"resource": ""
} |
q60925 | validation | function (connectionName, table, attrName, attrDef, cb) {
var connectionObject = connections[connectionName];
if (LOG_DEBUG) {
console.log("BEGIN addAttribute");
}
// Escape Table Name
table = utils.escapeName(table);
// Setup a Sc... | javascript | {
"resource": ""
} | |
q60926 | validation | function(connectionName, table, options, data, cb) {
if (LOG_DEBUG) {
console.log("BEGIN update");
}
//LIMIT in a oracle UPDATE command is not valid
if (hop(options, 'limit')) {
return cb(new Error('Your \'LIMIT ' + options.limit + '\' is n... | javascript | {
"resource": ""
} | |
q60927 | validation | function(connectionName, table, options, cb) {
if (LOG_DEBUG) {
console.log("BEGIN destroy");
}
var connectionObject = connections[connectionName];
var collection = connectionObject.collections[table];
var _schema = connectionObje... | javascript | {
"resource": ""
} | |
q60928 | printError | validation | function printError (message) {
arrayify(message).forEach(function (msg) {
console.error(ansi.format(msg, 'red'))
})
} | javascript | {
"resource": ""
} |
q60929 | printOutput | validation | function printOutput (message) {
process.stdout.on('error', err => {
if (err.code === 'EPIPE') {
/* no big deal */
}
})
arrayify(message).forEach(function (msg) {
console.log(ansi.format(msg))
})
} | javascript | {
"resource": ""
} |
q60930 | halt | validation | function halt (err, options) {
options = Object.assign({ exitCode: 1 }, options)
if (err) {
if (err.code === 'EPIPE') {
process.exit(0) /* no big deal */
} else {
const t = require('typical')
printError(t.isString(err) ? err : options.stack ? err.stack : err.message, options)
}
}
p... | javascript | {
"resource": ""
} |
q60931 | getCli | validation | function getCli (definitions, usageSections, argv) {
const commandLineArgs = require('command-line-args')
const commandLineUsage = require('command-line-usage')
const usage = usageSections ? commandLineUsage(usageSections) : ''
const options = commandLineArgs(definitions, argv)
return { options, usage }
} | javascript | {
"resource": ""
} |
q60932 | CompositeError | validation | function CompositeError(message, innerErrors) {
this.message = message;
this.name = 'CompositeError';
this.innerErrors = normalizeInnerErrors(innerErrors);
Error.captureStackTrace(this, this.constructor);
this.originalStackDescriptor = Object.getOwnPropertyDescriptor(this, 'stack');
// Override the stack pr... | javascript | {
"resource": ""
} |
q60933 | handleRequest | validation | function handleRequest(req, res) {
var self = this;
var config = self.app.config;
// if request is type POST|config.transport.method and on /exec|config.transport.path url then parse the data and handle it
if (req.url.indexOf(config.transport.path) !== -1 && req.method.toLowerCase() === config.transport.method... | javascript | {
"resource": ""
} |
q60934 | killPosix | validation | function killPosix() {
getDescendentProcessInfo(this.pid, (err, descendent) => {
if (err) {
return
}
descendent.forEach(({PID: pid}) => {
try {
process.kill(pid)
} catch (_err) {
// ignore.
}
})
})
} | javascript | {
"resource": ""
} |
q60935 | TreeWalker | validation | function TreeWalker(ast, recv) {
var self = this;
this.ast = ast;
this.recv = recv;
this.stack =
[{traverse: ast, parent: undefined, name: undefined},
{fun: function () {
if (self.hasProp(self.recv, 'finished') &&
Function ==... | javascript | {
"resource": ""
} |
q60936 | validation | function () {
self.log("enumerate");
var result = [], keys, i, name, desc;
stm.recordRead(self);
keys = handler.getPropertyNames();
for (i = 0; i < keys.length; i += 1) {
n... | javascript | {
"resource": ""
} | |
q60937 | validation | function (obj, meta) {
var val, parentId;
if (undefined === obj || util.isPrimitive(obj)) {
return {proxied: obj, raw: obj};
}
val = this.proxiedToTVar.get(obj);
if (undefined === val) {
val = this.ob... | javascript | {
"resource": ""
} | |
q60938 | ContractInstance | validation | function ContractInstance(config) {
_classCallCheck(this, ContractInstance);
this._config = config;
this._contract = config.contract;
this._web3 = this._contract._web3;
this._address = config.address;
this._inst = this.contract._contract.at(this._address);
/*
Logger is ... | javascript | {
"resource": ""
} |
q60939 | Transaction | validation | function Transaction(config) {
_classCallCheck(this, Transaction);
this._web3 = config.parent._web3;
this._logger = config.parent._logger;
this._hash = config.hash;
} | javascript | {
"resource": ""
} |
q60940 | spawnCommandWithKill | validation | function spawnCommandWithKill(...args) {
const child = spawnCommand(...args)
child.kill = kill.bind(child)
return child
} | javascript | {
"resource": ""
} |
q60941 | applyFormat | validation | function applyFormat(method, args, string) {
// Parse a string like "1, 2, false, 'test'"
var m, pos = 0;
while ((m = string.substring(pos).match(argsExp))) {
// number
args.push(m[2] ? +m[2]
// boolean
: (m[1] ? m[1]... | javascript | {
"resource": ""
} |
q60942 | FormatError | validation | function FormatError(func, msg, value) {
this.name = 'FormatError';
this.message = new Formatter()(msg, value);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, func);
}
} | javascript | {
"resource": ""
} |
q60943 | chooseDataSource | validation | function chooseDataSource(dataSource) {
if (dataSource === 'json') {
return function(file) {
return JSON.parse(file.contents.toString());
};
} else if (dataSource === 'vinyl') {
return function(file) {
file[bodyAttribute] = file.content... | javascript | {
"resource": ""
} |
q60944 | templatesFromStream | validation | function templatesFromStream(templateStream) {
var firstTemplate = null;
templateStream.on('data', function(file) {
var relpath = file.relative;
var deferred;
if (registry.hasOwnProperty(relpath)) {
deferred = registry[relpath];
} else {
... | javascript | {
"resource": ""
} |
q60945 | noMoreTemplates | validation | function noMoreTemplates() {
registryComplete = true;
// Reject all unresolved promises
Object.keys(registry).forEach(function(templateName) {
registry[templateName].reject(noSuchTemplate(templateName));
});
theOnlyTemplate.reject(noSuchTemplate('<default>'));
} | javascript | {
"resource": ""
} |
q60946 | templateFromFile | validation | function templateFromFile(path) {
// template source is a file name
forcedTemplateName = 'singleton';
if (cache.hasOwnProperty(templateSrc)) {
registry.singleton = cache[templateSrc];
return;
}
// Have to read this template for the first time
var d... | javascript | {
"resource": ""
} |
q60947 | processFile | validation | function processFile(file, cb) {
var data = dataSource(file);
return pickTemplate(
forcedTemplateName
|| getTemplateName(data)
|| defaultTemplateName)
.then(function(template) {
file.path = replaceExt(file.path, '.html');
... | javascript | {
"resource": ""
} |
q60948 | pickTemplate | validation | function pickTemplate(templateName) {
if (templateName === THE_ONLY_TEMPLATE)
return theOnlyTemplate.promise;
if (registry.hasOwnProperty(templateName))
return registry[templateName].promise;
if (registryComplete)
throw noSuchTemplate(templateName);
re... | javascript | {
"resource": ""
} |
q60949 | getTemplateName | validation | function getTemplateName(data) {
for (var i = 0; i < templateAttribute.length; ++i) {
if (!data) return null;
data = data[templateAttribute[i]];
}
return data;
} | javascript | {
"resource": ""
} |
q60950 | deepSet | validation | function deepSet(obj, path) {
var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var define = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
if (!(0, _object.isObject)(obj)) throw new TypeError('Deepget is only supported for objects');
var par... | javascript | {
"resource": ""
} |
q60951 | deepGet | validation | function deepGet(obj, path) {
var get_parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
if (!(0, _object.isObject)(obj)) throw new TypeError('Deepget is only supported for objects');
var parts = interpolatePath(path);
// Return obj if no parts were passed or if only 1 ... | javascript | {
"resource": ""
} |
q60952 | validation | function (/*message, channel*/) {
var args = Array.prototype.slice.apply(arguments);
var message = args[0];
var rpcCallbackHandler = function () {};
// Check if event is of type "rpc".
if ('__type' in message && message.__type === 'rpc') {
// After the app... | javascript | {
"resource": ""
} | |
q60953 | toPercentage | validation | function toPercentage(val) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var min = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var max = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
if (!isNumber(val) || isN... | javascript | {
"resource": ""
} |
q60954 | round | validation | function round(val) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
if (!isNumber(val) || isNumericalNaN(val)) {
throw new TypeError('Value should be numeric');
}
if (precision === !1 || precision < 1) {
return Math.round(val);
}
var ex... | javascript | {
"resource": ""
} |
q60955 | randomBetween | validation | function randomBetween() {
var min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
if (!isNumber(min) || isNumericalNaN(min)) {
throw new TypeError('Min should be numeric');
}
if (!is... | javascript | {
"resource": ""
} |
q60956 | Flow | validation | function Flow(limit) {
this.limit = limit;
Object.defineProperty(this, "futureStack_", {
enumerable: false,
writable: true,
value: []
});
Object.defineProperty(this, "runningNum_", {
enumerable: false,
writable: true,
value: 0
});
} | javascript | {
"resource": ""
} |
q60957 | Future | validation | function Future(f, args) {
var self = this;
function run() {
args[args.length] = function cb() {
switch (arguments.length) {
case 0:
self.result = null;
break;
case 1:
if (arguments[0] instanceof Error) {
self.err = arguments[0];
} else {
se... | javascript | {
"resource": ""
} |
q60958 | hashish | validation | function hashish() {
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Math.floor(Math.random() * 100);
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var base = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 36;
return _createHash... | javascript | {
"resource": ""
} |
q60959 | indexOfMatch | validation | function indexOfMatch(string, regex, index) {
const str = index !== null ? string.substring(index) : string;
const matches = str.match(regex);
return matches ? str.indexOf(matches[0]) + index : -1;
} | javascript | {
"resource": ""
} |
q60960 | lastIndexOfMatch | validation | function lastIndexOfMatch(string, regex, index) {
const str = index !== null ? string.substring(0, index) : string;
const matches = str.match(regex);
return matches ? str.lastIndexOf(matches[matches.length - 1]) : -1;
} | javascript | {
"resource": ""
} |
q60961 | splitLines | validation | function splitLines(string, index) {
const str = index ? string.substring(index) : string;
return str.split(/\r\n|\r|\n/);
} | javascript | {
"resource": ""
} |
q60962 | inlineHandler | validation | function inlineHandler(string, selectionRange, symbol) {
let newString = string;
const newSelectionRange = [...selectionRange];
// insertSymbols determines whether to add the symbol to either end of the selected text
// Stat with assuming we will insert them (we will remove as necessary)
const insertSymbols =... | javascript | {
"resource": ""
} |
q60963 | insertHandler | validation | function insertHandler(string, selectionRange, snippet) {
const start = selectionRange[0];
const end = selectionRange[1];
const value = string.substring(0, start) + snippet + string.substring(end, string.length);
return { value, range: [start, start + snippet.length] };
} | javascript | {
"resource": ""
} |
q60964 | markymark | validation | function markymark(container = document.getElementsByTagName('marky-mark')) {
if (container instanceof HTMLElement) {
return initializer(container);
}
if (!(container instanceof Array) && !(container instanceof HTMLCollection) && !(container instanceof NodeList)) {
throw new TypeError('argument should be... | javascript | {
"resource": ""
} |
q60965 | toJavascript | validation | function toJavascript(data, mergeInto) {
var result = mergeInto || {}
var keys = Object.keys(data)
for (var i = 0; i < keys.length; i++) {
var p = keys[i]
result[p] = toJsValue(data[p])
}
return result
} | javascript | {
"resource": ""
} |
q60966 | toDDB | validation | function toDDB(data, mergeInto) {
var result = mergeInto || {}
var keys = Object.keys(data)
for (var i = 0; i < keys.length; i++) {
var p = keys[i]
result[p] = toDDBValue(data[p])
}
return result
} | javascript | {
"resource": ""
} |
q60967 | deepClone | validation | function deepClone(obj) {
if (obj == null || typeof obj !== 'object') {
return obj;
}
var cloned = obj.constructor();
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
cloned[key] = deepClone(obj[key]);
}
}
return cloned;
} | javascript | {
"resource": ""
} |
q60968 | deepMerge | validation | function deepMerge(one, another) {
if (another == null || typeof another !== 'object') {
return another;
}
if(one == null && typeof another === 'object') {
if(Array.isArray(another)) {
one = [];
} else {
one = {};
}
}
var cloned = deepClone(another);
for (var key in cloned) {
... | javascript | {
"resource": ""
} |
q60969 | contentsToDisplay | validation | function contentsToDisplay(req, res, scsId, scId = 0, cb) {
var zlSiteContentIn = app.models.zlSiteContentIn;
var Role = app.models.Role;
var compMod = require('./helpers/component-from-model')(app);
// emit that content was requested
if (res.locals.emiter.emit(`fetching content ${scsId}`, cb)) {
// if a... | javascript | {
"resource": ""
} |
q60970 | vhostof | validation | function vhostof (req, regexp, subsite) {
var host = req.headers.host
var hostname = hostnameof(req)
if (!hostname) {
return
}
var match = regexp.exec(hostname)
if (!match) {
return
}
if (subsite && 'IS_ROUTE' != subsite && !_.startsWith(req.path, subsite+'/', 1)
&& (req.get('X-Base-Url-... | javascript | {
"resource": ""
} |
q60971 | setPackagesState | validation | function setPackagesState(app, dependencies, cb) {
var zealPacks = {};
let promises = [];
_.forEach(dependencies, function(val, key) {
buildPackagesList(app, zealPacks, val, key, promises);
});
/* app.debug('Installed themes: %O', app.locals.themes);
app.debug('Installed apps: %O', app.locals.apps); */... | javascript | {
"resource": ""
} |
q60972 | loadModels | validation | function loadModels(app, datasource, src, cb = null) {
const ds = app.dataSources[datasource];
let promises = [], modelsNames = [];
let files = fs.readdirSync(src);
if (files) {
files.forEach(file => {
// load model for all model json files
if (file.endsWith('.json')) {
promises.push( n... | javascript | {
"resource": ""
} |
q60973 | makeEntity | validation | function makeEntity(req, res, all, top, data, path = '', promises) {
var Role = app.models.Role;
const { zlSite } = res.locals;
const zsBaseUrlPath = (zlSite.zsBaseUrlPath) ? `/${zlSite.zsBaseUrlPath}/` : '/'
_.forEach(_.filter(all, ['scsParent', top]), function(val) {
val = val.toJSON();
/* check if ... | javascript | {
"resource": ""
} |
q60974 | buildAllRoles | validation | function buildAllRoles(all, roles) {
all.push(...roles);
_.forEach(roles, function(role) {
// check if have inherits
if (ROLE_INHERIT[role]) {
all = buildAllRoles(all, ROLE_INHERIT[role]);
}
});
return all;
} | javascript | {
"resource": ""
} |
q60975 | makeScreenCap | validation | function makeScreenCap(zsId, url, req) {
const zlSite = app.models.zlSite;
// make screen capture (skip if is screencap request during screencap building)
if (!req.get('X-Phantom-Js')) {
let siteScreenCap = '';
let cap = spawn(`${path.join(__dirname, "helpers/phantomjs")}`, [
'--ignore-ssl-errors=t... | javascript | {
"resource": ""
} |
q60976 | curry | validation | function curry(fn) {
return function resolver() {
for (var _len = arguments.length, resolverArgs = Array(_len), _key = 0; _key < _len; _key++) {
resolverArgs[_key] = arguments[_key];
}
return function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2... | javascript | {
"resource": ""
} |
q60977 | resetLocalOrResetUTC | validation | function resetLocalOrResetUTC(increment, date, utc) {
var _incrementHandlers;
var incrementHandlers = (_incrementHandlers = {}, defineProperty(_incrementHandlers, SECOND, function (date) {
return new Date(date['set' + utc + 'Seconds'](date['get' + utc + 'Seconds'](), 0));
}), defineProperty(_incrementHandler... | javascript | {
"resource": ""
} |
q60978 | getInheritTheme | validation | function getInheritTheme(theme, tree = {}) {
if (!app.locals.themes[theme]) {
// this theme is not installed
app.error('requested theme:%s but it is not installed', theme);
return tree;
}
// add the one been requested
tree[theme] = {};
// get inheritance
var config = app.locals.themes[theme].z... | javascript | {
"resource": ""
} |
q60979 | cache | validation | function cache(app) {
if (app.locals.config.cacheDb && 'redis' === app.locals.config.cacheDb.connector) {
// use redis for cache
let redis = require("redis").createClient(app.locals.config.cacheDb);
redis.on("error", function (err) {
app.error(err);
});
// clear existing cache on startup
... | javascript | {
"resource": ""
} |
q60980 | validation | function () {
if (3 == arguments.length) {
// hash request
redis.hget(arguments[0], arguments[1], arguments[2]);
}
else if (2 == arguments.length) {
// key request
redis.get(arguments[0], arguments[1]);
}
} | javascript | {
"resource": ""
} | |
q60981 | validation | function () {
if (4 == arguments.length) {
// hash request
redis.hset(arguments[0], arguments[1], arguments[2], arguments[3]);
}
else if (3 == arguments.length) {
// key request
redis.set(arguments[0], arguments[1], arguments[2]);
}
} | javascript | {
"resource": ""
} | |
q60982 | validation | function () {
if (4 == arguments.length) {
// key request
redis.set(arguments[0], arguments[1], () => {
redis.expire(arguments[0], arguments[2], arguments[3]);
});
}
} | javascript | {
"resource": ""
} | |
q60983 | validation | function () {
if (3 == arguments.length) {
// hash request
redis.hdel(arguments[0], arguments[1], arguments[2]);
}
else if (2 == arguments.length) {
// key request
redis.del(arguments[0], arguments[1]);
}
} | javascript | {
"resource": ""
} | |
q60984 | bypass | validation | function bypass(req, conditions = {files: 1, api: 1}) {
if (conditions.files) {
// bypass all files request
let regexp = /\w+\.\w+$/i;
if (req.path.match(regexp)) {
return true;
}
}
if (conditions.api) {
// bypass api request
let regexp = /^\/api\//i;
if (req.path.match(regexp)) ... | javascript | {
"resource": ""
} |
q60985 | authCtx | validation | function authCtx(req, res) {
let ctx = {
accessToken: null,
remotingContext: { req: req, res: res }
}
// populate accessToken
if (req && req.accessToken) ctx.accessToken = req.accessToken;
return ctx;
} | javascript | {
"resource": ""
} |
q60986 | mailCommon | validation | function mailCommon(type, data, req, res) {
const { zlSite } = res.locals;
if ('form-notice' === type) {
if (data.text) {
data.text += `\nReferred By: ${req.cookies.referer}\n\n`+
`-----------------------------------------------------------`+
`\nThis message was triggered by a website use... | javascript | {
"resource": ""
} |
q60987 | recaptchaVerify | validation | function recaptchaVerify(req, res, action = 'form_submit', cb, token = '', threshold = 0.3) {
const { zlSite } = res.locals;
if (zlSite.user) {
// signed in user don't need to verify
cb();
}
else {
if (!token && 'POST' === req.method) {
token = req.body.recaptcha;
}
if (!token) {
... | javascript | {
"resource": ""
} |
q60988 | copyFileFrom | validation | function copyFileFrom(file, to_dir){
var sys = require("sys");
var fs = require('fs');
var file_name = filenameFromPath(file);
if (file_name == ".DS_Store") {
return;
}
sys.pump(fs.createReadStream(file), fs.createWriteStream(to_dir),function(){
console.log("Copied file: " + fi... | javascript | {
"resource": ""
} |
q60989 | realDestinationPath | validation | function realDestinationPath(file, from_dir, to_dir)
{
var length = from_dir.length;
var from_dir_path = file.substring(length, file.length);
return to_dir + from_dir_path;
} | javascript | {
"resource": ""
} |
q60990 | removeFileAtPath | validation | function removeFileAtPath(file, to_dir){
var fs = require('fs');
var file_name = filenameFromPath(file);
var file_at_dest_dir = to_dir + file_name;
fs.unlink(file_at_dest_dir);
console.log("Removed file at directory: " + file_at_dest_dir);
} | javascript | {
"resource": ""
} |
q60991 | base | validation | function base(args, ctor) {
var plain = false;
// class instance constructor
function clas() {
// we can't simply use a plain new clas() here
// since we might get called unbound from a child class
// or as a constructor
// therefore we must use t... | javascript | {
"resource": ""
} |
q60992 | clas | validation | function clas() {
// we can't simply use a plain new clas() here
// since we might get called unbound from a child class
// or as a constructor
// therefore we must use the correct 'this' in that case
if (this !== global) {
plain ? (plain = fal... | javascript | {
"resource": ""
} |
q60993 | sizeIt | validation | function sizeIt(gridSize, sizeEle, sizeScreen = 'xs') {
// determine outer size
let outerSize = _getOuterSize(gridSize, sizeScreen);
// subtract outer from this size
let size = sizeEle * grid/outerSize;
if (size > grid) size = grid;
else if (size < 1) size = 1;
return Math.round(size);
} | javascript | {
"resource": ""
} |
q60994 | _getOuterSize | validation | function _getOuterSize(gridSize, sizeScreen) {
if ('lg' === sizeScreen) {
if (gridSize && gridSize.lg) {
return gridSize.lg;
}
else if (gridSize && gridSize.md) {
return gridSize.md;
}
else if (gridSize && gridSize.sm) {
return gridSize.sm;
}
else if (gridSize && gridSize... | javascript | {
"resource": ""
} |
q60995 | RecursiveConcat | validation | function RecursiveConcat(options) {
this.concat = null;
this.currentCountDirectories = 0;
this.currentCountFiles = 0;
this.currentFolder = null;
this.newFileGenerated = null;
this.newFinalFile = "";
this.options = options;
this.walkCounter=0;
this.stream = new Transform({objectMode: true});
this.stream._tran... | javascript | {
"resource": ""
} |
q60996 | check_role_authorization | validation | function check_role_authorization(req, res, next) {
if (!req.hasOwnProperty("user") || !req.user.hasOwnProperty('authorized_roles') ||
!(req.user.authorized_roles instanceof Array) || req.user.authorized_roles.length === 0){
running_debug("Unhautorized: Invalid role or path not configured");
... | javascript | {
"resource": ""
} |
q60997 | InSicht | validation | function InSicht() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, InSicht);
this.options = Object.assign({}, defaults, options);
this.init();
} | javascript | {
"resource": ""
} |
q60998 | userFromToken | validation | function userFromToken(req, cb) {
const { accessToken } = req;
app.models.zlUser.findById(accessToken.userId, (err, usr) => {
if (!err && usr) {
cb(null, usr);
}
else cb(err);
});
} | javascript | {
"resource": ""
} |
q60999 | render | validation | function render(rawCode, idPre) {
var codeArr = {};
// get js that is a src ref
// TODO: need to check for `async` OR `defer` prop
var re = /<script[^>]* src\s*=\s*'*"*([^'"]+)[^>]*>.*<\/script>/gi;
var HeaderCode = re.exec(rawCode);
if (HeaderCode) {
_.forEach(HeaderCode, function(code, key) {
i... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.