_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q31900
VogueClient
train
function VogueClient(clientSocket, watcher) { this.socket = clientSocket; this.watcher = watcher; this.watchedFiles = {}; clientSocket.on('watch', this.handleMessage.bind(this)); clientSocket.on('disconnect', this.disconnect.bind(this)); }
javascript
{ "resource": "" }
q31901
load
train
function load(context) { var files , layers , cacheKey ; // TODO: make it proper optional param context = context || {}; // create new context // in case if `load` called without context context = typeOf(context) == 'function' ? context : this.new(context); // fallback to defaults context...
javascript
{ "resource": "" }
q31902
transformChunk
train
function transformChunk(chunk, encoding, done) { if (chunk.isNull()) return done(); if (chunk.isStream()) return this.emit('error', new PluginError(logFlag, 'Streaming not supported')); if ( !(chunk.isMarkdown = options.regexpMarkdown.test(chunk.relative)) && !(chunk.isTemplate = options.regexpT...
javascript
{ "resource": "" }
q31903
transformChunkData
train
function transformChunkData(chunk) { var matter = grayMatter(String(chunk.contents)), relPath = chunk.hasOwnProperty('data') && chunk.data.relativePath ? chunk.data.relativePath : getRelativePath(chunk.relative), absPath = path.normalize(path.join(options.basePath, relPath)); chunk.dat...
javascript
{ "resource": "" }
q31904
transformChunkContents
train
function transformChunkContents(chunk) { var contents = String(chunk.contents); try { if (chunk.isMarkdown) { contents = options.renderMarkdown(contents); } if (chunk.isTemplate) { contents = options.renderTemplate(contents, chunk.data, chunk.data.srcPath); } chunk....
javascript
{ "resource": "" }
q31905
renderTemplate
train
function renderTemplate(contents, data, filename) { if (!templateCache.hasOwnProperty(contents)) { var jadeOptions = merge.recursive({}, options.jadeOptions, {filename: filename}); templateCache[contents] = options.jade.compile(contents, jadeOptions); } var locals = merge.recursive({}, data, {lo...
javascript
{ "resource": "" }
q31906
applyLayout
train
function applyLayout(chunk) { chunk.data.contents = String(chunk.contents); var layout = getLayout(chunk.data.layout), contents = options.renderTemplate(layout.contents, chunk.data, layout.path); chunk.contents = new Buffer(contents); return chunk; }
javascript
{ "resource": "" }
q31907
getRelativePath
train
function getRelativePath(filePath) { var urlPath = path.join( path.dirname(filePath), path.basename(filePath, path.extname(filePath)) ); if (options.slugify) { urlPath = urlPath.split('/').map(function(part) { return slug(part, options.slugOptions); }).join('/'); } ur...
javascript
{ "resource": "" }
q31908
getLayout
train
function getLayout(layout) { if (!layoutCache.hasOwnProperty(layout)) { var layoutContents = false, layoutPath = path.join( path.isAbsolute(options.layoutPath) ? options.layoutPath : path.join(process.cwd(), options.layoutPath), layout ); try { layoutCon...
javascript
{ "resource": "" }
q31909
logDuplicate
train
function logDuplicate(chunk) { log(logFlag, chalk.black.bgYellow('WARNING') + ' skipping ' + chalk.magenta(chunk.data.srcRelativePath) + ' as it would output to same path as ' + chalk.magenta(buffer[chunk.relative].data.srcRelativePath) ); }
javascript
{ "resource": "" }
q31910
includeFiles
train
function includeFiles(config, backRef) { backRef = backRef || []; Object.keys(config).forEach(function(key) { var value, oneOffContext; if (typeof config[key] == 'string') { // create temp context oneOffContext = merge.call(cloneFunction, this, { files: [config[key]] }); // try to...
javascript
{ "resource": "" }
q31911
GulpEmail
train
function GulpEmail(opts, cb) { this.fullContent = ''; this.default = {}; this.cb = cb || this.callback; this.options = extend(this.default, opts); this.stream = new Transform({objectMode: true}); this.stream._transform = function(chunk, encoding, callback){ var fullPath = null, file = {}, relative = chu...
javascript
{ "resource": "" }
q31912
Cell
train
function Cell (node, content) { let index = 0 if (node.parentNode && node.parentNode.childNodes) { index = Util.arrayIndexOf(node.parentNode.childNodes, node) } const prefix = (index === 0 ? '| ' : ' ') return prefix + content + ' |' }
javascript
{ "resource": "" }
q31913
getVar
train
function getVar(token, env) { var modifiers = token.split(/\s+/) , name = modifiers.pop() , result = '' ; if (typeof env[name] == 'string' && env[name].length > 0) { result = env[name]; // process value with modifiers, right to left result = modifiers.reverse().reduce(function(ac...
javascript
{ "resource": "" }
q31914
train
function(config, env) { return env.grunt.util._.extend({ banner: '', compress: { warnings: false }, mangle: {}, beautify: false, report: false }, env.task.options(config.uglify || {})); }
javascript
{ "resource": "" }
q31915
train
function(files, config, catalog, env) { var uglifyConfig = this.uglifyConfig(config, env); var grunt = env.grunt; var _ = grunt.util._; files.forEach(function(f) { var src = validFiles(f.src, grunt, config); var dest = utils.fileInfo(f.dest, config); grunt.log.write('Processing ' + dest.catalogPath.cy...
javascript
{ "resource": "" }
q31916
getCacheKey
train
function getCacheKey() { // use the one from the context var directories = this.directories || this.defaults.directories; return resolveDir(directories) + ':' + getFiles.call(this, process.env).join(',') + ':' + resolveExts.call(this).join(',') ; }
javascript
{ "resource": "" }
q31917
resolveDir
train
function resolveDir(directories) { var directoriesAbsPath; if (typeOf(directories) == 'array') { directoriesAbsPath = directories.map(function(d) { return path.resolve(d); }).join('|'); } else { directoriesAbsPath = path.resolve(directories); } return directoriesAbsPath; }
javascript
{ "resource": "" }
q31918
train
function(href) { var url = extract(href) var queryObj = omit(url.qs, this.config.excludeRequestParams) var desiredUrlParams = Object.keys(queryObj).map(function(paramName) { return paramName + '=' + encodeURIComponent(queryObj[paramName]) }).join('&') return desiredUrlParams ? url.url + '?' + desiredUrlP...
javascript
{ "resource": "" }
q31919
train
function(envelope) { var filePath = this._getFileName(envelope) filendir.writeFile(filePath, JSON.stringify(envelope), function(err) { if (err) { log('File could not be saved in ' + this.config.cacheDir) throw err } }.bind(this)) }
javascript
{ "resource": "" }
q31920
train
function(req, returnReference) { getRawBody(req).then(function(bodyBuffer) { returnReference.requestBody = bodyBuffer.toString() }).catch(function() { log('Unhandled error in getRawBody', arguments) }) }
javascript
{ "resource": "" }
q31921
createNew
train
function createNew(options) { var copy = cloneFunction(configly) , instance = copy.bind(copy) ; // enrich copy with helper methods // mind baked-in context of the copies applyProps.call(this, copy, options); // get fresh list of filenames // if needed copy.files = copy.files || getFilenames....
javascript
{ "resource": "" }
q31922
copyProps
train
function copyProps(target) { Object.keys(this).forEach(function(key) { target[key] = typeof this[key] == 'function' ? this[key].bind(this) : this[key]; }.bind(this)); return target; }
javascript
{ "resource": "" }
q31923
getFilenames
train
function getFilenames() { var hostname = getHostname() , host = hostname.split('.')[0] ; return [ 'default', '', // allow suffixes as a basename (e.g. `environment`) host, hostname, 'local', this.defaults.customIncludeFiles, this.defaults.customEnvVars, 'runtime' ]; }
javascript
{ "resource": "" }
q31924
deepMerge
train
function deepMerge (base, custom) { Object.keys(custom).forEach(function (key) { if (!base.hasOwnProperty(key) || typeof base[key] !== 'object') { base[key] = custom[key] } else { base[key] = deepMerge(base[key], custom[key]) } }) return base }
javascript
{ "resource": "" }
q31925
iterateFiles
train
function iterateFiles (dir, options, cb) { var iterateOptions = { ext: [], // extensions to look for dirs: false, // do callback for dirs too skip_: true, // skip files & dirs starting with _ recursive: true // do a recursive find } options = deepMerge(iterateOptions, options) // console.log('o...
javascript
{ "resource": "" }
q31926
iterateRecurse
train
function iterateRecurse (dir, options, cb) { try { var files = fs.readdirSync(dir) files.forEach(function (file, index) { var parsedPath = path.parse(file) var name = parsedPath.name var ext = parsedPath.ext var srcpath = path.join(dir, file) if (options.skip_ && name.charAt(0) ...
javascript
{ "resource": "" }
q31927
innertext
train
function innertext (html) { // Drop everything inside <...> (i.e., tags/elements), and keep the text. // Unlike browser innerText, this removes newlines; it also doesn't handle // un-encoded `<` or `>` characters very well, so don't feed it malformed HTML return entities.decode(html.split(/<[^>]+>/) .map(fu...
javascript
{ "resource": "" }
q31928
existsSync
train
function existsSync (path) { try { Fs.accessSync(Path.resolve(path), Fs.F_OK) return true } catch (err) { return false } }
javascript
{ "resource": "" }
q31929
getFiles
train
function getFiles(env) { var files = [] , environment = env['NODE_ENV'] || this.defaults.environment , appInstance = env['NODE_APP_INSTANCE'] ; // generate config files variations this.files.forEach(function(baseName) { // check for variables // keep baseName if no variables found ...
javascript
{ "resource": "" }
q31930
mergeLayers
train
function mergeLayers(layers) { var _instance = this , result = null ; layers.forEach(function(layer) { layer.exts.forEach(function(ext) { ext.dirs.forEach(function(cfg) { // have customizable's array merge function result = merge.call({ useCustomAdapters: ...
javascript
{ "resource": "" }
q31931
train
function() { cfg = this.config.get('pluginsConfig.localized-footer'), _this = this; try { fs.statSync(this.resolve(cfg.filename)); hasFooterFile = true; } catch (e) { hasFooterFile = false; return; } ...
javascript
{ "resource": "" }
q31932
applyHooks
train
function applyHooks(config, filename) { // sort hooks short first + alphabetically Object.keys(this.hooks).sort(compareHooks).forEach(function(hook) { // in order to match hook should either the same length // as the filename or smaller if (filename.substr(0, hook.length) === hook) { config ...
javascript
{ "resource": "" }
q31933
compareHooks
train
function compareHooks(a, b) { return a.length < b.length ? -1 : (a.length > b.length ? 1 : (a < b ? -1 : (a > b ? 1 : 0))); }
javascript
{ "resource": "" }
q31934
hasValue
train
function hasValue(value) { if (typeOf(value) === 'string') { return value.length > 0; } else { return typeOf(value) !== 'undefined' && typeOf(value) !== 'nan'; } }
javascript
{ "resource": "" }
q31935
watchAllStylesheets
train
function watchAllStylesheets() { var href; for (href in stylesheets) { if (hop.call(stylesheets, href)) { socket.emit("watch", { href: href }); } } }
javascript
{ "resource": "" }
q31936
reloadStylesheet
train
function reloadStylesheet(href) { var newHref = stylesheets[href].href + (href.indexOf("?") >= 0 ? "&" : "?") + "_vogue_nocache=" + (new Date).getTime(), stylesheet; // Check if the appropriate DOM Node is there. if (!stylesheets[href].setAttribute) { // Creat...
javascript
{ "resource": "" }
q31937
getLocalStylesheets
train
function getLocalStylesheets() { /** * Checks if the stylesheet is local. * * @param {Object} link The link to check for. * @returns {Boolean} */ function isLocalStylesheet(link) { var href, i, isExternal = true; if (link.getAttribute("rel") !== "styleshee...
javascript
{ "resource": "" }
q31938
isLocalStylesheet
train
function isLocalStylesheet(link) { var href, i, isExternal = true; if (link.getAttribute("rel") !== "stylesheet") { return false; } href = link.href; for (i = 0; i < script.bases.length; i += 1) { if (href.indexOf(script.bases[i]) > -1) { isExtern...
javascript
{ "resource": "" }
q31939
getBase
train
function getBase(href) { var base, j; for (j = 0; j < script.bases.length; j += 1) { base = script.bases[j]; if (href.indexOf(base) > -1) { return href.substr(base.length); } } return false; }
javascript
{ "resource": "" }
q31940
loadScript
train
function loadScript(src, loadedCallback) { var script = document.createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("src", src); // Call the callback when the script is loaded. script.onload = loadedCallback; script.onreadystatechange = function () { ...
javascript
{ "resource": "" }
q31941
loadScripts
train
function loadScripts(scripts, loadedCallback) { var srcs = [], property, count, i, src, countDown = function () { count -= 1; if (!count) { loadedCallback(); } }; for (property in scripts) { if (!(property in window)) { srcs.push(scripts[p...
javascript
{ "resource": "" }
q31942
getScriptInfo
train
function getScriptInfo() { var bases = [ document.location.protocol + "//" + document.location.host ], scripts, src, rootUrl, baseMatch; if (typeof window.__vogue__ === "undefined") { scripts = document.getElementsByTagName("script"); for (var i=0; i < scripts.length; i++) { src = sc...
javascript
{ "resource": "" }
q31943
getPort
train
function getPort(url) { // URL may contain the port number after the second colon. // http://domain:1234/ var index = url.indexOf(":", 6); // skipping 6 characters to ignore first colon return index < 0 ? 80 : parseInt(url.substr(index + 1), 10); }
javascript
{ "resource": "" }
q31944
nodeInjectmd
train
function nodeInjectmd (opts) { const inBuf = bl() assert.equal(typeof opts, 'object', 'opts should be an object') assert.equal(typeof opts.in, 'string', 'opts.in should be a string') assert.equal(typeof opts.tag, 'string', 'opts.tag should be a string') const inFile = opts.in const tag = opts.tag const ...
javascript
{ "resource": "" }
q31945
wrap
train
function wrap (str, quote) { if (this.typecheck) t.typecheck('wrap', [str, quote]); if (!quote||quote=="'") return "'"+str+"'"; if (quote == '"') return '"'+str+'"'; return quote+str+quote; }
javascript
{ "resource": "" }
q31946
string
train
function string (str, quote) { if (this.typecheck) t.typecheck('string', [str, quote]); return this.wrap(this.escape(str), quote); }
javascript
{ "resource": "" }
q31947
train
function(files, config, catalog, env) { var grunt = env.grunt; var that = this; files.forEach(function(f) { var file = utils.fileInfo(f.dest, config); grunt.log.write('Processing ' + file.catalogPath.cyan); var src = f.src.map(function(src) { return utils.fileInfo(src, {cwd: config.srcWebroot}); ...
javascript
{ "resource": "" }
q31948
Task
train
function Task(phase, name, func) { if (typeof name === 'function') { func = name; name = 'anonymous'; } if (phases.indexOf(phase) < 0) { throw new Error('Phase ' + phase + ' is not valid.'); } if (typeof func !== 'function') { throw new TypeError('Expected function, got ' + typeof func); }...
javascript
{ "resource": "" }
q31949
train
function(content) { if (typeof content != 'string') { content = JSON.stringify(content, null, '\t'); } fs.writeFileSync(catalogFile, content); }
javascript
{ "resource": "" }
q31950
train
function( callback ) { var self = this // Close a previously opened handle if( this.fd != null ) { return this.close( function( error ) { if( error != null ) return callback.call( self, error ) self.open( callback ) }) } // Open a new fd handle debug( 'fs...
javascript
{ "resource": "" }
q31951
train
function( size, step, limit, callback ) { var args = [].slice.call( arguments ) callback = args.pop() if( this.fd == null ) return callback.call( this, new Error( 'Invalid file descriptor' ) ) limit = args.pop() || 0x2000 step = args.pop() || 0x80 size = args.pop() || 0x200 var s...
javascript
{ "resource": "" }
q31952
train
function( cylinder, head, sector ) { if( this.headsPerTrack < 0 || this.sectorsPerTrack < 0 ) throw new Error( 'Unspecified device geometry' ) return ( cylinder * this.headsPerTrack + head ) * this.sectorsPerTrack + ( sector - 1 ) }
javascript
{ "resource": "" }
q31953
train
function( fromLBA, toLBA, buffer, callback ) { fromLBA = fromLBA || 0 toLBA = toLBA || ( fromLBA + 1 ) if( fromLBA > toLBA ) { var swap = fromLBA fromLBA = toLBA toLBA = swap swap = void 0 } if( typeof buffer === 'function' ) { callback = buffer buffer = null ...
javascript
{ "resource": "" }
q31954
envVars
train
function envVars(config, backRef) { backRef = backRef || []; Object.keys(config).forEach(function(key) { var value; if (typeof config[key] == 'string') { // try simple match first, for non-empty value value = getVar.call(this, config[key], process.env); // if not, try parsing for ...
javascript
{ "resource": "" }
q31955
name
train
function name (column, table, schema) { if (this.typecheck) t.typecheck('name', [column, table, schema]); var result = []; schema && result.push(this.quotes(schema)); table && result.push(this.quotes(table)); column && result.push(this.quotes(column)); return result.join('.'); }
javascript
{ "resource": "" }
q31956
names
train
function names (columns, table, schema) { if (this.typecheck) t.typecheck('names', [columns, table, schema]); var result = []; for (var i=0; i < columns.length; i++) { result.push(this.name(columns[i],table,schema)); } return result.join(','); }
javascript
{ "resource": "" }
q31957
as
train
function as (column, name) { if (this.typecheck) t.typecheck('as', [column, name]); return [column,'as',name].join(' '); }
javascript
{ "resource": "" }
q31958
select
train
function select (args) { if (this.typecheck) t.typecheck('select', [args]); if ('string'===typeof args) args = [args]; return 'select '+args.join(); }
javascript
{ "resource": "" }
q31959
join
train
function join (table, args, type) { this.typecheck && t.typecheck('join', [table, args, type]); if ('string'===typeof args) args = [args]; var result = ['join',table,'on',args.join(' and ')]; if (type) result.splice(0,0,type); return result.join(' '); }
javascript
{ "resource": "" }
q31960
eq
train
function eq (a, b) { if (this.typecheck) t.typecheck('eq', [a, b]); return a+'='+b; }
javascript
{ "resource": "" }
q31961
eqv
train
function eqv (column, value) { if (this.typecheck) t.typecheck('eqv', [column, value]); if (value===undefined||value===null) value = null; if ('string'===typeof value) value = this.string(value); if ('boolean'===typeof value) value = (this.dialect == 'pg') ? ((value == false) ? this....
javascript
{ "resource": "" }
q31962
groupby
train
function groupby (args) { if (this.typecheck) t.typecheck('groupby', [args]); if ('string'===typeof args) args = [args]; return 'group by '+args.join(); }
javascript
{ "resource": "" }
q31963
orderby
train
function orderby (args, order) { if (this.typecheck) t.typecheck('orderby', [args, order]); var o = (order&&'string'===typeof order) ? order : ''; var result = []; if ('string'===typeof args) { result = o ? [args+' '+o] : [args]; } else if (args instanceof Array) { for (var...
javascript
{ "resource": "" }
q31964
limit
train
function limit (a, b) { if (this.typecheck) t.typecheck('limit', [a, b]); return (this.dialect == 'pg') ? ['limit',b,'offset',a].join(' ') : 'limit '+[a,b].join(); }
javascript
{ "resource": "" }
q31965
between
train
function between (a, b) { if (this.typecheck) t.typecheck('between', [a, b]); return ['between',a,'and',b].join(' '); }
javascript
{ "resource": "" }
q31966
where
train
function where (expr, operator) { if (this.typecheck) t.typecheck('where', [expr, operator]); if ('string'===typeof expr) return 'where '+expr; return 'where ' + expr.join(' '+(operator||'and')+' '); }
javascript
{ "resource": "" }
q31967
update
train
function update (table, columns, values) { if (this.typecheck) t.typecheck('update', [table, columns, values]); if ('string'===typeof columns) { columns = [columns]; values = [values]; } var result = []; for (var i=0; i < columns.length; i++) { var value = ('string'===typeof ...
javascript
{ "resource": "" }
q31968
loadFiles
train
function loadFiles(directories, files) { // sort extensions to provide deterministic order of loading var _instance = this , extensions = resolveExts.call(this) , layers = [] ; // treat all inputs as list of directories directories = (typeOf(directories) == 'array') ? directories : [directorie...
javascript
{ "resource": "" }
q31969
Watch
train
function Watch(patterns, ids) { if (typeof patterns === 'undefined') { throw new Error('Watch constructor requires a patterns argument'); } if (typeof ids === 'undefined') { throw new Error('Watch constructor requires an ids argument'); } patterns = Array.isArray(patterns) ? patterns : [patterns]; ...
javascript
{ "resource": "" }
q31970
queue
train
function queue(runner) { if (running < tasks) { ++running; runner(release); } else { pending.push(runner); } }
javascript
{ "resource": "" }
q31971
removeUselessStackLines
train
function removeUselessStackLines(stack) { let pretty = stack.split('\n'); pretty = pretty.filter((line) => { return !line.includes('node_modules') && !line.includes('Error'); }); pretty = pretty.join('\n'); return pretty; }
javascript
{ "resource": "" }
q31972
formatErrors
train
function formatErrors (results) { return ''; var failCount = results.fail.length; var past = (failCount === 1) ? 'was' : 'were'; var plural = (failCount === 1) ? 'failure' : 'failures'; var out = '\n' + pad(format.red.bold('Failed Tests:') + ' There ' + past + ' ' + format.red.bold(failCount) + '...
javascript
{ "resource": "" }
q31973
_checkUpdate
train
function _checkUpdate(){ var notifier = updateNotifier({ pkg: pkg, updateCheckInterval: 1000 * 60 * 60 * 24 * 7 }) if (notifier.update) notifier.notify() }
javascript
{ "resource": "" }
q31974
_detectComment
train
function _detectComment(argv){ var comment = '' if(argv._.length == 1){ if(argv.m && typeof argv.m == 'string') comment = argv.m else if (argv.message && typeof argv.message == 'string') comment = argv.message return comment } else { console.log(chalk.red.bold('Invalid command: use stamplay deploy...
javascript
{ "resource": "" }
q31975
renderView
train
function renderView(view, layout, partials, context) { let options = { partials: partials }; // Handle dynamically-defined content tag let renderedView = {}; renderedView[opts.contentTag] = view(context, options); return layout(Object.assign({}, context, renderedView), options); }
javascript
{ "resource": "" }
q31976
train
function (nm) { el = d3.select(nm).append("svg") .attr("width", config.width + 2 * config.margin) .attr("height", config.height + 2 * config.margin) .append("g") .attr("transform", "translate(" + config.margin + ", " ...
javascript
{ "resource": "" }
q31977
makeGetterSetter
train
function makeGetterSetter(name) { xkcd[name] = function (value) { if (arguments.length === 0) { return config[name]; } config[name] = value; return xkcd; }; }
javascript
{ "resource": "" }
q31978
lineplot
train
function lineplot(data, x, y, opts) { var line = d3.svg.line().x(x).y(y).interpolate(xinterp), bgline = d3.svg.line().x(x).y(y), strokeWidth = _get(opts, "stroke-width", 3), color = _get(opts, "stroke", "steelblue"); el.append("svg:path").attr("d", bgline(data)) ...
javascript
{ "resource": "" }
q31979
_get
train
function _get(d, k, def) { if (typeof d === "undefined") return def; if (typeof d[k] === "undefined") return def; return d[k]; }
javascript
{ "resource": "" }
q31980
StackMapper
train
function StackMapper(sourcemap) { if (!(this instanceof StackMapper)) return new StackMapper(sourcemap); if (typeof sourcemap !== 'object') throw new Error('sourcemap needs to be an object, please use convert-source-map module to convert it from any other format\n' + 'See: https://github.co...
javascript
{ "resource": "" }
q31981
compileTemplate
train
function compileTemplate(baseDir, filePath, type) { return new options.Promise((resolve, reject) => { let now = timestamp(); let name = filePath.substring(baseDir.length + 1).replace(/\\/g, '/'); name = name.substring(0, name.indexOf('.')); // A cached template is only invalidated if the ...
javascript
{ "resource": "" }
q31982
compileTemplates
train
function compileTemplates(dir, type) { return getPaths(dir, ext, options).then(paths => { return options.Promise.all(paths.map(filePath => { return compileTemplate(dir, filePath, type); })).then(templates => { return templates.reduce((all, current) => { all[current._name] = cur...
javascript
{ "resource": "" }
q31983
jsCompile
train
function jsCompile(content, file) { // make it as a child of this module // Would be nice to actually make it transparent // and pretend it to be child of the caller module // but there is no obvious way, yet var jsMod = new Module(file, module); // override parents to exclude configly from the chain // ...
javascript
{ "resource": "" }
q31984
train
function(dt) { dt = dt || new Date(); return [dt.getFullYear(), padNumber(dt.getMonth() + 1), padNumber(dt.getDate()), padNumber(dt.getHours()), padNumber(dt.getMinutes()), padNumber(dt.getSeconds()) ].join(''); }
javascript
{ "resource": "" }
q31985
train
function(file, options) { file = this.absPath(file); var cwd = (options && options.cwd) || ''; if (file.substring(0, cwd.length) == cwd) { file = file.substring(cwd.length); if (file.charAt(0) != '/') { file = '/' + file; } } return file; }
javascript
{ "resource": "" }
q31986
train
function(grunt, task) { var config = task.options(grunt.config.getRaw('frontend') || {}); if (!config.webroot) { return grunt.fail.fatal('You should specify "webroot" property in frontend config', 100); } var cwd = this.absPath(config.cwd || config.webroot); var force = false; if ('force' in config) { ...
javascript
{ "resource": "" }
q31987
train
function(url, version, config) { if (!config.rewriteScheme) { return url; } var basename = path.basename(url); var ext = path.extname(url).substr(1); var filename = basename.replace(new RegExp('\\.' + ext + '$'), ''); var data = { url: url, dirname: path.dirname(url), basename: basename, ex...
javascript
{ "resource": "" }
q31988
train
function(x, y, silent) { if('number' != typeof x) { silent = y; y = x.y; x = x.x; } if(this.x === x && this.y === y) return this; this.x = Vec2.clean(x); this.y = Vec2.clean(y); if(silent !== false) return this.change(); }
javascript
{ "resource": "" }
q31989
train
function(vec2, returnNew) { if (!returnNew) { this.x += vec2.x; this.y += vec2.y; return this.change(); } else { // Return a new vector if `returnNew` is truthy return new Vec2( this.x + vec2.x, this.y + vec2.y ); } }
javascript
{ "resource": "" }
q31990
train
function(vec2, returnNew) { var x,y; if ('number' !== typeof vec2) { //.x !== undef) { x = vec2.x; y = vec2.y; // Handle incoming scalars } else { x = y = vec2; } if (!returnNew) { return this.set(this.x * x, this.y * y); } else { retur...
javascript
{ "resource": "" }
q31991
train
function(r, inverse, returnNew) { var x = this.x, y = this.y, cos = Math.cos(r), sin = Math.sin(r), rx, ry; inverse = (inverse) ? -1 : 1; rx = cos * x - (inverse * sin) * y; ry = (inverse * sin) * x + cos * y; if (returnNew) { return new Vec2(rx, ry...
javascript
{ "resource": "" }
q31992
train
function(vec2) { var x = this.x - vec2.x; var y = this.y - vec2.y; return Math.sqrt(x*x + y*y); }
javascript
{ "resource": "" }
q31993
train
function(returnNew) { var length = this.length(); // Collect a ratio to shrink the x and y coords var invertedLength = (length < Number.MIN_VALUE) ? 0 : 1/length; if (!returnNew) { // Convert the coords to be greater than zero // but smaller than or equal to 1.0 return ...
javascript
{ "resource": "" }
q31994
train
function(v, w) { if (w === undef) { w = v.y; v = v.x; } return (Vec2.clean(v) === this.x && Vec2.clean(w) === this.y); }
javascript
{ "resource": "" }
q31995
train
function(returnNew) { var x = Math.abs(this.x), y = Math.abs(this.y); if (returnNew) { return new Vec2(x, y); } else { return this.set(x, y); } }
javascript
{ "resource": "" }
q31996
train
function(v, returnNew) { var tx = this.x, ty = this.y, vx = v.x, vy = v.y, x = tx < vx ? tx : vx, y = ty < vy ? ty : vy; if (returnNew) { return new Vec2(x, y); } else { return this.set(x, y); } }
javascript
{ "resource": "" }
q31997
train
function(low, high, returnNew) { var ret = this.min(high, true).max(low); if (returnNew) { return ret; } else { return this.set(ret.x, ret.y); } }
javascript
{ "resource": "" }
q31998
train
function(vec2, returnNew) { var x,y; if ('number' !== typeof vec2) { x = vec2.x; y = vec2.y; // Handle incoming scalars } else { x = y = vec2; } if (x === 0 || y === 0) { throw new Error('division by zero') } if (isNaN(x) || isNaN(y)) { ...
javascript
{ "resource": "" }
q31999
json
train
function json(value) { var parsedPojo; try { parsedPojo = JSON.parse(value); } catch(e) { return throwModifierError('json', value, e); } return parsedPojo; }
javascript
{ "resource": "" }