_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q64400
Limon
test
function Limon (input, options) { if (!(this instanceof Limon)) { return new Limon(input, options) } lazy.use(this, { fn: function (app, opts) { app.options = lazy.utils.extend(app.options, opts) } }) this.defaults(input, options) this.use(lazy.plugin.prevNext()) }
javascript
{ "resource": "" }
q64401
planner
test
function planner(origin, dest, opts) { var tasks = new TaskPlanner(); var cmds = generateCommands(origin, dest); var state = _.cloneDeep(origin); var result; opts = xtend(defaults, opts); assert(opts.mode === 'quick' || opts.mode === 'safe', 'unknown mode'); tasks.addTask({ cmd: 'nop' }, {}); ...
javascript
{ "resource": "" }
q64402
test
function(strip) { if (!strip) { console.log(messagingTexts.noStrip); } if (!(strip instanceof pixel.Strip)) { console.log(messagingTexts.wrongStrip); } pattern.reset(strip, interval); interval = pattern.domino(strip, 'white'); }
javascript
{ "resource": "" }
q64403
test
function(strip) { if (!strip) { console.log(messagingTexts.noStrip); } if (!(strip instanceof pixel.Strip)) { console.log(messagingTexts.wrongStrip); } pattern.reset(strip, interval); setTimeout(function() { pattern.flash(strip, 'gre...
javascript
{ "resource": "" }
q64404
create
test
function create(parent, baseUrl, params, callback) { parent.getClient().post(baseUrl, params, function(err, definition, response) { if (err) return callback(err); callback(null, new this(parent, definition)); }.bind(this)); }
javascript
{ "resource": "" }
q64405
register
test
function register ( type, lang, handler ) { if (Array.isArray(lang)) { lang.forEach((v) => store[type].langs[v] = handler); return; } store[type].langs[lang] = handler; }
javascript
{ "resource": "" }
q64406
test
function( kind, promisesDfd ) { return function() { // operate on this unless we forced a deferred to work on var dfd = promisesDfd || this; var fnSet = [].slice.call( arguments ); // as long as this is a progress handler or the state isn't reached add it // otherwise call it right now if ( k...
javascript
{ "resource": "" }
q64407
test
function( set, args) { // nothing to see here folks if ( set.length < 1 ) { return; } // the args to call with var apply = []; // we passed inline arguments if ( set.length > 1 ) { for ( var i = 1; i < set.length; i++ ) { // is it one of those cool perform.arg(X) thingies? // if no...
javascript
{ "resource": "" }
q64408
test
function( kind, args ) { var bucket = this[ kind + 's' ]; for ( var i = 0; i < bucket.length; i++ ) { callSet.call( this, bucket[i], args ); } }
javascript
{ "resource": "" }
q64409
test
function() { var dfd = this; // since people might be used to .promise() var promise = function(){ return promise; }; promise.done = stackNFire( 'done', dfd ); promise.fail = stackNFire( 'fail', dfd ); promise.progress = stackNFire( 'progress', dfd ); promise.state = dfd.state; return promise; }
javascript
{ "resource": "" }
q64410
test
function( kind ) { return function() { if ( this.state === 'pending' ) { if ( kind !== 'progress' ) { this[ kind + 'Args' ] = arguments; this.state = this.promise.state = kind; } callSets.call( this, kind, arguments ); } return this; }; }
javascript
{ "resource": "" }
q64411
test
function() { this.dones = []; this.doneArgs = []; this.fails = []; this.failArgs = []; this.pendings = []; this.pendingArgs = []; this.state = 'pending'; // expose the promise this.promise = iPromise.call( this ); }
javascript
{ "resource": "" }
q64412
test
function( performer ) { // everything checks out var state = performer.state; // everything resolved if ( state.allCount === 0 ) { var args = []; for ( var i = 0; i < performer.args.length; i++ ) { args = args.concat( [].concat( performer.args[i].args ) ); } // either fail/done are 0 o...
javascript
{ "resource": "" }
q64413
test
function(schema) { this._decoders = decoders; this._encoders = encoders; this._schemas = {}; // Allow to pass the fields direclty if(Object.keys(schema).join(',') !== 'name,fields'){ schema = { name: '_auto-' + new Date().getTime(), fields: schema }; } this._schema = schema; this._...
javascript
{ "resource": "" }
q64414
test
function(selector, properties, value) { let rule = postcss.rule({selector: selector}) let decls = _.map(properties, function(property) { return postcss.decl({prop: property, value: value}) }) rule.append(decls) return rule }
javascript
{ "resource": "" }
q64415
test
function(breakpoints, spacingScale) { return _.map(breakpoints, function(breakpointValue, breakpointKey) { let mediaQuery = postcss.atRule({ name: 'media', params: breakpointValue, }) let rules = _.flatMap(spacingScale, function(scaleValue, scaleKey) { re...
javascript
{ "resource": "" }
q64416
destroy
test
function destroy(callback) { this.getClient().destroy(this.definition._links.self.href, function(err, definition, response) { if (err) return callback(err); callback(); }.bind(this)); }
javascript
{ "resource": "" }
q64417
load_config
test
function load_config () { let config = {}; if (fs.existsSync(pgrunner_config_file)) { config = JSON.parse(fs.readFileSync(pgrunner_config_file, {'encoding':'utf8'})); if (argv.v) { debug.log('Loaded from ', pgrunner_config_file); } } if (!is.array(config.servers)) { config.servers = []; } return config...
javascript
{ "resource": "" }
q64418
save_config
test
function save_config (config) { fs.writeFileSync(pgrunner_config_file, JSON.stringify(config, null, 2), {'encoding':'utf8'}); if (argv.v) { debug.log('Saved to ', pgrunner_config_file); } }
javascript
{ "resource": "" }
q64419
get_server_opts
test
function get_server_opts (opts) { debug.assert(opts).is('object'); debug.assert(opts.settings).is('object'); return { 'dbconfig': opts.dbconfig, 'host': opts.settings.host, 'port': opts.settings.port, 'user': opts.settings.user, 'database': opts.settings.database }; }
javascript
{ "resource": "" }
q64420
getResources
test
function getResources(domains) { return store.getResources().then(rsrcs => { return rsrcs.filter(e => domains.includes(e.domain)); }); }
javascript
{ "resource": "" }
q64421
urlFormat
test
function urlFormat(obj) { // ensure it's an object, and not a string url. // If it's an obj, this is a no-op. // this way, you can call url_format() on strings // to clean up potentially wonky urls. if (isString(obj)) { obj = urlParse(obj); } else if (!isObject(obj) || isNull(obj)) { ...
javascript
{ "resource": "" }
q64422
rayLineVsCircle
test
function rayLineVsCircle(ray, circle) { var rayLine = new Line2( ray.start.x, ray.start.y, ray.end.x, ray.end.y ); return rayLine.intersectCircle(circle.position, circle.radius); }
javascript
{ "resource": "" }
q64423
scopeUrl
test
function scopeUrl(options, inst) { options = _.extend(_.clone(options || {}), inst) if (typeof options !== 'object' && (!options.tournament_id || !options.flight_id)) throw new Error('tournament_id or flight_id required to make tibreak preference api calls') var url = '' if (options.tournament_id...
javascript
{ "resource": "" }
q64424
test
function(options, callback) { var url = scopeUrl(options, this) return Super.fetch.call(this, url, options, callback) }
javascript
{ "resource": "" }
q64425
test
function(module, debug) { this.debug = debug || false; this.jsonrpc = "2.0"; // check & load the methods in module this.methods = module; if(handy.getType(module)=='string') { this.methods = require(module); } if(this.debug) { logger.debug('Loaded with methods:'+_.functions(this.methods)); } }
javascript
{ "resource": "" }
q64426
_getParamNames
test
function _getParamNames(func) { var funStr = func.toString(); return funStr.slice(funStr.indexOf('(')+1, funStr.indexOf(')')).match(/([^\s,]+)/g); }
javascript
{ "resource": "" }
q64427
_getChangedProperties
test
function _getChangedProperties() { var retVal = {}, key; for (key in this._changed) { retVal[key] = this._changed[key]; } return retVal; }
javascript
{ "resource": "" }
q64428
update
test
function update(properties, callback) { if (typeof properties == 'function') { callback = properties; properties = {}; } var key, changed; var exceptions = ['addresses_update_action', 'emails_update_action', 'phone_numbers_update_action']; for (key in properties) { if ('set' + inflection.camelize...
javascript
{ "resource": "" }
q64429
byClass
test
function byClass (c) { c = classnames(c) if (/^\./.test(c)) { throw new Error('No need to "." on start') } return bySelector(`.${c}`) }
javascript
{ "resource": "" }
q64430
subtemplate
test
function subtemplate(template, data) { try { return new JSDOC.JsPlate(publish.conf.templatesDir+template).process(data); } catch(e) { print(e.message); quit(); } }
javascript
{ "resource": "" }
q64431
makeSignature
test
function makeSignature(params) { if (!params) return "()"; var signature = "(" + params.filter( function($) { return !/\w+\.\w+/.test($.name); } ).map( function($) { var name = $.isOptional ? '[' + $.name + ']' : $.name; return name; } ).join(", ") + ")"; return signature; }
javascript
{ "resource": "" }
q64432
approach
test
function approach(index, x, onAxis) { while (0 <= x && x <= 1) { candidateHSVA[index] = x; WebInspector.Color.hsva2rgba(candidateHSVA, candidateRGBA); WebInspector.Color.blendColors(candidateRGBA, bgRGBA, blendedRGBA); var fgLuminance =...
javascript
{ "resource": "" }
q64433
updateNodeColor
test
function updateNodeColor(data) { d3.selectAll('.node').select('.node-symbol') .style('fill', d => d3scale.scaleFunction(data.scale)(d[data.column.key])); }
javascript
{ "resource": "" }
q64434
mainControlBox
test
function mainControlBox() { d3.select('#show-struct') .on('change', function () { const data = nodeContentInput(); d3.select('#main-control').datum(data); updateNodeStructure(data); }) .dispatch('change'); }
javascript
{ "resource": "" }
q64435
centerGraph
test
function centerGraph(newScale, duration, delay) { if (typeof delay === 'function') { delay = delay.call(this); } delay = typeof delay === 'number' ? delay : 0; setTimeout(function() { if (typeof newScale === 'function') { newScale = newScale.call(this); } if (typeof durati...
javascript
{ "resource": "" }
q64436
detectAllNodesFixed
test
function detectAllNodesFixed() { if (data) { var currentNodesFixed = data.allNodesFixed; var allNodesFixed = true; data.nodes.forEach(function(node) { if (!node.fixed) { allNodesFixed = false; } }); data.allNodesFixed = allNodesFixed; if (currentNodesFixed !==...
javascript
{ "resource": "" }
q64437
fadeRelatedNodes
test
function fadeRelatedNodes(targetNode, selected, nodes, links) { var opacity = selected ? 0.1 : 1; var elm = findElementByNode('circle', targetNode); // Highlight circle elm.classed('selected', opacity < 1); // Clean links $('path.link').removeAttr('data-show'); // Traver...
javascript
{ "resource": "" }
q64438
findElementByNode
test
function findElementByNode(prefix, node) { var selector = '.' + formatClassName(prefix, node); return graph.select(selector); }
javascript
{ "resource": "" }
q64439
getElementCoords
test
function getElementCoords(element) { var ctm = element.getCTM(); return { x: ctm.e + element.getAttribute('cx') * ctm.a, y: ctm.f + element.getAttribute('cy') * ctm.d }; }
javascript
{ "resource": "" }
q64440
getSVG
test
function getSVG(elementType) { var returnVal; var svgElement; var cached; switch (elementType) { case 'circle': case 'g': case 'path': case 'text': returnVal = function(data) { svgElement = svgElementMap[element...
javascript
{ "resource": "" }
q64441
hideNodeContextMenu
test
function hideNodeContextMenu(event) { // Provide an early out if there is no selected context node. if (typeof selectedContextNode === 'undefined') { return; } var contextMenuButton = $('#context-menu'); var popupmenu = $('#contextpopup .mdl-menu__container'); // If an event is define...
javascript
{ "resource": "" }
q64442
isConnected
test
function isConnected(targetNode, otherNode) { return targetNode.index === otherNode.index || linkedByIndex[targetNode.index + ',' + otherNode.index]; }
javascript
{ "resource": "" }
q64443
onControlDepsClicked
test
function onControlDepsClicked() { // Do nothing if scope has not changed if (this.value === appOptions.currentScope) { return; } // If max depth is set to sticky and current level is equal max level of old scope then set max level for // the new scope. if (appOptions.maxDepthSticky && ...
javascript
{ "resource": "" }
q64444
onControlLevelChanged
test
function onControlLevelChanged() { appOptions.currentLevel = parseInt(this.value); $('.control-level input').val(appOptions.currentLevel); $('.control-level label').html(appOptions.currentLevel); // Redraw graph data updateAll({ redrawOnly: true }); // Center graph w/ zoom fit ...
javascript
{ "resource": "" }
q64445
onControlMenuClicked
test
function onControlMenuClicked() { switch ($(this).data('action')) { case 'toggleFreezeAllNodes': setNodesFixed(!data.allNodesFixed); break; case 'showFullNames': appOptions.showFullNames = !appOptions.showFullNames; updateAll({ redrawOnly...
javascript
{ "resource": "" }
q64446
onControlTableRowContextClick
test
function onControlTableRowContextClick(node, event) { event.preventDefault(); // Prevents default browser context menu from showing. onNodeContextClick(node, { x: event.pageX, y: event.pageY }); }
javascript
{ "resource": "" }
q64447
onControlTableRowMouseOver
test
function onControlTableRowMouseOver(nodes, links, node, enter) { // Hide the node context menu if currently showing when a new table row / node is moused over. if (node !== selectedContextNode) { hideNodeContextMenu(event); } onNodeMouseOverOut(nodes, links, enter, node); }
javascript
{ "resource": "" }
q64448
onControlZoomClicked
test
function onControlZoomClicked() { var newScale = 1; var scalePercentile = 0.20; // Add or subtract scale percentile from current scale value. switch ($(this).data('action')) { case 'zoom_in': newScale = Math.max(Math.min(zoom.scale() * (1 + scalePercentile), maxSca...
javascript
{ "resource": "" }
q64449
onNodeContextMenuClick
test
function onNodeContextMenuClick() { // When a context menu is selected remove node highlighting. hideNodeContextMenu(); console.log('!! action: ' + $(this).data('action') + '; link: ' + $(this).data('link')); switch ($(this).data('action')) { case 'openLink': var link = ...
javascript
{ "resource": "" }
q64450
onNodeContextClick
test
function onNodeContextClick(targetNode, coords) { // Hides any existing node context menu. hideNodeContextMenu(); if (typeof coords !== 'object') { coords = getElementCoords(this); } var popupmenu = $('#contextpopup .mdl-menu__container'); var packageData = targetNode.packageData; ...
javascript
{ "resource": "" }
q64451
onNodeMouseDown
test
function onNodeMouseDown(nodes, links, targetNode) { hideNodeContextMenu(); // Only select / drag nodes with left clicked otherwise stop propagation of event. if (d3.event.button === 0) { selectedDragNode = targetNode; // Select / highlight related nodes or remove attribut...
javascript
{ "resource": "" }
q64452
onNodeMouseOverOut
test
function onNodeMouseOverOut(nodes, links, enter, targetNode) { // If there is an existing selected node then exit early. if (isNodeSelected()) { return; } // Select / highlight related nodes or remove attributes based on enter state. fadeRelatedNodes(targetNode, enter, nodes, links); }
javascript
{ "resource": "" }
q64453
onResize
test
function onResize() { // Update graph parameters. graphWidth = window.innerWidth; graphHeight = window.innerHeight; graph.attr('width', graphWidth).attr('height', graphHeight); layout.size([graphWidth, graphHeight]).resume(); updateMenuUI(); updateTableUIExtent(); ...
javascript
{ "resource": "" }
q64454
onTick
test
function onTick() { nodes.attr('cx', function(node) { return node.x; }) .attr('cy', function(node) { return node.y; }) .attr('transform', function(node) { return 'translate(' + node.x + ',' + node.y + ')'; }); // Pull data from data.nodes array. Provides a curve to the links. links.a...
javascript
{ "resource": "" }
q64455
recycleGraph
test
function recycleGraph() { var childNodes = graph.selectAll('g > *').remove(); if (!Array.isArray(childNodes) && !Array.isArray(childNodes['0'])) { return; } // Get the child nodes group from selection. childNodes = childNodes['0']; for (var cntr = 0; cntr < childNodes.length; cntr++)...
javascript
{ "resource": "" }
q64456
reverseGraphLinks
test
function reverseGraphLinks() { for (var key in dataPackageMap) { var graphData = dataPackageMap[key]; graphData.links.forEach(function(link) { var linkSource = link.source; link.source = link.target; link.target = linkSource; }); ...
javascript
{ "resource": "" }
q64457
updateMenuUI
test
function updateMenuUI() { if (data) { $('.control-menu li[data-action=toggleFreezeAllNodes]').html(data.allNodesFixed ? 'Unfreeze nodes' : 'Freeze nodes'); } appMenuToggleOptions.forEach(function(key) { var icon = appOptions[key] ? 'check_box' : 'check_box_o...
javascript
{ "resource": "" }
q64458
updateTableUI
test
function updateTableUI() { var table = $('.control-table tbody'); table.off('mouseenter', 'tr', onControlTableRowMouseOver); table.off('mouseleave', 'tr', onControlTableRowMouseOver); table.off('contextmenu', 'tr', onControlTableRowContextClick); table.empty(); if (data) ...
javascript
{ "resource": "" }
q64459
updateTableUIExtent
test
function updateTableUIExtent() { var tableDiv = $('.control-table-inner'); var nodeTable = $('#nodeTable'); var tableHeight = nodeTable.height(); var offset = tableDiv.offset(); var maxTableHeight = window.innerHeight - offset.top - 20; tableDiv.css('max-height', maxTableHeight...
javascript
{ "resource": "" }
q64460
zoomFit
test
function zoomFit() { var bounds = graph.node().getBBox(); var parent = graph.node().parentElement; var fullWidth = parent.clientWidth, fullHeight = parent.clientHeight; var width = bounds.width, height = bounds.height; if (width === 0 || height === 0) { return 1; } // nothing to fit ...
javascript
{ "resource": "" }
q64461
getWindowWidth
test
function getWindowWidth() { if (window.innerWidth) { return window.innerWidth; } else if (document.documentElement.clientWidth) { return document.documentElement.clientWidth; } else if (document.body.clientWidth) { return document.body.clientWidth; } else{ return 0; } }
javascript
{ "resource": "" }
q64462
test
function(cssScreen, cssHandheld, mobileMaxWidth) { // Set config values if (typeof(cssScreen) != "undefined") { config.cssScreen = cssScreen; } if (typeof(cssHandheld) != "undefined") { config.cssHandheld = cssHandheld; } if (typeof(mobileMaxWidth) != "undefined") { config.mobil...
javascript
{ "resource": "" }
q64463
do_success
test
function do_success(req, res, msg) { res.writeHead(200, {'Content-Type': ((typeof msg === 'string') ? 'text/plain' : 'application/json')}); msg = (typeof msg === 'string') ? msg : helpers.stringify(msg); res.end(msg); }
javascript
{ "resource": "" }
q64464
do_failure
test
function do_failure(req, res, opts) { opts = opts || {}; var obj = { 'type': opts.type || 'error', 'code': opts.code || 501, 'desc': opts.desc || (''+opts) }; res.writeHead(obj.code, {'Content-Type': 'application/json'}); res.end(helpers.stringify(obj) + '\n'); }
javascript
{ "resource": "" }
q64465
do_create_req
test
function do_create_req(config, routes) { routes = routes || {}; var version = routes.version || {}; if(version && (typeof version === 'object')) { } else { version = {'self':routes.version || config.pkg.version}; } if(!version.api) { version.api = api_config.pkg.version; } routes.version = version; v...
javascript
{ "resource": "" }
q64466
do_create_server
test
function do_create_server(config, do_req) { var http = require('http'); if(config.host) { http.createServer(do_req).listen(config.port, config.host); //console.log("Server running at http://"+config.host+":"+config.port+"/"); } else { http.createServer(do_req).listen(config.port); //console.log("Server runni...
javascript
{ "resource": "" }
q64467
setup_server
test
function setup_server(config, opts) { config._def('port', 3000); var req_handler = do_create_req(config, opts); var server = do_create_server(config, function(req, res) { req_handler(req, res).then(function(obj) { if(obj === api.replySent) { // Silently return since reply has been handler already. retur...
javascript
{ "resource": "" }
q64468
test
function(element, ev, fn){ if(element.addEventListener) element.addEventListener(ev, fn, false); else element.attachEvent("on" + ev, fn); }
javascript
{ "resource": "" }
q64469
Reply
test
function Reply(parent, definition) { var key; for (key in updateMixin) { this[key] = updateMixin[key]; } Reply.super_.apply(this, arguments); }
javascript
{ "resource": "" }
q64470
serveGitFile
test
function serveGitFile(repo, tree, parts, res, next) { //console.log("Serving git file: " + parts); var thisPart = parts.shift(); var isLastPart = parts.length === 0; var entryIndex = -1; for (var i=0; i < tree.entries.length; i++) { if (tree.entries[i].name === thisPart) { entryIndex = i; brea...
javascript
{ "resource": "" }
q64471
processFileList
test
function processFileList(files, base, settings, state) { for (var i = 0; i < files.length; i++) { var modulePath = path.join(base, files[i]); var stats = fs.statSync(modulePath); if (stats.isFile()) { // Try to load the module var module = require(modulePath); ...
javascript
{ "resource": "" }
q64472
packageModule
test
function packageModule(global, name, api) { if (global.define && global.define.amd) { define([], api); } else if (typeof exports !== "undefined") { module.exports = api; } else { global[name] = api; } }
javascript
{ "resource": "" }
q64473
Ebus
test
function Ebus(p) { "use strict"; this.debug = false; this.yields = false; this.handlers = {}; if (p) { this.priorities = p; } else { this.priorities = {}; } }
javascript
{ "resource": "" }
q64474
ApiClient
test
function ApiClient(config) { var self = this this.config = _.extend({}, config, {client:this}) config.headers = _.extend({}, config.headers, { Accept: 'application/json' }) this.auth = config.auth models.sync = require('./sync') models.Model = require('./modelbase') models.NginModel = require('./nginMod...
javascript
{ "resource": "" }
q64475
getFirstIndexOf
test
function getFirstIndexOf(value, array) { error_if_not_primitive_or_array_1.errorIfNotPrimitiveOrArray(value); if (isArray_notArray_1.isArray(value)) { return getFirstIndexOfArray_1.getFirstIndexOfArray(value, array); } else { // if primitive... return getIndexOfPrimitive_1.getIndexOfPrim...
javascript
{ "resource": "" }
q64476
scopeUrl
test
function scopeUrl(options, inst) { options = _.extend({}, inst, options) if (!options.season_id) throw new Error('season_id required to make division instance api calls') return ngin.Season.urlRoot() + '/' + options.season_id + Division.urlRoot() }
javascript
{ "resource": "" }
q64477
Customer
test
function Customer(parent, definition) { var key; for (key in updateMixin) { this[key] = updateMixin[key]; } Customer.super_.apply(this, arguments); }
javascript
{ "resource": "" }
q64478
copy
test
function copy(obj) { return Object.getOwnPropertyNames(obj || {}).reduce((a, c) => { a[c] = obj[c]; return a; }, {}); }
javascript
{ "resource": "" }
q64479
formatWith
test
function formatWith(options) { options = Object.assign({}, DEFAULTS, options); return (message, ...args) => { return _formatter(options, message, ...args); }; }
javascript
{ "resource": "" }
q64480
test
function(sourceDir, destFile, opts) { opts = opts || { archive_path: '/' }; return new Promise(function (resolve, reject) { try { var archive = archiver.create('zip', { zlib: { level: 9 } }); ...
javascript
{ "resource": "" }
q64481
test
function(sourceFile, destDir) { return new Promise(function(resolve, reject) { var zip = new AdmZip(sourceFile); try { zip.extractAllTo(destDir); resolve(destDir); } catch(err) { reject(err); } }); }
javascript
{ "resource": "" }
q64482
test
function(sourceDir, destFile, opts) { opts = opts || { archive_path: '/' }; return new Promise(function(resolve, reject) { // pack var tempFile = destFile + '.tmp.tar'; try { var archive = archiver.create('tar'); var output = fs.createW...
javascript
{ "resource": "" }
q64483
test
function(sourceFile, destDir) { return new Promise(function(resolve, reject) { // expand var tempFile = sourceFile + '.tmp.tar'; try { var data = new Buffer(fs.readFileSync(sourceFile)); var expanded = Bzip2.decompressFile(data); ...
javascript
{ "resource": "" }
q64484
make
test
async function make(dir) { try { await makePromise(mkdir, dir) } catch (err) { if (err.code == 'ENOENT') { const parentDir = dirname(dir) await make(parentDir) await make(dir) } else if (err.code != 'EEXIST') { // created in parallel throw err } } }
javascript
{ "resource": "" }
q64485
fabricator
test
function fabricator(stack, options) { options = options || {}; // // Empty strings, arrays or objects should not be processed, return early. // if (empty(stack)) return []; switch (is(stack)) { case 'string': stack = read(stack, options); break; case 'object': stack = Object.keys(...
javascript
{ "resource": "" }
q64486
read
test
function read(filepath, options) { if ('string' !== is(filepath)) return fabricator(filepath, options); if (options.source) filepath = path.resolve(options.source, filepath); // // Check if the provided string is a JS file or when recursion is not allowed. // if (js(filepath) || options.recursive === false...
javascript
{ "resource": "" }
q64487
iterator
test
function iterator(traverse, obj, options) { return function reduce(stack, entity) { var base = obj ? obj[entity] : entity , name = options.name || entity; // // Fabricated objects should provide each constructor with the name // of its property on the original object. // if (obj) option...
javascript
{ "resource": "" }
q64488
js
test
function js(file) { var type = is(file); return 'function' === type || 'string' === type && path.extname(file) === '.js'; }
javascript
{ "resource": "" }
q64489
empty
test
function empty(value) { if (!value) return true; switch (is(value)) { case "object": return !Object.keys(value).length; case "array": return !value.length; default: return !value; } }
javascript
{ "resource": "" }
q64490
click
test
function click(e) { var op = 'remove'; if (this.className==='menuLink') { op = document.body.classList.contains('menu-open') ? 'remove' : 'add'; e.preventDefault(); } document.body.classList[op]('menu-open'); }
javascript
{ "resource": "" }
q64491
ShellStream
test
function ShellStream(args){ if(this instanceof ShellStream === false){ return new ShellStream(args); } this._command = args; this._events = []; var self = this; // Create holders for events to be added streams.forEach(function(stream){ self[stream] = {on:this.on, _events:[]}...
javascript
{ "resource": "" }
q64492
test
function(name, specs) { this.name = name; this.id = 0; this.properties = specs.properties || []; this.extends = specs.extends || null; this.depends = specs.depends || null; this.factory = specs.factory || "new"; this.init = specs.init || "default"; this.frequent = false; this.keepUsedProperties = false; this....
javascript
{ "resource": "" }
q64493
test
function( o ) { // Don't extend 'depends', extend only 'extends' if (this.extends) { this.embed = o.embed.concat(this.embed); this.properties = o.properties.concat(this.properties); this.postInit = o.postInit + this.postInit; // Replace init & Factory if different if (this.init === "default") this.i...
javascript
{ "resource": "" }
q64494
test
function( instVar, prefix ) { var code = "[", getCode = "", prop="", defaultGet = "$inst.$prop"; if (this.defaultGet) defaultGet = defaultGet; for (var i=0, l=this.properties.length; i<l; ++i) { prop = this.properties[i]; if (i > 0) code += ","; if (this.propCustomGet[prop]) { getCode = this.propCust...
javascript
{ "resource": "" }
q64495
test
function() { var props = this.properties.slice().sort(); return 'init' + crypto.createHash('md5').update(props.join(",")).digest("hex"); }
javascript
{ "resource": "" }
q64496
test
function( instVar, valVar, pageszVar, offsetVar, prefix, indent ) { var code = "", usedProps = {}, defaultAssign = "$inst.$prop = $value", replaceVariableMacro = (function(s,v) { var i = this.properties.indexOf(v); if (i >= 0) { usedProps[v] = true; } else { throw "Macro "+s+" refers to a pro...
javascript
{ "resource": "" }
q64497
bufferMode
test
function bufferMode( contents, options, callback ) { ProfileCompiler( contents.toString('utf-8'), options, function(err, encBuf, decBuf){ if (err) { callback(err); return; } // Callback buffers callback(null, new Buffer(encBuf,'utf8'), new Buffer(decBuf,'utf8') ); }); }
javascript
{ "resource": "" }
q64498
streamMode
test
function streamMode( contents, options, callback ) { toArray(contents, function(err, chunks) { if (err) { callback(err); return; } bufferMode( Buffer.concat(chunks), options, function(err, encBuf, decBuf) { if (err) { callback(err); return; } var encStream = new Readable(); encStream.p...
javascript
{ "resource": "" }
q64499
test
function( err, encContents, decContents ) { // Emmit errors if (err) { var error = new PluginError(PLUGIN_NAME, err, { showStack: true }); self.emit('error', error); done(); return; } // Get base name var dir = path.dirname( originalFile.path ); var name = path.basename( originalF...
javascript
{ "resource": "" }