_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q59000 | initProcessor | validation | function initProcessor(options = {}, defaultBabelProcessorName) {
let {js, css, tpl, wxs} = options;
if (tpl !== false) {
initTplProcessor(tpl);
}
if (css !== false) {
initStyleProcessor(css);
}
if (js !== false) {
initJsProcessor(js, defaultBabelProcessorName);
}
... | javascript | {
"resource": ""
} |
q59001 | process | validation | function process(file, options) {
let content = file.content.toString();
let {config: rules, logger} = options;
let result = content;
try {
result = doReplacement(content, rules || [], file);
}
catch (ex) {
let tip;
if (ex === 'devServer') {
tip = ', please e... | javascript | {
"resource": ""
} |
q59002 | convertMediaQueryToJSExpression | validation | function convertMediaQueryToJSExpression(tokens, allAppTypes, appType) {
let result = [];
tokens.forEach(item => {
item = item.trim();
if (allAppTypes.includes(item)) {
result.push(`('${item}' === '${appType}')`);
}
else if (item === 'and') {
result.push('... | javascript | {
"resource": ""
} |
q59003 | isAppMediaMatch | validation | function isAppMediaMatch(params, tokens, allAppTypes, appType) {
let expression = convertMediaQueryToJSExpression(tokens, allAppTypes, appType);
try {
return {
/* eslint-disable fecs-no-eval */
value: eval(expression),
expression
};
}
catch (ex) {
... | javascript | {
"resource": ""
} |
q59004 | normalizeAppMediaQueryTokens | validation | function normalizeAppMediaQueryTokens(tokens) {
for (let i = tokens.length - 1; i >= 0; i--) {
let item = tokens[i].trim();
if (item && item !== '(') {
break;
}
tokens.pop();
}
} | javascript | {
"resource": ""
} |
q59005 | initAppMediaTargetInfo | validation | function initAppMediaTargetInfo(ctx, currToken) {
let {allAppTypes, hasAppMediaType} = ctx;
let isAppMediaTarget = allAppTypes.includes(currToken);
hasAppMediaType || (ctx.hasAppMediaType = isAppMediaTarget);
if (!isAppMediaTarget && !MEDIA_QUERY_OPERATORS.includes(currToken)) {
return true;
... | javascript | {
"resource": ""
} |
q59006 | initAppMediaQueryToken | validation | function initAppMediaQueryToken(ctx, buffer, separator) {
let currToken = buffer.trim();
let {tokens} = ctx;
if (currToken) {
if (initAppMediaTargetInfo(ctx, currToken)) {
return true;
}
tokens.push(buffer);
tokens.push(separator);
return '';
}
... | javascript | {
"resource": ""
} |
q59007 | parseAppMediaQueryParam | validation | function parseAppMediaQueryParam(allAppTypes, params) {
let ctx = {
allAppTypes,
hasAppMediaType: false,
tokens: []
};
let buffer = '';
for (let i = 0, len = params.length; i < len; i++) {
let c = params[i];
if (QUERY_PARAMS_SEPARATORS.includes(c)) {
... | javascript | {
"resource": ""
} |
q59008 | compilePug | validation | function compilePug(file, options) {
let content = file.content.toString();
// 取出用于pug模板的配置项,包括渲染所需的数据(data字段)
let config = options.config || {};
// 考虑到给之后的处理器传递数据,所以这里强制 pretty 为true
config.pretty = true;
let data = config.data;
delete config.data;
let fn = pug.compile(content, config)... | javascript | {
"resource": ""
} |
q59009 | initJsProcessor | validation | function initJsProcessor(opts, defaultBabelProcessorName) {
let plugins = (opts && opts.plugins) || [adapterPlugin];
registerProcessor({
name: (opts && opts.processor) || defaultBabelProcessorName, // override existed processor
hook: {
before(file, options) {
if (file... | javascript | {
"resource": ""
} |
q59010 | initProcessor | validation | function initProcessor(options = {}, defaultBabelProcessorName) {
let {js} = options;
if (js !== false) {
initJsProcessor(js, defaultBabelProcessorName);
}
} | javascript | {
"resource": ""
} |
q59011 | confirm | validation | function confirm(params) {
params = _.extend({
text: 'Are you sure?',
yesText: 'Yes',
yesClass: 'btn-danger',
noText: 'Cancel',
escapedHtml: false,
msgConfirmation: false,
additionalText: '',
name: ''
}, params);
$('#g-dialog-container').html(C... | javascript | {
"resource": ""
} |
q59012 | wrap | validation | function wrap(obj, funcName, wrapper) {
obj.prototype[funcName] = _.wrap(obj.prototype[funcName], wrapper);
} | javascript | {
"resource": ""
} |
q59013 | validation | function (opts) {
opts = opts || {};
const defaults = {
// the default 'method' is 'GET', as set by 'jquery.ajax'
girderToken: getCurrentToken() || cookie.find('girderToken'),
error: (error, status) => {
let info;
if (error.status === 401) {
even... | javascript | {
"resource": ""
} | |
q59014 | sortOperations | validation | function sortOperations(op1, op2) {
var pathCmp = op1.path.localeCompare(op2.path);
if (pathCmp !== 0) {
return pathCmp;
}
var index1 = methodOrder.indexOf(op1.method);
var index2 = methodOrder.indexOf(op2.method);
if (index1 > -1 && index2 > -1) {
... | javascript | {
"resource": ""
} |
q59015 | formatDate | validation | function formatDate(datestr, resolution) {
datestr = datestr.replace(' ', 'T'); // Cross-browser accepted date format
var date = new Date(datestr);
var output = MONTHS[date.getMonth()];
resolution = resolution || DATE_MONTH;
if (resolution >= DATE_DAY) {
output += ' ' + date.getDate() + ',... | javascript | {
"resource": ""
} |
q59016 | formatSize | validation | function formatSize(sizeBytes) {
if (sizeBytes < 1024) {
return sizeBytes + ' B';
}
var i, sizeVal = sizeBytes, precision = 1;
for (i = 0; sizeVal >= 1024; i += 1) {
sizeVal /= 1024;
}
// If we are just reporting a low number, no need for decimal places.
if (sizeVal < 10) {
... | javascript | {
"resource": ""
} |
q59017 | formatCount | validation | function formatCount(n, opts) {
n = n || 0;
opts = opts || {};
var i = 0,
base = opts.base || 1000,
sep = opts.sep || '',
maxLen = opts.maxLen || 3,
precision = maxLen - 1;
for (; n > base; i += 1) {
n /= base;
}
if (!i) {
precision = 0;
} e... | javascript | {
"resource": ""
} |
q59018 | localeComparator | validation | function localeComparator(model1, model2) {
var a1 = model1.get(this.sortField),
a2 = model2.get(this.sortField);
if (a1 !== undefined && a1.localeCompare) {
var result = a1.localeCompare(a2) * this.sortDir;
if (result || !this.secondarySortField) {
return result;
}
... | javascript | {
"resource": ""
} |
q59019 | localeSort | validation | function localeSort(a1, a2) {
if (a1 !== undefined && a1.localeCompare) {
return a1.localeCompare(a2);
}
return a1 > a2 ? 1 : (a1 < a2 ? -1 : 0);
} | javascript | {
"resource": ""
} |
q59020 | addFile | validation | function addFile(filename) {
var file = zip.addFile(filename);
var sha = new SHAWriteStream(manifest, filename, file);
return sha;
} | javascript | {
"resource": ""
} |
q59021 | signManifest | validation | function signManifest(template, manifest, callback) {
var identifier = template.passTypeIdentifier().replace(/^pass./, "");
var args = [
"smime",
"-sign", "-binary",
"-signer", Path.resolve(template.keysPath, identifier + ".pem"),
"-certfile", Path.resolve(template.keysPath, "wwdr.pem"),
"-... | javascript | {
"resource": ""
} |
q59022 | cloneObject | validation | function cloneObject(object) {
var clone = {};
if (object) {
for (var key in object)
clone[key] = object[key];
}
return clone;
} | javascript | {
"resource": ""
} |
q59023 | nanoRemainder | validation | function nanoRemainder(msFloat) {
var modulo = 1e6;
var remainder = (msFloat * 1e6) % modulo;
var positiveRemainder = remainder < 0 ? remainder + modulo : remainder;
return Math.floor(positiveRemainder);
} | javascript | {
"resource": ""
} |
q59024 | getEpoch | validation | function getEpoch(epoch) {
if (!epoch) { return 0; }
if (typeof epoch.getTime === "function") { return epoch.getTime(); }
if (typeof epoch === "number") { return epoch; }
throw new TypeError("now should be milliseconds since UNIX epoch");
} | javascript | {
"resource": ""
} |
q59025 | tryShutdown | validation | async function tryShutdown () {
if (jobsToComplete === 0) {
await new Promise((resolve) => { setTimeout(resolve, 500) })
await worker.end()
process.exit()
}
} | javascript | {
"resource": ""
} |
q59026 | validation | function (itemData) {
var newItems = this.items.concat(itemData),
// Calculate aspect ratios for items only; exclude spacing
rowWidthWithoutSpacing = this.width - (newItems.length - 1) * this.spacing,
newAspectRatio = newItems.reduce(function (sum, item) {
return sum + item.aspectRatio;
}, 0),
tar... | javascript | {
"resource": ""
} | |
q59027 | validation | function (newHeight, widowLayoutStyle) {
var itemWidthSum = this.left,
rowWidthWithoutSpacing = this.width - (this.items.length - 1) * this.spacing,
clampedToNativeRatio,
clampedHeight,
errorWidthPerItem,
roundedCumulativeErrors,
singleItemGeometry,
centerOffset;
// Justify unless explicitly ... | javascript | {
"resource": ""
} | |
q59028 | createNewRow | validation | function createNewRow(layoutConfig, layoutData) {
var isBreakoutRow;
// Work out if this is a full width breakout row
if (layoutConfig.fullWidthBreakoutRowCadence !== false) {
if (((layoutData._rows.length + 1) % layoutConfig.fullWidthBreakoutRowCadence) === 0) {
isBreakoutRow = true;
}
}
return new Row(... | javascript | {
"resource": ""
} |
q59029 | validation | function (path, strategy) {
if (typeof path !== 'string') {
throw new Error('path should be a string');
}
if (!util.isFolder(path)) {
throw new Error('path should be a folder');
}
if (this._remoteStorage && this._remoteStorage.access &&
!this._remoteStorage.access.checkPathPermis... | javascript | {
"resource": ""
} | |
q59030 | validation | function (cb) {
var i;
log('[Caching] Setting activate handler', cb, this.pendingActivations);
this.activateHandler = cb;
for (i=0; i<this.pendingActivations.length; i++) {
cb(this.pendingActivations[i]);
}
delete this.pendingActivations;
} | javascript | {
"resource": ""
} | |
q59031 | validation | function (path) {
if (this._rootPaths[path] !== undefined) {
return this._rootPaths[path];
} else if (path === '/') {
return 'SEEN';
} else {
return this.checkPath(containingFolder(path));
}
} | javascript | {
"resource": ""
} | |
q59032 | validation | function(scope, mode) {
if (typeof(scope) !== 'string' || scope.indexOf('/') !== -1 || scope.length === 0) {
throw new Error('Scope should be a non-empty string without forward slashes');
}
if (!mode.match(/^rw?$/)) {
throw new Error('Mode should be either \'r\' or \'rw\'');
}
this._adju... | javascript | {
"resource": ""
} | |
q59033 | validation | function(scope) {
var savedMap = {};
var name;
for (name in this.scopeModeMap) {
savedMap[name] = this.scopeModeMap[name];
}
this.reset();
delete savedMap[scope];
for (name in savedMap) {
this.set(name, savedMap[name]);
}
} | javascript | {
"resource": ""
} | |
q59034 | metaTitleFromFileName | validation | function metaTitleFromFileName (filename) {
if (filename.substr(-1) === '/') {
filename = filename.substr(0, filename.length - 1);
}
return decodeURIComponent(filename);
} | javascript | {
"resource": ""
} |
q59035 | baseName | validation | function baseName (path) {
const parts = path.split('/');
if (path.substr(-1) === '/') {
return parts[parts.length-2]+'/';
} else {
return parts[parts.length-1];
}
} | javascript | {
"resource": ""
} |
q59036 | validation | function () {
this.rs.setBackend('googledrive');
this.rs.authorize({ authURL: AUTH_URL, scope: AUTH_SCOPE, clientId: this.clientId });
} | javascript | {
"resource": ""
} | |
q59037 | validation | function (path, body, contentType, options) {
const fullPath = googleDrivePath(path);
function putDone(response) {
if (response.status >= 200 && response.status < 300) {
const meta = JSON.parse(response.responseText);
const etagWithoutQuotes = removeQuotes(meta.etag);
return Promi... | javascript | {
"resource": ""
} | |
q59038 | validation | function (path, options) {
const fullPath = googleDrivePath(path);
return this._getFileId(fullPath).then((id) => {
if (!id) {
// File doesn't exist. Ignore.
return Promise.resolve({statusCode: 200});
}
return this._getMeta(id).then((meta) => {
let etagWithoutQuotes;
... | javascript | {
"resource": ""
} | |
q59039 | validation | function () {
const url = BASE_URL + '/drive/v2/about?fields=user';
// requesting user info(mainly for userAdress)
return this._request('GET', url, {}).then(function (resp){
try {
const info = JSON.parse(resp.responseText);
return Promise.resolve(info);
} catch (e) {
retu... | javascript | {
"resource": ""
} | |
q59040 | validation | function (id, path, body, contentType, options) {
const metadata = {
mimeType: contentType
};
const headers = {
'Content-Type': 'application/json; charset=UTF-8'
};
if (options && options.ifMatch) {
headers['If-Match'] = '"' + options.ifMatch + '"';
}
return this._request... | javascript | {
"resource": ""
} | |
q59041 | validation | function (path, body, contentType/*, options*/) {
return this._getParentId(path).then((parentId) => {
const fileName = baseName(path);
const metadata = {
title: metaTitleFromFileName(fileName),
mimeType: contentType,
parents: [{
kind: "drive#fileLink",
id: par... | javascript | {
"resource": ""
} | |
q59042 | validation | function (path, options) {
return this._getFileId(path).then((id) => {
return this._getMeta(id).then((meta) => {
let etagWithoutQuotes;
if (typeof(meta) === 'object' && typeof(meta.etag) === 'string') {
etagWithoutQuotes = removeQuotes(meta.etag);
}
if (options && op... | javascript | {
"resource": ""
} | |
q59043 | validation | function (path/*, options*/) {
return this._getFileId(path).then((id) => {
let query, fields, data, etagWithoutQuotes, itemsMap;
if (! id) {
return Promise.resolve({statusCode: 404});
}
query = '\'' + id + '\' in parents';
fields = 'items(downloadUrl,etag,fileSize,id,mimeType,... | javascript | {
"resource": ""
} | |
q59044 | validation | function (path) {
const foldername = parentPath(path);
return this._getFileId(foldername).then((parentId) => {
if (parentId) {
return Promise.resolve(parentId);
} else {
return this._createFolder(foldername);
}
});
} | javascript | {
"resource": ""
} | |
q59045 | validation | function (path) {
return this._getParentId(path).then((parentId) => {
return this._request('POST', BASE_URL + '/drive/v2/files', {
body: JSON.stringify({
title: metaTitleFromFileName(baseName(path)),
mimeType: GD_DIR_MIME_TYPE,
parents: [{
id: parentId
... | javascript | {
"resource": ""
} | |
q59046 | validation | function (path) {
let id;
if (path === '/') {
// "root" is a special alias for the fileId of the root folder
return Promise.resolve('root');
} else if ((id = this._fileIdCache.get(path))) {
// id is cached.
return Promise.resolve(id);
}
// id is not cached (or file doesn't e... | javascript | {
"resource": ""
} | |
q59047 | validation | function (id) {
return this._request('GET', BASE_URL + '/drive/v2/files/' + id, {}).then(function (response) {
if (response.status === 200) {
return Promise.resolve(JSON.parse(response.responseText));
} else {
return Promise.reject("request (getting metadata for " + id + ") failed with s... | javascript | {
"resource": ""
} | |
q59048 | unHookGetItemURL | validation | function unHookGetItemURL (rs) {
if (!rs._origBaseClientGetItemURL) { return; }
BaseClient.prototype.getItemURL = rs._origBaseClientGetItemURL;
delete rs._origBaseClientGetItemURL;
} | javascript | {
"resource": ""
} |
q59049 | validation | function (eventName, handler) {
if (typeof(eventName) !== 'string') {
throw new Error('Argument eventName should be a string');
}
if (typeof(handler) !== 'function') {
throw new Error('Argument handler should be a function');
}
log('[Eventhandling] Adding event listener', eventName);
... | javascript | {
"resource": ""
} | |
q59050 | validation | function (eventName, handler) {
this._validateEvent(eventName);
var hl = this._handlers[eventName].length;
for (var i=0;i<hl;i++) {
if (this._handlers[eventName][i] === handler) {
this._handlers[eventName].splice(i, 1);
return;
}
}
} | javascript | {
"resource": ""
} | |
q59051 | Discover | validation | function Discover(userAddress) {
return new Promise((resolve, reject) => {
if (userAddress in cachedInfo) {
return resolve(cachedInfo[userAddress]);
}
var webFinger = new WebFinger({
tls_only: false,
uri_fallback: true,
request_timeout: 5000
});
return webFinger.lookup(u... | javascript | {
"resource": ""
} |
q59052 | validation | function () {
// TODO handling when token is already present
this.rs.setBackend('dropbox');
if (this.token){
hookIt(this.rs);
} else {
this.rs.authorize({ authURL: AUTH_URL, scope: '', clientId: this.clientId });
}
} | javascript | {
"resource": ""
} | |
q59053 | validation | function (path) {
var url = 'https://api.dropboxapi.com/2/files/list_folder';
var revCache = this._revCache;
var self = this;
var processResponse = function (resp) {
var body, listing;
if (resp.status !== 200 && resp.status !== 409) {
return Promise.reject('Unexpected response stat... | javascript | {
"resource": ""
} | |
q59054 | validation | function (path, options) {
if (! this.connected) { return Promise.reject("not connected (path: " + path + ")"); }
var url = 'https://content.dropboxapi.com/2/files/download';
var self = this;
var savedRev = this._revCache.get(path);
if (savedRev === null) {
// file was deleted server side
... | javascript | {
"resource": ""
} | |
q59055 | validation | function (path) {
var url = 'https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings';
var options = {
body: {path: getDropboxPath(path)}
};
return this._request('POST', url, options).then((response) => {
if (response.status !== 200 && response.status !== 409) {
return... | javascript | {
"resource": ""
} | |
q59056 | validation | function () {
var url = 'https://api.dropboxapi.com/2/users/get_current_account';
return this._request('POST', url, {}).then(function (response) {
var info = response.responseText;
try {
info = JSON.parse(info);
} catch (e) {
return Promise.reject(new Error('Could not query c... | javascript | {
"resource": ""
} | |
q59057 | validation | function (path) {
const url = 'https://api.dropboxapi.com/2/files/delete';
const requestBody = { path: getDropboxPath(path) };
return this._request('POST', url, { body: requestBody }).then((response) => {
if (response.status !== 200 && response.status !== 409) {
return Promise.resolve({status... | javascript | {
"resource": ""
} | |
q59058 | validation | function (path) {
var url = 'https://api.dropbox.com/2/sharing/list_shared_links';
var options = {
body: {
path: getDropboxPath(path),
direct_only: true
}
};
return this._request('POST', url, options).then((response) => {
if (response.status !== 200 && response.status ... | javascript | {
"resource": ""
} | |
q59059 | hookSync | validation | function hookSync(rs) {
if (rs._dropboxOrigSync) { return; } // already hooked
rs._dropboxOrigSync = rs.sync.sync.bind(rs.sync);
rs.sync.sync = function () {
return this.dropbox.fetchDelta.apply(this.dropbox, arguments).
then(rs._dropboxOrigSync, function (err) {
rs._emit('error', new Sync.SyncE... | javascript | {
"resource": ""
} |
q59060 | unHookSync | validation | function unHookSync(rs) {
if (! rs._dropboxOrigSync) { return; } // not hooked
rs.sync.sync = rs._dropboxOrigSync;
delete rs._dropboxOrigSync;
} | javascript | {
"resource": ""
} |
q59061 | hookSyncCycle | validation | function hookSyncCycle(rs) {
if (rs._dropboxOrigSyncCycle) { return; } // already hooked
rs._dropboxOrigSyncCycle = rs.syncCycle;
rs.syncCycle = () => {
if (rs.sync) {
hookSync(rs);
rs._dropboxOrigSyncCycle(arguments);
unHookSyncCycle(rs);
} else {
throw new Error('expected sync to... | javascript | {
"resource": ""
} |
q59062 | unHookSyncCycle | validation | function unHookSyncCycle(rs) {
if (!rs._dropboxOrigSyncCycle) { return; } // not hooked
rs.syncCycle = rs._dropboxOrigSyncCycle;
delete rs._dropboxOrigSyncCycle;
} | javascript | {
"resource": ""
} |
q59063 | hookGetItemURL | validation | function hookGetItemURL (rs) {
if (rs._origBaseClientGetItemURL) { return; }
rs._origBaseClientGetItemURL = BaseClient.prototype.getItemURL;
BaseClient.prototype.getItemURL = function (/*path*/) {
throw new Error('getItemURL is not implemented for Dropbox yet');
};
} | javascript | {
"resource": ""
} |
q59064 | extractFeatures | validation | function extractFeatures(chunk) {
//make it a F32A for efficiency
var frame = arrayToTyped(chunk);
//run the extraction of selected features
var fset = Meyda.extract(featuresToExtract, frame);
for (let j = 0; j < featuresToExtract.length; j++) {
var feature = fset[featuresToExtract[j]];
... | javascript | {
"resource": ""
} |
q59065 | getIdFromURL | validation | function getIdFromURL (url) {
var id = url.replace(youtubeRegexp, '$1');
if (id.includes(';')) {
var pieces = id.split(';');
if (pieces[1].includes('%')) {
var uriComponent = decodeURIComponent(pieces[1]);
id = ("http://youtube.com" + uriComponent).replace(youtubeRegexp, '$1');
} else {
... | javascript | {
"resource": ""
} |
q59066 | getTimeFromURL | validation | function getTimeFromURL (url) {
if ( url === void 0 ) url = '';
var times = url.match(timeRegexp);
if (!times) {
return 0
}
var full = times[0];
var minutes = times[1];
var seconds = times[2];
if (typeof seconds !== 'undefined') {
seconds = parseInt(seconds, 10);
minutes = parseInt(minut... | javascript | {
"resource": ""
} |
q59067 | onTablesSelected | validation | function onTablesSelected(tables) {
// Assign partialed functions to make the code slightly more readable
steps.collect = mapValues(steps.collect, function(method) {
return partial(method, adapter, { tables: tables });
});
// Collect the data in parallel
async.parallel(steps.collect, onTabl... | javascript | {
"resource": ""
} |
q59068 | onTableDataCollected | validation | function onTableDataCollected(err, data) {
bailOnError(err);
var tableName, models = {}, model;
for (tableName in data.tableStructure) {
model = steps.tableToObject({
name: tableName,
columns: data.tableStructure[tableName],
comment: data.tableComments[tableName]... | javascript | {
"resource": ""
} |
q59069 | getOffset | validation | function getOffset(cursor, defaultOffset) {
if (typeof cursor === 'undefined' || cursor === null) {
return defaultOffset;
}
let offset = cursorToOffset(cursor);
if (isNaN(offset)) {
return defaultOffset;
}
return offset;
} | javascript | {
"resource": ""
} |
q59070 | importSpecifier | validation | function importSpecifier(name, def) {
return {
type: def === true ? 'ImportDefaultSpecifier' : 'ImportSpecifier',
id: {
type: 'Identifier',
name: name
},
name: null
};
} | javascript | {
"resource": ""
} |
q59071 | ruleCodes | validation | function ruleCodes(flags, value) {
var flag = flags.FLAG
var result = []
var length
var index
if (!value) {
return result
}
if (flag === 'long') {
index = 0
length = value.length
while (index < length) {
result.push(value.substr(index, 2))
index += 2
}
return resul... | javascript | {
"resource": ""
} |
q59072 | add | validation | function add(buf) {
var self = this
var flags = self.flags
var lines = buf.toString('utf8').split('\n')
var length = lines.length
var index = -1
var line
var forbidden
var word
var model
var flag
// Ensure there’s a key for `FORBIDDENWORD`: `false` cannot be set through an
// affix file so its ... | javascript | {
"resource": ""
} |
q59073 | generate | validation | function generate(context, memory, words, edits) {
var characters = context.flags.TRY
var characterLength = characters.length
var data = context.data
var flags = context.flags
var result = []
var upper
var length
var index
var word
var position
var count
var before
var after
var nextAfter
... | javascript | {
"resource": ""
} |
q59074 | check | validation | function check(value, double) {
var state = memory.state[value]
var corrected
if (state !== Boolean(state)) {
result.push(value)
corrected = form(context, value)
state = corrected && !flag(flags, noSuggestType, data[corrected])
memory.state[value] = state
if (state) {
... | javascript | {
"resource": ""
} |
q59075 | add | validation | function add(word, rules) {
// Some dictionaries will list the same word multiple times with different
// rule sets.
var curr = (own.call(dict, word) && dict[word]) || []
dict[word] = curr.concat(rules || [])
} | javascript | {
"resource": ""
} |
q59076 | flag | validation | function flag(values, value, flags) {
return flags && own.call(values, value) && flags.indexOf(values[value]) !== -1
} | javascript | {
"resource": ""
} |
q59077 | normalize | validation | function normalize(value, patterns) {
var length = patterns.length
var index = -1
var pattern
while (++index < length) {
pattern = patterns[index]
value = value.replace(pattern[0], pattern[1])
}
return value
} | javascript | {
"resource": ""
} |
q59078 | form | validation | function form(context, value, all) {
var dict = context.data
var flags = context.flags
var alternative
value = trim(value)
if (!value) {
return null
}
value = normalize(value, context.conversion.in)
if (exact(context, value)) {
if (!all && flag(flags, 'FORBIDDENWORD', dict[value])) {
r... | javascript | {
"resource": ""
} |
q59079 | NSpell | validation | function NSpell(aff, dic) {
var length
var index
var dictionaries
if (!(this instanceof NSpell)) {
return new NSpell(aff, dic)
}
if (typeof aff === 'string' || buffer(aff)) {
if (typeof dic === 'string' || buffer(dic)) {
dictionaries = [{dic: dic}]
}
} else if (aff) {
if ('length' ... | javascript | {
"resource": ""
} |
q59080 | add | validation | function add(value, model) {
var self = this
var dict = self.data
var codes = model && own.call(dict, model) ? dict[model].concat() : []
push(dict, value, codes, self)
return self
} | javascript | {
"resource": ""
} |
q59081 | parse | validation | function parse(buf, options, dict) {
var index
var last
var value
// Parse as lines.
value = buf.toString(UTF8)
last = value.indexOf(linefeed) + 1
index = value.indexOf(linefeed, last)
while (index !== -1) {
if (value.charCodeAt(last) !== tab) {
parseLine(value.slice(last, index), options, d... | javascript | {
"resource": ""
} |
q59082 | parseLine | validation | function parseLine(line, options, dict) {
var word
var codes
var result
var hashOffset
var slashOffset
// Find offsets.
slashOffset = line.indexOf(slash)
while (slashOffset !== -1 && line.charAt(slashOffset - 1) === backslash) {
line = line.slice(0, slashOffset - 1) + line.slice(slashOffset)
sl... | javascript | {
"resource": ""
} |
q59083 | casing | validation | function casing(value) {
var head = exact(value.charAt(0))
var rest = value.slice(1)
if (!rest) {
return head
}
rest = exact(rest)
if (head === rest) {
return head
}
if (head === 'u' && rest === 'l') {
return 's'
}
return null
} | javascript | {
"resource": ""
} |
q59084 | apply | validation | function apply(value, rule, rules) {
var entries = rule.entries
var words = []
var index = -1
var length = entries.length
var entry
var next
var continuationRule
var continuation
var position
var count
while (++index < length) {
entry = entries[index]
if (!entry.match || value.match(entr... | javascript | {
"resource": ""
} |
q59085 | spell | validation | function spell(word) {
var self = this
var dict = self.data
var flags = self.flags
var value = form(self, word, true)
// Hunspell also provides `root` (root word of the input word), and `compound`
// (whether `word` was compound).
return {
correct: self.correct(word),
forbidden: Boolean(value && ... | javascript | {
"resource": ""
} |
q59086 | add | validation | function add(buf) {
var self = this
var compound = self.compoundRules
var compoundCodes = self.compoundRuleCodes
var index = -1
var length = compound.length
var rule
var source
var character
var offset
var count
parse(buf, self, self.data)
// Regenerate compound expressions.
while (++index <... | javascript | {
"resource": ""
} |
q59087 | exact | validation | function exact(context, value) {
var data = context.data
var flags = context.flags
var codes = own.call(data, value) ? data[value] : null
var compound
var index
var length
if (codes) {
return !flag(flags, 'ONLYINCOMPOUND', codes)
}
compound = context.compoundRules
length = compound.length
in... | javascript | {
"resource": ""
} |
q59088 | validation | function() {
var retVal, parsedOptions;
if (this.model) {
retVal = this.model.toJSON();
} else if (this.collection) {
retVal = {
models: this.collection.toJSON(),
meta: this.collection.meta,
params: this.collection.params
};
}
// Remove options that are du... | javascript | {
"resource": ""
} | |
q59089 | validation | function(data) {
if (this.app) {
data._app = this.app;
}
if (this.model) {
data._model = this.model;
}
if (this.collection) {
data._collection = this.collection;
}
data._view = this;
return data;
} | javascript | {
"resource": ""
} | |
q59090 | validation | function() {
var attributes = {},
fetchSummary = {},
modelUtils = this.app.modelUtils,
nonAttributeOptions = this.nonAttributeOptions;
if (this.attributes) {
_.extend(attributes, _.result(this, 'attributes'));
}
if (this.id) {
attributes.id = _.result(this, "id");
... | javascript | {
"resource": ""
} | |
q59091 | validation | function() {
var template = this.getTemplate(),
data;
this._preRender();
data = this.getTemplateData();
data = this.decorateTemplateData(data);
if (template == null) {
throw new Error(this.name + ": template \"" + this.getTemplateName() + "\" not found.");
}
return template(da... | javascript | {
"resource": ""
} | |
q59092 | validation | function() {
var html = this.getInnerHtml(),
attributes = this.getAttributes(),
tagName = _.result(this, "tagName"),
attrString;
attrString = _.inject(attributes, function(memo, value, key) {
return memo += " " + key + "=\"" + _.escape(value) + "\"";
}, '');
return "<" + ... | javascript | {
"resource": ""
} | |
q59093 | validation | function() {
var params = {},
fetchOptions,
fetchSpec;
if (this.options.fetch_params) {
if (!_.isObject(this.options.fetch_params)) {
throw new Error('fetch_params must be an object for lazy loaded views');
}
params = this.options.fetch_params;
} else if (this.opt... | javascript | {
"resource": ""
} | |
q59094 | getAppAttributes | validation | function getAppAttributes(attrs, req, res) {
if (typeof attrs === 'function') {
attrs = attrs(req, res);
}
return attrs || {};
} | javascript | {
"resource": ""
} |
q59095 | actionCall | validation | function actionCall(action, params) {
action.call(router, params, router.getRenderCallback(route));
} | javascript | {
"resource": ""
} |
q59096 | validation | function(pattern, controller, options) {
var realAction, action, handler, route, routeObj, routerContext = this;
route = parseRouteDefinitions([controller, options]);
realAction = this.getAction(route);
if (isServer) {
action = realAction;
} else {
action = function(params, callback) {... | javascript | {
"resource": ""
} | |
q59097 | unmarshalPublicKey | validation | function unmarshalPublicKey (curve, key) {
const byteLen = curveLengths[curve]
if (!key.slice(0, 1).equals(Buffer.from([4]))) {
throw new Error('Invalid key format')
}
const x = new BN(key.slice(1, byteLen + 1))
const y = new BN(key.slice(1 + byteLen))
return {
kty: 'EC',
crv: curve,
x: to... | javascript | {
"resource": ""
} |
q59098 | pbkdf2 | validation | function pbkdf2 (password, salt, iterations, keySize, hash) {
const hasher = hashName[hash]
if (!hasher) {
throw new Error(`Hash '${hash}' is unknown or not supported`)
}
const dek = forgePbkdf2(
password,
salt,
iterations,
keySize,
hasher)
return forgeUtil.encode64(dek)
} | javascript | {
"resource": ""
} |
q59099 | getRawHeader | validation | function getRawHeader(_block) {
if (typeof _block.difficulty !== 'string') {
_block.difficulty = '0x' + _block.difficulty.toString(16)
}
const block = new EthereumBlock(_block)
return block.header
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.