_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q31800
polygonize
train
function polygonize (str, properties) { var coordinates = str.split(' ').map(function
javascript
{ "resource": "" }
q31801
decodify
train
function decodify (featureCollection, code, properties) { var feature = find(featureCollection.features, {'id': code}); if (feature) {
javascript
{ "resource": "" }
q31802
toCSSProp
train
function toCSSProp(prop) { var dashed = prop.replace(regex, '-$&').toLowerCase(); return dashed[0]
javascript
{ "resource": "" }
q31803
reduceFunctionCall
train
function reduceFunctionCall(string, functionRE, callback) { var call = string return getFunctionCalls(string, functionRE).reduce(function(string, obj) { return string.replace(obj.functionIdentifier +
javascript
{ "resource": "" }
q31804
getFunctionCalls
train
function getFunctionCalls(call, functionRE) { var expressions = [] var fnRE = typeof functionRE === "string" ? new RegExp("\\b(" + functionRE + ")\\(") : functionRE do { var searchMatch = fnRE.exec(call) if (!searchMatch) { return expressions } if (searchMatch[1] === undefined) { thro...
javascript
{ "resource": "" }
q31805
evalFunctionCall
train
function evalFunctionCall (string, functionIdentifier, callback, call, functionRE) { // allow recursivity return
javascript
{ "resource": "" }
q31806
space
train
function space(json) { var match = json.match(/^(?:(\t+)|( +))"/m) return
javascript
{ "resource": "" }
q31807
mergeInto
train
function mergeInto(one, two) { checkMergeObjectArg(one); if (two != null) { checkMergeObjectArg(two);
javascript
{ "resource": "" }
q31808
getRawRequest
train
function getRawRequest ( { resource, loaderIndex, loaders }, excludedPreLoaders = /eslint-loader/ ) { return loaderUtils.getRemainingRequest({ resource: resource,
javascript
{ "resource": "" }
q31809
stringifyLoaders
train
function stringifyLoaders (loaders) { return loaders .map( obj => obj && typeof obj === 'object' && typeof
javascript
{ "resource": "" }
q31810
_hash
train
function _hash() { var set = Array.prototype.map.call(arguments, function(v) { return typeof v === 'string' ? v : Object.keys(v).join(' '); }).join(' '); return set.split(/\s+/)
javascript
{ "resource": "" }
q31811
matchRoute
train
function matchRoute(route, path) { if (route.pattern === undefined && route.path !== undefined) { var routePattern; if (route.path instanceof RegExp) { routePattern = route.path; } else { var routePath = normalize(route.path); routePattern = route.children.length > 0 ? routePath + '*' ...
javascript
{ "resource": "" }
q31812
matchRoutes
train
function matchRoutes(routes, path, query) { query = query === undefined
javascript
{ "resource": "" }
q31813
AsyncHelpers
train
function AsyncHelpers(options) { if (!(this instanceof AsyncHelpers)) { return new AsyncHelpers(options); } this.options = Object.assign({}, options); this.prefix = this.options.prefix || '{$ASYNCID$';
javascript
{ "resource": "" }
q31814
wrapper
train
function wrapper() { var num = self.counter++; var id = createId(prefix, num); var token = { name: name, async: !!fn.async, prefix: prefix, num: num, id: id, fn: fn,
javascript
{ "resource": "" }
q31815
formatError
train
function formatError(err, helper, args) { err.helper = helper;
javascript
{ "resource": "" }
q31816
toRegex
train
function toRegex(prefix) { var key = appendPrefix(prefix, '(\\d+)'); if (cache.hasOwnProperty(key)) {
javascript
{ "resource": "" }
q31817
createRegexString
train
function createRegexString(prefix) { var key = 'createRegexString:' + prefix; if (cache.hasOwnProperty(key)) {
javascript
{ "resource": "" }
q31818
getCss
train
function getCss(shapes, options) { const spriteRelative = path.relative(options.styleOutput, options.spritePath); return new CSS(shapes, { nameSpace: options.nameSpace, block: options.dirname,
javascript
{ "resource": "" }
q31819
_isSvgFile
train
function _isSvgFile(file, dirPath) { let flag = false, isFile = fs.statSync(path.resolve(dirPath, file)).isFile(); if (isFile) { // Exclude directory if (path.extname(file) === '.svg') {
javascript
{ "resource": "" }
q31820
log
train
function log(msg, type) { switch (type) { case 'error': fancyLog(`${PLUGINNAME}: ${colors.red(`Error, ${msg}`)}`); break; case 'warn': fancyLog(`${PLUGINNAME}: ${colors.yellow(`Warning, ${msg}`)}`); break; case 'info':
javascript
{ "resource": "" }
q31821
parseProcesses
train
function parseProcesses(list, ps) { var p = ps.split(/ +/); list.push({ user: p[0], pid: p[1], cpu: parseFloat(p[2]), mem: parseFloat(p[3]), vsz: p[4], rss: p[5],
javascript
{ "resource": "" }
q31822
cleanValue
train
function cleanValue(val, char) { var num; var conditions = val.split(' '); var i = 0; while (!num && i < conditions.length) { if (conditions[i].indexOf(char) > -1) {
javascript
{ "resource": "" }
q31823
ancestorMatch
train
function ancestorMatch(el, tokens, dividedTokens, root) { var cand // recursively work backwards through the tokens and up the dom, covering all options function crawl(e, i, p) { while (p = walker[dividedTokens[i]](p, e)) { if (isNode(p) && (found = interpret.apply(p, q(tokens[i]))))...
javascript
{ "resource": "" }
q31824
train
function(callback) { async.each(task.files, function(file, callback2) { var srcPath = file.src[0], extName = path.extname(srcPath).toLowerCase(); // if it’s an SVG or a PDF, copy the file to the output dir if (extName === '.svg' || extName === '.pdf') { var dstPath = getDestination(srcPa...
javascript
{ "resource": "" }
q31825
train
function(response) { delete self._requestState[transactionId]; if (typeof callback === 'function') { // negative response if (response.error) { var owner = response.answerRecords[0].nb.entries[0].address; callback(null, false, owner);
javascript
{ "resource": "" }
q31826
train
function() { delete self._requestState[transactionId]; self._localMap.add(nbname, group, address, ttl, self._type); self._sendRefresh(nbname, function(error) {
javascript
{ "resource": "" }
q31827
getWatcherByPath
train
function getWatcherByPath(path) { var rlt = undefined; watchers.forEach(function(watcher) { if (watcher.path == path)
javascript
{ "resource": "" }
q31828
makeViewFactoryForMatch
train
function makeViewFactoryForMatch(match) { var views = {}; for (var i = match.activeTrace.length - 1; i >= 0; i--) { var step = match.activeTrace[i]; var stepProps = getStepProps(step); views = merge(views, collectSubViews(stepProps, views));
javascript
{ "resource": "" }
q31829
AsyncRoute
train
function AsyncRoute(props) { props = merge(props, { viewPromise:
javascript
{ "resource": "" }
q31830
CanIHazIp
train
function CanIHazIp(callback) { return new Promise(function (resolve) { var httpCallback = function (response) { var responseData = ''; // When data is received, append it to `responseData`. response.on('data', function (chunk) { responseData += chunk; }); // When response e...
javascript
{ "resource": "" }
q31831
mapDependencyData
train
function mapDependencyData(bowerInfo) { return { name: bowerInfo.name, commit: bowerInfo._resolution !== undefined ? bowerInfo._resolution.commit : undefined,
javascript
{ "resource": "" }
q31832
getDependency
train
function getDependency(filepath) { var bowerInfoStr = fs.readFileSync(filepath, {encoding: 'utf8'}); var bowerInfo =
javascript
{ "resource": "" }
q31833
getBowerFolder
train
function getBowerFolder() { var bowerRC = getBowerRC(); if (bowerRC === null
javascript
{ "resource": "" }
q31834
getAllDependencies
train
function getAllDependencies() { var folder = './' + getBowerFolder(); var bowerDependencies = fs.readdirSync(folder, {encoding: 'utf8'}); var dependencyInfos = []; bowerDependencies.forEach(function(dirname) { var filepath = nodePath.resolve(cwd, folder, dirname, '.bower.json'); if (fs....
javascript
{ "resource": "" }
q31835
optimizeHistogram
train
function optimizeHistogram(histogram, options) { options = _.defaults(options || {}, { colorDistanceThreshold: 22 }); for (var i = 0; i < histogram.length - 1; i++) { if (histogram[i].count === 0) { continue; } for (var j = i + 1; j < histogram.length; j++) { var distance = getColorD...
javascript
{ "resource": "" }
q31836
train
function (filepath) { // console.log('processing: ' + filepath); // read file source, saved in RAM var content = grunt.file.read(filepath); /* * Reset pattern's last search index to 0 * at the beginning for each file content. * ...
javascript
{ "resource": "" }
q31837
unpackQuestion
train
function unpackQuestion(buf, offset) { var bytes = 0; var question = {}; // - variable length compressed question name var nbname = NBName.fromBuffer(buf, offset + bytes); if (nbname.error) { return {error: nbname.error}; } question.nbname = nbname; bytes += nbname.bytesRead; // Ensure we have...
javascript
{ "resource": "" }
q31838
detectUserOptions
train
function detectUserOptions () { let outputPath = program.output; let userOptions = { output: false }; cliProps.forEach(prop => { let value = program[prop]; if ((prop === 'stream' || prop === 'langdetect') && value) { return; }
javascript
{ "resource": "" }
q31839
detectUserInput
train
function detectUserInput () { let validatePath = program.input; if (typeof validatePath !== 'string') { validatePath = process.cwd(); } else { if (!(/^(http(s)?:)?\/\//i.test(validatePath))) {
javascript
{ "resource": "" }
q31840
getOptions
train
function getOptions (userOptions = {}) { let options = _.cloneDeep(userOptions); if (options.format === 'html') { options.outputAsHtml = true;
javascript
{ "resource": "" }
q31841
getArgvFromObject
train
function getArgvFromObject (options) { let argv = []; let format = options.format; if (formatList.get(format)) { argv.push(`--format ${format}`); } if (options.asciiquotes) { argv.push('--asciiquotes yes'); } if (options.stream === false) { argv.push('--no-stream'); } if (options.langdetect === false...
javascript
{ "resource": "" }
q31842
doSomethingUninteresting
train
function doSomethingUninteresting(data) { // simulate latency var wait = randomWait(1000); return Promise.delay(wait).then( ()
javascript
{ "resource": "" }
q31843
fetchProps
train
function fetchProps(props, match) { var newProps = {}; var deferreds = {}; var promises = {}; var tasks = {}; var name; for (name in props) { var m = isPromisePropRe.exec(name); if (m) { var promiseName = m[1]; var deferred = Promise.defer(); tasks[promiseName] = makeTask(props[...
javascript
{ "resource": "" }
q31844
renderScene
train
function renderScene () { gl.clearColor(0, 0, 0, 1) gl.clear(gl.COLOR_BUFFER_BIT) gl.viewport(0, 0, shape[0], shape[1]) shader.bind()
javascript
{ "resource": "" }
q31845
FileSystem
train
function FileSystem(base, options) { options || (options = {}); this.base = this.pathResolve(base); if(options.captureFile) { this._readFiles = [];
javascript
{ "resource": "" }
q31846
train
function(pos) { var topOffset = $(this).css(pos).offset().top; if (topOffset < 0) {
javascript
{ "resource": "" }
q31847
train
function(force, event) { var self = this, options = self.options, saveScroll; if ((options.modal && !force) || (!options.stack && !options.modal)) { return self._trigger('focus', event); } if (options.zIndex > $.ui.dialog.maxZ) { $.ui.dialog.maxZ = options.zIndex; } if (self.overlay) { $...
javascript
{ "resource": "" }
q31848
train
function(match, value, len) { var num = '' + value; if
javascript
{ "resource": "" }
q31849
asciifyImage
train
function asciifyImage( canvasRenderer, oAscii ) { oCtx.clearRect( 0, 0, iWidth, iHeight ); oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight ); var oImgData = oCtx.getImageData( 0, 0, iWidth, iHeight ).data; // Coloring loop starts now var strChars = ""; // console.time('rendering'); for ( var y = 0; ...
javascript
{ "resource": "" }
q31850
BrokenLinkChecker
train
function BrokenLinkChecker(options) { this.runningScope = options.scope || BrokenLinkChecker.RUNNING_SCOPE_COMMAND; this.pluginConfig = {}; this.pluginConfig.enabled = (typeof userConfig.enabled !== 'undefined')? userConfig.enabled : true; this.pluginConfig.storageDir = userConfig.storage_dir || 'temp/link_chec...
javascript
{ "resource": "" }
q31851
train
function(src, dest) { if (grunt.file.isDir(src)) { grunt.file.mkdir(dest); if (options.log) { Utils.writeln(chalk.gray.bold(' create dir =>
javascript
{ "resource": "" }
q31852
train
function (names) { this.names = Object.keys(names); // store the keys this.hash = util.map(names, function (value) { // store values for
javascript
{ "resource": "" }
q31853
train
function (name, lazy) { return Array.isArray(name) ? (name.length ? name.every(function (name) { return this.defined(name, lazy);
javascript
{ "resource": "" }
q31854
train
function (name) { return Array.isArray(name)
javascript
{ "resource": "" }
q31855
train
function(file) { var FileSystem = require('./fs.js'); var ReadStream = require('./read_stream.js'); if(FileSystem.fs.existFile(file)) {
javascript
{ "resource": "" }
q31856
get
train
function get(code) { if (!Object.prototype.hasOwnProperty.call(osm, code)) { throw new TypeError('The alpha-3
javascript
{ "resource": "" }
q31857
registerDual
train
function registerDual(numberType, numericType, checkFn, toJSONSchema) { context.registerType(numberType, 'number', checkFn, numberType, extra => toJSONSchema('number', extra)) context.registerType(numericType, 'string', value => { let numberValue = toNumber(value)
javascript
{ "resource": "" }
q31858
registerTaggedDual
train
function registerTaggedDual(numberTag, numericTag, checkFn, toJSONSchema) { context.registerTaggedType({ tag: numberTag, jsonType: 'number', minArgs: 2, maxArgs: 2, sparse: true, numeric: true }, checkFn, returnOriginal, toJSONSchema) context.registerTaggedType({ tag: numericTag, jsonType...
javascript
{ "resource": "" }
q31859
createFunction
train
function createFunction(sCode, settings) { /*jshint evil:true, laxbreak:true, quotmark:false*/ var nI, params, sName; if (! settings) { settings = {}; } params = settings.paramNames; if (settings.expression) { sCode = "return (" + sCode + ");"; } if (settings.scope) { ...
javascript
{ "resource": "" }
q31860
createDelegateMethod
train
function createDelegateMethod(delegate, sMethod, settings) { var result = function() { return delegate[sMethod].apply(delegate, arguments); }; if (settings && settings.destination) {
javascript
{ "resource": "" }
q31861
closure
train
function closure(action, paramList, context, settings) { if (! settings) { settings = {}; } var bUseArgs = ! settings.ignoreArgs, bAppendArgs = ! settings.prependArgs; return function() { var params; if (bUseArgs) { params = paramList ? Array.prototype.sl...
javascript
{ "resource": "" }
q31862
map
train
function map(funcList, paramList, context, settings) { /*jshint laxbreak:true*/ var result = [], nL = funcList.length, bGetContext, bGetParamList, func, nI; if (! paramList) { paramList = []; } if (! context) { context = null; } if (! settings) { setti...
javascript
{ "resource": "" }
q31863
train
function(response, body) { var responseCodes = [ { codes: 400, message: 'Request was invalid.' }, { codes: 401, message: 'Bad access token.' }, { codes: 403, message: 'Bad OAuth scope.' }, { codes: 404, message: 'Selector did not match any lights.' }, ...
javascript
{ "resource": "" }
q31864
train
function(selector) { var validSelectors = [ 'all', 'label:', 'id:', 'group_id:', 'group:', 'location_id:', 'location:', 'scene_id:'
javascript
{ "resource": "" }
q31865
context
train
function context(schema, value, options) { schema = context.parse(schema) let ret = schema.validate(value, options) context.lastError = schema.lastError context.lastErrorMessage
javascript
{ "resource": "" }
q31866
parseTagged
train
function parseTagged(definition, taggedTypes) { let match = definition.match(/^(\w+)(?:\((.*)\))?$/), tag, args, typeInfo if (!match) { return } // Get type info tag = match[1] typeInfo = taggedTypes[tag] if (!typeInfo) { return } // Special no-'()' case: only match 'tag' if minArgs is zero if (typeIn...
javascript
{ "resource": "" }
q31867
train
function (recipient, donor) { for (var prop in donor) {
javascript
{ "resource": "" }
q31868
train
function (obj, mapper, scope) { var map = {}, prop; scope = scope || obj; for (prop in obj) {
javascript
{ "resource": "" }
q31869
verifyDevice
train
async function verifyDevice (userId, deviceId) { await exports.matrixClient.setDeviceKnown(userId,
javascript
{ "resource": "" }
q31870
fixParagraphNode
train
function fixParagraphNode(node, fullText) { const firstNode = node.children[0]; const lastNode = node.children[node.children.length - 1]; node.range = [firstNode.range[0], lastNode.range[1]]; node.raw = fullText.slice(node.range[0], node.range[1]); node.loc = { start: { line: fir...
javascript
{ "resource": "" }
q31871
fixSignatureParams
train
function fixSignatureParams(node, item, signature) { signature.params = []; for (var i = 0; i < signature.arity; i++) { var paramCopy = _.extend({}, item.params[i]); if (node && node.paramTags) { if (node.paramTags[paramCopy.name])
javascript
{ "resource": "" }
q31872
closeHost
train
function closeHost() { // close the host itself me.addresses = {}; if (me.server) { me.server.close(); me.server = null;
javascript
{ "resource": "" }
q31873
FFParameterRejected
train
function FFParameterRejected(parameter) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.message = 'A parameter
javascript
{ "resource": "" }
q31874
collectRefs
train
function collectRefs() { // check if there's a shadow root in the element if (typeof this.shadowRoot === 'undefined') { throw new Error('You must create a shadowRoot on the element'); } // create refs base object this.refs = {}; var refsList = this.shadowRoot.querySelectorAll('[ref]'); // collect r...
javascript
{ "resource": "" }
q31875
_isRefNode
train
function _isRefNode(node) { return ( node.nodeType && node.nodeType
javascript
{ "resource": "" }
q31876
_handleSingleMutation
train
function _handleSingleMutation(mutation) { var addedNodes = _toArray(mutation.addedNodes); var addedRefs = addedNodes.filter(_isRefNode); // assign added
javascript
{ "resource": "" }
q31877
action_putpost
train
function action_putpost(si,args,done) { var ent_type = parse_ent(args) var ent = si.make(ent_type.zone,ent_type.base,ent_type.name) var data = args.data || {} var good = _.filter(_.keys(data),function(k){return !~k.indexOf('$')}) var fields = _.pick(data,good) ent.data$(fields) if( null...
javascript
{ "resource": "" }
q31878
handleVisibilityChange
train
function handleVisibilityChange() { if (document[hidden]) { let gifPlayers = document.querySelectorAll('.vjs-gifplayer'); for (let gifPlayer of gifPlayers) { let
javascript
{ "resource": "" }
q31879
_getKeyInfo
train
function _getKeyInfo(combination, action) { var keys, key, i, modifiers = []; // take the keys from this pattern and figure out what the actual // pattern is all about keys = _keysFromString(combination); for (i = 0; i < keys.length; ++i) { key = keys[i]; // normalize key names ...
javascript
{ "resource": "" }
q31880
train
function(keys, callback, action) { keys = keys instanceof Array ? keys : [keys];
javascript
{ "resource": "" }
q31881
train
function(e, element) { // if the element has the class "mousetrap" then no need to stop if ((' ' + element.className + ' ').indexOf(' mousetrap ') >
javascript
{ "resource": "" }
q31882
train
function (name, transform, config, filefog_options){ this.name = name; this.config = config || {}; this._transform =
javascript
{ "resource": "" }
q31883
on
train
function on(emitter, eventName, handler, context) { handler = context ? handler.bind(context) : handler;
javascript
{ "resource": "" }
q31884
once
train
function once(emitter, eventName, handler, context) { handler = context ? handler.bind(context) : handler; let wrapper = function onceHandler(event) { emitter.removeEventListener(eventName,
javascript
{ "resource": "" }
q31885
until
train
function until(emitter, eventName, handler, context) { handler = context ? handler.bind(context) : handler; let wrapper = function
javascript
{ "resource": "" }
q31886
train
function(cb, settings) { if (!VK._apiId) { return false; } var url = VK._domain.main + VK._path.login + '?client_id='+VK._apiId+'&display=popup&redirect_uri=close.html&response_type=token'; if (settings && parseInt(settings, 10) > 0) { url += '&scope=' + settings; ...
javascript
{ "resource": "" }
q31887
postMessage
train
function postMessage(ctx) { var queue = [], message = "nextTick"; function handle(event) { if (event.source === ctx && event.data === message) { if (!!event.stopPropogation) { event.stopPropogation(); } if (queue.length > 0) { queue.shift()(); ...
javascript
{ "resource": "" }
q31888
send
train
function send(ev, data, fn) { /* jshint validthis: true */ // ignore newListener event to avoid this error in node 0.8 // https://github.com/cayasso/primus-emitter/issues/3 if
javascript
{ "resource": "" }
q31889
Emitter
train
function Emitter(conn) { if (!(this instanceof Emitter)) return new Emitter(conn); this.ids = 1; this.acks = {};
javascript
{ "resource": "" }
q31890
renderToString
train
function renderToString(reactClass, data) { let classPath = path.join(viewsDir, reactClass); let element
javascript
{ "resource": "" }
q31891
installed
train
function installed(){ findUp('README.*') .then(function(filepath){ if(filepath === null){ return process.cwd(); }else{ return path.resolve(filepath[0], '../'); } }) .then(function(parent){ return config.readLocal(parent); }) .then(data => {...
javascript
{ "resource": "" }
q31892
train
function(name,transform, provider_config, credentials, filefog_options){ this.name = name; this.config = provider_config || {}; this.credentials =
javascript
{ "resource": "" }
q31893
convertOutline
train
function convertOutline (jstruct) { //7/16/14 by DW var theNewOutline = {}, atts, subs; if (jstruct ["source:outline"] != undefined) { if (jstruct ["@"] != undefined) { atts = jstruct ["@"]; subs = jstruct ["source:outline"]; } else { atts = jstruct ["source:outline"] ["@"]; ...
javascript
{ "resource": "" }
q31894
getDebugger
train
function getDebugger() { const isCustom = arguments.length === 1; const layoutDebug = isCustom ? new
javascript
{ "resource": "" }
q31895
consume
train
function consume (len) { count -= len if (count < 0) { count = 0; console.warn('Not enough samples fed for the next data frame. Expected frame is ' + samplesPerFrame + ' samples ' + channels + '
javascript
{ "resource": "" }
q31896
getLibPaths
train
function getLibPaths(libs, inject) { inject = inject || false; var libName, libSrcs = [], outSrcs = []; for (libName in libs) { libSrcs = libs[libName]; if (typeof libSrcs === "string") { libSrcs = [libSrcs]; } var basePath; if (inject === true) { // Adapt basepath for inject basePath = path....
javascript
{ "resource": "" }
q31897
train
function (valueKey, signed) { return function (bytes) { var result = {}; result[valueKey] =
javascript
{ "resource": "" }
q31898
train
function (options) { return function (bytes) { var result = { min: options.min, max: options.max, range: options.max - options.min, raw: misc.bufferToInt(bytes)
javascript
{ "resource": "" }
q31899
train
function (name, id, bytes, parser) { this.name = name; this.id = id; this.bytes = bytes; // the parser is null by
javascript
{ "resource": "" }