_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q8400 | AESCipher | train | function AESCipher(key, iv, bits, mode) {
if (!(this instanceof AESCipher))
return new AESCipher(key, iv, mode);
| javascript | {
"resource": ""
} |
q8401 | AESDecipher | train | function AESDecipher(key, iv, bits, mode) {
if (!(this instanceof AESDecipher))
return new AESDecipher(key, iv, mode);
assert(mode === 'ecb' || mode === 'cbc', 'Unknown mode.');
this.key = new | javascript | {
"resource": ""
} |
q8402 | Miner | train | function Miner(options) {
if (!(this instanceof Miner))
return new Miner(options);
AsyncObject.call(this);
this.options = new MinerOptions(options);
this.network = this.options.network;
this.logger = | javascript | {
"resource": ""
} |
q8403 | Witness | train | function Witness(options) {
if (!(this instanceof Witness))
return new Witness(options);
| javascript | {
"resource": ""
} |
q8404 | HostListOptions | train | function HostListOptions(options) {
if (!(this instanceof HostListOptions))
return new HostListOptions(options);
this.network = Network.primary;
this.logger = Logger.global;
this.resolve = dns.lookup;
this.host = '0.0.0.0';
this.port = this.network.port;
this.services = common.LOCAL_SERVICES;
| javascript | {
"resource": ""
} |
q8405 | CPUMiner | train | function CPUMiner(miner) {
if (!(this instanceof CPUMiner))
return new CPUMiner(miner);
AsyncObject.call(this);
this.miner = miner;
this.network = this.miner.network;
this.logger = this.miner.logger.context('cpuminer');
this.workers = this.miner.workers;
this.chain = this.miner.chain;
this.locker ... | javascript | {
"resource": ""
} |
q8406 | setAbsolutePath | train | function setAbsolutePath(file) {
file.absolutePath = path.resolve(process.cwd(), | javascript | {
"resource": ""
} |
q8407 | watchFile | train | function watchFile(file, cb, partial) {
setAbsolutePath(file);
storeDirectory(file);
if (!watched_files[file.fullPath]) {
if (use_fs_watch) {
(function() {
watched_files[file.fullPath] = fs.watch(file.fullPath, function() {
typeof cb === "function" && cb(file);
... | javascript | {
"resource": ""
} |
q8408 | storeDirectory | train | function storeDirectory(file) {
var directory = file.fullParentDir;
if (!watched_directories[directory]) {
fs.stat(directory, function(err, stats) {
if (err) {
watched_directories[directory] = (new Date).getTime();
} | javascript | {
"resource": ""
} |
q8409 | distinguishPaths | train | function distinguishPaths(paths) {
paths = Array.isArray(paths) ? paths : [paths];
var result = {
directories: [],
files: []
};
paths.forEach(function(name) {
if | javascript | {
"resource": ""
} |
q8410 | extend | train | function extend(prototype, attributes) {
var object = {};
Object.keys(prototype).forEach(function(key) {
object[key] = prototype[key];
});
| javascript | {
"resource": ""
} |
q8411 | watchPaths | train | function watchPaths(args) {
var result = distinguishPaths(args.path)
if (result.directories.length) {
result.directories.forEach(function(directory) {
watchDirectory(extend(args, {root: directory}));
| javascript | {
"resource": ""
} |
q8412 | siphash24 | train | function siphash24(data, key, shift) {
const blocks = Math.floor(data.length / 8);
const c0 = U64(0x736f6d65, 0x70736575);
const c1 = U64(0x646f7261, 0x6e646f6d);
const c2 = U64(0x6c796765, 0x6e657261);
const c3 = U64(0x74656462, 0x79746573);
const f0 = U64(blocks << (shift - 32), 0);
const f1 = U64(0, 0x... | javascript | {
"resource": ""
} |
q8413 | BufferReader | train | function BufferReader(data, zeroCopy) {
if (!(this instanceof BufferReader))
return new BufferReader(data, zeroCopy);
assert(Buffer.isBuffer(data), 'Must pass a Buffer.'); | javascript | {
"resource": ""
} |
q8414 | updateSession | train | function updateSession(callback) {
core.api({method: ''}, function(err, response) {
var session;
if (err) {
core.log('error encountered updating session:', err);
callback && callback(err, null);
return;
}
if (!response.token.valid) {
// Invalid token. Either it has expired or | javascript | {
"resource": ""
} |
q8415 | makeSession | train | function makeSession(session) {
return {
authenticated: !!session.token,
token: session.token,
scope: session.scope,
| javascript | {
"resource": ""
} |
q8416 | getStatus | train | function getStatus(options, callback) {
if (typeof options === 'function') {
callback = options;
}
if (typeof callback !== 'function') {
callback = function() {};
}
if (!core.session) {
throw new Error('You must call init() before getStatus()');
}
| javascript | {
"resource": ""
} |
q8417 | login | train | function login(options) {
if (!gui.isActive()) {
throw new Error('Cannot login without a GUI.');
}
if (!options.scope) {
throw new Error('Must specify list of requested scopes');
}
var params = {
response_type: 'token',
client_id: core.clientId,
redirect_uri: 'https://api.twitch.tv/kraken... | javascript | {
"resource": ""
} |
q8418 | logout | train | function logout(callback) {
// Reset the current session
core.setSession({}); | javascript | {
"resource": ""
} |
q8419 | initSession | train | function initSession(storedSession, callback) {
if (typeof storedSession === "function") {
callback = storedSession;
}
core.setSession((storedSession && makeSession(storedSession)) || {});
getStatus({ force: true }, function(err, status) {
if (status.authenticated) | javascript | {
"resource": ""
} |
q8420 | runWebServerInProcess | train | function runWebServerInProcess(rawConfig, serverConfig, emitter) {
var server = require('./server.js');
if (serverConfig.command == 'stop') {
logger.info('stopping server');
return server.stop();
| javascript | {
"resource": ""
} |
q8421 | runWebServerAsWorker | train | function runWebServerAsWorker(rawConfig, serverConfig, emitter, callback) {
if (serverConfig.command == 'stop') {
logger.info('stopping server workers');
if (netServer) {
netServer.close();
netServer = null;
}
for (var i=0;i<webservers.length;i++) {
var webserver = webserver... | javascript | {
"resource": ""
} |
q8422 | train | function(err, result) {
if (err && !util.isError(err)) {
err = new Error(err);
| javascript | {
"resource": ""
} | |
q8423 | Peer | train | function Peer(options) {
if (!(this instanceof Peer))
return new Peer(options);
EventEmitter.call(this);
this.options = options;
this.network = this.options.network;
this.logger = this.options.logger.context('peer');
this.locker = new Lock();
this.parser = new Parser(this.network);
this.framer = ... | javascript | {
"resource": ""
} |
q8424 | retrievePolicyArn | train | function retrievePolicyArn(identifier, context, searchParams) {
if (/arn:aws:iam::\d{12}:policy\/?[a-zA-Z_0-9+=,.@\-_/]+]/.test(identifier)) {
return Promise.resolve(identifier);
}
// @TODO make this code more beautiful
// Try ENV_PolicyName_stage
let policyIdentifier = context.environment + '_' + identi... | javascript | {
"resource": ""
} |
q8425 | retrieveRoleArn | train | function retrieveRoleArn(identifier, context) {
const iam = new AWS.IAM();
// First check if the parameter already is an ARN
if (/arn:aws:iam::\d{12}:role\/?[a-zA-Z_0-9+=,.@\-_\/]+/.test(identifier)) {
return Promise.resolve(identifier);
}
// Then, we check if a role exists with a name "ENVIRONMENT_identi... | javascript | {
"resource": ""
} |
q8426 | fileName | train | function fileName(file) {
let prefix = null
let reference = null
if (isPathSubDirOf(file, PROJECT_DIR)) {
// Assets from the target project.
prefix = []
reference = PROJECT_DIR
} else if (isPathSubDirOf(file, TOOLBOX_DIR)) {
// Assets from the Toolbox.
prefix = ['__borela__']
reference ... | javascript | {
"resource": ""
} |
q8427 | train | function (commentObj, code, filepath, context, emitter) {
var tagRegexp = tags.getTagRegexp();
var sym = new Symbol({file:filepath});
var comment = commentObj.comment,
match = tagRegexp.exec(comment), description,
l = comment.length, i;
if (match && match[1]) {
... | javascript | {
"resource": ""
} | |
q8428 | getProjectRootDirectory | train | function getProjectRootDirectory() {
// From the current directory, check if parent directories have a package.json file and if it contains
// a reference to the @myrmex/core node_module
let cwd = process.cwd();
let packageJson;
let found = false;
do {
try {
packageJson = require(path.join(cwd, '... | javascript | {
"resource": ""
} |
q8429 | getConfig | train | function getConfig() {
// Load the myrmex main configuration file
let config = {};
try {
// try to load a myrmex.json or myrmex.js file
config = require(path.join(process.cwd(), 'myrmex'));
} catch (e) {
// Silently ignore if there is no configuration file
return config;
}
config.config = c... | javascript | {
"resource": ""
} |
q8430 | loadTemplate | train | function loadTemplate(templatePath, identifier) {
return plugin.myrmex.fire('beforeTemplateLoad', templatePath, identifier)
.spread((templatePath, name) => {
const templateDoc = _.cloneDeep(require(path.join(templatePath)));
// Lasy loading because the plugin has to be registered in a Myrmex instance befor... | javascript | {
"resource": ""
} |
q8431 | toggleFullscreen | train | function toggleFullscreen(element, callback) {
if (callback && typeof callback === 'function') {
if (!isFullscreen()) {
var fn = function (e) {
if (isFullscreen()) {
callback(true);
}
else {
callback(false);
... | javascript | {
"resource": ""
} |
q8432 | enterFullscreen | train | function enterFullscreen(element) {
var userAgent = navigator.userAgent.toLowerCase();
if (element.requestFullscreen) {
element.requestFullscreen();
}
else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
else if (element.mozRequ... | javascript | {
"resource": ""
} |
q8433 | exitFullscreen | train | function exitFullscreen() {
var _doument = document;
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (_doument.msExitFullscreen) {
_doument.msExitFullscreen();
}
else if (_doument.mozCancelFullScreen) {
| javascript | {
"resource": ""
} |
q8434 | isFullscreen | train | function isFullscreen() {
var _document = document;
if (!_document.fullscreenElement &&
!_document.mozFullScreenElement &&
!_document.webkitFullscreenElement &&
| javascript | {
"resource": ""
} |
q8435 | fullscreenChange | train | function fullscreenChange(callback) {
var _document = document;
return new Promise(function (resolve, reject) {
if (document.fullscreenEnabled) {
document.addEventListener('fullscreenchange', callback);
}
else if (_document.mozFullScreenEnabled) {
_document.addEve... | javascript | {
"resource": ""
} |
q8436 | timeInMs | train | function timeInMs(time) {
var HOUR_IN_MS = 3.6e+6,
DAY_IN_MS = HOUR_IN_MS * 24,
WK_IN_MS = DAY_IN_MS * 7,
MS_DICTIONARY = {
'weeks': WK_IN_MS,
'week': WK_IN_MS,
'w': WK_IN_MS,
'days': DAY_IN_MS,
'day': DAY_IN_MS,
'd': DAY_IN_MS,
| javascript | {
"resource": ""
} |
q8437 | loadApis | train | function loadApis() {
// Shortcut if apis already have been loaded
if (apis !== undefined) {
return Promise.resolve(apis);
}
const apiSpecsPath = path.join(process.cwd(), plugin.config.apisPath);
// This event allows to inject code before loading all APIs
return plugin.myrmex.fire('beforeApisLoad')
... | javascript | {
"resource": ""
} |
q8438 | loadApi | train | function loadApi(apiSpecPath, identifier) {
return plugin.myrmex.fire('beforeApiLoad', apiSpecPath, identifier)
.spread((apiSpecPath, identifier) => {
// Because we use require() to get the spec, it could either be a JSON file
// or the content exported by a node module
// But because require() caches t... | javascript | {
"resource": ""
} |
q8439 | loadEndpoints | train | function loadEndpoints() {
// Shortcut if endpoints already have been loaded
if (endpoints !== undefined) {
return Promise.resolve(endpoints);
}
const endpointSpecsPath = path.join(process.cwd(), plugin.config.endpointsPath);
return plugin.myrmex.fire('beforeEndpointsLoad')
.spread(() => {
const e... | javascript | {
"resource": ""
} |
q8440 | loadModels | train | function loadModels() {
const modelSpecsPath = path.join(process.cwd(), plugin.config.modelsPath);
return plugin.myrmex.fire('beforeModelsLoad')
.spread(() => {
return Promise.promisify(fs.readdir)(modelSpecsPath);
})
.then(fileNames => {
// Load all the model specifications
return Promise.map(fi... | javascript | {
"resource": ""
} |
q8441 | loadModel | train | function loadModel(modelSpecPath, name) {
return plugin.myrmex.fire('beforeModelLoad', modelSpecPath, name)
.spread(() => {
// Because we use require() to get the spec, it could either be a JSON file
// or the content exported by a node module
// But because require() caches the content it loads, we clo... | javascript | {
"resource": ""
} |
q8442 | loadIntegrations | train | function loadIntegrations(region, context, endpoints) {
// The `deployIntegrations` hook takes four arguments
// The region of the deployment
// The "context" of the deployment
// The list of endpoints that must be deployed
// An array that will receive integration results
const integrationDataInjectors = [... | javascript | {
"resource": ""
} |
q8443 | findApi | train | function findApi(identifier) {
return loadApis()
.then(apis => {
const api = _.find(apis, (api) => { return api.getIdentifier() === identifier; });
if (!api) {
return Promise.reject(new | javascript | {
"resource": ""
} |
q8444 | findEndpoint | train | function findEndpoint(resourcePath, method) {
return loadEndpoints()
.then(endpoints => {
const endpoint = _.find(endpoints, endpoint => { return endpoint.getResourcePath() === resourcePath && endpoint.getMethod() === method; });
if (!endpoint) {
| javascript | {
"resource": ""
} |
q8445 | findModel | train | function findModel(name) {
return loadModels()
.then(models => {
const model = _.find(models, model => { return model.getName('spec') === name; });
if (!model) {
return Promise.reject(new | javascript | {
"resource": ""
} |
q8446 | mergeSpecsFiles | train | function mergeSpecsFiles(beginPath, subPath) {
// Initialise specification
const spec = {};
// List all directories where we have to look for specifications
const subDirs = subPath.split(path.sep);
// Initialize the directory path for the do/while statement
let searchSpecDir = beginPath;
do {
let s... | javascript | {
"resource": ""
} |
q8447 | getSelectValue | train | function getSelectValue (elem) {
var value, option, i
var options = elem.options
var index = elem.selectedIndex
var one = elem.type === 'select-one'
var values = one ? null : []
var max = one ? index + 1 : options.length
if (index < 0) {
i = max
} else {
i = one ? index : 0
}
// Loop throu... | javascript | {
"resource": ""
} |
q8448 | updateBinary | train | function updateBinary (os = platform, arch = process.arch) {
return new Promise((resolve, reject) => {
if (platform === 'freebsd') return resolve(`
There are no static ffmpeg builds for FreeBSD currently available.
The module will try to use the system-wide installation.
Install it by running "pkg install ffmpeg... | javascript | {
"resource": ""
} |
q8449 | sortArrayByIndex | train | function sortArrayByIndex(array) {
let ii = 0;
let length = array.length;
let output = | javascript | {
"resource": ""
} |
q8450 | Endpoint | train | function Endpoint(spec, resourcePath, method) {
this.method = method;
| javascript | {
"resource": ""
} |
q8451 | monkeyPatchPipe | train | function monkeyPatchPipe(stream) {
while (!stream.hasOwnProperty('pipe')) {
stream = Object.getPrototypeOf(stream)
if (!stream) return null
}
let existingPipe = stream.pipe
newPipe['$$monkey-patch'] = true
return stream.pipe = newPipe
/** Create new pipe copy of existing pipe */
function newPipe... | javascript | {
"resource": ""
} |
q8452 | train | function(db, id) {
this._db = db;
this._id = id;
this._index = new Map();
| javascript | {
"resource": ""
} | |
q8453 | configureBundleStats | train | function configureBundleStats(config) {
// Interactive tree map of the bundle.
if (interactiveBundleStats)
config.plugins.push(new BundleAnalyzerPlugin)
// JSON file containing the bundle stats.
if (bundleStats) {
| javascript | {
"resource": ""
} |
q8454 | configureJsMinification | train | function configureJsMinification(config) {
if (!(minify || minifyJs))
return
config.optimization.minimize = true
config.optimization.minimizer = [new UglifyJsPlugin({
| javascript | {
"resource": ""
} |
q8455 | parseArffFile | train | function parseArffFile(arffObj, cb) {
var arffFile = '';
arffFile += '@relation ';
arffFile += arffObj.name;
arffFile += '\n\n';
async.waterfall([
function (callback) {
var i = 0;
async.eachSeries(arffObj.data, function (obj, dataCb) {
async.eachSeries(_.keys(obj... | javascript | {
"resource": ""
} |
q8456 | train | function(N) {
cosMap = cosMap || {};
cosMap[N] = new Array(N*N);
var PI_N = Math.PI / N;
for (var k = 0; k < N; k++) {
for | javascript | {
"resource": ""
} | |
q8457 | SVGObj | train | function SVGObj(file, svg, config) {
this.file = file;
this.id = path.basename(this.file, '.svg');
// this.newSVG = ;
// this.newSVG = new dom().parseFromString('<book><title>Harry Potter</title></book>');
// this.newSVG = new dom().parseFromString(svg);
// this.svg = libxmljs.parseXml(svg);... | javascript | {
"resource": ""
} |
q8458 | dateLastPaymentShouldHaveBeenMade | train | function dateLastPaymentShouldHaveBeenMade(loan, cb) {
var d = Q.defer();
var result;
if (!loan || _.isEmpty(loan.amortizationTable)) {
d.reject(new Error('required dateLastPaymentShouldHaveBeenMade not provided'));
} else {
var determinationDate = loan.determinationDate ? moment(loan.determ... | javascript | {
"resource": ""
} |
q8459 | addLateFees | train | function addLateFees(loan, cb) {
var d = Q.defer();
if (!loan || !loan.closingDate || !loan.loanAmount || !loan.interestRate || !loan.paymentAmount) {
d.reject(new Error('required parameters for addLateFees not provided'));
} else {
var lateFee = calcLateFee(loan);
var determinationDate =... | javascript | {
"resource": ""
} |
q8460 | SpotifySearch | train | function SpotifySearch (title) {
/**
* @public {Array} tracks.
*/
this.tracks = []
// Query spotify, parse xml response, display in terminal,
// prompt user for track number, play track.
this._query(title) | javascript | {
"resource": ""
} |
q8461 | train | function (modelName) {
if (["make", "list"].indexOf(modelName) === -1) {
throw new Error(
"checkOwnerApp middleware can only be configured with 'make' or 'list'. You passed in: '" +
modelName +
"'"
);
}
return function (req, res, next) {
// Don't ... | javascript | {
"resource": ""
} | |
q8462 | getPrototype | train | function getPrototype(value) {
let prototype;
if (!_.isUndefined(value) && !_.isNull(value)) {
if (!_.isObject(value)) {
prototype = value.constructor.prototype;
}
else if (_.isFunction(value)) {
prototype = | javascript | {
"resource": ""
} |
q8463 | generateKey | train | function generateKey(length) {
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const possibleLength = possible.length - 1;
let text = '';
| javascript | {
"resource": ""
} |
q8464 | executeCommand | train | function executeCommand(parameters) {
// If a name has been provided, we create the project directory
const modelFilePath = path.join(process.cwd(), plugin.config.modelsPath);
return mkdirpAsync(modelFilePath)
.then(() => {
const model = {
type: 'object',
properties: {}
};
... | javascript | {
"resource": ""
} |
q8465 | loadPolicies | train | function loadPolicies() {
const policyConfigsPath = path.join(process.cwd(), plugin.config.policiesPath);
// This event allows to inject code before loading all APIs
return plugin.myrmex.fire('beforePoliciesLoad')
.then(() => {
// Retrieve configuration path of all API specifications
return fs.readdirA... | javascript | {
"resource": ""
} |
q8466 | loadPolicy | train | function loadPolicy(documentPath, name) {
return plugin.myrmex.fire('beforePolicyLoad', documentPath, name)
.spread((documentPath, name) => {
// Because we use require() to get the document, it could either be a JSON file
// or the content exported by a node module
// But because require() caches the co... | javascript | {
"resource": ""
} |
q8467 | findPolicies | train | function findPolicies(identifiers) {
return loadPolicies()
.then((policies) => {
return _.filter(policies, (policy) | javascript | {
"resource": ""
} |
q8468 | registerCommands | train | function registerCommands(icli) {
return Promise.all([
require('./cli/create-policy')(icli),
require('./cli/create-role')(icli),
| javascript | {
"resource": ""
} |
q8469 | hasInOfType | train | function hasInOfType(value, path, validator) {
return _.hasIn(value, | javascript | {
"resource": ""
} |
q8470 | rot13 | train | function rot13(x) {
return Array.prototype.map.call(x, (ch) => {
var code = ch.charCodeAt(0);
if (code >= 0x41 && code <= 0x5a)
code = (((code - 0x41) + 13) % 26) + 0x41;
else if (code >= 0x61 | javascript | {
"resource": ""
} |
q8471 | train | function(options) {
options = options || {};
this.datasources = [];
this.styles = [];
this.projection = DEFAULT_PROJECTION;
this.assetsPath = ".";
if (options.projection){
this.projection = projector.util.cleanProjString(options.projection);
console.log(this.projection);
}
| javascript | {
"resource": ""
} | |
q8472 | train | function() {
var projection = this.projection;
this.datasources.forEach(function(datasource) {
datasource.load && datasource.load(function(error) {
| javascript | {
"resource": ""
} | |
q8473 | differenceKeys | train | function differenceKeys(first, second) {
return filterKeys(first, | javascript | {
"resource": ""
} |
q8474 | slugify | train | function slugify(string) {
return _.deburr(string).trim().toLowerCase().replace(/ | javascript | {
"resource": ""
} |
q8475 | objectWith | train | function objectWith() {
const args = _.reverse(arguments);
const [value, path] = _.take(args, 2);
const | javascript | {
"resource": ""
} |
q8476 | executeCommand | train | function executeCommand(parameters) {
// If a name has been provided, we create the project directory
const specFilePath = path.join(process.cwd(), plugin.config.apisPath, parameters.apiIdentifier);
return mkdirpAsync(specFilePath)
.then(() => {
const spec = {
swagger: '2.0',
info:... | javascript | {
"resource": ""
} |
q8477 | generateCode | train | function generateCode(filepath) {
var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'amd';
// support 4 types of output as follows:
// amd/commonjs/global/umd
var choice = {
amd: {
prefix: 'define([\'module\', \'exports\'], function (module, exports) {'... | javascript | {
"resource": ""
} |
q8478 | compile | train | function compile(_ref2) {
var resource = _ref2.resource,
dest = _ref2.dest,
mode = _ref2.mode;
dest = dest || 'dest';
resource = resource || '*.vue';
mode = ['amd', 'commonjs', 'umd', 'global'].indexOf(mode) > -1 ? mode : 'amd';
if ((0, _fs.existsSync)(dest)) {
if (!(0, _fs.... | javascript | {
"resource": ""
} |
q8479 | train | function(callback) {
fs.exists(file, function(exists) {
if(!exists) {
rawData = file;
if(typeof rawData === "string") rawData = new Buffer(file);
return callback();
}
fs.readFile(file, functi... | javascript | {
"resource": ""
} | |
q8480 | train | function(callback) {
spidex.put(self.baseUri + "/" + uploadFilename, {
data: rawData,
header: header,
charset: "utf8"
}, function(html, status, respHeader) {
if(200 !== status && 201 !== status) {
return c... | javascript | {
"resource": ""
} | |
q8481 | executeCommand | train | function executeCommand(parameters) {
if (!parameters.role && parameters.roleManually) { parameters.role = parameters.roleManually; }
if (parameters.resourcePath.charAt(0) !== '/') { parameters.resourcePath = '/' + parameters.resourcePath; }
// We calculate the path where we will save the specification and... | javascript | {
"resource": ""
} |
q8482 | executeCommand | train | function executeCommand(parameters) {
const configFilePath = path.join(process.cwd(), plugin.config.policiesPath);
return mkdirpAsync(configFilePath)
.then(() => {
// We create the configuration file of the Lambda
const document = {
Version: '2012-10-17',
Statement: [{
... | javascript | {
"resource": ""
} |
q8483 | transformValueMap | train | function transformValueMap(collection, path, transformer) {
_.each(collection, (element) => {
let val = _.get(element, path);
if (!_.isUndefined(val)) {
| javascript | {
"resource": ""
} |
q8484 | executeCommand | train | function executeCommand(parameters) {
if (parameters.colors === undefined) { parameters.colors = plugin.myrmex.getConfig('colors'); }
return plugin.findEndpoint(parameters.resourcePath, parameters.httpMethod)
| javascript | {
"resource": ""
} |
q8485 | executeCommand | train | function executeCommand(parameters) {
let msg = '\n ' + icli.format.ko('Unknown command \n\n');
msg += ' Enter ' + icli.format.cmd('myrmex -h') + ' to see available commands\n';
msg += ' You have to | javascript | {
"resource": ""
} |
q8486 | getDocument | train | function getDocument(node) {
if (isDocument(node)) {
return node;
} else if (isDocument(node.ownerDocument)) {
return node.ownerDocument;
} else if (isDocument(node.document)) {
return node.document;
} else if (node.parentNode) {
return getDocument(node.parentNode);
// Range support
} el... | javascript | {
"resource": ""
} |
q8487 | d2h | train | function d2h(d, digits) {
d = d.toString(16);
while (d.length < digits) {
| javascript | {
"resource": ""
} |
q8488 | train | function() {
_.each(this._models, function(model) {
var cid = model.get('cid');
model.fetch({
success: function(model, response, options) {
if (_.isFunction(model.parseJSON)) | javascript | {
"resource": ""
} | |
q8489 | train | function(method, args){
_.each(this._elements, function(elem){
| javascript | {
"resource": ""
} | |
q8490 | executeCommand | train | function executeCommand(parameters) {
const configFilePath = path.join(process.cwd(), plugin.config.rolesPath);
return mkdirpAsync(configFilePath)
.then(() => {
if (parameters.model !== 'none') {
// Case a preset config has been choosen
const src = path.join(__dirname, 'templates', 'ro... | javascript | {
"resource": ""
} |
q8491 | getFunction | train | function getFunction(value, replacement) {
| javascript | {
"resource": ""
} |
q8492 | browser | train | function browser (winOptions) {
winOptions = assign({ graceful: true }, winOptions)
// Handle `browser-window` being passed as `parent`.
if (winOptions.parent && winOptions.parent._native) {
winOptions.parent = winOptions.parent._native
}
if (winOptions.graceful) winOptions.show = false
... | javascript | {
"resource": ""
} |
q8493 | load | train | function load (source, options, callback = noop) {
if (typeof options === 'function') callback = options, options = {}
options = assign({type: null, encoding: 'base64'}, options)
// Callback handler
var contents = window.webContents
eventcb(contents, 'did-finish-load', 'did-fail-load', ca... | javascript | {
"resource": ""
} |
q8494 | loadLambdas | train | function loadLambdas() {
const lambdasPath = path.join(process.cwd(), plugin.config.lambdasPath);
// This event allows to inject code before loading all APIs
return plugin.myrmex.fire('beforeLambdasLoad')
.then(() => {
// Retrieve configuration path of all Lambdas
return Promise.promisify(fs.readdir)(l... | javascript | {
"resource": ""
} |
q8495 | loadLambda | train | function loadLambda(lambdaPath, identifier) {
return plugin.myrmex.fire('beforeLambdaLoad', lambdaPath, identifier)
.spread((lambdaPath, identifier) => {
// Because we use require() to get the config, it could either be a JSON file
// or the content exported by a node module
// But because require() cac... | javascript | {
"resource": ""
} |
q8496 | loadNodeModule | train | function loadNodeModule(nodeModulePath, name) {
return plugin.myrmex.fire('beforeNodeModuleLoad', nodeModulePath, name)
.spread((nodeModulePath, name) => {
let packageJson = {};
try {
packageJson = _.cloneDeep(require(path.join(nodeModulePath, 'package.json')));
} catch (e) {
if (e.code !== ... | javascript | {
"resource": ""
} |
q8497 | findLambda | train | function findLambda(identifier) {
return loadLambdas()
.then(lambdas => {
const lambda = _.find(lambdas, (lambda) => { return lambda.getIdentifier() === identifier; });
if (!lambda) {
throw | javascript | {
"resource": ""
} |
q8498 | findNodeModule | train | function findNodeModule(name) {
return loadModules()
.then(nodeModules => {
const nodeModule = _.find(nodeModules, (nodeModule) => { return nodeModule.getName() === name; });
if (!nodeModule) {
| javascript | {
"resource": ""
} |
q8499 | registerCommandsHook | train | function registerCommandsHook(icli) {
return Promise.all([
require('./cli/create-lambda')(icli),
require('./cli/create-node-module')(icli),
| javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.