_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
|---|---|---|---|---|---|
q13600
|
ParseWithConfig
|
train
|
function ParseWithConfig(config, argv)
{
const debug = false;
const parser = dashdash.createParser({ options : config });
const helpText = parser.help({ includeEnv : true }).trimRight();
try
{
const opts = parser.parse(argv, 2);
const innerOptions = parser.options;
const keyValues = {};
/**
* From opts build a key/value object consting ONLY of the options keys and no extra stuff
* Note that dashdash puts a bunch of other stuff in opts.
* AND then wrap the keyValue object in a CliOptions object for returing
*/
innerOptions.forEach((element) =>
{
const k = element.key;
if (debug) debugLog(`loop k: ${k} v: ${opts[k]}`);
const v = (opts.hasOwnProperty(k)) ? opts[k] : undefined;
keyValues[k] = v;
});
/**
* @NOTE - the next two variables are temporary and disappear when the function is complete
* so there is no need to copy them
*/
const cliOptions = CliOptions(keyValues);
const cliArgs = CliArguments(opts._args);
if (debug) debugLog(util.inspect(cliOptions.getOptions()));
return [cliOptions, cliArgs, helpText];
}
catch (e)
{
debugger;
console.log(e.stack);
raiseError(`Command Line Parser found an error: ${e.message}`);
console.error('Command Line Parser found an error: %s', e.message);
process.exit(1);
}
}
|
javascript
|
{
"resource": ""
}
|
q13601
|
hasEscapeFirst
|
train
|
function hasEscapeFirst (data, offset) {
isBuffer = (!isQuiet && typeof data !== 'string')
escaped = (this.prev.idx > 0)
return escaped
? ( escapeOffset = offset - escLength, -1 )
//HACK to bypass the trimLeft/trimRight properties
: ( this.prev.prev.length = leftLength + 1, atok.offset--, 1 )
}
|
javascript
|
{
"resource": ""
}
|
q13602
|
train
|
function (config) {
'use strict';
//If is not instance of SaySomething return a new instance
if (false === (this instanceof SaySomething)) {
return new SaySomething(config);
}
events.EventEmitter.call(this);
this.defaults = {
language: 'en'
};
//Extend default with the config object
_.extend(this.defaults, config);
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q13603
|
executeController
|
train
|
function executeController(server, controller, req, res) {
try {
const promise = controller.call(server, req, res);
if (promise && typeof promise.catch === 'function') {
promise.catch(function(err) {
res.status(500).send(err);
});
}
} catch (err) {
res.send(err);
}
}
|
javascript
|
{
"resource": ""
}
|
q13604
|
findMatchingExample
|
train
|
function findMatchingExample(req, code, type) {
const swagger = req.swagger.root;
const responses = req.swagger.rel.responses;
// if no responses then exit
const responseKeys = responses && typeof responses === 'object' ? Object.keys(responses) : [];
if (responseKeys.length === 0) return { code: 501, type: undefined };
// get first code if not provided
if (arguments.length < 1) code = responseKeys[0];
// validate that responses exist
const responseSchema = responses[code];
if (!responseSchema) return { code: 501, type: undefined };
const examples = responses[code].examples;
const accept = type ?
type :
req.headers.hasOwnProperty('accept')
? req.headers.accept
: Array.isArray(swagger.produces) && swagger.produces.length > 0
? swagger.produces[0]
: examples && Object.keys(examples)[0];
// check if there are examples
const keys = examples ? Object.keys(examples) : [];
const typesLength = keys.length;
if (typesLength === 0) return { code: 501, type: undefined };
// if anything is accepted then return first example
if (accept === '*') return { code: code, type: keys[0] };
// determine what types and subtypes are supported by examples
const types = keys.map(key => {
const ar = key.split('/');
return { type: ar[0] || '*', subtype: ar[1] || '*' };
});
// find all the types that the client accepts
const accepts = accept.split(/,\s*/);
const length = accepts.length;
for (let i = 0; i < length; i++) {
// remove variable from type and separate type and subtype
const item = accepts[i].split(';')[0];
const parts = item.split('/');
const a = {
type: parts[0] || '*',
subtype: parts[1] || '*'
};
// look for a match between types and accepts
for (let j = 0; j < typesLength; j++) {
const t = types[j];
if ((t.type === '*' || a.type === '*' || a.type === t.type) &&
(t.subtype === '*' || a.subtype === '*' || a.subtype === t.subtype)) return { code: code, type: keys[j] };
}
}
return { code: 406, type: undefined };
}
|
javascript
|
{
"resource": ""
}
|
q13605
|
loadController
|
train
|
function loadController(controllersDirectory, controller, development) {
const filePath = path.resolve(controllersDirectory, controller);
try {
return require(filePath);
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND' && e.message.indexOf("Cannot find module '" + filePath + "'") === 0 && development) {
console.error('Cannot find controller: ' + filePath);
return null;
} else {
throw e;
}
}
}
|
javascript
|
{
"resource": ""
}
|
q13606
|
full_uri_encode
|
train
|
function full_uri_encode(string) {
string = encodeURIComponent(string);
string = string.replace(/\./g, '%2E');
return(string);
}
|
javascript
|
{
"resource": ""
}
|
q13607
|
train
|
function(err, privkey, pubkey) {
if (err) throw err;
this.pubkey = pubkey;
this.privkey = privkey;
this.user_host_field = pubkey.split(' ')[2].trim();
console.log("Adding Heroku SSH keypair via API");
add_ssh_key(api_key, pubkey, this);
}
|
javascript
|
{
"resource": ""
}
|
|
q13608
|
train
|
function(err, r, b) {
if (err) throw err;
try {
fs.unlink(keyname, this.parallel());
fs.unlink(keyname + ".pub", this.parallel());
} catch(e) {
// do nothing
};
console.log("Heroku SSH keypair deleted from local FS");
callback(err, this.privkey, this.pubkey, this.user_host_field);
}
|
javascript
|
{
"resource": ""
}
|
|
q13609
|
preparePackage
|
train
|
function preparePackage() {
var ignoreFiles = ['package.json', 'README.md', 'LICENSE.md', '.gitignore', '.npmignore'];
var ignoreCopyFiles = [];
var copyRecursiveSync = function(src, dest) {
var exists = fs.existsSync(src);
var stats = exists && fs.statSync(src);
var isDirectory = exists && stats.isDirectory();
if (exists && isDirectory) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
fs.readdirSync(src).forEach(function(filename) {
copyRecursiveSync(upath.join(src, filename),
upath.join(dest, filename));
});
} else {
if (ignoreCopyFiles.indexOf(upath.basename(src)) === -1) {
fs.linkSync(src, dest);
}
}
};
var srcPkg = upath.join(process.cwd(), 'src');
if (fs.existsSync(srcPkg)) {
fs.readdirSync(process.cwd()).forEach(function(filename) {
var curPath = upath.join(process.cwd(), filename);
if (ignoreFiles.indexOf(upath.basename(curPath)) === -1 && fs.statSync(curPath).isFile()) {
fs.unlinkSync(curPath);
}
});
copyRecursiveSync(srcPkg, process.cwd());
}
deleteFolderRecursive(srcPkg);
deleteFolderRecursive(upath.join(process.cwd(), 'test'));
deleteFolderRecursive(upath.join(process.cwd(), 'env'));
}
|
javascript
|
{
"resource": ""
}
|
q13610
|
describe
|
train
|
function describe( object ) {
return Object.getOwnPropertyNames( object )
.reduce( function( desc, key ) {
desc[ key ] = Object.getOwnPropertyDescriptor( object, key )
return desc
}, Object.create( null ))
}
|
javascript
|
{
"resource": ""
}
|
q13611
|
inherit
|
train
|
function inherit( ctor, sctor ) {
ctor.prototype = Object.create(
sctor.prototype,
describe( ctor.prototype )
)
}
|
javascript
|
{
"resource": ""
}
|
q13612
|
CommandAsker
|
train
|
function CommandAsker(questions, options) {
options = options || {};
if (!_.isArray(questions)) {
throw "there are no questions available :'(";
}
this.questions = questions;
this.response = {};
this.cli = readline.createInterface({
input: process.stdin,
output: process.stdout
});
this.askCallback = null;
this.errorMsg = options.errorMsg || clc.xterm(160);
this.currentQuestion = 0;
}
|
javascript
|
{
"resource": ""
}
|
q13613
|
train
|
function( editor ) {
// Backward compatibility.
if ( editor instanceof CKEDITOR.dom.document )
return applyStyleOnSelection.call( this, editor.getSelection() );
if ( this.checkApplicable( editor.elementPath(), editor ) ) {
var initialEnterMode = this._.enterMode;
// See comment in removeStyle.
if ( !initialEnterMode )
this._.enterMode = editor.activeEnterMode;
applyStyleOnSelection.call( this, editor.getSelection(), 0, editor );
this._.enterMode = initialEnterMode;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q13614
|
train
|
function( elementPath, editor, filter ) {
// Backward compatibility.
if ( editor && editor instanceof CKEDITOR.filter )
filter = editor;
if ( filter && !filter.check( this ) )
return false;
switch ( this.type ) {
case CKEDITOR.STYLE_OBJECT:
return !!elementPath.contains( this.element );
case CKEDITOR.STYLE_BLOCK:
return !!elementPath.blockLimit.getDtd()[ this.element ];
}
return true;
}
|
javascript
|
{
"resource": ""
}
|
|
q13615
|
train
|
function( element, fullMatch ) {
var def = this._.definition;
if ( !element || !def.ignoreReadonly && element.isReadOnly() )
return false;
var attribs,
name = element.getName();
// If the element name is the same as the style name.
if ( typeof this.element == 'string' ? name == this.element : name in this.element ) {
// If no attributes are defined in the element.
if ( !fullMatch && !element.hasAttributes() )
return true;
attribs = getAttributesForComparison( def );
if ( attribs._length ) {
for ( var attName in attribs ) {
if ( attName == '_length' )
continue;
var elementAttr = element.getAttribute( attName ) || '';
// Special treatment for 'style' attribute is required.
if ( attName == 'style' ? compareCssText( attribs[ attName ], elementAttr ) : attribs[ attName ] == elementAttr ) {
if ( !fullMatch )
return true;
} else if ( fullMatch ) {
return false;
}
}
if ( fullMatch )
return true;
} else {
return true;
}
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
|
q13616
|
checkIfNodeCanBeChildOfStyle
|
train
|
function checkIfNodeCanBeChildOfStyle( def, currentNode, lastNode, nodeName, dtd, nodeIsNoStyle, nodeIsReadonly, includeReadonly ) {
// Style can be applied to text node.
if ( !nodeName )
return 1;
// Style definitely cannot be applied if DTD or data-nostyle do not allow.
if ( !dtd[ nodeName ] || nodeIsNoStyle )
return 0;
// Non-editable element cannot be styled is we shouldn't include readonly elements.
if ( nodeIsReadonly && !includeReadonly )
return 0;
// Check that we haven't passed lastNode yet and that style's childRule allows this style on current element.
return checkPositionAndRule( currentNode, lastNode, def, posPrecedingIdenticalContained );
}
|
javascript
|
{
"resource": ""
}
|
q13617
|
checkIfStyleCanBeChildOf
|
train
|
function checkIfStyleCanBeChildOf( def, currentParent, elementName, isUnknownElement ) {
return currentParent &&
( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement ) &&
( !def.parentRule || def.parentRule( currentParent ) );
}
|
javascript
|
{
"resource": ""
}
|
q13618
|
checkPositionAndRule
|
train
|
function checkPositionAndRule( nodeA, nodeB, def, posBitFlags ) {
return ( nodeA.getPosition( nodeB ) | posBitFlags ) == posBitFlags &&
( !def.childRule || def.childRule( nodeA ) );
}
|
javascript
|
{
"resource": ""
}
|
q13619
|
applyStyleOnNestedEditables
|
train
|
function applyStyleOnNestedEditables( editablesContainer ) {
var editables = findNestedEditables( editablesContainer ),
editable,
l = editables.length,
i = 0,
range = l && new CKEDITOR.dom.range( editablesContainer.getDocument() );
for ( ; i < l; ++i ) {
editable = editables[ i ];
// Check if style is allowed by this editable's ACF.
if ( checkIfAllowedInEditable( editable, this ) ) {
range.selectNodeContents( editable );
applyInlineStyle.call( this, range );
}
}
}
|
javascript
|
{
"resource": ""
}
|
q13620
|
checkIfAllowedInEditable
|
train
|
function checkIfAllowedInEditable( editable, style ) {
var filter = CKEDITOR.filter.instances[ editable.data( 'cke-filter' ) ];
return filter ? filter.check( style ) : 1;
}
|
javascript
|
{
"resource": ""
}
|
q13621
|
toPre
|
train
|
function toPre( block, newBlock ) {
var bogus = block.getBogus();
bogus && bogus.remove();
// First trim the block content.
var preHtml = block.getHtml();
// 1. Trim head/tail spaces, they're not visible.
preHtml = replace( preHtml, /(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g, '' );
// 2. Delete ANSI whitespaces immediately before and after <BR> because
// they are not visible.
preHtml = preHtml.replace( /[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi, '$1' );
// 3. Compress other ANSI whitespaces since they're only visible as one
// single space previously.
// 4. Convert to spaces since is no longer needed in <PRE>.
preHtml = preHtml.replace( /([ \t\n\r]+| )/g, ' ' );
// 5. Convert any <BR /> to \n. This must not be done earlier because
// the \n would then get compressed.
preHtml = preHtml.replace( /<br\b[^>]*>/gi, '\n' );
// Krugle: IE normalizes innerHTML to <pre>, breaking whitespaces.
if ( CKEDITOR.env.ie ) {
var temp = block.getDocument().createElement( 'div' );
temp.append( newBlock );
newBlock.$.outerHTML = '<pre>' + preHtml + '</pre>';
newBlock.copyAttributes( temp.getFirst() );
newBlock = temp.getFirst().remove();
} else {
newBlock.setHtml( preHtml );
}
return newBlock;
}
|
javascript
|
{
"resource": ""
}
|
q13622
|
getAttributesForComparison
|
train
|
function getAttributesForComparison( styleDefinition ) {
// If we have already computed it, just return it.
var attribs = styleDefinition._AC;
if ( attribs )
return attribs;
attribs = {};
var length = 0;
// Loop through all defined attributes.
var styleAttribs = styleDefinition.attributes;
if ( styleAttribs ) {
for ( var styleAtt in styleAttribs ) {
length++;
attribs[ styleAtt ] = styleAttribs[ styleAtt ];
}
}
// Includes the style definitions.
var styleText = CKEDITOR.style.getStyleText( styleDefinition );
if ( styleText ) {
if ( !attribs.style )
length++;
attribs.style = styleText;
}
// Appends the "length" information to the object.
attribs._length = length;
// Return it, saving it to the next request.
return ( styleDefinition._AC = attribs );
}
|
javascript
|
{
"resource": ""
}
|
q13623
|
train
|
function( callback ) {
if ( !this._.stylesDefinitions ) {
var editor = this,
// Respect the backwards compatible definition entry
configStyleSet = editor.config.stylesCombo_stylesSet || editor.config.stylesSet;
// The false value means that none styles should be loaded.
if ( configStyleSet === false ) {
callback( null );
return;
}
// #5352 Allow to define the styles directly in the config object
if ( configStyleSet instanceof Array ) {
editor._.stylesDefinitions = configStyleSet;
callback( configStyleSet );
return;
}
// Default value is 'default'.
if ( !configStyleSet )
configStyleSet = 'default';
var partsStylesSet = configStyleSet.split( ':' ),
styleSetName = partsStylesSet[ 0 ],
externalPath = partsStylesSet[ 1 ];
CKEDITOR.stylesSet.addExternal( styleSetName, externalPath ? partsStylesSet.slice( 1 ).join( ':' ) : CKEDITOR.getUrl( 'styles.js' ), '' );
CKEDITOR.stylesSet.load( styleSetName, function( stylesSet ) {
editor._.stylesDefinitions = stylesSet[ styleSetName ];
callback( editor._.stylesDefinitions );
} );
} else {
callback( this._.stylesDefinitions );
}
}
|
javascript
|
{
"resource": ""
}
|
|
q13624
|
walk
|
train
|
function walk (directoryPath, filter, collector) {
var defer = Q.defer()
fs.stat(directoryPath, function (err, stat) {
if (err) {
if (err.code === 'ENOENT') {
// Like q-io/fs, return an empty array, if the directory does not exist
return defer.resolve([])
}
return defer.reject(err)
}
// Call filter to get result, "true" if no filter is set
var filterResult = !filter || filter(directoryPath, stat)
if (filterResult) {
collector.push(directoryPath)
}
// false/true => iterate directory
if (stat.isDirectory() && filterResult !== null) {
fs.readdir(directoryPath, function (err, filenames) {
if (err) {
return defer.reject(err)
}
var paths = filenames.map(function (name) {
return path.join(directoryPath, name)
})
// Walk all files/subdirs
Q.all(paths.map(function (filepath) {
return walk(filepath, filter, collector)
}))
.then(function () {
defer.fulfill(collector)
})
})
} else {
// No recursive call with a file
defer.fulfill(collector)
}
})
return defer.promise
}
|
javascript
|
{
"resource": ""
}
|
q13625
|
doesEscapeRoot
|
train
|
function doesEscapeRoot(root,file) {
if (file.indexOf(path.normalize(root+"/")) === 0) return just(file);
else return nothing();
}
|
javascript
|
{
"resource": ""
}
|
q13626
|
httpOk
|
train
|
function httpOk(response,isHead,body) {
response.setHeader(HTTP_CONTENT_TYPE,MIME_TYPE_JAVASCRIPT);
response.setHeader(HTTP_CONTENT_LENGTH,body.length);
response.statusCode = HTTP_OK;
if (isHead) response.end();
else response.end(body);
}
|
javascript
|
{
"resource": ""
}
|
q13627
|
closeConnection
|
train
|
function closeConnection(options) {
//no options, close/delete all connection references
if (!options) {
try {
mssql.close();
} catch(err){}
//create list to track items to close
let closeList = [];
//iterate through each connection
for (let key in promises) {
//if there's a close method (connection match), add it to the list
if (promises[key] && typeof promises[key].close === 'function') closeList.push(promises[key]);
}
//iterate through list and close each connection
closeList.forEach((item)=>item.close());
}
//either a connection promise, or a connection
if (options._mssqlngKey && typeof options.close === 'function') return options.close();
//match against connection options
let key = stringify(options || {});
if (connections[key]) connections[key].close();
if (promises[key]) promises[key].then((conn)=>conn.close()).catch(()=>{ delete promises[key]; delete connections[key] });
}
|
javascript
|
{
"resource": ""
}
|
q13628
|
train
|
function (_data, cb) {
if(!db.data) return cb(new Error('kiddb not open'))
if(!writing) return db._update(_data, cb)
db.__data = _data
qcb.push(cb)
onWrote = function () {
onWrote = null
var cbs = qcb; qcb = []
var _data = db.__data
db.__data = null
db.update(_data, function (err) {
cbs.forEach(function (cb) {
cb(err)
})
})
}
}
|
javascript
|
{
"resource": ""
}
|
|
q13629
|
train
|
function (key, cb) {
if(!db.data) return cb(new Error('kiddb not open'))
if(db.data[key]) cb(null, db.data[key])
else cb(new Error('not found'))
}
|
javascript
|
{
"resource": ""
}
|
|
q13630
|
downloadArchive
|
train
|
function downloadArchive(id, call, options, done)
{
grunt.log.write('Downloading '.gray + id.yellow + ' ... '.gray);
request(call, function(err, response, body)
{
if (err) return done(err);
var result = JSON.parse(body);
if (!result.success)
{
return done(result.error + ' with game "' + id + '"');
}
if (options.json)
{
grunt.log.write('Writing json ... '.gray);
var writeStream = fs.createWriteStream(path.join(options.dest, id + '.json'));
writeStream.write(JSON.stringify(result.data, null, options.debug ? "\t":""));
writeStream.end();
}
grunt.log.write('Installing ... '.gray);
this.get(result.data.url).run(function(err, files)
{
if (err)
{
return done('Unable to download archive for game "' + id + '"');
}
grunt.log.writeln('Done.'.green);
done(null, files);
});
}
.bind(this));
}
|
javascript
|
{
"resource": ""
}
|
q13631
|
train
|
function(dest, src) {
if(src.indexOf('.js') > -1) {
return dest + src.replace('.js','.' + tsPrefix + newTS + '.js');
}
else {
return dest + src.replace('.css','.' + tsPrefix + newTS + '.css');
}
}
|
javascript
|
{
"resource": ""
}
|
|
q13632
|
isEscapeingAt
|
train
|
function isEscapeingAt(string, index) {
if (index === 0) { return false; }
let i = index - 1;
while (
i >= 0 && string[i] === '\\'
) { --i; }
return (index - i) % 2 === 0;
}
|
javascript
|
{
"resource": ""
}
|
q13633
|
parse
|
train
|
function parse (defaultValue, data) {
try {
return JSON.parse(data)
} catch (error) {
if (defaultValue === null || defaultValue === undefined) {
throw error
} else {
return defaultValue
}
}
}
|
javascript
|
{
"resource": ""
}
|
q13634
|
load
|
train
|
function load(fromPath, relativePaths, opts) {
opts = opts || {};
var ignores = opts.ignores || [];
if (typeof ignores === 'string') ignores = [ignores];
var conf = {};
relativePaths.forEach(function(relativePath) {
var path = Path.resolve(fromPath, relativePath);
var config = loadFile(path, ignores);
extend(conf, config);
});
if (conf.get === undefined) {
bindGetMethod(conf);
} else {
throw new Error('`get` property cannot be the root key of config');
}
return conf;
}
|
javascript
|
{
"resource": ""
}
|
q13635
|
create
|
train
|
function create() {
var args = Array.prototype.slice.call(arguments);
var conf = {};
args.forEach(function(config) {
extend(conf, config);
});
if (conf.get === undefined) {
bindGetMethod(conf);
} else {
throw new Error('`get` property cannot be the root key of config');
}
return conf;
}
|
javascript
|
{
"resource": ""
}
|
q13636
|
SettingsFile
|
train
|
function SettingsFile(app, options) {
if (!app) {
throw new TypeError('SettingsFile must accept an app name');
}
else if (typeof app !== 'string') {
throw new TypeError('SettingsFile app name must be a string');
}
debug('initialize new settings file for app: %s', app);
this._app = app;
this._path = nachosHome('data', app + '.json');
debug('resolved path is %s', this._path);
this._options = defaults(options, {
globalDefaults: {},
instanceDefaults: {}
});
}
|
javascript
|
{
"resource": ""
}
|
q13637
|
train
|
function (content) {
var fileContent = self._readFileSync();
fileContent.instances = fileContent.instances || {};
fileContent.instances[this._id] = content;
self._writeFileSync(fileContent);
}
|
javascript
|
{
"resource": ""
}
|
|
q13638
|
train
|
function(id, params) {
return req.standardRequest(`${config.host}/teams/${id}/teams?${req.assembleQueryParams(params,
['page'])}`);
}
|
javascript
|
{
"resource": ""
}
|
|
q13639
|
train
|
function(id, projectId, body) {
return req.standardRequest(`${config.host}/teams/${id}/projects/${projectId}`, 'put', body);
}
|
javascript
|
{
"resource": ""
}
|
|
q13640
|
createStream
|
train
|
function createStream (options) {
options = options || {}
var stream = through2.obj(function transform (chunk, encoding, cb) {
stream.push(options.objectMode ? chunk : JSON.stringify(chunk)+'\n')
cb()
})
stream.close = function close () {
setImmediate(function () {
stream.push(null)
changes.unpipe(stream)
})
numStreams--
}
changes.pipe(stream)
numStreams++
return stream
}
|
javascript
|
{
"resource": ""
}
|
q13641
|
feed
|
train
|
function feed(op, pnode) {
if (numStreams > 0) {
changes.push({op:op, pnode:pnode.toJSON()})
}
}
|
javascript
|
{
"resource": ""
}
|
q13642
|
setPnodeData
|
train
|
function setPnodeData (pnode, value) {
if (!pnode.exists) {
pnode._data = value
persistPnode(pnode)
}
else if (pnode._data !== value) {
pnode._data = value
incTransaction()
incPnodeVersion(pnode)
feed('change', pnode)
}
return pnode
}
|
javascript
|
{
"resource": ""
}
|
q13643
|
unsetPnodeData
|
train
|
function unsetPnodeData (pnode) {
if (pnode.hasOwnProperty('_data') && pnode._data !== undefined) {
pnode._data = undefined
incTransaction()
incPnodeVersion(pnode)
feed('change', pnode)
}
return pnode
}
|
javascript
|
{
"resource": ""
}
|
q13644
|
incPnodeVersion
|
train
|
function incPnodeVersion (pnode) {
pnode._version = pnode._version ? pnode._version + 1 : 1
pnode._mtxid = ptree.txid
pnode._mtime = new Date
if (!pnode._ctxid) pnode._ctxid = pnode._mtxid
if (!pnode._ctime) pnode._ctime = pnode._mtime
return pnode
}
|
javascript
|
{
"resource": ""
}
|
q13645
|
incChildrenVersion
|
train
|
function incChildrenVersion (pnode) {
if (pnode && pnode._childrenVersion) pnode._childrenVersion++
else pnode._childrenVersion = 1
return pnode
}
|
javascript
|
{
"resource": ""
}
|
q13646
|
addChild
|
train
|
function addChild(parent, child) {
parent._children.push(child)
incChildrenVersion(parent)
return parent
}
|
javascript
|
{
"resource": ""
}
|
q13647
|
removeChild
|
train
|
function removeChild(parent, child) {
var parentChildIdx = parent._children.indexOf(child)
parent._children.splice(parentChildIdx, 1)
incChildrenVersion(parent)
return parent
}
|
javascript
|
{
"resource": ""
}
|
q13648
|
pnodeParents
|
train
|
function pnodeParents (pnode) {
if (!pnode.valid) return undefined
var parentPaths = parents(pnode.path),
list = []
for (var i = 0; i < parentPaths.length; i++) list.push( ptree(parentPaths[i]) )
return list
}
|
javascript
|
{
"resource": ""
}
|
q13649
|
pnodeParent
|
train
|
function pnodeParent (pnode) {
if (!pnode.valid) return undefined
var parentPath = parents.immediate(pnode.path)
return parentPath ? ptree(parentPath) : null
}
|
javascript
|
{
"resource": ""
}
|
q13650
|
parameters
|
train
|
function parameters (spec) {
var defs = {}
var envs = {}
return function (params) {
init(spec, defs, envs)
var opts = cat(defs, envs, params)
var errs = []
def(opts, spec, errs)
req(opts, spec, errs)
val(opts, spec, errs)
return {
error: errs.length ? errs[0] : null,
errors: errs,
params: opts
}
}
}
|
javascript
|
{
"resource": ""
}
|
q13651
|
init
|
train
|
function init (spec, defs, envs) {
for (var key in spec || {}) {
if (spec[key].def) defs[key] = spec[key].def
if (has(spec[key].env)) envs[key] = get(spec[key].env)
}
}
|
javascript
|
{
"resource": ""
}
|
q13652
|
def
|
train
|
function def (params, spec, errs) {
for (var key in params) {
if (!spec.hasOwnProperty(key)) defError(key, errs)
}
}
|
javascript
|
{
"resource": ""
}
|
q13653
|
req
|
train
|
function req (params, spec, errs) {
for (var key in spec) {
if (spec[key].req && !params.hasOwnProperty(key)) reqError(key, errs)
}
}
|
javascript
|
{
"resource": ""
}
|
q13654
|
val
|
train
|
function val (params, spec, errs) {
for (var key in params) {
if (key in spec && isFunction(spec[key].val) && !spec[key].val(params[key])) valError(key, errs)
}
}
|
javascript
|
{
"resource": ""
}
|
q13655
|
header
|
train
|
function header(length) {
var res = [0x09, 0x09, 0x00, 0x00];
res.push((length & 0x000000FF) >> 0);
res.push((length & 0x0000FF00) >> 8);
res.push((length & 0x00FF0000) >> 16);
res.push((length & 0xFF000000) >> 24);
return new Buffer(res);
}
|
javascript
|
{
"resource": ""
}
|
q13656
|
train
|
function (emit) {
ipc.send({
cmd : 'setup',
emit: emit,
daemon: process.pid,
message: errorBuffer === "" ? null : errorBuffer
});
}
|
javascript
|
{
"resource": ""
}
|
|
q13657
|
resolveObjectName
|
train
|
function resolveObjectName(view){
return cache[view] || (cache[view] = view
.split('/')
.slice(-1)[0]
.split('.')[0]
.replace(/^_/, '')
.replace(/[^a-zA-Z0-9 ]+/g, ' ')
.split(/ +/).map(function(word, i){
return i ? word[0].toUpperCase() + word.substr(1) : word;
}).join(''));
}
|
javascript
|
{
"resource": ""
}
|
q13658
|
block
|
train
|
function block(name, html) {
// bound to the blocks object in renderFile
var blk = this[name];
if (!blk) {
// always create, so if we request a
// non-existent block we'll get a new one
blk = this[name] = new Block();
}
if (html) {
blk.append(html);
}
return blk;
}
|
javascript
|
{
"resource": ""
}
|
q13659
|
script
|
train
|
function script(path, type) {
if (path) {
var html = '<script src="'+path+'"'+(type ? 'type="'+type+'"' : '')+'></script>';
if (this.html.indexOf(html) == -1) this.append(html);
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
q13660
|
stylesheet
|
train
|
function stylesheet(path, media) {
if (path) {
var html = '<link rel="stylesheet" href="'+path+'"'+(media ? 'media="'+media+'"' : '')+' />';
if (this.html.indexOf(html) == -1) this.append(html);
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
q13661
|
insertAds
|
train
|
function insertAds(adUnit, ads, adLoadedCallback) {
var adContainers = page.getAdContainers(adUnit);
if (!adContainers.length) {
logger.error("No ad containers could be found. stopping insertion for adUnit " + adUnit.name);
return []; //Ad can't be inserted
}
var adBuilder = new AdBuilder(ads);
var beforeElement;
var insertedAdElements = [];
for (var i = 0; i < adContainers.length; i++) {
var adContainer = adContainers[i];
while ((beforeElement = adContainer.getNextElement()) !== null) {
var adToInsert = adBuilder.createAdUnit(adUnit, adContainer.containerElement);
if (adToInsert === null) {
//we ran out of ads.
break;
}
insertedAdElements.push(adToInsert);
beforeElement.parentNode.insertBefore(adToInsert, beforeElement.nextSibling);
// var elementDisplay = adToInsert.style.display || "block";
//TODO: Why are we defaulting to block here?
// adToInsert.style.display = elementDisplay;
handleImageLoad(adToInsert, adLoadedCallback);
}
}
return insertedAdElements;
}
|
javascript
|
{
"resource": ""
}
|
q13662
|
handleImageLoad
|
train
|
function handleImageLoad(adElement, adLoadedCallback) {
var adImage = adElement.querySelector("img");
if (adImage) {
(function (adToInsert, adImage) {
adImage.onload = function () {
adLoadedCallback(adToInsert, true);
};
})(adElement, adImage);
} else {
adLoadedCallback(adElement, false);
}
}
|
javascript
|
{
"resource": ""
}
|
q13663
|
train
|
function (powder) {
var callback = function (err) {
shooting--;
if (err) {
// Only emit error if a listener exists
// This is mainly to prevent silent errors in promises
if (machinegun.listenerCount('error')) machinegun.emit('error', err);
if (opt.giveUpOnError) machinegun.giveUp(err);
}
trigger();
};
var primer = function () {
var maybeThenable = powder(callback);
if (maybeThenable && (typeof maybeThenable.then == 'function')) {
maybeThenable.then(callback.bind(null, null), function (err) { callback(err || new Error()); });
}
};
this.shoot = function () {
shooting++;
process.nextTick(primer);
};
}
|
javascript
|
{
"resource": ""
}
|
|
q13664
|
callPromise
|
train
|
function callPromise(fn, args) {
return new Promise((resolve, reject) => {
// promisified callback
function callback(err,other) {
// check if the 'err' is boolean, if so then this is a 'exists' callback special case
if (err && (typeof err !== 'boolean')) return reject(err);
// convert arguments to proper array, ignoring error argument
let args = Array.prototype.slice.call(arguments, 1);
// if arguments length is one or more resolve arguments as array,
// otherwise resolve the argument as is.
return resolve(args.length < 2 ? args[0] : args);
}
fn.apply(null, args.concat([callback]));
});
}
|
javascript
|
{
"resource": ""
}
|
q13665
|
makePromise
|
train
|
function makePromise(fn) {
return function() {
var args = Array.prototype.slice.call(arguments);
if (hasCallback(args)) {
// argument list has callback, so call method with callback
return callCallback(fn, args);
} else {
// no callback, call method with promises
return callPromise(fn, args);
}
}
}
|
javascript
|
{
"resource": ""
}
|
q13666
|
standardizeAddress
|
train
|
function standardizeAddress(address, callback) {
var url = address_url + encodeURIComponent(address) + '?format=json';
request(url, function(err, resp, body) {
var error = resp.statusCode != 200 ? new Error('Unable to standardize address') : err;
callback(error, body);
});
}
|
javascript
|
{
"resource": ""
}
|
q13667
|
getAddressDetails
|
train
|
function getAddressDetails(body, callback) {
var addresses = JSON.parse(body).addresses
if(addresses.length == 0) {
callback(new Error('No property information for that address'), null);
}
else {
var url = property_url + encodeURIComponent(addresses[0].standardizedAddress);
request(url, function(err, resp, body) {
callback(err, body);
});
}
}
|
javascript
|
{
"resource": ""
}
|
q13668
|
isValidPackageName
|
train
|
function isValidPackageName(name) {
const stats = validateName(name);
return stats.validForNewPackages === true
&& stats.validForOldPackages === true;
}
|
javascript
|
{
"resource": ""
}
|
q13669
|
isValidPlatform
|
train
|
function isValidPlatform() {
if (appSettings.overrides && appSettings.overrides.platform) {
return true; //If a platform override is set, it's always valid
}
return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
}
|
javascript
|
{
"resource": ""
}
|
q13670
|
detectFormFactor
|
train
|
function detectFormFactor() {
var viewPortWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var displaySettings = appSettings.displaySettings; //convenience variable
var formFactor;
if (viewPortWidth >= displaySettings.mobile.minWidth && viewPortWidth <= displaySettings.mobile.maxWidth) {
formFactor = DeviceEnumerations.formFactor.smartPhone;
} else if (viewPortWidth >= displaySettings.tablet.minWidth && viewPortWidth <= displaySettings.tablet.maxWidth) {
formFactor = DeviceEnumerations.formFactor.tablet;
} else {
formFactor = DeviceEnumerations.formFactor.desktop;
}
return formFactor;
}
|
javascript
|
{
"resource": ""
}
|
q13671
|
train
|
function () {
var pkgJson = grunt.file.readJSON("package.json");
if (pkgJson.jspm && pkgJson.jspm.directories && pkgJson.jspm.directories.baseURL) {
return pkgJson.jspm.directories.baseURL;
}
return "";
}
|
javascript
|
{
"resource": ""
}
|
|
q13672
|
train
|
function(treeRoot) {
var stat = fs.statSync(treeRoot);
if (stat.isDirectory()) {
return buildTree(treeRoot);
} else {
throw new Error("path: " + treeRoot + " is not a directory");
}
}
|
javascript
|
{
"resource": ""
}
|
|
q13673
|
train
|
function(tree, options) {
if (!options) {
options = {
ext: '.css',
importFormat: null, // to be initialized just bellow
encoding: 'utf-8'
};
}
if (!options.ext) {
options.ext = '.css';
}
if (!options.importFormat) {
if (options.ext === '.css') {
options.importFormat = function(path) {
return '@import "' + path + '";';
};
} else if (options.ext === '.less') {
options.importFormat = function(path) {
return '@import (less) "' + path + '";';
};
}
}
if (!options.encoding) {
options.encoding = 'utf-8';
}
generate(tree, null, options);
}
|
javascript
|
{
"resource": ""
}
|
|
q13674
|
validateBemDecl
|
train
|
function validateBemDecl(bemDecl, fileName) {
let errors = [];
bemDecl.forEach((decl) => {
errors = errors.concat(validateBemDeclItem(decl, fileName));
});
return errors;
}
|
javascript
|
{
"resource": ""
}
|
q13675
|
validateBemDeclItem
|
train
|
function validateBemDeclItem(decl, fileName) {
let errors = [];
Object.keys(decl).forEach((key) => {
const val = decl[key];
if (val === '[object Object]') {
errors.push(new Error('Error in BemJson ' + fileName +
' produced wrong BemDecl ' + JSON.stringify(decl, null, 2)));
}
});
return errors;
}
|
javascript
|
{
"resource": ""
}
|
q13676
|
_getToken
|
train
|
function _getToken( /*klass, klass1, klass2*/ ) {
if ( !tokens ) {
throw new Error( 'no tokens found' );
}
var _args = [ ].slice.call( arguments ).join( ' ' ).split( ' ' );
var _result = _args.map( function ( klass ) {
var token = tokens[ klass ];
if ( !token ) {
throw new Error( 'no token found for ' + klass );
}
return token;
} ).join( ' ' );
return _result;
}
|
javascript
|
{
"resource": ""
}
|
q13677
|
handleBuffer
|
train
|
function handleBuffer (file, encoding, cb) {
const config = configParser(String(file.contents));
holograph.holograph(config);
return cb(null, file);
}
|
javascript
|
{
"resource": ""
}
|
q13678
|
handleStream
|
train
|
function handleStream (file, encoding, cb) {
let config = '';
file.contents.on('data', chunk => {
config += chunk;
});
file.contents.on('end', () => {
config = configParser(config);
holograph.holograph(config);
return cb(null, file);
});
}
|
javascript
|
{
"resource": ""
}
|
q13679
|
gulpHolograph
|
train
|
function gulpHolograph () {
return through.obj(function (file, encoding, cb) {
// Handle any non-supported types.
// This covers directories and symlinks as well, as they have to be null.
if (file.isNull()) {
this.emit('error', new PluginError(PLUGIN_NAME, 'No file contents.'));
}
// Handle buffers.
if (file.isBuffer()) {
handleBuffer(file, encoding, cb);
}
// Handle streams.
if (file.isStream()) {
handleStream(file, encoding, cb);
}
});
}
|
javascript
|
{
"resource": ""
}
|
q13680
|
JModelError
|
train
|
function JModelError(obj) {
this.message = obj['message'];
this.propertyName = obj['propertyName'];
Error.call(this);
Error.captureStackTrace(this, this.constructor);
}
|
javascript
|
{
"resource": ""
}
|
q13681
|
normalize
|
train
|
function normalize(filepath) {
// resolve to an absolute ppath
if (!path.isAbsolute || !path.isAbsolute(filepath))
filepath = path.resolve(path.dirname(module.parent.filename), filepath);
// tack .json on the end if need be
if (!/\.json$/.test(filepath))
filepath = filepath + '.json';
return filepath;
}
|
javascript
|
{
"resource": ""
}
|
q13682
|
parse
|
train
|
function parse(contents, retained, parser) {
var errors = [], data = [], lines = 0;
// optional parser
if (!parser) parser = JSON;
// process each line of the file
contents.toString().split('\n').forEach(function(line) {
if (!line) return;
lines++;
try {
data.push(parser.parse(line));
} catch (e) {
e.line = line;
errors.push(e);
}
});
// if no errors/data, don't return an empty array
var ret = {};
if (errors.length) ret.errors = errors;
if (data.length) ret.data = data;
// if every line failed, probably not line-delimited
if (errors.length == lines) ret.errors = retained;
return ret;
}
|
javascript
|
{
"resource": ""
}
|
q13683
|
createTranspiler
|
train
|
function createTranspiler ({ mappers = {}, initialScopeData } = {}) {
const config = {
scope: createScope(initialScopeData),
mappers
};
return (config.decoratedTranspile = transpile.bind(null, config));
}
|
javascript
|
{
"resource": ""
}
|
q13684
|
MatchPath
|
train
|
function MatchPath() {
var defaultAction = 'welcome',
defaultMethod = 'index';
/**
* Resolve uri
* @param request
* @returns {*}
*/
this.resolve = function (request) {
var action = defaultAction;
var method = defaultMethod;
if ('/' != request.url) {
var uriComponents = request.url.split('?')[0].substr(1).split('/');
if (uriComponents.length > 1) {
method = uriComponents.pop();
action = uriComponents.join('/');
} else if (uriComponents.length == 1) {
action = uriComponents[0];
}
}
return {
action: action,
method: method,
arguments: []
};
};
/**
* Set default action
* @param action
* @returns {MatchPath}
*/
this.setDefaultAction = function (action) {
defaultAction = action;
return this;
};
/**
* Set default method
* @param method
* @returns {MatchPath}
*/
this.setDefaultMethod = function (method) {
defaultMethod = method;
return this;
};
return this;
}
|
javascript
|
{
"resource": ""
}
|
q13685
|
resolveTemplateFiles
|
train
|
function resolveTemplateFiles(name) {
// Create paths for resolving
var customFile = customDir + '/' + name + '.js',
customTemplateDir = customDir + '/' + name + '/**/*',
stdFile = stdDir + '/' + name + '.js',
stdTemplateDir = stdDir + '/' + name + '/**/*';
// Grab any and all files
var customFiles = expandFiles(customFile).concat(expandFiles(customTemplateDir)),
stdFiles = expandFiles(stdFile).concat(expandFiles(stdTemplateDir));
// Generate a hash of files
var fileMap = {};
// Iterate over the customFiles
customFiles.forEach(function (file) {
// Extract the relative path of the file
var relPath = path.relative(customDir, file);
// Save the relative path
fileMap[relPath] = file;
});
// Iterate over the stdFiles
stdFiles.forEach(function (file) {
// Extract the relative path of the file
var relPath = path.relative(stdDir, file),
overrideExists = fileMap[relPath];
// If it does not exist, save it
if (!overrideExists) {
fileMap[relPath] = file;
}
});
// Return the fileMap
return fileMap;
}
|
javascript
|
{
"resource": ""
}
|
q13686
|
rotate
|
train
|
function rotate(angle, cx, cy) {
var cosAngle = cos(angle);
var sinAngle = sin(angle);
var rotationMatrix = {
a: cosAngle, c: -sinAngle, e: 0,
b: sinAngle, d: cosAngle, f: 0
};
if ((0, _utils.isUndefined)(cx) || (0, _utils.isUndefined)(cy)) {
return rotationMatrix;
}
return (0, _transform.transform)([(0, _translate.translate)(cx, cy), rotationMatrix, (0, _translate.translate)(-cx, -cy)]);
}
|
javascript
|
{
"resource": ""
}
|
q13687
|
rotateDEG
|
train
|
function rotateDEG(angle) {
var cx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
var cy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
return rotate(angle * PI / 180, cx, cy);
}
|
javascript
|
{
"resource": ""
}
|
q13688
|
reload
|
train
|
function reload(args) {
if (args !== undefined) {
if (args.l !== undefined) {
fs.closeSync(1);
fs.openSync(args.l, 'a+');
}
if (args.e !== undefined) {
fs.closeSync(2);
fs.openSync(args.e, 'a+');
}
}
}
|
javascript
|
{
"resource": ""
}
|
q13689
|
setupHandlers
|
train
|
function setupHandlers() {
function terminate(err) {
util.log('Uncaught Error: ' + err.message);
console.log(err.stack);
if (proc.shutdownHook) {
proc.shutdownHook(err, gracefulShutdown);
}
}
process.on('uncaughtException', terminate);
process.addListener('SIGINT', gracefulShutdown);
process.addListener('SIGHUP', function () {
util.log('RECIEVED SIGHUP signal, reloading log files...');
reload(argv);
});
}
|
javascript
|
{
"resource": ""
}
|
q13690
|
enableCommand
|
train
|
function enableCommand(consoleService, moduleId, msg, cb) {
if (!moduleId) {
logger.error(`fail to enable admin module for ${moduleId}`);
cb('empty moduleId');
return;
}
const modules = consoleService.modules;
if (!modules[moduleId]) {
cb(null, protocol.PRO_FAIL);
return;
}
if (consoleService.master) {
consoleService.enable(moduleId);
consoleService.agent.notifyCommand('enable', moduleId, msg);
cb(null, protocol.PRO_OK);
} else {
consoleService.enable(moduleId);
cb(null, protocol.PRO_OK);
}
}
|
javascript
|
{
"resource": ""
}
|
q13691
|
registerRecord
|
train
|
function registerRecord(service, moduleId, module) {
const record = {
moduleId: moduleId,
module: module,
enable: false
};
if (module.type && module.interval) {
if (!service.master && record.module.type === 'push' || service.master && record.module.type !== 'push') {// eslint-disable-line
// push for monitor or pull for master(default)
record.delay = module.delay || 0;
record.interval = module.interval || 1;
// normalize the arguments
if (record.delay < 0) {
record.delay = 0;
}
if (record.interval < 0) {
record.interval = 1;
}
record.interval = Math.ceil(record.interval);
record.delay *= MS_OF_SECOND;
record.interval *= MS_OF_SECOND;
record.schedule = true;
}
}
return record;
}
|
javascript
|
{
"resource": ""
}
|
q13692
|
addToSchedule
|
train
|
function addToSchedule(service, record) {
if (record && record.schedule) {
record.jobId = schedule.scheduleJob({
start: Date.now() + record.delay,
period: record.interval
},
doScheduleJob, {
service: service,
record: record
});
}
}
|
javascript
|
{
"resource": ""
}
|
q13693
|
exportEvent
|
train
|
function exportEvent(outer, inner, event) {
inner.on(event, (...args) => {
args.unshift(event);
outer.emit(...args);
});
}
|
javascript
|
{
"resource": ""
}
|
q13694
|
add_group
|
train
|
function add_group() {
server.EntryGroupNew(function(err, path) {
if (err) {
sails.log.error('DBus: Could not call org.freedesktop.Avahi.Server.EntryGroupNew');
return;
}
service.getInterface(
path,
avahi.DBUS_INTERFACE_ENTRY_GROUP.value,
function (
err,
newGroup
) {
group = newGroup;
add_service();
}
)
});
}
|
javascript
|
{
"resource": ""
}
|
q13695
|
add_service
|
train
|
function add_service() {
// Default configuration. Overrides can be defined in `config/avahi.js`.
sails.log.info('Publishing service ' + config.name + ' (' + config.type + ') on port '+ config.port);
group.AddService(
avahi.IF_UNSPEC.value,
avahi.PROTO_INET.value,
0,
config.name,
config.type,
config.domain,
config.host,
config.port,
'',
function(err) {
if (err) {
sails.log.error('DBus: Could not call org.freedesktop.Avahi.EntryGroup.AddService');
return;
}
group.Commit();
}
);
}
|
javascript
|
{
"resource": ""
}
|
q13696
|
triggerEvent
|
train
|
function triggerEvent(eventType, options) {
var event, key;
options = options || {};
eventType = 'opbeat' + eventType.substr(0,1).toUpperCase() + eventType.substr(1);
if (document.createEvent) {
event = document.createEvent('HTMLEvents');
event.initEvent(eventType, true, true);
} else {
event = document.createEventObject();
event.eventType = eventType;
}
for (key in options) if (hasKey(options, key)) {
event[key] = options[key];
}
if (document.createEvent) {
// IE9 if standards
document.dispatchEvent(event);
} else {
// IE8 regardless of Quirks or Standards
// IE9 if quirks
try {
document.fireEvent('on' + event.eventType.toLowerCase(), event);
} catch(e) {}
}
}
|
javascript
|
{
"resource": ""
}
|
q13697
|
train
|
function(url, method = 'get', body = undefined) {
var deferred = Q.defer();
this.extendedRequest(url, method, body)
.then((res) => { deferred.resolve(res.body); })
.catch((err) => { deferred.reject(err); });
return deferred.promise;
}
|
javascript
|
{
"resource": ""
}
|
|
q13698
|
bowerPackageURL
|
train
|
function bowerPackageURL(packageName, cb) {
if (typeof cb !== 'function') {
throw new TypeError('cb must be a function');
}
if (typeof packageName !== 'string') {
cb(new TypeError('packageName must be a string'));
return;
}
http.get('https://bower.herokuapp.com/packages/' + packageName)
.end(function(err, res) {
if (err && err.status === 404) {
err = new Error('Package ' + packageName + ' not found on Bower');
}
cb(err, res.body.url);
});
}
|
javascript
|
{
"resource": ""
}
|
q13699
|
addPoints
|
train
|
function addPoints (x1, y1, x2, y2, cb) {
var xFinal = x1 + x2;
var yFinal = y1 + y2;
cb(xFinal, yFinal);
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.