_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q25100 | train | function(obj, section, options = {}) {
var children, dotSplit, out, safe;
if (arguments.length === 2) {
options = section;
section = void 0;
}
if (options.separator == null) {
options.separator = ' = ';
}
if (options.eol == null) {
options.eol = !options.ssh && process.pl... | javascript | {
"resource": ""
} | |
q25101 | encode | train | function encode(utm, accuracy) {
// prepend with leading zeroes
const seasting = '00000' + utm.easting,
snorthing = '00000' + utm.northing;
return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthi... | javascript | {
"resource": ""
} |
q25102 | get100kID | train | function get100kID(easting, northing, zoneNumber) {
const setParm = get100kSetForZone(zoneNumber);
const setColumn = Math.floor(easting / 100000);
const setRow = Math.floor(northing / 100000) % 20;
return getLetter100kID(setColumn, setRow, setParm);
} | javascript | {
"resource": ""
} |
q25103 | getB58String | train | function getB58String (peer) {
let b58Id = null
if (multiaddr.isMultiaddr(peer)) {
const relayMa = multiaddr(peer)
b58Id = relayMa.getPeerId()
} else if (PeerInfo.isPeerInfo(peer)) {
b58Id = peer.id.toB58String()
}
return b58Id
} | javascript | {
"resource": ""
} |
q25104 | peerInfoFromMa | train | function peerInfoFromMa (peer) {
let p
// PeerInfo
if (PeerInfo.isPeerInfo(peer)) {
p = peer
// Multiaddr instance (not string)
} else if (multiaddr.isMultiaddr(peer)) {
const peerIdB58Str = peer.getPeerId()
try {
p = swarm._peerBook.get(peerIdB58Str)
} catch (err) ... | javascript | {
"resource": ""
} |
q25105 | writeResponse | train | function writeResponse (streamHandler, status, cb) {
cb = cb || (() => {})
streamHandler.write(proto.CircuitRelay.encode({
type: proto.CircuitRelay.Type.STATUS,
code: status
}))
return cb()
} | javascript | {
"resource": ""
} |
q25106 | quickstart | train | async function quickstart() {
const url = 'https://www.googleapis.com/discovery/v1/apis/';
const res = await request({url});
console.log(`status: ${res.status}`);
console.log(`data:`);
console.log(res.data);
} | javascript | {
"resource": ""
} |
q25107 | disable | train | function disable( group ) {
widgets.forEach( Widget => {
const els = _getElements( group, Widget.selector );
new Collection( els ).disable( Widget );
} );
} | javascript | {
"resource": ""
} |
q25108 | _getElements | train | function _getElements( group, selector ) {
if ( selector ) {
if ( selector === 'form' ) {
return [ formHtml ];
}
// e.g. if the widget selector starts at .question level (e.g. ".or-appearance-draw input")
if ( group.classList.contains( 'question' ) ) {
return ... | javascript | {
"resource": ""
} |
q25109 | setDpi | train | function setDpi() {
const dpiO = {};
const e = document.body.appendChild( document.createElement( 'DIV' ) );
e.style.width = '1in';
e.style.padding = '0';
dpiO.v = e.offsetWidth;
e.parentNode.removeChild( e );
dpi = dpiO.v;
} | javascript | {
"resource": ""
} |
q25110 | getPrintStyleSheet | train | function getPrintStyleSheet() {
let sheet;
// document.styleSheets is an Object not an Array!
for ( const i in document.styleSheets ) {
if ( document.styleSheets.hasOwnProperty( i ) ) {
sheet = document.styleSheets[ i ];
if ( sheet.media.mediaText === 'print' ) {
... | javascript | {
"resource": ""
} |
q25111 | styleToAll | train | function styleToAll() {
// sometimes, setStylesheet fails upon loading
printStyleSheet = printStyleSheet || getPrintStyleSheet();
$printStyleSheetLink = $printStyleSheetLink || getPrintStyleSheetLink();
// Chrome:
printStyleSheet.media.mediaText = 'all';
// Firefox:
$printStyleSheetLink.attr... | javascript | {
"resource": ""
} |
q25112 | t | train | function t( key, options ) {
let str = '';
let target = SOURCE_STRINGS;
// crude string getter
key.split( '.' ).forEach( part => {
target = target ? target[ part ] : '';
str = target;
} );
// crude interpolator
options = options || {};
str = str.replace( /__([^_]+)__/, (... | javascript | {
"resource": ""
} |
q25113 | initializeForm | train | function initializeForm() {
form = new Form( 'form.or:eq(0)', {
modelStr: modelStr
}, {
arcGis: {
basemaps: [ 'streets', 'topo', 'satellite', 'osm' ],
webMapId: 'f2e9b762544945f390ca4ac3671cfa72',
hasZ: true
},
'clearIrrelevantImmediately': tru... | javascript | {
"resource": ""
} |
q25114 | getURLParameter | train | function getURLParameter( name ) {
return decodeURI(
( new RegExp( name + '=' + '(.+?)(&|$)' ).exec( location.search ) || [ null, null ] )[ 1 ]
);
} | javascript | {
"resource": ""
} |
q25115 | TranslatedError | train | function TranslatedError( message, translationKey, translationOptions ) {
this.message = message;
this.translationKey = translationKey;
this.translationOptions = translationOptions;
} | javascript | {
"resource": ""
} |
q25116 | parseFunctionFromExpression | train | function parseFunctionFromExpression( expr, func ) {
let index;
let result;
let openBrackets;
let start;
let argStart;
let args;
const findFunc = new RegExp( `${func}\\s*\\(`, 'g' );
const results = [];
if ( !expr || !func ) {
return results;
}
while ( ( result = fi... | javascript | {
"resource": ""
} |
q25117 | toArray | train | function toArray( list ) {
const array = [];
// iterate backwards ensuring that length is an UInt32
for ( let i = list.length >>> 0; i--; ) {
array[ i ] = list[ i ];
}
return array;
} | javascript | {
"resource": ""
} |
q25118 | updateDownloadLink | train | function updateDownloadLink( anchor, objectUrl, fileName ) {
if ( window.updateDownloadLinkIe11 ) {
return window.updateDownloadLinkIe11( ...arguments );
}
anchor.setAttribute( 'href', objectUrl || '' );
anchor.setAttribute( 'download', fileName || '' );
} | javascript | {
"resource": ""
} |
q25119 | getValidSyntax | train | function getValidSyntax(className, namespaces) {
const parsedClassName = parseClassName(className, namespaces);
// Try to guess the namespaces or use the first one
let validSyntax = parsedClassName.namespace || namespaces[0] || '';
if (parsedClassName.helper) {
validSyntax += `${parsedClassName.helper}-`;
... | javascript | {
"resource": ""
} |
q25120 | pushTextNode | train | function pushTextNode(list, html, level, start, ignoreWhitespace) {
// calculate correct end of the content slice in case there's
// no tag after the text node.
var end = html.indexOf('<', start);
var content = html.slice(start, end === -1 ? undefined : end); // if a node is nothing but whitespace, coll... | javascript | {
"resource": ""
} |
q25121 | Page | train | function Page() {
const { t, i18n } = useTranslation();
const changeLanguage = lng => {
i18n.changeLanguage(lng);
};
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<Welcome />
</div>
<div className="App-i... | javascript | {
"resource": ""
} |
q25122 | mockRequireUglify | train | function mockRequireUglify(loadError, callback) {
var Module = require('module');
var _resolveFilename = Module._resolveFilename;
delete require.cache[require.resolve('uglify-js')];
delete require.cache[require.resolve('../dist/cjs/precompiler')];
Module._resolveFilename = function(request, mod) {
... | javascript | {
"resource": ""
} |
q25123 | minify | train | function minify(output, sourceMapFile) {
try {
// Try to resolve uglify-js in order to see if it does exist
require.resolve('uglify-js');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
// Something else seems to be wrong
throw e;
}
// it does not exist!
console.error('Code mi... | javascript | {
"resource": ""
} |
q25124 | train | function(node, name) {
let value = this.accept(node[name]);
if (this.mutating) {
// Hacky sanity check: This may have a few false positives for type for the helper
// methods but will generally do the right thing without a lot of overhead.
if (value && !Visitor.prototype[value.type]) {
... | javascript | {
"resource": ""
} | |
q25125 | train | function(node, name) {
this.acceptKey(node, name);
if (!node[name]) {
throw new Exception(node.type + ' requires ' + name);
}
} | javascript | {
"resource": ""
} | |
q25126 | shouldRegenerate | train | function shouldRegenerate(node, state) {
if (node.generator) {
if (node.async) {
// Async generator
return state.opts.asyncGenerators !== false;
} else {
// Plain generator
return state.opts.generators !== false;
}
} else if (node.async) {
// Async function
return state.o... | javascript | {
"resource": ""
} |
q25127 | getOuterFnExpr | train | function getOuterFnExpr(funPath) {
const t = util.getTypes();
let node = funPath.node;
t.assertFunction(node);
if (!node.id) {
// Default-exported function declarations, and function expressions may not
// have a name to reference, so we explicitly add one.
node.id = funPath.scope.parent.generateUi... | javascript | {
"resource": ""
} |
q25128 | explodeViaTempVar | train | function explodeViaTempVar(tempVar, childPath, ignoreChildResult) {
assert.ok(
!ignoreChildResult || !tempVar,
"Ignoring the result of a child expression but forcing it to " +
"be assigned to a temporary variable?"
);
let result = self.explodeExpression(childPath, ignoreChildResult);
... | javascript | {
"resource": ""
} |
q25129 | allowTouchMove | train | function allowTouchMove(el) {
return locks.some(function (lock) {
if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
return true;
}
return false;
});
} | javascript | {
"resource": ""
} |
q25130 | toRelativePath | train | function toRelativePath(relativePath) {
const stripped = relativePath.replace(/\/$/g, '') // Remove trailing /
return /^((\.\.)|(\.))($|\/)/.test(stripped) ? stripped : `./${stripped}`
} | javascript | {
"resource": ""
} |
q25131 | getDefaultImportName | train | function getDefaultImportName(node) {
const defaultSpecifier = node.specifiers
.find(specifier => specifier.type === 'ImportDefaultSpecifier')
return defaultSpecifier != null ? defaultSpecifier.local.name : undefined
} | javascript | {
"resource": ""
} |
q25132 | hasNamespace | train | function hasNamespace(node) {
const specifiers = node.specifiers
.filter(specifier => specifier.type === 'ImportNamespaceSpecifier')
return specifiers.length > 0
} | javascript | {
"resource": ""
} |
q25133 | hasSpecifiers | train | function hasSpecifiers(node) {
const specifiers = node.specifiers
.filter(specifier => specifier.type === 'ImportSpecifier')
return specifiers.length > 0
} | javascript | {
"resource": ""
} |
q25134 | hasProblematicComments | train | function hasProblematicComments(node, sourceCode) {
return (
hasCommentBefore(node, sourceCode) ||
hasCommentAfter(node, sourceCode) ||
hasCommentInsideNonSpecifiers(node, sourceCode)
)
} | javascript | {
"resource": ""
} |
q25135 | createModule | train | function createModule(filename) {
const mod = new Module(filename)
mod.filename = filename
mod.paths = Module._nodeModulePaths(path.dirname(filename))
return mod
} | javascript | {
"resource": ""
} |
q25136 | train | function ({ body }) {
function processBodyStatement(declaration) {
if (declaration.type !== 'ImportDeclaration') return
if (declaration.specifiers.length === 0) return
const imports = Exports.get(declaration.source.value, context)
if (imports == null) return null
... | javascript | {
"resource": ""
} | |
q25137 | train | function (namespace) {
var declaration = importDeclaration(context)
var imports = Exports.get(declaration.source.value, context)
if (imports == null) return null
if (imports.errors.length) {
imports.reportErrors(context, declaration)
return
}
if (!i... | javascript | {
"resource": ""
} | |
q25138 | checkCommon | train | function checkCommon(call) {
if (call.callee.type !== 'Identifier') return
if (call.callee.name !== 'require') return
if (call.arguments.length !== 1) return
const modulePath = call.arguments[0]
if (modulePath.type !== 'Literal') return
if (typeof modulePath.value !== 'string') return
chec... | javascript | {
"resource": ""
} |
q25139 | makeOptionsSchema | train | function makeOptionsSchema(additionalProperties) {
const base = {
'type': 'object',
'properties': {
'commonjs': { 'type': 'boolean' },
'amd': { 'type': 'boolean' },
'esmodule': { 'type': 'boolean' },
'ignore': {
'type': 'array',
'minItems': 1,
'items': { 'type'... | javascript | {
"resource": ""
} |
q25140 | reverse | train | function reverse(array) {
return array.map(function (v) {
return {
name: v.name,
rank: -v.rank,
node: v.node,
}
}).reverse()
} | javascript | {
"resource": ""
} |
q25141 | isReachViolation | train | function isReachViolation(importPath) {
const steps = normalizeSep(importPath)
.split('/')
.reduce((acc, step) => {
if (!step || step === '.') {
return acc
} else if (step === '..') {
return acc.slice(0, -1)
} else {
return acc.conc... | javascript | {
"resource": ""
} |
q25142 | captureDoc | train | function captureDoc(source, docStyleParsers, ...nodes) {
const metadata = {}
// 'some' short-circuits on first 'true'
nodes.some(n => {
try {
let leadingComments
// n.leadingComments is legacy `attachComments` behavior
if ('leadingComments' in n) {
leadingComments = n.leadingComme... | javascript | {
"resource": ""
} |
q25143 | captureJsDoc | train | function captureJsDoc(comments) {
let doc
// capture XSDoc
comments.forEach(comment => {
// skip non-block comments
if (comment.type !== 'Block') return
try {
doc = doctrine.parse(comment.value, { unwrap: true })
} catch (err) {
/* don't care, for now? maybe add to `errors?` */
}
... | javascript | {
"resource": ""
} |
q25144 | captureTomDoc | train | function captureTomDoc(comments) {
// collect lines up to first paragraph break
const lines = []
for (let i = 0; i < comments.length; i++) {
const comment = comments[i]
if (comment.value.match(/^\s*$/)) break
lines.push(comment.value.trim())
}
// return doctrine-like object
const statusMatch = ... | javascript | {
"resource": ""
} |
q25145 | childContext | train | function childContext(path, context) {
const { settings, parserOptions, parserPath } = context
return {
settings,
parserOptions,
parserPath,
path,
}
} | javascript | {
"resource": ""
} |
q25146 | makeSourceCode | train | function makeSourceCode(text, ast) {
if (SourceCode.length > 1) {
// ESLint 3
return new SourceCode(text, ast)
} else {
// ESLint 4, 5
return new SourceCode({ text, ast })
}
} | javascript | {
"resource": ""
} |
q25147 | isSrcSubdir | train | function isSrcSubdir (src, dest) {
const srcArray = path.resolve(src).split(path.sep)
const destArray = path.resolve(dest).split(path.sep)
return srcArray.reduce((acc, current, i) => acc && destArray[i] === current, true)
} | javascript | {
"resource": ""
} |
q25148 | getRootPath | train | function getRootPath (p) {
p = path.normalize(path.resolve(p)).split(path.sep)
if (p.length > 0) return p[0]
return null
} | javascript | {
"resource": ""
} |
q25149 | rimraf_ | train | function rimraf_ (p, options, cb) {
assert(p)
assert(options)
assert(typeof cb === 'function')
// sunos lets the root user unlink directories, which is... weird.
// so we have to lstat here and make sure it's not a dir.
options.lstat(p, (er, st) => {
if (er && er.code === 'ENOENT') {
return cb(nu... | javascript | {
"resource": ""
} |
q25150 | isSrcSubdir | train | function isSrcSubdir (src, dest) {
try {
return fs.statSync(src).isDirectory() &&
src !== dest &&
dest.indexOf(src) > -1 &&
dest.split(path.dirname(src) + path.sep)[1].split(path.sep)[0] === path.basename(src)
} catch (e) {
return false
}
} | javascript | {
"resource": ""
} |
q25151 | dayMatchesModifier | train | function dayMatchesModifier(day, modifier) {
if (!modifier) {
return false;
}
var arr = Array.isArray(modifier) ? modifier : [modifier];
return arr.some(function (mod) {
if (!mod) {
return false;
}
if (mod instanceof Date) {
return (0, _DateUtils.isSameDay)(day, mod);
}
if ((... | javascript | {
"resource": ""
} |
q25152 | getModifiersForDay | train | function getModifiersForDay(day) {
var modifiersObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(modifiersObj).reduce(function (modifiers, modifierName) {
var value = modifiersObj[modifierName];
if (dayMatchesModifier(day, value)) {
modifiers.push(modif... | javascript | {
"resource": ""
} |
q25153 | addMonths | train | function addMonths(d, n) {
var newDate = clone(d);
newDate.setMonth(d.getMonth() + n);
return newDate;
} | javascript | {
"resource": ""
} |
q25154 | isSameDay | train | function isSameDay(d1, d2) {
if (!d1 || !d2) {
return false;
}
return d1.getDate() === d2.getDate() && d1.getMonth() === d2.getMonth() && d1.getFullYear() === d2.getFullYear();
} | javascript | {
"resource": ""
} |
q25155 | isSameMonth | train | function isSameMonth(d1, d2) {
if (!d1 || !d2) {
return false;
}
return d1.getMonth() === d2.getMonth() && d1.getFullYear() === d2.getFullYear();
} | javascript | {
"resource": ""
} |
q25156 | isDayBefore | train | function isDayBefore(d1, d2) {
var day1 = clone(d1).setHours(0, 0, 0, 0);
var day2 = clone(d2).setHours(0, 0, 0, 0);
return day1 < day2;
} | javascript | {
"resource": ""
} |
q25157 | isDayAfter | train | function isDayAfter(d1, d2) {
var day1 = clone(d1).setHours(0, 0, 0, 0);
var day2 = clone(d2).setHours(0, 0, 0, 0);
return day1 > day2;
} | javascript | {
"resource": ""
} |
q25158 | isDayBetween | train | function isDayBetween(d, d1, d2) {
var date = clone(d);
date.setHours(0, 0, 0, 0);
return isDayAfter(date, d1) && isDayBefore(date, d2) || isDayAfter(date, d2) && isDayBefore(date, d1);
} | javascript | {
"resource": ""
} |
q25159 | addDayToRange | train | function addDayToRange(day) {
var range = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: null, to: null };
var from = range.from,
to = range.to;
if (!from) {
from = day;
} else if (from && to && isSameDay(from, to) && isSameDay(day, from)) {
from = null;
to = null... | javascript | {
"resource": ""
} |
q25160 | isDayInRange | train | function isDayInRange(day, range) {
var from = range.from,
to = range.to;
return from && isSameDay(day, from) || to && isSameDay(day, to) || from && to && isDayBetween(day, from, to);
} | javascript | {
"resource": ""
} |
q25161 | OverlayComponent | train | function OverlayComponent(_ref) {
var input = _ref.input,
selectedDay = _ref.selectedDay,
month = _ref.month,
children = _ref.children,
classNames = _ref.classNames,
props = _objectWithoutProperties(_ref, ['input', 'selectedDay', 'month', 'children', 'classNames']);
return _react2.def... | javascript | {
"resource": ""
} |
q25162 | defaultFormat | train | function defaultFormat(d) {
if ((0, _DateUtils.isDate)(d)) {
var year = d.getFullYear();
var month = '' + (d.getMonth() + 1);
var day = '' + d.getDate();
return year + '-' + month + '-' + day;
}
return '';
} | javascript | {
"resource": ""
} |
q25163 | defaultParse | train | function defaultParse(str) {
if (typeof str !== 'string') {
return undefined;
}
var split = str.split('-');
if (split.length !== 3) {
return undefined;
}
var year = parseInt(split[0], 10);
var month = parseInt(split[1], 10) - 1;
var day = parseInt(split[2], 10);
if (isNaN(year) || String(year)... | javascript | {
"resource": ""
} |
q25164 | throttle | train | function throttle(func) {
var context,
args,
result,
timeout = null,
previous = 0,
later = function() {
previous = getNow()
timeout = null
result = func.apply(context, args)
if (!timeout) {
// eslint-disable-next-line no-multi-assign
... | javascript | {
"resource": ""
} |
q25165 | getComputedStyle | train | function getComputedStyle(prop, el) {
var retVal = 0
el = el || document.body // Not testable in phantonJS
retVal = document.defaultView.getComputedStyle(el, null)
retVal = null !== retVal ? retVal[prop] : 0
return parseInt(retVal, base)
} | javascript | {
"resource": ""
} |
q25166 | setupBodyMarginValues | train | function setupBodyMarginValues() {
if (
'number' ===
typeof (settings[iframeId] && settings[iframeId].bodyMargin) ||
'0' === (settings[iframeId] && settings[iframeId].bodyMargin)
) {
settings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin
settings[iframeId].... | javascript | {
"resource": ""
} |
q25167 | init | train | function init(msg) {
function iFrameLoaded() {
trigger('iFrame.onload', msg, iframe, undefined, true)
checkReset()
}
function createDestroyObserver(MutationObserver) {
if (!iframe.parentNode) {
return
}
var destroyObserver = new MutationObserver(func... | javascript | {
"resource": ""
} |
q25168 | createProxyHandler | train | function createProxyHandler (proxies, urlRoot) {
if (!proxies.length) {
const nullProxy = (request, response, next) => next()
nullProxy.upgrade = () => {}
return nullProxy
}
function createProxy (request, response, next) {
const proxyRecord = proxies.find((p) => request.url.startsWith(p.path))
... | javascript | {
"resource": ""
} |
q25169 | createSourceFilesMiddleware | train | function createSourceFilesMiddleware (filesPromise, serveFile, basePath, urlRoot) {
return function (request, response, next) {
const requestedFilePath = composeUrl(request.url, basePath, urlRoot)
// When a path contains HTML-encoded characters (e.g %2F used by Jenkins for branches with /)
const requested... | javascript | {
"resource": ""
} |
q25170 | createReadFilePromise | train | function createReadFilePromise () {
return (filepath) => {
return new Promise((resolve, reject) => {
fs.readFile(filepath, 'utf8', function (error, data) {
if (error) {
reject(new Error(`Cannot read ${filepath}, got: ${error}`))
} else if (!data) {
reject(new Error(`No co... | javascript | {
"resource": ""
} |
q25171 | CaptureTimeoutLauncher | train | function CaptureTimeoutLauncher (timer, captureTimeout) {
if (!captureTimeout) {
return
}
let pendingTimeoutId = null
this.on('start', () => {
pendingTimeoutId = timer.setTimeout(() => {
pendingTimeoutId = null
if (this.state !== this.STATE_BEING_CAPTURED) {
return
}
l... | javascript | {
"resource": ""
} |
q25172 | BaseLauncher | train | function BaseLauncher (id, emitter) {
if (this.start) {
return
}
// TODO(vojta): figure out how to do inheritance with DI
Object.keys(EventEmitter.prototype).forEach(function (method) {
this[method] = EventEmitter.prototype[method]
}, this)
this.bind = KarmaEventEmitter.prototype.bind.bind(this)
... | javascript | {
"resource": ""
} |
q25173 | groupToElements | train | function groupToElements(array, n) {
var lists = _.groupBy(array, function(element, index){
return Math.floor(index / n);
});
return _.toArray(lists);
} | javascript | {
"resource": ""
} |
q25174 | extend | train | function extend(destination, source, recursive) {
destination = destination || {};
source = source || {};
recursive = recursive || false;
for (var attrName in source) {
if (source.hasOwnProperty(attrName)) {
var destVal = destination[attrName];
var sourceVal = source[att... | javascript | {
"resource": ""
} |
q25175 | createProfileWatchErrorHandler | train | function createProfileWatchErrorHandler(dispatch, firebase) {
const { config: { onProfileListenerError, logErrors } } = firebase._
return function handleProfileError(err) {
if (logErrors) {
// eslint-disable-next-line no-console
console.error(`Error with profile listener: ${err.message || ''}`, err)... | javascript | {
"resource": ""
} |
q25176 | runCommand | train | function runCommand(cmd) {
return exec(cmd).catch(err =>
Promise.reject(
err.message && err.message.indexOf('not found') !== -1
? new Error(`${cmd.split(' ')[0]} must be installed to upload`)
: err
)
)
} | javascript | {
"resource": ""
} |
q25177 | uploadList | train | function uploadList(files) {
return Promise.all(
files.map(file =>
upload(file)
.then(({ uploadPath, output }) => {
console.log(`Successfully uploaded: ${uploadPath}`) // eslint-disable-line no-console
return output
})
.catch(err => {
console.log('Error ... | javascript | {
"resource": ""
} |
q25178 | createUploadMetaResponseHandler | train | function createUploadMetaResponseHandler({
fileData,
firebase,
uploadTaskSnapshot,
downloadURL
}) {
/**
* Converts upload meta data snapshot into an object (handling both
* RTDB and Firestore)
* @param {Object} metaDataSnapshot - Snapshot from metadata upload (from
* RTDB or Firestore)
* @retu... | javascript | {
"resource": ""
} |
q25179 | initMobileMenu | train | function initMobileMenu () {
var mobileBar = document.getElementById('mobile-bar')
var sidebar = document.querySelector('.sidebar')
var menuButton = mobileBar.querySelector('.menu-button')
menuButton.addEventListener('click', function () {
sidebar.classList.toggle('open')
})
document.bod... | javascript | {
"resource": ""
} |
q25180 | initVersionSelect | train | function initVersionSelect () {
// version select
var versionSelect = document.querySelector('.version-select')
versionSelect && versionSelect.addEventListener('change', function (e) {
var version = e.target.value
var section = window.location.pathname.match(/\/v\d\/(\w+?)\//)[1]
if (versi... | javascript | {
"resource": ""
} |
q25181 | regions | train | function regions(token) {
var r1, r2, rv, len;
var i;
r1 = r2 = rv = len = token.length;
// R1 is the region after the first non-vowel following a vowel,
for (var i = 0; i < len - 1 && r1 == len; i++) {
if (isVowel(token[i]) && !isVowel(token[i + 1])) {
r1 = i + 2;
}
}
// Or is the null re... | javascript | {
"resource": ""
} |
q25182 | endsinArr | train | function endsinArr(token, suffixes) {
var i, longest = '';
for (i = 0; i < suffixes.length; i++) {
if (endsin(token, suffixes[i]) && suffixes[i].length > longest.length)
longest = suffixes[i];
}
return longest;
} | javascript | {
"resource": ""
} |
q25183 | normalizeLength | train | function normalizeLength(token, length) {
length = length || 6;
if (token.length < length) {
token += (new Array(length - token.length + 1)).join('0');
}
return token.slice(0, length);
} | javascript | {
"resource": ""
} |
q25184 | _getMatchStart | train | function _getMatchStart(distanceMatrix, matchEnd, sourceLength) {
var row = sourceLength;
var column = matchEnd;
var tmpRow;
var tmpColumn;
// match will be empty string
if (matchEnd === 0) { return 0; }
while(row > 1 && column > 1) {
tmpRow = row;
tmpColumn = column;
row = distanceMatrix[tmpRo... | javascript | {
"resource": ""
} |
q25185 | runDisambiguator | train | function runDisambiguator(disambiguateRules, word){
var result = undefined;
for(var i in disambiguateRules){
result = disambiguateRules[i](word);
if(find(result)){
break;
}
}
if(result==undefined){
this.current_word = word;
this.removal = undefined;
retur... | javascript | {
"resource": ""
} |
q25186 | stemPluralWord | train | function stemPluralWord(plural_word){
var matches = plural_word.match(/^(.*)-(.*)$/);
if(!matches){
return plural_word;
}
words = [matches[1], matches[2]];
//malaikat-malaikat-nya -> malaikat malaikat-nya
suffix = words[1];
suffixes = ["ku", "mu", "nya", "lah", "kah", "tah", "pun"];... | javascript | {
"resource": ""
} |
q25187 | stemSingularWord | train | function stemSingularWord(word){
original_word = word; // Save the original word for reverting later
current_word = word;
// Step 1
if(current_word.length>3){
// Step 2-5
stemmingProcess();
}
// Step 6
if(find(current_word)){
return current_word;
}
else{
... | javascript | {
"resource": ""
} |
q25188 | loopRestorePrefixes | train | function loopRestorePrefixes(){
restorePrefix();
var reversed_removals = removals.reverse();
var temp_current_word = current_word;
for(var i in reversed_removals){
current_removal = reversed_removals[i];
if(!isSuffixRemovals(current_removal)){
continue
}
i... | javascript | {
"resource": ""
} |
q25189 | precedenceAdjustmentSpecification | train | function precedenceAdjustmentSpecification(word){
var regex_rules = [
/^be(.*)lah$/,
/^be(.*)an$/,
/^me(.*)i$/,
/^di(.*)i$/,
/^pe(.*)i$/,
/^ter(.*)i$/,
];
for(var i in regex_rules){
if(word.match(regex_rules[i])){
return true;
}
... | javascript | {
"resource": ""
} |
q25190 | attemptReplace | train | function attemptReplace(token, pattern, replacement, callback) {
var result = null;
if((typeof pattern == 'string') && token.substr(0 - pattern.length) == pattern)
result = token.replace(new RegExp(pattern + '$'), replacement);
else if((pattern instanceof RegExp) && token.match(pattern))
... | javascript | {
"resource": ""
} |
q25191 | train | function (start) {
var index = start || 0,
length = this.string.length,
region = length;
while (index < length - 1 && region === length) {
if (this.hasVowelAtIndex(index) && !this.hasVowelAtIndex(index + 1)) {
region = index + 2;
}
index++;
}
return region;
} | javascript | {
"resource": ""
} | |
q25192 | train | function () {
var rv = this.string.length;
if (rv > 3) {
if (!this.hasVowelAtIndex(1)) {
rv = this.nextVowelIndex(2) + 1;
} else if (this.hasVowelAtIndex(0) && this.hasVowelAtIndex(1)) {
rv = this.nextConsonantIndex(2) + 1;
} else {
rv = 3;
}
}
return ... | javascript | {
"resource": ""
} | |
q25193 | Removal | train | function Removal (original_word, result, removedPart, affixType) {
this.original_word = original_word;
this.result = result;
this.removedPart = removedPart
this.affixType = affixType;
} | javascript | {
"resource": ""
} |
q25194 | Lexicon | train | function Lexicon(language, defaultCategory, defaultCategoryCapitalised) {
switch (language) {
case 'EN':
this.lexicon = englishLexicon;
break;
case 'DU':
this.lexicon = dutchLexicon;
break;
default:
this.lexicon = dutchLexicon;
break;
}
if (defaultCategory) {
th... | javascript | {
"resource": ""
} |
q25195 | train | function(g) {
this.isDag = true;
this.sorted = topoSort(uniqueVertexs(g.edges()), g.edges());
} | javascript | {
"resource": ""
} | |
q25196 | applyRuleSection | train | function applyRuleSection(token, intact) {
var section = token.substr( - 1);
var rules = ruleTable[section];
if (rules) {
for (var i = 0; i < rules.length; i++) {
if ((intact || !rules[i].intact)
// only apply intact rules to intact tokens
&& token.substr(0 - rul... | javascript | {
"resource": ""
} |
q25197 | currentWord | train | function currentWord(x) {
if ((x.b.data.wordWindow["0"] === token) &&
(x.a === tag)) {
return 1;
}
return 0;
} | javascript | {
"resource": ""
} |
q25198 | countNgrams | train | function countNgrams(ngram) {
nrOfNgrams++;
var key = arrayToKey(ngram);
if (!frequencies[key]) {
frequencies[key] = 0;
}
frequencies[key]++;
} | javascript | {
"resource": ""
} |
q25199 | train | function(sequence, n, startSymbol, endSymbol, stats) {
var result = [];
frequencies = {};
nrOfNgrams = 0;
if (!_(sequence).isArray()) {
sequence = tokenizer.tokenize(sequence);
}
var count = _.max([0, sequence.length - n + 1]);
// Check for left padding
if(typeof start... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.