_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q52700 | train | function(options) {
var t = this,
json = {id: t.get('probeId')};
// Transfer all non-monitor attrs
_.each(t.toJSON(options), function(value, key) {
| javascript | {
"resource": ""
} | |
q52701 | train | function(name, params, callback) {
var t = this,
controlFn = t[name + '_control'],
startTime = Date.now(),
errMsg,
logId = 'onControl.' + t.probeClass + '.' + name;
params = params || {};
callback = callback || function(){};
log.info(logId, t.get('id'), p... | javascript | {
"resource": ""
} | |
q52702 | train | function(attrs, callback) {
var t = this,
writableAttributes = t.get('writableAttributes') || [];
// Validate the attributes are writable
if (writableAttributes !== '*') {
for (var attrName in attrs) {
if (writableAttributes.indexOf(attrName) < 0) {
| javascript | {
"resource": ""
} | |
q52703 | train | function(options, callback) {
if (typeof options === 'function') {
callback = options;
options = null;
}
options = options || {};
callback = callback || function(){};
var t = this, server = t.get('server'), error,
startTime = Date.now(),
port = options.p... | javascript | {
"resource": ""
} | |
q52704 | train | function(callback) {
var t = this, server = t.get('server'), router = Monitor.getRouter();
callback = callback || function(){};
// Call the callback, but don't stop more than once.
if (!t.isListening) {
return callback();
}
// Release resources
t.connections.each(rout... | javascript | {
"resource": ""
} | |
q52705 | train | function(firewall) {
var t = Monitor.getRouter(); // This is a static method
| javascript | {
"resource": ""
} | |
q52706 | train | function(options) {
var t = this;
options.gateway = false; // New connection can't be an inbound gateway
options.firewall = true; // Gateways are | javascript | {
"resource": ""
} | |
q52707 | train | function() {
var localStorage = root.localStorage;
if (!hostName) {
if (localStorage) {hostName = localStorage.hostName;}
hostName = hostName || Monitor.generateUniqueId();
| javascript | {
"resource": ""
} | |
q52708 | train | function(options) {
var t = this,
startTime = Date.now();
// Default the firewall value
if (_.isUndefined(options.firewall)) {
options = _.extend({},options, {firewall: t.firewall});
}
// Generate a unique ID for the connection
options.id = Monitor.generateUniqueC... | javascript | {
"resource": ""
} | |
q52709 | train | function(connection) {
var t = this;
log.info('removeConnection', 'Conn_' + connection.id);
connection.disconnect('connection_removed');
| javascript | {
"resource": ""
} | |
q52710 | train | function(monitor, reason, callback) {
callback = callback || function(){};
var t = this, probe = monitor.probe, probeId = monitor.get('probeId');
// The monitor must be connected
if (!probe) {return callback('Monitor must be connected');}
// Called upon disconnect (internal or external)
... | javascript | {
"resource": ""
} | |
q52711 | train | function(probeJSON) {
var probeKey = probeJSON.probeClass,
initParams = probeJSON.initParams;
// Allow probes to be externally identified by name
if (probeJSON.probeName) {
return probeJSON.probeName;
}
if (initParams) {
| javascript | {
"resource": ""
} | |
q52712 | train | function(hostName, appName, appInstance) {
var t = this, thisInstance = 0;
return t.connections.find(function(conn) {
// Host or app matches if not specified or if specified and equal
var matchesHost = !hostName || conn.isThisHost(hostName);
var matchesApp = !appName || appName === ... | javascript | {
"resource": ""
} | |
q52713 | train | function(hostName, appName) {
var t = this;
return t.connections.filter(function(conn) {
// Host or app matches if not specified or if specified and equal
var matchesHost = !hostName || conn.isThisHost(hostName);
var matchesApp = !appName || appName === conn.get('remoteAppName'); | javascript | {
"resource": ""
} | |
q52714 | train | function(hostName, callback) {
var t = this,
errStr = '',
connectedPorts = [],
portStart = Config.Monitor.serviceBasePort,
portEnd = Config.Monitor.serviceBasePort + Config.Monitor.portsToScan - 1;
// Create an array to hold callbacks for this host
if (!t.addHo... | javascript | {
"resource": ""
} | |
q52715 | train | function(error) {
t.addHostCallbacks[hostName].forEach(function(cb) {
cb(error);
| javascript | {
"resource": ""
} | |
q52716 | train | function(probeId, callback) {
var t = this, probeImpl = t.runningProbesById[probeId];
if (!probeImpl) {return callback('Probe not running');}
if (--probeImpl.refCount === 0) {
// Release probe resources & internal references if still no references after a while
setTimeout(function() {... | javascript | {
"resource": ""
} | |
q52717 | train | function(monitorJSON, connection, callback) {
// Build a key for this probe from the probeClass and initParams
var t = this,
errStr = '',
probeKey = t.buildProbeKey(monitorJSON);
// Get the probe proxy
var probeId = connection.remoteProbeIdsByKey[probeKey];
var probeP... | javascript | {
"resource": ""
} | |
q52718 | train | function(connection, probeId, callback) {
var t = this, proxy = connection.remoteProbesById[probeId];
if (!proxy) {return callback('Probe not running');}
if (--proxy.refCount === 0) {
// Release probe resources
proxy.release();
proxy.connection = null;
delete connection... | javascript | {
"resource": ""
} | |
q52719 | train | function(error) {
// Don't connect the instance monitor if errors
if (error) {
return callback(error);
}
// Called to disconnect the listeners
var disconnectListeners = function() {
logger.info('disconnectLiveSync', t.className, model.toJSON());
model.off('change'... | javascript | {
"resource": ""
} | |
q52720 | train | function() {
logger.info('disconnectLiveSync', t.className, model.toJSON());
model.off('change', modelListener);
| javascript | {
"resource": ""
} | |
q52721 | train | function(changedModel, options) {
options = options || {};
// Don't persist unless the model is different
if (_.isEqual(JSON.parse(JSON.stringify(model)), JSON.parse(JSON.stringify(model.syncMonitor.get('model'))))) {
logger.info('modelListener.noChanges', t.className, model.toJSON())... | javascript | {
"resource": ""
} | |
q52722 | train | function(params, callback) {
var t = this,
connectError = false,
monitors = t.get('monitors');
if (t.get('started')) {
var err = {code:'RUNNING', msg:'Cannot start - the recipe is already running.'};
logger.warn(err);
return callback(err);
}
// Calle... | javascript | {
"resource": ""
} | |
q52723 | train | function(error) {
if (connectError) {return;}
if (error) {
var err = {code:'CONNECT_ERROR', err: error};
connectError = true;
logger.error('start', err);
return callback(err);
}
for (var name1 in t.monitors) { | javascript | {
"resource": ""
} | |
q52724 | train | function(params, callback) {
var t = this,
disconnectError = false;
if (!t.get('started')) {
var err = {code:'NOT_RUNNING', msg:'The recipe is already stopped.'};
logger.warn('precondition', err);
return callback(err);
}
// Called when a monitor has disconnect... | javascript | {
"resource": ""
} | |
q52725 | train | function(error) {
if (disconnectError) {return;}
if (error) {
var err = {code:'DISONNECT_ERROR', err: error};
disconnectError = true;
logger.error('onDisconnect', err);
return callback(err);
}
for (var name1 in t.monitors) { | javascript | {
"resource": ""
} | |
q52726 | train | function(connect) {
var t = this,
triggeredBy = t.get('triggeredBy'),
onTrigger = t.onTrigger.bind(t);
// Default to listen on changes to all monitors
if (!triggeredBy) {
for (var monitorName in t.monitors) {
t.monitors[monitorName][connect ? 'on' : 'off']('chang... | javascript | {
"resource": ""
} | |
q52727 | train | function(params, callback) {
var t = this,
error = null;
if (!t.get('started')) {
error = {code:'NOT_RUNNING', msg:'Cannot run - recipe not started.'};
logger.warn(error);
return callback(error);
}
// Name the probe
t.name = t.get('probeName') || t.get('i... | javascript | {
"resource": ""
} | |
q52728 | train | function(context) {
var varName,
localVars = [];
for (varName in context) { | javascript | {
"resource": ""
} | |
q52729 | train | function(item) {
var t = this,
now = Date.now(),
msSinceLastSend = now - t.lastSendTime;
// Queue the item
t.queue.push(item);
// Send the bundle?
if (msSinceLastSend > t.interval) {
| javascript | {
"resource": ""
} | |
q52730 | train | function() {
var t = this,
now = Date.now();
// This kicks off the send
t.lastSendTime = now;
t.set({
bundle: t.queue,
sequence: t.get('sequence') + 1
});
| javascript | {
"resource": ""
} | |
q52731 | train | function(error, content) {
var isInitializing = (callback !== null),
initCallback = callback;
callback = null;
if (error && error.code === 'ENOENT') {
// File doesn't exist. Set the model to null.
t.set({model: {}}, {silent: isInitializing});
... | javascript | {
"resource": ""
} | |
q52732 | train | function(args, callback) {
// Make sure the ID exists
var t = this, model = args.model;
if (!model || !model.id) {
return callback({msg:'SyncProbe create - Data model with ID not present'});
}
// Make sure the file doesn't already exist
t.getFullPath(model.id, function(error... | javascript | {
"resource": ""
} | |
q52733 | train | function(modelId, callback) {
var t = this,
dirPath = t.dirPath;
// Don't allow relative paths
var fullPath = Path.join(t.dirPath, modelId);
if (fullPath.indexOf(dirPath) !== 0) {
return callback({msg: 'Model ID ' + modelId + ' cannot represent a relative path'});
}
... | javascript | {
"resource": ""
} | |
q52734 | extend | train | function extend() {
// copy reference to target object
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
// Handle a deep copy situation
if (typeof target === "boolean") {
deep = target;
target = arguments[1] || {};
// skip the boolean and the... | javascript | {
"resource": ""
} |
q52735 | transformFactory | train | function transformFactory(methods) {
var length = methods.length
return transformer
// Transformer.
function transformer(cst) {
visit(cst, visitor)
}
function visitor(node, position, parent) {
var index = | javascript | {
"resource": ""
} |
q52736 | oldschool | train | function oldschool(node) {
if (node.value === threeDashes) {
node.value = emDash
| javascript | {
"resource": ""
} |
q52737 | inverted | train | function inverted(node) {
if (node.value === threeDashes) {
node.value = enDash
} | javascript | {
"resource": ""
} |
q52738 | backticks | train | function backticks(node) {
if (node.value === twoBackticks) {
node.value = openingDoubleQuote
} else if (node.value === | javascript | {
"resource": ""
} |
q52739 | all | train | function all(node) {
backticks(node)
if (node.value === backtick) {
node.value | javascript | {
"resource": ""
} |
q52740 | ellipses | train | function ellipses(node, index, parent) {
var value = node.value
var siblings = parent.children
var position
var nodes
var sibling
var type
var count
var queue
// Simple node with three dots and without white-space.
if (threeFullStopsExpression.test(node.value)) {
node.value = ellipsis
retur... | javascript | {
"resource": ""
} |
q52741 | quotes | train | function quotes(node, index, parent) {
var siblings = parent.children
var value = node.value
var next
var nextNext
var prev
var nextValue
if (value !== doubleQuote && value !== singleQuote) {
return
}
prev = siblings[index - 1]
next = siblings[index + 1]
nextNext = siblings[index + 2]
next... | javascript | {
"resource": ""
} |
q52742 | padToEven | train | function padToEven(value) {
var a = value; // eslint-disable-line
if (typeof a !== 'string') {
throw new Error(`[ethjs-util] while padding to even, value must be string, is | javascript | {
"resource": ""
} |
q52743 | arrayContainsArray | train | function arrayContainsArray(superset, subset, some) {
if (Array.isArray(superset) !== true) { throw new Error(`[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '${typeof | javascript | {
"resource": ""
} |
q52744 | toUtf8 | train | function toUtf8(hex) {
const bufferValue = new Buffer(padToEven(stripHexPrefix(hex).replace(/^0+|0+$/g, | javascript | {
"resource": ""
} |
q52745 | toAscii | train | function toAscii(hex) {
var str = ''; // eslint-disable-line
var i = 0, l = hex.length; // eslint-disable-line
if (hex.substring(0, 2) === | javascript | {
"resource": ""
} |
q52746 | prompForPassword | train | function prompForPassword(done) {
inquirer.prompt([
{
type: 'password',
message: 'Enter the password',
name: 'password',
validate(input) {
| javascript | {
"resource": ""
} |
q52747 | parseOptions | train | function parseOptions(options) {
let opts = {};
_.each(nodecipher.defaults, (defaultVal, name) => {
if (!_.isUndefined(options[name])) | javascript | {
"resource": ""
} |
q52748 | cipher | train | function cipher(command, input, output, options) {
if (_.isUndefined(options.password)) {
prompForPassword(password => {
cipher(command, input, output, options, _.assign(options, { password }));
});
} else {
| javascript | {
"resource": ""
} |
q52749 | handleCipher | train | function handleCipher(opts, err) {
if (err) {
switch (err.name) {
case nodecipher.errors.BAD_ALGORITHM:
handleInvalidAlgorithm(opts, err);
break;
case nodecipher.errors.BAD_DIGEST:
handleInvalidHash(opts, err);
break;
case nodecipher.errors.BAD_FILE:
handl... | javascript | {
"resource": ""
} |
q52750 | handleEnoentError | train | function handleEnoentError(opts, err) {
console.log(chalk.red(
'\nError: ' + err.name + | javascript | {
"resource": ""
} |
q52751 | train | function () {
var toolbarHeight = $toolbar[0].offsetHeight;
var toolbarWidth = $toolbar[0].offsetWidth;
var spacing = 5;
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var boundary = range.getBoundingClientRect();
var topPosition = bo... | javascript | {
"resource": ""
} | |
q52752 | train | function (e) {
// if you click something from the toolbar
// don't do anything
if(e && e.target && $toolbar.find(e.target).length) {
return false;
}
var newSelection = window.getSelection();
// get selection node
var anchorNode = newSelection.anchorNo... | javascript | {
"resource": ""
} | |
q52753 | train | function (selection) {
var parentNode = selection.anchorNode;
if (!parentNode.tagName) {
parentNode = selection.anchorNode.parentNode;
}
var childNode = parentNode.childNodes[0];
if(childNode && childNode.tagName && childNode.tagName.toLowerCase() in generatedTags) {... | javascript | {
"resource": ""
} | |
q52754 | replaceResponse | train | function replaceResponse(res) {
// copy for response.headers.hasOwnProperty is undefined case
// https://github.com/oauthjs/node-oauth2-server/pull/486
const newResponse = {
headers: {},
};
for (const property in res) {
if (property !== 'headers') {
newResponse[property] = res[property];
}
| javascript | {
"resource": ""
} |
q52755 | train | function(url, callback) {
logger('Fetching URL resource: ' + url);
request(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
callback(body);
| javascript | {
"resource": ""
} | |
q52756 | train | function(filePath, callback) {
if (!fs.existsSync(filePath)) {
errorHandler("File " + filePath + " does not exist. Please specify a valid path.");
}
var body = '';
var reader = fs.createReadStream(filePath);
reader.on('data', function(chunks) {
| javascript | {
"resource": ""
} | |
q52757 | getName | train | function getName(str) {
var name = path.basename(str);
if (name.lastIndexOf('.') === | javascript | {
"resource": ""
} |
q52758 | handleOutput | train | function handleOutput(destConfig, jsonString) {
var type = destConfig.type,
destPath = destConfig.path,
defaultFileName = destConfig.defaultFileName,
force = destConfig.force,
pretty = destConfig.pretty;
| javascript | {
"resource": ""
} |
q52759 | train | function ( name, opts ) {
if ( ! name ) {
return cbk( new Error( "Geocoder.selectProvider requires a name.") );
}
this.provider = name;
| javascript | {
"resource": ""
} | |
q52760 | train | function ( loc, cbk, opts ) {
if ( ! loc ) {
return cbk( new Error( "Geocoder.geocode requires | javascript | {
"resource": ""
} | |
q52761 | concurrent | train | function concurrent(scripts) {
const {colors, scripts: quotedScripts, names} = Object.keys(scripts)
.reduce(reduceScripts, {
colors: [],
scripts: [],
names: [],
})
const flags = [
'--kill-others-on-fail',
`--prefix-colors "${colors.join(',')}"`,
'--prefix "[{name}]"',
`--na... | javascript | {
"resource": ""
} |
q52762 | includePackage | train | function includePackage(packageNameOrOptions) {
const packageScriptsPath = typeof packageNameOrOptions === 'string' ?
`./packages/${packageNameOrOptions}/package-scripts.js` :
packageNameOrOptions.path
const startingDir = process.cwd().split('\\').join('/')
const relativeDir = path
.relative(startin... | javascript | {
"resource": ""
} |
q52763 | getBin | train | function getBin(packageName, binName = packageName) {
const packagePath = require.resolve(`${packageName}/package.json`)
const concurrentlyDir = path.dirname(packagePath)
let {bin: binRelativeToPackage} | javascript | {
"resource": ""
} |
q52764 | done | train | function done(failures, fn, reportersWithDone, waitFor = identity) {
const count = reportersWithDone.length;
const waitReporter = waitOn((r, f) => r.done(failures, f));
const progress = | javascript | {
"resource": ""
} |
q52765 | needsSubtitution | train | function needsSubtitution(prop) {
var needsSub = false;
if (typeof prop === 'string') {
if (prop.indexOf('#{INDEX}') !== -1) needsSub = true;
} else if (typeof prop === 'object') {
| javascript | {
"resource": ""
} |
q52766 | substituteFnWhereNeeded | train | function substituteFnWhereNeeded(actions) {
actions = actions || [];
return actions.map(function (action) {
return Object.keys(action).reduce(function (accum, key) {
if ((key === 'get' || key === 'head' || key === 'put' || key === 'post' || key === 'del' || key === 'patch') &&
needsSubtitution(a... | javascript | {
"resource": ""
} |
q52767 | bindSubtituteFnsWithTokens | train | function bindSubtituteFnsWithTokens(actions, tokens) {
return actions.map(function (action) {
return Object.keys(action).reduce(function (accum, key) {
// if it is list of sub keys, and | javascript | {
"resource": ""
} |
q52768 | execAnySubFns | train | function execAnySubFns(actions) {
return actions.map(function (action) {
return Object.keys(action).reduce(function (accum, key) {
// if it is list of sub keys, and is a fn, then | javascript | {
"resource": ""
} |
q52769 | train | function(scope, element, attrs, autoCtrl){
element.bind('mouseenter', function() {
autoCtrl.preSelect(attrs.val);
autoCtrl.setIndex(attrs.index);
});
| javascript | {
"resource": ""
} | |
q52770 | train | function (data) {
var lines = data.match(/[^\r\n]+/g); //cut lines
return lines.map(function (line) {
try {
return JSON.parse(line);
| javascript | {
"resource": ""
} | |
q52771 | playback | train | function playback(resHeaders, resBody) {
if (!forceLive) {
var headerContent = fs.readFileSync(filename + '.headers');
resHeaders = JSON.parse(headerContent);
}
var socket = new EventEmitter();
socket.setTimeout = socket.setEncoding = function() {};
// Needed... | javascript | {
"resource": ""
} |
q52772 | train | function( arg ) {
var listItems, listItem, i, len, results;
var options = _callMethod( this, "option" );
var searched = arg instanceof $.Event ? arg.target.value : arg;
var bselect = _callMethod( this, "element" );
if ( this[ 0 ].disabled ) {
... | javascript | {
"resource": ""
} | |
q52773 | train | function() {
var bselect = _callMethod( this, "element" );
var optionList = bselect.find( ".bselect-option-list" ).empty();
var mapping = {};
var i = 0;
bselect.toggleClass( "disabled", this.prop( "disabled" ) );
this.find( "option, > opt... | javascript | {
"resource": ""
} | |
q52774 | adjustDropdownHeight | train | function adjustDropdownHeight( $elem ) {
var list = $elem.find( ".bselect-option-list" );
var len = list.find( "li:visible" ).length;
| javascript | {
"resource": ""
} |
q52775 | updateOptions | train | function updateOptions( $elem, prev, curr ) {
var bselect = _callMethod( $elem, "element" );
$.each( prev, function(key, val) {
if ( curr[ key ] !== val ) {
if ( key === "size" ) {
var sizes = $.map( bootstrapButtonSizes.slice( 0 ), function( size )... | javascript | {
"resource": ""
} |
q52776 | showNoOptionsAvailable | train | function showNoOptionsAvailable( $elem ) {
var bselect = _callMethod( $elem, "element" );
| javascript | {
"resource": ""
} |
q52777 | setup | train | function setup( elem, options ) {
var caret, label, container, id, dropdown;
var $elem = $( elem );
// First of, let's build the base HTML of BSelect
id = ++elements;
container = $( "<div class='bselect' />", {
id: "bselect-" + id
});
dropd... | javascript | {
"resource": ""
} |
q52778 | someCollections | train | function someCollections(db, collections, next) {
var last = ~~collections.length, counter = 0;
if (last === 0) { // empty set
return next(null);
}
collections.forEach(function(collection) {
db.collection(collection, function(err, collection) {
logger('select collection ' + collection.collecti... | javascript | {
"resource": ""
} |
q52779 | strFromEnvironmentVarSetting | train | function strFromEnvironmentVarSetting(functionsVar, envVar) {
if (!process.env[envVar]) {
const msg = `${envVar} does not exist on within environment | javascript | {
"resource": ""
} |
q52780 | createConfigSetString | train | function createConfigSetString(mapEnvSettings) {
const settingsStrsArr = map(mapEnvSettings, strFromEnvironmentVarSetting)
const settingsStr = compact(settingsStrsArr).join(' ') | javascript | {
"resource": ""
} |
q52781 | mergeResults | train | function mergeResults(jsRes, coffeeRes) {
if (!coffeeRes) {
return jsRes;
}
jsRes.reports = jsRes.reports.concat(coffeeRes.reports);
| javascript | {
"resource": ""
} |
q52782 | train | function(file, cb) {
zip.entry(fs.createReadStream(file.path), | javascript | {
"resource": ""
} | |
q52783 | hmacSha1 | train | function hmacSha1 (options) {
return crypto.createHmac('sha1', | javascript | {
"resource": ""
} |
q52784 | readFile | train | function readFile(file) {
return new Promise(
(resolve, reject) => {
fs.readFile(
file, 'utf8', (error, contents) => { | javascript | {
"resource": ""
} |
q52785 | writeFile | train | function writeFile(file, contents) {
return new Promise(
(resolve, reject) => {
fs.writeFile(
file, contents, error => | javascript | {
"resource": ""
} |
q52786 | writeFile | train | function writeFile(filepath, data, options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
}
if (typeof cb !== 'function') {
return writeFile.promise.apply(null, arguments);
}
if (typeof filepath !== 'string') {
cb(new TypeError('expected filepath to be a string'));
... | javascript | {
"resource": ""
} |
q52787 | errorHandler | train | function errorHandler(errorKey, nativeError, alternate) {
const errorMessages = {
add_characteristic_exists_error: `Characteristic ${alternate} already exists.`,
characteristic_error: `Characteristic ${alternate} not found. Add ${alternate} to device using addCharacteristic or try another characteristic.`,
conn... | javascript | {
"resource": ""
} |
q52788 | styleFn | train | function styleFn(prefix, cssProp) {
return function (style) {
if (!style.size) {
return {};
}
var value = style.filter(function (val) {
return val.startsWith(prefix);
}).first();
| javascript | {
"resource": ""
} |
q52789 | findModuleFromOptions | train | function findModuleFromOptions(host, options) {
if (options.hasOwnProperty('skipImport') && options.skipImport) {
return undefined;
}
if (!options.module) {
const pathToCheck = (options.sourceDir || '') + '/' + (options.path || '')
+ (options.flat ? '' : '/' + strings_1.dasherize... | javascript | {
"resource": ""
} |
q52790 | findModule | train | function findModule(host, generateDir) {
let dir = host.getDir('/' + generateDir);
const moduleRe = /\.module\.ts$/;
const routingModuleRe = /-routing\.module\.ts/;
while (dir) {
const matches = dir.subfiles.filter(p => moduleRe.test(p) && !routingModuleRe.test(p));
if (matches.length ==... | javascript | {
"resource": ""
} |
q52791 | buildRelativePath | train | function buildRelativePath(from, to) {
from = core_1.normalize(from);
to = core_1.normalize(to);
// Convert to arrays.
const fromParts = from.split('/');
const toParts = to.split('/');
// Remove file names (preserving destination)
fromParts.pop();
const toFileName = toParts.pop();
co... | javascript | {
"resource": ""
} |
q52792 | getPreciseType | train | function getPreciseType(propValue) {
var propType = getPropType(propValue);
if (propType === 'object') {
if (propValue instanceof Date) {
return 'date';
} else | javascript | {
"resource": ""
} |
q52793 | setCanvasSize | train | function setCanvasSize (width, height) {
canvas.setAttribute('width', width);
canvas.setAttribute('height', height);
canvas.style.width | javascript | {
"resource": ""
} |
q52794 | getPointRelativeToCanvas | train | function getPointRelativeToCanvas (point) {
return {
x: point.x / canvas.width,
| javascript | {
"resource": ""
} |
q52795 | getCursorRelativeToCanvas | train | function getCursorRelativeToCanvas (e) {
var cur = {};
if (isTouchEvent(e)) {
cur.x = e.touches[0].pageX - canvas.offsetLeft;
cur.y = e.touches[0].pageY - canvas.offsetTop;
} else {
var rect = | javascript | {
"resource": ""
} |
q52796 | clearCanvas | train | function clearCanvas () {
context.clearRect(0, 0, canvas.width, canvas.height);
if (opts.backgroundColor) {
context.fillStyle | javascript | {
"resource": ""
} |
q52797 | normalizePoint | train | function normalizePoint (point) {
return {
x: point.x * canvas.width,
| javascript | {
"resource": ""
} |
q52798 | drawStroke | train | function drawStroke (stroke) {
context.beginPath();
for (var j = 0; j < stroke.points.length - 1; j++) {
var start = normalizePoint(stroke.points[j]);
var end = normalizePoint(stroke.points[j + 1]);
context.moveTo(start.x, start.y);
... | javascript | {
"resource": ""
} |
q52799 | redraw | train | function redraw () {
clearCanvas();
for (var i = 0; i < that.strokes.length; i++) {
| javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.